2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Allow send_media_group send media from URLs

This commit is contained in:
Dan 2019-07-19 13:40:12 +02:00
parent f2b3db47a9
commit 62a39521d9

View File

@ -31,7 +31,6 @@ log = logging.getLogger(__name__)
class SendMediaGroup(BaseClient): class SendMediaGroup(BaseClient):
# TODO: Add progress parameter # TODO: Add progress parameter
# TODO: Figure out how to send albums using URLs
def send_media_group( def send_media_group(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
@ -88,7 +87,24 @@ class SendMediaGroup(BaseClient):
id=types.InputPhoto( id=types.InputPhoto(
id=media.photo.id, id=media.photo.id,
access_hash=media.photo.access_hash, access_hash=media.photo.access_hash,
file_reference=b"" file_reference=media.photo.file_reference
)
)
elif i.media.startswith("http"):
media = self.send(
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaPhotoExternal(
url=i.media
)
)
)
media = types.InputMediaPhoto(
id=types.InputPhoto(
id=media.photo.id,
access_hash=media.photo.access_hash,
file_reference=media.photo.file_reference
) )
) )
else: else:
@ -126,7 +142,24 @@ class SendMediaGroup(BaseClient):
id=types.InputDocument( id=types.InputDocument(
id=media.document.id, id=media.document.id,
access_hash=media.document.access_hash, access_hash=media.document.access_hash,
file_reference=b"" file_reference=media.document.file_reference
)
)
elif i.media.startswith("http"):
media = self.send(
functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaDocumentExternal(
url=i.media
)
)
)
media = types.InputMediaDocument(
id=types.InputDocument(
id=media.document.id,
access_hash=media.document.access_hash,
file_reference=media.document.file_reference
) )
) )
else: else: