From 2fb42772c606382cbe2b88944bc5c1b22ce1444e Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 8 Mar 2018 20:21:56 +0100 Subject: [PATCH] Add .video_note and .gif convenience properties to NewMessage --- telethon/events/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/telethon/events/__init__.py b/telethon/events/__init__.py index 1bd9b8e7..76aab2a5 100644 --- a/telethon/events/__init__.py +++ b/telethon/events/__init__.py @@ -522,6 +522,23 @@ class NewMessage(_EventBuilder): """ return self._document_by_attribute(types.DocumentAttributeVideo) + @property + def video_note(self): + """ + If the message media is a document with a Video attribute, + this returns the (:obj:`Document`) object. + """ + return self._document_by_attribute(types.DocumentAttributeVideo, + lambda attr: attr.round_message) + + @property + def gif(self): + """ + If the message media is a document with an Animated attribute, + this returns the (:obj:`Document`) object. + """ + return self._document_by_attribute(types.DocumentAttributeAnimated) + @property def sticker(self): """