From 05bfaa3d876d7a8486d7598cd7dc8c674e6c267e Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 1 Feb 2022 11:38:58 +0100 Subject: [PATCH] Add support for video stickers Add Sticker.is_video attribute --- pyrogram/types/messages_and_media/message.py | 16 ++++++++-------- pyrogram/types/messages_and_media/sticker.py | 6 ++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 02bf2d3d..1f6e432a 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -674,6 +674,14 @@ class Message(Object, Update): video_attributes = attributes.get(raw.types.DocumentAttributeVideo, None) animation = types.Animation._parse(client, doc, video_attributes, file_name) media_type = "animation" + elif raw.types.DocumentAttributeSticker in attributes: + sticker = await types.Sticker._parse( + client, doc, + attributes.get(raw.types.DocumentAttributeImageSize, None), + attributes[raw.types.DocumentAttributeSticker], + file_name + ) + media_type = "sticker" elif raw.types.DocumentAttributeVideo in attributes: video_attributes = attributes[raw.types.DocumentAttributeVideo] @@ -683,14 +691,6 @@ class Message(Object, Update): else: video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds) media_type = "video" - elif raw.types.DocumentAttributeSticker in attributes: - sticker = await types.Sticker._parse( - client, doc, - attributes.get(raw.types.DocumentAttributeImageSize, None), - attributes[raw.types.DocumentAttributeSticker], - file_name - ) - media_type = "sticker" else: document = types.Document._parse(client, doc, file_name) media_type = "document" diff --git a/pyrogram/types/messages_and_media/sticker.py b/pyrogram/types/messages_and_media/sticker.py index be494e30..bd08792f 100644 --- a/pyrogram/types/messages_and_media/sticker.py +++ b/pyrogram/types/messages_and_media/sticker.py @@ -46,6 +46,9 @@ class Sticker(Object): is_animated (``bool``): True, if the sticker is animated + is_video (``bool``): + True, if the sticker is a video sticker + file_name (``str``, *optional*): Sticker file name. @@ -79,6 +82,7 @@ class Sticker(Object): width: int, height: int, is_animated: bool, + is_video: bool, file_name: str = None, mime_type: str = None, file_size: int = None, @@ -98,6 +102,7 @@ class Sticker(Object): self.width = width self.height = height self.is_animated = is_animated + self.is_video = is_video self.emoji = emoji self.set_name = set_name self.thumbs = thumbs @@ -167,6 +172,7 @@ class Sticker(Object): width=image_size_attributes.w if image_size_attributes else 512, height=image_size_attributes.h if image_size_attributes else 512, is_animated=sticker.mime_type == "application/x-tgsticker", + is_video=sticker.mime_type == "video/webm", # TODO: mask_position set_name=set_name, emoji=sticker_attributes.alt or None,