Provide easier access to media through NewMessage event

This commit is contained in:
Lonami Exo 2018-02-08 19:43:15 +01:00
parent c79fbe451f
commit 91ba50174a

View File

@ -316,6 +316,24 @@ class NewMessage(_EventBuilder):
def forward(self):
return self.message.fwd_from
@property
def media(self):
return self.message.media
@property
def photo(self):
if isinstance(self.message.media, types.MessageMediaPhoto):
photo = self.message.media.photo
if isinstance(photo, types.Photo):
return photo
@property
def document(self):
if isinstance(self.message.media, types.MessageMediaDocument):
doc = self.message.media.document
if isinstance(doc, types.Document):
return doc
@property
def out(self):
return self.message.out