【发布时间】:2016-06-23 12:35:24
【问题描述】:
我的 python 脚本作为 cronjob 安装,它每分钟运行一次,并根据请求将报告发送给用户(基本上我的电报机器人与授权用户交互并发送报告)。一切正常,只是需要延迟 1 分钟。我希望我的脚本能够实时监听请求并立即发送报告,不会有任何延迟。我不太确定该怎么做。
import telepot
# Get the latest update
def fetch():
response = bot.getUpdates()
# Authorize the user
def authorize():
---Code to Authorize---
# Send the stats
def stat():
---Code to send the stats/report---
【问题讨论】:
-
我不太了解 Telepot,但您也许可以为 getUpdates 设置超时。然后只需在循环中使用该超时调用 getUpdates
标签: python-2.7 telegram python-telegram-bot