eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.02k stars 2.02k forks source link

message_handler: Processes the first two media together when sent simultaneously (type: media_group_id) #2391

Open tandat132 opened 2 weeks ago

tandat132 commented 2 weeks ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using? 4.22.1
  2. What OS are you using? windows
  3. What version of python are you using? 3.11.9

The first two media files are processed together, leading to the same output or action being applied to both. Code:

i = 1
@bot.message_handler(func=lambda message: True)
def handle_message(message):
     global i
     print(i)
     print(message)
     i = i+1

Result:

1
1
message
message
2
message
3
message
...
coder2020official commented 2 weeks ago

Hi. This behaviour is not due to library but API.

The only solution I can offer is implementing a logic yourself. Examples:

Badiboy commented 2 days ago

@coder2020official Frankly speaking, receiving gallery is a real pain. I suppose when (if) we have time it may be useful to make some joint handler for media gallery, that will allow to receive gallery itself. I did not make long thinking on it, but it may be useful.

coder2020official commented 2 days ago

Yes, I will take a look at this at some point.