Handle web pages on .download_media

This commit is contained in:
Lonami Exo 2018-04-14 13:07:50 +02:00
parent 88597f0da8
commit 75d37a3870

View File

@ -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(