在Telegram Bot API中,更新对象可以重复update_id吗?

发布于 2025-02-01 18:02:59 字数 368 浏览 2 评论 0原文

在更新对象中,可以重复update_id吗?

例如,引用文档...

如果至少一周没有新的更新,则将随机选择下一个更新的标识符。

这是否意味着在至少一周的休息之后,有机会使用update_id值进行更新,以用于另一个更新?

upd。引用电报支持响应:

由于更新ID应适合2^32-1,因此在技术上不可能使其独特(显而易见)并告诉我们,只有在获得更新以按时间订购时,您才能依靠顺序订购。不建议使用其他用途,也不建议更新ID的唯一性:)

In Update object, can update_id be ever repeated?

For instance, citing documentation...

If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

Does this mean that after a break of at least one week long, there is a chance to get an Update with update_id value that was used in the past for another update?

UPD. Citing Telegram Support response:

As update id should fit in 2^32-1 it’s not technically possible to make it unique (which is obvious) and dev told us that you should rely on sequential order only right when get update to order them by time. Other uses are not recommended and uniqueness of update id also :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2025-02-08 18:02:59

可以重复 code>

不,update_id是唯一的!

从文档中,在您的问题上引用该行:

更新的唯一标识符。更新标识符从一定的正数开始,并顺序增加。如果您使用 webhooks ,此ID变得特别方便重复更新或恢复正确的更新顺序,如果它们失败。 如果至少一周没有新的更新,则将随机选择下一个更新的标识符,而不是顺序选择
source


代码> 具有独特的,否则可以使用已经使用的密钥来调用getupdates,然后使电报想到该ID之后的消息被看到。

Can update_id be ever repeated?

No, an update_id is unique!

From the docs, quoting the line before the quote in your question:

The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
Source


The update_id has to be unique, otherwise it will be possible to call getUpdates with an already used key, that will then make Telegram think the messages after that id haven't already been seen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文