Fix _document_by_attribute failing on empty media

This commit is contained in:
Lonami Exo 2018-09-06 15:41:04 +02:00
parent 4e5b8c9c34
commit 11ef4ce370

View File

@ -700,9 +700,12 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
Helper method to return the document only if it has an attribute Helper method to return the document only if it has an attribute
that's an instance of the given kind, and passes the condition. that's an instance of the given kind, and passes the condition.
""" """
for attr in self.document.attributes: doc = self.document
if doc:
for attr in doc.attributes:
if isinstance(attr, kind): if isinstance(attr, kind):
if not condition or condition(self.document): if not condition or condition(doc):
return self.document return doc
return None
# endregion Private Methods # endregion Private Methods