From 75d37a3870f79442744f584485b50e0287655440 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 14 Apr 2018 13:07:50 +0200 Subject: [PATCH] Handle web pages on .download_media --- telethon/telegram_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 503f1c0f..05926216 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -84,7 +84,7 @@ from .tl.types import ( InputMessageEntityMentionName, DocumentAttributeVideo, UpdateEditMessage, UpdateEditChannelMessage, UpdateShort, Updates, MessageMediaWebPage, ChannelParticipantsSearch, PhotoSize, PhotoCachedSize, - PhotoSizeEmpty, MessageService, ChatParticipants, User, + PhotoSizeEmpty, MessageService, ChatParticipants, User, WebPage, ChannelParticipantsBanned, ChannelParticipantsKicked ) from .tl.types.messages import DialogsSlice @@ -1905,6 +1905,10 @@ class TelegramClient(TelegramBareClient): date = datetime.now() media = message + if isinstance(media, MessageMediaWebPage): + if isinstance(media.webpage, WebPage): + media = media.webpage.document or media.webpage.photo + if isinstance(media, (MessageMediaPhoto, Photo, PhotoSize, PhotoCachedSize)): return self._download_photo(