Skip to content

Commit 05bfaa3

Browse files
committed
Add support for video stickers
Add Sticker.is_video attribute
1 parent b676297 commit 05bfaa3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

pyrogram/types/messages_and_media/message.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,14 @@ async def _parse(
674674
video_attributes = attributes.get(raw.types.DocumentAttributeVideo, None)
675675
animation = types.Animation._parse(client, doc, video_attributes, file_name)
676676
media_type = "animation"
677+
elif raw.types.DocumentAttributeSticker in attributes:
678+
sticker = await types.Sticker._parse(
679+
client, doc,
680+
attributes.get(raw.types.DocumentAttributeImageSize, None),
681+
attributes[raw.types.DocumentAttributeSticker],
682+
file_name
683+
)
684+
media_type = "sticker"
677685
elif raw.types.DocumentAttributeVideo in attributes:
678686
video_attributes = attributes[raw.types.DocumentAttributeVideo]
679687

@@ -683,14 +691,6 @@ async def _parse(
683691
else:
684692
video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds)
685693
media_type = "video"
686-
elif raw.types.DocumentAttributeSticker in attributes:
687-
sticker = await types.Sticker._parse(
688-
client, doc,
689-
attributes.get(raw.types.DocumentAttributeImageSize, None),
690-
attributes[raw.types.DocumentAttributeSticker],
691-
file_name
692-
)
693-
media_type = "sticker"
694694
else:
695695
document = types.Document._parse(client, doc, file_name)
696696
media_type = "document"

pyrogram/types/messages_and_media/sticker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class Sticker(Object):
4646
is_animated (``bool``):
4747
True, if the sticker is animated
4848
49+
is_video (``bool``):
50+
True, if the sticker is a video sticker
51+
4952
file_name (``str``, *optional*):
5053
Sticker file name.
5154
@@ -79,6 +82,7 @@ def __init__(
7982
width: int,
8083
height: int,
8184
is_animated: bool,
85+
is_video: bool,
8286
file_name: str = None,
8387
mime_type: str = None,
8488
file_size: int = None,
@@ -98,6 +102,7 @@ def __init__(
98102
self.width = width
99103
self.height = height
100104
self.is_animated = is_animated
105+
self.is_video = is_video
101106
self.emoji = emoji
102107
self.set_name = set_name
103108
self.thumbs = thumbs
@@ -167,6 +172,7 @@ async def _parse(
167172
width=image_size_attributes.w if image_size_attributes else 512,
168173
height=image_size_attributes.h if image_size_attributes else 512,
169174
is_animated=sticker.mime_type == "application/x-tgsticker",
175+
is_video=sticker.mime_type == "video/webm",
170176
# TODO: mask_position
171177
set_name=set_name,
172178
emoji=sticker_attributes.alt or None,

0 commit comments

Comments
 (0)