0

我正在为巴士路线创建一个带有 Python telepot 的机器人。我不明白如何管理命令,谁能向我解释如何获得使用我的机器人的用户的位置(街道名称)?

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)
4

1 回答 1

0

您没有向我们显示msg返回的响应的打印输出。

在 中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

于 2020-04-18T20:26:44.477 回答