【问题标题】:how do i get location in telegram telepot?我如何在电报 Telepot 中获取位置?
【发布时间】:2020-02-07 22:14:24
【问题描述】:

您好,我希望我的 python 聊天机器人能够获取用户位置。 我找不到那个代码——你能帮忙吗?

def testbot_basic():
def handle(msg):
  content_type, chat_type, chat_id = telepot.glance(msg)
  if content_type == 'text':
      bot.sendMessage(chat_id,"ciao sono un Bot")
      print(bot.getMe())
      pprint(bot.getUpdates())

bot = telepot.Bot('xxxxxxxxxxxxx')
print(bot.getMe())
pprint(bot.getUpdates())
#per ogni messaggio ricevuto viene aperta una istanza della funzione handle
bot.message_loop(handle)
print ('Listening ...')
# diamo 10 secondi di pausa
while 1:
    time.sleep(5)

【问题讨论】:

    标签: python location telegram telepot


    【解决方案1】:

    知道了

          if content_type == 'location':
          print(msg['location'])
          print(msg['location']['latitude'])
          print(msg['location']['longitude'])
    

    【讨论】:

      猜你喜欢
      • 2020-08-01
      • 2018-01-13
      • 2017-12-29
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      相关资源
      最近更新 更多