hopfenspace / MateBot-Telegram

Telegram Bot exposing the MateBot API in a user-friendly way
GNU General Public License v3.0
0 stars 0 forks source link

Bot can't send all inline callback query responses when the incoming messages are spammed #1

Open CrsiX opened 4 years ago

CrsiX commented 4 years ago

Currently (29f6dc48383c3fe59f59f7c3c01258fb64eb32a4), the inline reply via update.callback_query.answer can't always be send. This happens on extreme spamming of inline keyboard buttons, e.g. when a user clicks on an inline button more than appr. ten times a second. A AfterReply exception will be raised, because the bot always tries to reply. And the Telegram API seems to limit the bot's responses per second.

Such an exception may look like this: telegram.error.RetryAfter: Flood control exceeded. Retry in X seconds where the X is a number of seconds obviously.

This is related to hopfenspace/MateBot#24 because it may be solved with a response queue for all bot replies. However, the two bugs use very different reply methods, so this may be hard to achieve.

An approach to fix this is capturing this exception and just waiting for the specified time without answering any further bot requests so that the limit is not exceeded. The downside of this is that a legitimate user doesn't get his reply, too.

CrsiX commented 3 years ago

The milestone was set to Advanced Features because it looks like it's really heavy to fix this issue. And it doesn't matter so much anyway. The internal structure of the bot is not affected by those errors, e.g. adding externals is working even if the message that holds that counter is not updated anymore.