2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Fix determining video sticker resolution. Add sticker duration to Sticker type (#1065)

This commit is contained in:
LёNya 2022-08-14 11:50:48 +03:00 committed by GitHub
parent 6c34c83a3e
commit 95de5f7eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -50,9 +50,10 @@ class GetCustomEmojiStickers:
sticker = await types.Sticker._parse(
self, item,
attributes[raw.types.DocumentAttributeImageSize],
attributes[raw.types.DocumentAttributeImageSize] if raw.types.DocumentAttributeImageSize in attributes else None,
attributes[raw.types.DocumentAttributeCustomEmoji],
attributes[raw.types.DocumentAttributeFilename].file_name
attributes[raw.types.DocumentAttributeFilename].file_name,
attributes[raw.types.DocumentAttributeVideo] if raw.types.DocumentAttributeVideo in attributes else None
)
stickers.append(sticker)

View File

@ -700,7 +700,8 @@ class Message(Object, Update):
client, doc,
attributes.get(raw.types.DocumentAttributeImageSize, None),
attributes[raw.types.DocumentAttributeSticker],
file_name
file_name,
attributes.get(raw.types.DocumentAttributeVideo, None)
)
media_type = enums.MessageMediaType.STICKER
elif raw.types.DocumentAttributeVideo in attributes:

View File

@ -50,6 +50,9 @@ class Sticker(Object):
is_video (``bool``):
True, if the sticker is a video sticker
duration (``int``):
Video sticker duration in seconds.
file_name (``str``, *optional*):
Sticker file name.
@ -84,6 +87,7 @@ class Sticker(Object):
height: int,
is_animated: bool,
is_video: bool,
duration: int = None,
file_name: str = None,
mime_type: str = None,
file_size: int = None,
@ -148,7 +152,8 @@ class Sticker(Object):
sticker: "raw.types.Document",
image_size_attributes: "raw.types.DocumentAttributeImageSize",
sticker_attributes: "raw.types.DocumentAttributeSticker",
file_name: str
file_name: str,
video_attributes: "raw.types.DocumentAttributeVideo"
) -> "Sticker":
sticker_set = sticker_attributes.stickerset
@ -170,10 +175,11 @@ class Sticker(Object):
file_unique_type=FileUniqueType.DOCUMENT,
media_id=sticker.id
).encode(),
width=image_size_attributes.w if image_size_attributes else 512,
height=image_size_attributes.h if image_size_attributes else 512,
width=image_size_attributes.w if image_size_attributes else (video_attributes.w if video_attributes else 512),
height=image_size_attributes.h if image_size_attributes else (video_attributes.h if video_attributes else 512),
is_animated=sticker.mime_type == "application/x-tgsticker",
is_video=sticker.mime_type == "video/webm",
duration=video_attributes.duration if video_attributes else None,
# TODO: mask_position
set_name=set_name,
emoji=sticker_attributes.alt or None,