0

When a user sends a grouped media (let's say three PDF files grouped together) to a Telegram bot, the Message object corresponding to this grouped Media has only the file_id of the first file, but we can't obtain the file_id of the rest of the files in the grouped media.

The Message object does have the media_group_id, but this ID can't be used to extract file_id of other rest documents/media.

@CallMeStag suggested in his previous answer that grouped media is just several messages, but on using Python debugger also, in fact, I found a grouped media is received as a single Message object, not multiple Message followed by one another.

bot = telebot.TeleBot(API_KEY, parse_mode=None)

@bot.message_handler(func=lambda msg_file: True)
def grouped_media_handler(msg_file):
    print(msg_file.document.file_id)
    bot.register_next_step_handler(msg_file, grouped_media_handler)

keep_alive.keep_alive()
bot.infinity_polling()

Ideally, This function should print all the file_id of the documents, if grouped media were just several messages. But, the function is called only once (for the first document)

Roj
  • 995
  • 1
  • 8
  • 22

0 Answers0