本文整理汇总了Python中telegram.Bot.sendLocation方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.sendLocation方法的具体用法?Python Bot.sendLocation怎么用?Python Bot.sendLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telegram.Bot
的用法示例。
在下文中一共展示了Bot.sendLocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from telegram import Bot [as 别名]
# 或者: from telegram.Bot import sendLocation [as 别名]
#.........这里部分代码省略.........
reply_markup = ReplyKeyboardMarkup(chat.journey.get_options(next_key_journey))
print(reply_markup)
self.manualbot.sendMessage(chat_id, text=chat.journey.get_question(next_key_journey), reply_markup = reply_markup)
self.chat_user_actions[(chat_id, user_id)] = [self.travelJourney,next_key_journey]
else:
print("question WITHOUT keyboard")
self.manualbot.sendMessage(chat_id, text=chat.journey.get_question(next_key_journey),reply_markup=ReplyKeyboardHide())
self.chat_user_actions[(chat_id, user_id)] = [self.travelJourney,next_key_journey]
else:
#end of the journey
if (chat_id, user_id) in self.chat_user_actions.keys():
del self.chat_user_actions[(chat_id, user_id)]
self.manualbot.sendMessage(chat_id, text="Danke! Let me see if I can find any good for you.",reply_markup=ReplyKeyboardHide())
#need to reset user thing
user = self.users[user_id]
print chat.journey.get_attribute('ACTIVITIES')
rec = travelBotrecommend.travelBotrecommend(str(user.latitude) + " " + str(user.longitude))
print "time " + str( chat.journey.get_attribute('MAXTRAVELTIME'))
res = rec.top_hotels(chat.journey.get_attribute('ACTIVITIES'), int(chat.journey.get_attribute('MAXTRAVELTIME')), int(chat.journey.get_attribute('MAXBUDGET')))
print "MAIN ",res
if len(res.keys())> 0:
i = 1
bot_ans_keyboard = []
#{'Price': '143.66', 'Star Rating': '5', 'Sat Temp': 10.29, 'Time': u'3 hours 40 mins', 'Sun Temp': 8.08, 'Position': 2, 'Review': '84.0'}
for (place, hotel), details in res.items():
bot_ans = "%d. In %s, %s from here, there is a nice hotel %s for only %s pound for two nights. The weather forecast is %s." % (
i, place, details['Time'], hotel, details['Total Price'] ,details['Sat Weather'])
self.manualbot.sendMessage(chat_id, text=bot_ans,reply_markup=ReplyKeyboardHide())
bot_ans_keyboard.append([str(i)])
chat.journey.add_results(i, (place, hotel), details, rec.getCoordinates(hotel,place + ',UK'))
print rec.getCoordinates(hotel,place+',UK')
i += 1
reply_markup = ReplyKeyboardMarkup(bot_ans_keyboard)
print(reply_markup)
self.manualbot.sendMessage(chat_id, text="Any preference?", reply_markup = reply_markup)
self.chat_user_actions[(chat_id, user_id)] = [self.selectSolution,None]
else:
self.manualbot.sendMessage(chat_id, text="Sorry I couldn't find anything for you. Try again.",reply_markup=ReplyKeyboardHide())
if (chat_id, user_id) in self.chat_user_actions.keys():
del self.chat_user_actions[(chat_id, user_id)]
chat.journey.start()
def selectSolution(self, question_key, chat_id, user_id, msg):
chat = self.chats[chat_id]
if msg.text.isdigit():
location = chat.journey.get_results(int(msg.text))
lat = location['location'][0]
lon = location['location'][1]
self.manualbot.sendMessage(chat_id, text="The option " + str(msg.text) + " it\'s my favourite too",reply_markup=ReplyKeyboardHide())
self.manualbot.sendMessage(chat_id, text="Do you know how to get there?",reply_markup=ReplyKeyboardHide())
self.manualbot.sendLocation(chat_id, latitude=float(lat), longitude=float(lon))
if (chat_id, user_id) in self.chat_user_actions.keys():
del self.chat_user_actions[(chat_id, user_id)]
chat.journey.start()
print("we got everything")
def echo(self, bot, update):
if not (self.is_a_new_chat(update.message.chat.id)):
if not (self.chats[update.message.chat.id].active):
return
self.message_event(bot,update.message)
#msg_meaning = self.botnltk.classify(update.message.text)
#bot.sendMessage(update.message.chat_id, text=msg_meaning)
# Check if the msg is a reply to a previous command
if (update.message.chat_id, update.message.from_user.id) in self.chat_user_actions:
_call_method, question_key = self.chat_user_actions[(update.message.chat_id, update.message.from_user.id)]
ret = _call_method(
question_key = question_key,
chat_id = update.message.chat_id,
user_id = update.message.from_user.id,
msg = update.message)
# bot.sendLocation(update.message.chat_id, latitude=float(ret['lat']), longitude=float(ret['lng']))
# bot.sendMessage(update.message.chat_id, text='Got it!', reply_markup=ReplyKeyboardHide())
# del self.chat_user_actions[(update.message.chat_id, update.message.from_user.id)]
def error(bot, update, error, error2):
print('Update "%s" caused error "%s"' % (update, error))
raise ValueError('Parameter should...')