通过Python在Telegram Bot的后台跟踪实时位置

时间:2020-05-16 12:18:56

标签: python location telegram

我正在使用库:python-telegram-bot 我想使用/ where命令来跟踪实时位置。 首先,我已经发送了实时位置信息,但是几分钟后我不知道如何使用/ where命令来跟踪位置信息。到现在为止,这就是我所拥有的:

def where(update, context):
    message = None
    if update.edited_message:
        message = update.edited_message
    else:
        message = update.message
    location = message.location.latitude, message.location.longitude

    context.bot.send_message( chat_id=update.message.chat_id, text=str(location))

dispatcher.add_handler(MessageHandler(Filters.location, where))

问题在于自从发送位置以来,每次移动时都会返回更新的坐标,而不是在执行/ where命令时返回。

0 个答案:

没有答案