我如何在电报电报站中找到位置?

问题描述 投票:0回答:1

嗨,我希望我的python chatbot能够获取用户位置。我找不到相应的代码-您能帮上忙吗?

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个回答
0
投票

明白了

      if content_type == 'location':
      print(msg['location'])
      print(msg['location']['latitude'])
      print(msg['location']['longitude'])
© www.soinside.com 2019 - 2024. All rights reserved.