Telegram limits with sendMediaGroup

Viewed 1317

sendMediaGroup method allows sending multiple images or videos in a single album.

Telegram has a limit of max 30 messages per second.

In the description of sendMediaGroup is written that it returns an array of sent messages. Does it mean that each one of them is being counted within the limit?

1 Answers

The send_media_group can send up to 10 media files (See telegram.Bot.send_media_group): in this case the method returns the list of message successfully sent

{
'message_id': 187,
'date': 1602754918,
'chat': {
    'id': 931365322,
    'type': 'private',
    'username': 'xxx',
    'first_name': 'xxx',
    'last_name': 'xxx'
},
'photo': [{
        'file_id': 'AgACAgQAAxkDAAO7X4gZZmu7aFIc0DAD9Wrao8yPe88AAki0MRsITUBQoza6QlZh2tvhrMkiXQADAQADAgADbQADTtsGAAEbBA',
        'file_unique_id': 'AQAD4azJIl0AA07bBgAB',
        'width': 320,
        'height': 301,
        'file_size': 5295
    },...
],

If you exceed the limit (11 or more media) the method will return an error

telegram.error.BadRequest: Too much messages to send as an album

Each message counts within the Telegram Rate limits (30 messages per second): you can send up to 3 messages with 10 media each (in total 30) but cannot add anything else in the same transaction (not even a simple text message).

With the Python Telegram BOT the 31st message is eventually still processed, after receiving an error (telegram.error.TimedOut: Timed out) but this might be how the framework deals with error returned by Telegram.

Related