telegram-bot-api
telegram-bot-api copied to clipboard
Provide 429 exception for webhook updates on inline query
When several users are active on my bot at one time, mostly interacting with callback queries, I am getting a 429 error sending the update back. I believe if my bot is receiving one callback query, a 1:1 ratio of requests in to requests out should not trigger the 429 rate limiter, especially in reference to the same inline message id, as this cannot be used to spam.
You can call answerCallbackQuery without any limits, editing of the message in question is still subject to per chat limits.
@levlam I have rewritten the bot to edit the message in the http response, but when mutliple users are simultaneously using the bot, I still sometimes get drops, only now there is no error to inspect.
What are the "per chat limits"? With the state of the bot being changed, the users enter an irredeemable loop where they cannot proceed.
Per chat limits are documented at https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this:
In a single chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you'll begin receiving 429 errors. In a group, bots are not be able to send more than 20 messages per minute.
@levlam does this include editing messages? I saw this FAQ but it does not mention that, and I'm still surprised to be running into limits like this.
Yes, it includes message editing.
@levlam in that case, my thought is this: If I receive an inline query, and send back an edit for that same message, there is no way to abuse the system with those kind of updates, especially with it being 1:1 with user interaction. Couple that with cutting down traffic by giving a webhook response rather than a separate request, and it seems reasonable that these not be rated.
Is there some other consideration I am missing?
This is possible, but it would require harder limits for callback query sending by users.
@levlam that is my suggestion then, especially because responding to a webhook query yields no way to know if the action was successful.
I cannot picture a use case where a bot would require more than, say, 1 interaction per second per message with callback queries, and the bot I am asking about is a game- which would be more interaction than most bots.