Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would one wait for a message with multiple photos? #130

Open
Serpentarius13 opened this issue Feb 8, 2025 · 3 comments
Open

How would one wait for a message with multiple photos? #130

Serpentarius13 opened this issue Feb 8, 2025 · 3 comments
Labels
question Further information is requested

Comments

@Serpentarius13
Copy link

Hello. Right now in Telegram API (as I understand), if you send multiple photos in a single message, you will receive multiple updates with :media filter. I think it happens in conversations too. What would be a correct way to wait for multiple photos, or just receive them all in a single waitFor call?

@KnorpelSenf
Copy link
Member

There are no messages with multiple photos (except for paid media messages which I assume you're not referring to).

https://grammy.dev/resources/faq#how-can-i-handle-albums

@KnorpelSenf KnorpelSenf added the question Further information is requested label Feb 9, 2025
@Serpentarius13
Copy link
Author

Serpentarius13 commented Feb 9, 2025

There are no messages with multiple photos (except for paid media messages which I assume you're not referring to).

https://grammy.dev/resources/faq#how-can-i-handle-albums

Thank you for explaining it so thoroughly :) Do you maybe have in mind how to make a workaround for this? I want to make a "profile pictures" functionality for my bot. Should I use some persistent storage/sessions to accumulate photos with switch to check whether they are for this feature? I would of course be very happy with doing

await Promise.all([waitForPhoto1, waitForPhoto2...])

But the amount is dynamic and when the user doesn't load more photos, I guess conversation would come to a halt until he does?

@KnorpelSenf
Copy link
Member

I would personally use a conversation with a loop that pushes photos to an array until

  • the maximum number of photos is received, or
  • the user sends /done or clicks a button or so

I would always handle an album with 3 photos the same way I would handle three individual messages. I don't like bots that distinguish between these two types of input anyway. But this is more of a personal recommendation, you are free to build whichever bot you like :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants