You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suggest adding a new type of handler for the media group.
bot = AsyncTeleBot(
token='TOKEN',
media_groups=True, # Enable media group processing
media_group_timeout=1.5 # Group collect timeout
)
# Method 1: A single handler for all media groups
@bot.media_group_handler()
async def handle_media_group(messages: List[Message]):
"""Handles any media group"""
count_in_group = len(messages)
await bot.send_message(msg.chat.id, f"Received media group with {count_in_group} messages")
# Method 2: Filtering by content type
@bot.media_group_handler(content_types=['photo'])
async def handle_photo_video_group(messages: List[Message]):
"""Processes groups of photos"""
...
Backward compatibility - the old code continues to work
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I suggest adding a new type of handler for the media group.
Backward compatibility - the old code continues to work
Beta Was this translation helpful? Give feedback.
All reactions