Skip to content

Commit d6448c2

Browse files
committed
Handle STICKERSET_INVALID error
1 parent 26f0d77 commit d6448c2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

pyrogram/client/message_parser.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import pyrogram
2222
from pyrogram.api import types, functions
23+
from pyrogram.api.errors import StickersetInvalid
2324
from .utils import encode
2425

2526
# TODO: Organize the code better?
@@ -396,9 +397,12 @@ def parse_message(
396397
sticker_attribute = attributes[types.DocumentAttributeSticker]
397398

398399
if isinstance(sticker_attribute.stickerset, types.InputStickerSetID):
399-
set_name = client.send(
400-
functions.messages.GetStickerSet(sticker_attribute.stickerset)
401-
).set.short_name
400+
try:
401+
set_name = client.send(
402+
functions.messages.GetStickerSet(sticker_attribute.stickerset)
403+
).set.short_name
404+
except StickersetInvalid:
405+
set_name = None
402406
else:
403407
set_name = None
404408

@@ -417,7 +421,7 @@ def parse_message(
417421
thumb=parse_thumb(doc.thumb),
418422
# TODO: mask_position
419423
set_name=set_name,
420-
emoji=sticker_attribute.alt,
424+
emoji=sticker_attribute.alt or None,
421425
file_size=doc.size,
422426
mime_type=doc.mime_type,
423427
file_name=file_name,

0 commit comments

Comments
 (0)