Telegram bot API限制

2024-05-15 07:59:13 发布

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

如果您打开telegram bot FAQ,您可以在特定聊天中看到每秒1条消息,在群聊中每秒可以看到30条消息,在群聊中则可以看到每分钟不到20条消息。在

我有带简单速率限制器的简单电报机器人:

  1. 它不使用群聊
  2. 它在特定的聊天中每秒只发送1条消息
  3. 它在特定的聊天中每分钟发送不到20条信息

但我总是收到429错误:

"error_code":429,"description":"Too Many Requests: retry after 236"

我很困惑,因为我没有违反电报限制。请帮我找出问题。在

源代码here,bot使用this库在轮询模式下与telegram进行交互。复制步骤:

^{pr2}$

Tags: 信息消息速率bot错误机器人codeerror
1条回答
网友
1楼 · 发布于 2024-05-15 07:59:13

你的msg_count似乎正在跟踪每次私人聊天的发送消息。但它应该是全局的,因为你当前的代码似乎允许你的机器人每秒向无限的用户发送一些消息。所以它可能会超过极限。在

If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results. Telegram Bots FAQ

相关问题 更多 >