Configurable message queueing and rate limit for Telegram groups
Is your feature request related to a problem? Please describe.
time="2023-03-15T19:45:33Z" level=error msg="SendMessage failed: Too Many Requests: retry after 9" func=handleMessage file="gateway/handlers.go:228" prefix=gateway https://phabricator.wikimedia.org/T332226
Telegram groups can be set to slow mode to rate limit each member's posts. Currently when matterbridge exceeds the rate limit it will log an error message and continue on. This causes data loss on the Telegram view of the chat.
Describe the solution you'd like A perfect world solution would adaptively respond to the upstream rate limit. Per https://github.com/tdlib/telegram-bot-api/issues/75 this sounds like a complex problem, but the limit (if any exists) is returned by the getChat API endpoint response.
A less complex solution would be implementing the equivalent of the IRC client's MessageQueue and MessageDelay flood control settings. Ideally these would be configurable per-gateway.
Describe alternatives you've considered A workaround for this issue is to grant the Telegram account used by the gateway an administrator role in the Telegram group. No explicit permissions are needed for the role to bypass the rate limit, so it can be configured with all available "what can this admin do?" toggles turned off to limit the mischief the account might be used for.