简体   繁体   English

为什么telegram.Bot.getUpdates()长轮询立即返回?

[英]Why does telegram.Bot.getUpdates() long polling returns immediately?

According to telegram api , the getUpdates function receives incoming updates using long polling ( wiki ). 根据电报apigetUpdates函数使用长轮询( wiki )接收传入的更新。 From wiki: 从维基:

If the server does not have any information available for the client when the poll is received, instead of sending an empty response, the server holds the request open and waits for response information to become available. 如果在收到轮询时服务器没有任何可用于客户端的信息,则服务器将保持打开请求并等待响应信息变为可用,而不是发送空响应。 Once it does have new information, the server immediately sends an HTTP/S response to the client, completing the open HTTP/S Request. 一旦收到新信息,服务器将立即向客户端发送HTTP / S响应,从而完成打开的HTTP / S请求。

Then, why does the function getUpdates() returns immediately, even though the timeout parameter is set? 那么,即使设置了timeout参数,为什么函数getUpdates()也会立即返回?

The function call: bot.getUpdates(offset=lastUpdateID, timeout=120) 函数调用: bot.getUpdates(offset=lastUpdateID, timeout=120)

There are no new updates and the offset=lastUpdateID is the last update. 没有新的更新,offset = lastUpdateID是最近的更新。

I'm using library python telegram bot library 我正在使用库python电报bot库

问题是我要求offset=lastUpdateID x ,我应该要求offset=lastUpdateID x + 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM