1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
1919from datetime import datetime
20- from typing import List
20+ from typing import List , Dict , Type
2121
2222import pyrogram
2323from pyrogram import raw , utils
@@ -50,9 +50,6 @@ class Sticker(Object):
5050 is_video (``bool``):
5151 True, if the sticker is a video sticker
5252
53- duration (``int``):
54- Video sticker duration in seconds.
55-
5653 file_name (``str``, *optional*):
5754 Sticker file name.
5855
@@ -87,7 +84,6 @@ def __init__(
8784 height : int ,
8885 is_animated : bool ,
8986 is_video : bool ,
90- duration : int = None ,
9187 file_name : str = None ,
9288 mime_type : str = None ,
9389 file_size : int = None ,
@@ -150,11 +146,16 @@ async def _get_sticker_set_name(invoke, input_sticker_set_id):
150146 async def _parse (
151147 client ,
152148 sticker : "raw.types.Document" ,
153- image_size_attributes : "raw.types.DocumentAttributeImageSize" ,
154- sticker_attributes : "raw.types.DocumentAttributeSticker" ,
155- file_name : str ,
156- video_attributes : "raw.types.DocumentAttributeVideo"
149+ document_attributes : Dict [Type ["raw.base.DocumentAttribute" ], "raw.base.DocumentAttribute" ],
157150 ) -> "Sticker" :
151+ sticker_attributes = document_attributes .get (
152+ raw .types .DocumentAttributeSticker ,
153+ document_attributes [raw .types .DocumentAttributeCustomEmoji ]
154+ )
155+ image_size_attributes = document_attributes .get (raw .types .DocumentAttributeImageSize , None )
156+ file_name = getattr (document_attributes .get (raw .types .DocumentAttributeFilename , None ), "file_name" , None )
157+ video_attributes = document_attributes .get (raw .types .DocumentAttributeVideo , None )
158+
158159 sticker_set = sticker_attributes .stickerset
159160
160161 if isinstance (sticker_set , raw .types .InputStickerSetID ):
@@ -175,11 +176,22 @@ async def _parse(
175176 file_unique_type = FileUniqueType .DOCUMENT ,
176177 media_id = sticker .id
177178 ).encode (),
178- width = image_size_attributes .w if image_size_attributes else (video_attributes .w if video_attributes else 512 ),
179- height = image_size_attributes .h if image_size_attributes else (video_attributes .h if video_attributes else 512 ),
179+ width = (
180+ image_size_attributes .w
181+ if image_size_attributes
182+ else video_attributes .w
183+ if video_attributes
184+ else 512
185+ ),
186+ height = (
187+ image_size_attributes .h
188+ if image_size_attributes
189+ else video_attributes .h
190+ if video_attributes
191+ else 512
192+ ),
180193 is_animated = sticker .mime_type == "application/x-tgsticker" ,
181194 is_video = sticker .mime_type == "video/webm" ,
182- duration = video_attributes .duration if video_attributes else None ,
183195 # TODO: mask_position
184196 set_name = set_name ,
185197 emoji = sticker_attributes .alt or None ,
0 commit comments