Return new .web_preview's .photo/.document if present in Message

This commit is contained in:
Lonami Exo 2018-09-15 10:45:15 +02:00
parent 080585da49
commit 4e07712b04

View File

@ -356,6 +356,10 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
return self.media.photo return self.media.photo
elif isinstance(self.action, types.MessageActionChatEditPhoto): elif isinstance(self.action, types.MessageActionChatEditPhoto):
return self.action.photo return self.action.photo
else:
web = self.web_preview
if web and isinstance(web.photo, types.Photo):
return web.photo
@property @property
def document(self): def document(self):
@ -366,6 +370,16 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
if isinstance(self.media, types.MessageMediaDocument): if isinstance(self.media, types.MessageMediaDocument):
if isinstance(self.media.document, types.Document): if isinstance(self.media.document, types.Document):
return self.media.document return self.media.document
else:
web = self.web_preview
if web and isinstance(web.photo, types.Document):
return web.photo
@property
def web_preview(self):
if isinstance(self.media, types.MessageMediaWebPage):
if isinstance(self.media.webpage, types.WebPage):
return self.media.webpage
@property @property
def audio(self): def audio(self):