传入更新的电报bot API限制 [英] Telegram bot api limit of incoming updates

查看:123
本文介绍了传入更新的电报bot API限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试Telegram机器人api,以便使用来获取更新

I was testing the Telegram bot api in order to get updates using

https://api.telegram.org/bot<tokenOfBot>/getUpdates

但是,我意识到我只能得到100个更新,而其他更新没有出现. 有什么办法可以获取我其余的更新?

However, I realized I can get only 100 updates, and other ones don't appear. Is there any way to get the rest of my updates?

推荐答案

您可以使用limit参数控制收到的更新数量.但是,根据文档:

You may use the limit parameter to control how many updates you received. However, according to the documentation:

限制:...可接受1到100之间的值.默认为100

limit: ... Values between 1—100 are accepted. Defaults to 100

这意味着您一次不能接收超过100个更新.

That means you cannot receive more than 100 updates at a time.

如果要接收较新的更新,则必须确认较旧的更新,因此服务器不会一遍又一遍地给您同样的旧消息.注意update_id.例如,如果收到的update_id为999,则下次调用getUpdates时,应使用:

If you want to receive newer updates, you would have to acknowledge the older updates, so the server won't give you the same old messages over and over. Pay attention to update_id. For example, if you have received an update_id of 999, next time you call getUpdates, you should use:

https://api.telegram.org/bot<token>/getUpdates?offset=1000

这样,服务器知道您收到的update_id低于1000,并且不会一遍又一遍地发出相同的旧消息.

This way, the server knows you have received update_ids below 1000, and will not give the same old messages over and over.

这篇关于传入更新的电报bot API限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆