From d6448c20444f2dfba090bc1dd2b5e336bf4656d4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 18 Apr 2018 16:39:42 +0200 Subject: [PATCH] Handle STICKERSET_INVALID error --- pyrogram/client/message_parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/message_parser.py b/pyrogram/client/message_parser.py index 51eba3ae..20158e63 100644 --- a/pyrogram/client/message_parser.py +++ b/pyrogram/client/message_parser.py @@ -20,6 +20,7 @@ from struct import pack import pyrogram from pyrogram.api import types, functions +from pyrogram.api.errors import StickersetInvalid from .utils import encode # TODO: Organize the code better? @@ -396,9 +397,12 @@ def parse_message( sticker_attribute = attributes[types.DocumentAttributeSticker] if isinstance(sticker_attribute.stickerset, types.InputStickerSetID): - set_name = client.send( - functions.messages.GetStickerSet(sticker_attribute.stickerset) - ).set.short_name + try: + set_name = client.send( + functions.messages.GetStickerSet(sticker_attribute.stickerset) + ).set.short_name + except StickersetInvalid: + set_name = None else: set_name = None @@ -417,7 +421,7 @@ def parse_message( thumb=parse_thumb(doc.thumb), # TODO: mask_position set_name=set_name, - emoji=sticker_attribute.alt, + emoji=sticker_attribute.alt or None, file_size=doc.size, mime_type=doc.mime_type, file_name=file_name,