y-young / nazurin

🎉 Images collection done right. Telegram 图片收藏机器人 / A Telegram bot that helps you collect ACG illustrations.
http://nazurin.readthedocs.io
MIT License
259 stars 55 forks source link

Regarding the issue of TG-Bot limit of 20 messages per minute in groups/channels (and more pictures count as more messages) #6

Closed SagiriShiho closed 3 years ago

SagiriShiho commented 3 years ago

-problem "Also note that your bot will not be able to send more than 20 messages per minute to the same group." https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this

Due to official restrictions, TG-Bot limits 20 messages per minute in groups/channels (and multiple pictures count as more information) So when the limit is reached, there will be a failure to publish

2020-11-20T22:22:20.886923+00:00 app[web.1]: 2020-11-20 22:22:20,886-bot-INFO-BadRequest exception: Group send failed

So I recommend using userbot/pyrogram instead of TG-Bot Or add delayed release / failed retransmission

y-young commented 3 years ago

Just a few notes here:

Still using python-telegram-bot:

  1. Wait when hitting flooding limit: blocks executing because this application is currently synchronous, although run_async may helps a bit
  2. Use MessageQueue: works but the usage of PTB's MQ is not so elegant, and they're considering refactoring it

Use asynchronous Bot API frameworks:

  1. aiogram
  2. python-telegram-bot v14: PTB will switch to asyncio in v14, but that is not due in the forseable future

Use asynchronous MtProto API frameworks: