I develop telegram bot using python-telegram-bot.
Despite the usage of MessageQueue (just as mentioned in the docs) I keep getting
telegram.error.RetryAfter: Flood control exceeded. Retry in N seconds
when I flooding from the client (by pressing reply keyboard buttons really-really quickly) to my bot and it answers me.
MessageQueue actually works, I can see the delay during sending big number of messages at once (with for loop). I've tried different values for message queue but none of those helped.
Seems like the bot gets ban from telegram regardless of number of messages it actually send.
Method threading (sync or async) does not change anything. How can I prevent users from flooding or avoid banning my bot when this is happening?
The problem was in bot's replying message size: it was bigger than 512 bytes. Such messages are considered by Telegram API as large ones. So making bot's reply message shorter solved the problem.
You can learn more in the article.