Fix story parsing

This commit is contained in:
KurimuzonAkuma 2023-12-11 11:14:26 +03:00
parent f7d0ec4e62
commit c991036a85

View File

@ -25,7 +25,7 @@ import pyrogram
from pyrogram import raw, enums from pyrogram import raw, enums
from pyrogram import types from pyrogram import types
from pyrogram import utils 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 pyrogram.parser import utils as parser_utils, Parser
from ..object import Object from ..object import Object
from ..update import Update from ..update import Update
@ -868,7 +868,11 @@ class Message(Object, Update):
media_type = enums.MessageMediaType.GIVEAWAY media_type = enums.MessageMediaType.GIVEAWAY
elif isinstance(media, raw.types.MessageMediaStory): elif isinstance(media, raw.types.MessageMediaStory):
if not media.story: 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: if not story:
story = await types.Story._parse(client, media, users, chats, media.peer) story = await types.Story._parse(client, media, users, chats, media.peer)
else: else:
@ -1098,7 +1102,7 @@ class Message(Object, Update):
parsed_message.reply_to_story_user_id, parsed_message.reply_to_story_user_id,
parsed_message.reply_to_story_id parsed_message.reply_to_story_id
) )
except Exception: except BotMethodInvalid:
pass pass
else: else:
parsed_message.reply_to_story = reply_to_story parsed_message.reply_to_story = reply_to_story