Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
New method - get_media_group() #550
Conversation
Support for GetMediaGroup
Added new method - get_media_group
|
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) |
delivrance
Nov 28, 2020
Member
You can import List directly from pyrogram.types
You can import List directly from pyrogram.types
Legenda24
Dec 9, 2020
•
Author
Yes, but it will be "mismatching" between typing List and pyrogram List
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 |
delivrance
Nov 28, 2020
Member
media_group_id = messages[9].media_group_id
if media_group_id is None:
raise ...
looks better.
media_group_id = messages[9].media_group_id
if media_group_id is None:
raise ...looks better.
Method to get all media group messages knowing only one. Special thank to Danipulok (https://github.com/Danipulok)
"Problems":
Docs
Doubt how to write correctly so I marked those lines with "#TODO" + examples.
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 :)