Pyrofork: Update stories with Layer 174 changes

This commit is contained in:
wulan17 2024-02-28 21:18:00 +07:00
parent 29ec92c92f
commit cb23b6d17b
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
5 changed files with 34 additions and 13 deletions

View file

@ -139,7 +139,7 @@ class Dispatcher:
await pyrogram.types.Story._parse(self.client, update.story, update.peer),
StoryHandler
)
async def message_bot_na_reaction_parser(update, users, chats):
return (
pyrogram.types.MessageReactionUpdated._parse(self.client, update, users, chats),

View file

@ -25,8 +25,8 @@ class InputReplyToStory(Object):
Parameters:
user_id (:obj:`~pyrogram.raw.types.InputUser`):
An InputUser.
peer (:obj:`~pyrogram.raw.types.InputPeer`):
An InputPeer.
story_id (``int``):
Unique identifier for the target story.
@ -34,16 +34,16 @@ class InputReplyToStory(Object):
def __init__(
self, *,
user_id: "raw.types.InputUser" = None,
peer: "raw.types.InputPeer" = None,
story_id: int = None
):
super().__init__()
self.user_id = user_id
self.peer = peer
self.story_id = story_id
def write(self):
return raw.types.InputReplyToStory(
user_id=self.user_id,
peer=self.peer,
story_id=self.story_id
).write()

View file

@ -117,6 +117,9 @@ class Message(Object, Update):
reply_to_story_user_id (``int``, *optional*):
The id of the story sender which this message directly replied to.
reply_to_story_chat_id (``int``, *optional*):
The id of the chat where the story was sent which this message directly replied to.
reply_to_top_message_id (``int``, *optional*):
The id of the first message which started this message thread.
@ -404,6 +407,7 @@ class Message(Object, Update):
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_story_user_id: int = None,
reply_to_story_chat_id: int = None,
reply_to_top_message_id: int = None,
reply_to_message: "Message" = None,
reply_to_story: "types.Story" = None,
@ -503,6 +507,7 @@ class Message(Object, Update):
self.reply_to_message_id = reply_to_message_id
self.reply_to_story_id = reply_to_story_id
self.reply_to_story_user_id = reply_to_story_user_id
self.reply_to_story_chat_id = reply_to_story_chat_id
self.reply_to_top_message_id = reply_to_top_message_id
self.reply_to_message = reply_to_message
self.reply_to_story = reply_to_story
@ -1106,7 +1111,12 @@ class Message(Object, Update):
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
else:
parsed_message.reply_to_story_id = message.reply_to.story_id
parsed_message.reply_to_story_user_id = message.reply_to.user_id
if isinstance(message.reply_to, raw.types.PeerUser):
parsed_message.reply_to_story_user_id = message.reply_to.peer.user_id
elif isinstance(message.reply_to, raw.types.PeerChat):
parsed_message.reply_to_story_chat_id = utils.get_channel_id(message.reply_to.peer.chat_id)
else:
parsed_message.reply_to_story_chat_id = utils.get_channel_id(message.reply_to.peer.channel_id)
if replies:
if parsed_message.reply_to_message_id:
@ -1134,7 +1144,7 @@ class Message(Object, Update):
elif parsed_message.reply_to_story_id:
try:
reply_to_story = await client.get_stories(
parsed_message.reply_to_story_user_id,
parsed_message.reply_to_story_user_id or parsed_message.reply_to_story_chat_id,
parsed_message.reply_to_story_id
)
except Exception:

View file

@ -31,9 +31,12 @@ class Story(Object, Update):
id (``int``):
Unique story identifier.
chat (:obj:`~pyrogram.types.Chat`, *optional*):
Chat the story was sent in.
from_user (:obj:`~pyrogram.types.User`, *optional*):
Sender of the story.
sender_chat (:obj:`~pyrogram.types.Chat`, *optional*):
Sender of the story. If the story is from channel.
@ -59,7 +62,7 @@ class Story(Object, Update):
video (:obj:`~pyrogram.types.Video`, *optional*):
Story is a video, information about the video.
edited (``bool``, *optional*):
True, if the Story has been edited.
@ -111,6 +114,7 @@ class Story(Object, Update):
*,
client: "pyrogram.Client" = None,
id: int,
chat: "types.Chat" = None,
from_user: "types.User" = None,
sender_chat: "types.Chat" = None,
date: datetime,
@ -140,6 +144,7 @@ class Story(Object, Update):
super().__init__(client)
self.id = id
self.chat = chat
self.from_user = from_user
self.sender_chat = sender_chat
self.date = date
@ -181,6 +186,7 @@ class Story(Object, Update):
animation = None
photo = None
video = None
chat = None
from_user = None
sender_chat = None
privacy = None
@ -218,7 +224,11 @@ class Story(Object, Update):
id=[await client.resolve_peer(chat_id)]
)
)
sender_chat = types.Chat._parse_chat(client, chat.chats[0])
if stories.from_id is not None:
from_user = await client.get_users(stories.from_id.user_id)
chat = types.Chat._parse_chat(client, chat.chats[0])
else:
sender_chat = types.Chat._parse_chat(client, chat.chats[0])
elif isinstance(peer, raw.types.InputPeerSelf):
from_user = client.me
else:
@ -261,6 +271,7 @@ class Story(Object, Update):
return Story(
id=stories.id,
chat=chat,
from_user=from_user,
sender_chat=sender_chat,
date=utils.timestamp_to_datetime(stories.date),

View file

@ -472,9 +472,9 @@ async def get_reply_to(
quote_entities=entities
)
if reply_to_story_id:
user_id = await client.resolve_peer(chat_id)
peer = await client.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(
user_id=user_id,
peer=peer,
story_id=reply_to_story_id
)
return reply_to