mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Handle STICKERSET_INVALID error
This commit is contained in:
parent
26f0d77a1a
commit
d6448c2044
@ -20,6 +20,7 @@ from struct import pack
|
|||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types, functions
|
from pyrogram.api import types, functions
|
||||||
|
from pyrogram.api.errors import StickersetInvalid
|
||||||
from .utils import encode
|
from .utils import encode
|
||||||
|
|
||||||
# TODO: Organize the code better?
|
# TODO: Organize the code better?
|
||||||
@ -396,9 +397,12 @@ def parse_message(
|
|||||||
sticker_attribute = attributes[types.DocumentAttributeSticker]
|
sticker_attribute = attributes[types.DocumentAttributeSticker]
|
||||||
|
|
||||||
if isinstance(sticker_attribute.stickerset, types.InputStickerSetID):
|
if isinstance(sticker_attribute.stickerset, types.InputStickerSetID):
|
||||||
set_name = client.send(
|
try:
|
||||||
functions.messages.GetStickerSet(sticker_attribute.stickerset)
|
set_name = client.send(
|
||||||
).set.short_name
|
functions.messages.GetStickerSet(sticker_attribute.stickerset)
|
||||||
|
).set.short_name
|
||||||
|
except StickersetInvalid:
|
||||||
|
set_name = None
|
||||||
else:
|
else:
|
||||||
set_name = None
|
set_name = None
|
||||||
|
|
||||||
@ -417,7 +421,7 @@ def parse_message(
|
|||||||
thumb=parse_thumb(doc.thumb),
|
thumb=parse_thumb(doc.thumb),
|
||||||
# TODO: mask_position
|
# TODO: mask_position
|
||||||
set_name=set_name,
|
set_name=set_name,
|
||||||
emoji=sticker_attribute.alt,
|
emoji=sticker_attribute.alt or None,
|
||||||
file_size=doc.size,
|
file_size=doc.size,
|
||||||
mime_type=doc.mime_type,
|
mime_type=doc.mime_type,
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user