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
@@ -146,10 +146,18 @@ async def _get_sticker_set_name(invoke, input_sticker_set_id):
146146 async def _parse (
147147 client ,
148148 sticker : "raw.types.Document" ,
149- image_size_attributes : "raw.types.DocumentAttributeImageSize" ,
150- sticker_attributes : "raw.types.DocumentAttributeSticker" ,
151- file_name : str
149+ document_attributes : Dict [Type ["raw.base.DocumentAttribute" ], "raw.base.DocumentAttribute" ],
152150 ) -> "Sticker" :
151+ sticker_attributes = (
152+ document_attributes [raw .types .DocumentAttributeSticker ]
153+ if raw .types .DocumentAttributeSticker in document_attributes
154+ else document_attributes [raw .types .DocumentAttributeCustomEmoji ]
155+ )
156+
157+ image_size_attributes = document_attributes .get (raw .types .DocumentAttributeImageSize , None )
158+ file_name = getattr (document_attributes .get (raw .types .DocumentAttributeFilename , None ), "file_name" , None )
159+ video_attributes = document_attributes .get (raw .types .DocumentAttributeVideo , None )
160+
153161 sticker_set = sticker_attributes .stickerset
154162
155163 if isinstance (sticker_set , raw .types .InputStickerSetID ):
@@ -170,8 +178,20 @@ async def _parse(
170178 file_unique_type = FileUniqueType .DOCUMENT ,
171179 media_id = sticker .id
172180 ).encode (),
173- width = image_size_attributes .w if image_size_attributes else 512 ,
174- height = image_size_attributes .h if image_size_attributes else 512 ,
181+ width = (
182+ image_size_attributes .w
183+ if image_size_attributes
184+ else video_attributes .w
185+ if video_attributes
186+ else 512
187+ ),
188+ height = (
189+ image_size_attributes .h
190+ if image_size_attributes
191+ else video_attributes .h
192+ if video_attributes
193+ else 512
194+ ),
175195 is_animated = sticker .mime_type == "application/x-tgsticker" ,
176196 is_video = sticker .mime_type == "video/webm" ,
177197 # TODO: mask_position
0 commit comments