繁体   English   中英

我如何在电报 Telepot 中获取位置?

[英]how do i get location in telegram telepot?

嗨,我希望我的 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)

知道了

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM