通过Python在电报机器人的后台跟踪实时位置

2024-04-25 20:25:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用这个库:python电报机器人 我想用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命令时


Tags: 命令noneidmessageifdefcontextchat