From c991036a8568dae04b4f16ee9e6d3cbc765e1532 Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Mon, 11 Dec 2023 11:14:26 +0300 Subject: [PATCH] Fix story parsing --- pyrogram/types/messages_and_media/message.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index abb2ec42..510d861b 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -25,7 +25,7 @@ import pyrogram from pyrogram import raw, enums from pyrogram import types from pyrogram import utils -from pyrogram.errors import MessageIdsEmpty, PeerIdInvalid, ChannelPrivate +from pyrogram.errors import MessageIdsEmpty, PeerIdInvalid, ChannelPrivate, BotMethodInvalid from pyrogram.parser import utils as parser_utils, Parser from ..object import Object from ..update import Update @@ -868,7 +868,11 @@ class Message(Object, Update): media_type = enums.MessageMediaType.GIVEAWAY elif isinstance(media, raw.types.MessageMediaStory): if not media.story: - story = await client.get_stories(utils.get_peer_id(media.peer), media.id) + try: + story = await client.get_stories(utils.get_peer_id(media.peer), media.id) + except BotMethodInvalid: + pass + if not story: story = await types.Story._parse(client, media, users, chats, media.peer) else: @@ -1098,7 +1102,7 @@ class Message(Object, Update): parsed_message.reply_to_story_user_id, parsed_message.reply_to_story_id ) - except Exception: + except BotMethodInvalid: pass else: parsed_message.reply_to_story = reply_to_story