[英]How to get users's location and Venue in a bot telegram by telepot
我正在为公交车行程创建一个带有 Python Telepot 的机器人。 我不明白如何管理命令,谁能向我解释如何获得使用我的机器人的用户的 position(街道名称)?
import json
import time
from pprint import pprint
import telepot
from telepot.loop import MessageLoop
import telepot.namedtuple
bot = telepot.Bot("token")
lista = ["New York","Los Angeles","Miami","Toronto","Berlin","Rome"]
seq = iter(lista)
keyboard = {"keyboard": [[{"text": i} for i in pair] for pair in zip(seq)]}
def handle(msg):
content_type, chat_type, chat_id = telepot.glance(msg)
print(content_type, chat_type, chat_id)
if content_type == "text":
bot.sendMessage(chat_id, msg["text"], reply_markup=keyboard)
bot.editMessageLiveLocation(latitude, longitude) #i've tried here but nothing
MessageLoop(bot, handle).run_as_thread()
while 1:
time.sleep(10)
您没有向我们展示为返回的msg
响应打印的 output。
在if
中,第一行是有意义的,它符合https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.sendMessage 。
第二行没有什么意义,它没有传入https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.editMessageLiveLocation解释你需要的参数。 我没有看到msg_identifier
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.