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

New method - get_media_group() #550

Draft
wants to merge 3 commits into
base: master
from
Draft

Conversation

@Legenda24
Copy link

@Legenda24 Legenda24 commented Nov 25, 2020

Method to get all media group messages knowing only one. Special thank to Danipulok (https://github.com/Danipulok)

"Problems":

  1. Docs
    Doubt how to write correctly so I marked those lines with "#TODO" + examples.

  2. Should it raises error in case it's passed "wrong" (not related to media group) message_id or just return an empty list

P. s. Now(at the moment of first 2 commits) you can use this method as
client.get_media_group(chat_id, message_id)
Maybe it will be different.

UPD(5.12.2020):
I just noticed that other media groups have media_group_id attribute too (playlists etc.)
So now this method supports all types of media groups(playlists, albums etc.) as it should be :)

Legenda24 added 2 commits Nov 25, 2020
Support for GetMediaGroup
Added new method - get_media_group
@Danipulok
Copy link

@Danipulok Danipulok commented Nov 25, 2020

Well, I can say that we were testing a few options and it was the fastest one and pretty the easiest one to read.

And I also think that the name should be get_album(), because if there's method that will get all the files in one file group (like a few audiofiles together or a file .txt or other files) that one should be called get_media_group().

Add pyro stuff
else:
raise ValueError("Message isn't related to media group") #TODO

return list.List(msg for msg in messages if msg.media_group_id == media_group_id)

This comment has been minimized.

@delivrance

delivrance Nov 28, 2020
Member

You can import List directly from pyrogram.types

This comment has been minimized.

@Legenda24

Legenda24 Dec 9, 2020
Author

Yes, but it will be "mismatching" between typing List and pyrogram List

if messages[9].media_group_id:
media_group_id = messages[9].media_group_id
else:
raise ValueError("Message isn't related to media group") #TODO

This comment has been minimized.

@delivrance

delivrance Nov 28, 2020
Member
media_group_id = messages[9].media_group_id

if media_group_id is None:
    raise ...

looks better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.