mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 22:34:52 +00:00
Pyrofork: Update stories with Layer 174 changes
This commit is contained in:
parent
29ec92c92f
commit
cb23b6d17b
5 changed files with 34 additions and 13 deletions
|
|
@ -139,7 +139,7 @@ class Dispatcher:
|
||||||
await pyrogram.types.Story._parse(self.client, update.story, update.peer),
|
await pyrogram.types.Story._parse(self.client, update.story, update.peer),
|
||||||
StoryHandler
|
StoryHandler
|
||||||
)
|
)
|
||||||
|
|
||||||
async def message_bot_na_reaction_parser(update, users, chats):
|
async def message_bot_na_reaction_parser(update, users, chats):
|
||||||
return (
|
return (
|
||||||
pyrogram.types.MessageReactionUpdated._parse(self.client, update, users, chats),
|
pyrogram.types.MessageReactionUpdated._parse(self.client, update, users, chats),
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ class InputReplyToStory(Object):
|
||||||
|
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
user_id (:obj:`~pyrogram.raw.types.InputUser`):
|
peer (:obj:`~pyrogram.raw.types.InputPeer`):
|
||||||
An InputUser.
|
An InputPeer.
|
||||||
|
|
||||||
story_id (``int``):
|
story_id (``int``):
|
||||||
Unique identifier for the target story.
|
Unique identifier for the target story.
|
||||||
|
|
@ -34,16 +34,16 @@ class InputReplyToStory(Object):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, *,
|
self, *,
|
||||||
user_id: "raw.types.InputUser" = None,
|
peer: "raw.types.InputPeer" = None,
|
||||||
story_id: int = None
|
story_id: int = None
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.user_id = user_id
|
self.peer = peer
|
||||||
self.story_id = story_id
|
self.story_id = story_id
|
||||||
|
|
||||||
def write(self):
|
def write(self):
|
||||||
return raw.types.InputReplyToStory(
|
return raw.types.InputReplyToStory(
|
||||||
user_id=self.user_id,
|
peer=self.peer,
|
||||||
story_id=self.story_id
|
story_id=self.story_id
|
||||||
).write()
|
).write()
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,9 @@ class Message(Object, Update):
|
||||||
reply_to_story_user_id (``int``, *optional*):
|
reply_to_story_user_id (``int``, *optional*):
|
||||||
The id of the story sender which this message directly replied to.
|
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*):
|
reply_to_top_message_id (``int``, *optional*):
|
||||||
The id of the first message which started this message thread.
|
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_message_id: int = None,
|
||||||
reply_to_story_id: int = None,
|
reply_to_story_id: int = None,
|
||||||
reply_to_story_user_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_top_message_id: int = None,
|
||||||
reply_to_message: "Message" = None,
|
reply_to_message: "Message" = None,
|
||||||
reply_to_story: "types.Story" = 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_message_id = reply_to_message_id
|
||||||
self.reply_to_story_id = reply_to_story_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_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_top_message_id = reply_to_top_message_id
|
||||||
self.reply_to_message = reply_to_message
|
self.reply_to_message = reply_to_message
|
||||||
self.reply_to_story = reply_to_story
|
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
|
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
|
||||||
else:
|
else:
|
||||||
parsed_message.reply_to_story_id = message.reply_to.story_id
|
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 replies:
|
||||||
if parsed_message.reply_to_message_id:
|
if parsed_message.reply_to_message_id:
|
||||||
|
|
@ -1134,7 +1144,7 @@ class Message(Object, Update):
|
||||||
elif parsed_message.reply_to_story_id:
|
elif parsed_message.reply_to_story_id:
|
||||||
try:
|
try:
|
||||||
reply_to_story = await client.get_stories(
|
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
|
parsed_message.reply_to_story_id
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,12 @@ class Story(Object, Update):
|
||||||
id (``int``):
|
id (``int``):
|
||||||
Unique story identifier.
|
Unique story identifier.
|
||||||
|
|
||||||
|
chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||||
|
Chat the story was sent in.
|
||||||
|
|
||||||
from_user (:obj:`~pyrogram.types.User`, *optional*):
|
from_user (:obj:`~pyrogram.types.User`, *optional*):
|
||||||
Sender of the story.
|
Sender of the story.
|
||||||
|
|
||||||
sender_chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
sender_chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||||
Sender of the story. If the story is from channel.
|
Sender of the story. If the story is from channel.
|
||||||
|
|
||||||
|
|
@ -59,7 +62,7 @@ class Story(Object, Update):
|
||||||
|
|
||||||
video (:obj:`~pyrogram.types.Video`, *optional*):
|
video (:obj:`~pyrogram.types.Video`, *optional*):
|
||||||
Story is a video, information about the video.
|
Story is a video, information about the video.
|
||||||
|
|
||||||
edited (``bool``, *optional*):
|
edited (``bool``, *optional*):
|
||||||
True, if the Story has been edited.
|
True, if the Story has been edited.
|
||||||
|
|
||||||
|
|
@ -111,6 +114,7 @@ class Story(Object, Update):
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.Client" = None,
|
client: "pyrogram.Client" = None,
|
||||||
id: int,
|
id: int,
|
||||||
|
chat: "types.Chat" = None,
|
||||||
from_user: "types.User" = None,
|
from_user: "types.User" = None,
|
||||||
sender_chat: "types.Chat" = None,
|
sender_chat: "types.Chat" = None,
|
||||||
date: datetime,
|
date: datetime,
|
||||||
|
|
@ -140,6 +144,7 @@ class Story(Object, Update):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.chat = chat
|
||||||
self.from_user = from_user
|
self.from_user = from_user
|
||||||
self.sender_chat = sender_chat
|
self.sender_chat = sender_chat
|
||||||
self.date = date
|
self.date = date
|
||||||
|
|
@ -181,6 +186,7 @@ class Story(Object, Update):
|
||||||
animation = None
|
animation = None
|
||||||
photo = None
|
photo = None
|
||||||
video = None
|
video = None
|
||||||
|
chat = None
|
||||||
from_user = None
|
from_user = None
|
||||||
sender_chat = None
|
sender_chat = None
|
||||||
privacy = None
|
privacy = None
|
||||||
|
|
@ -218,7 +224,11 @@ class Story(Object, Update):
|
||||||
id=[await client.resolve_peer(chat_id)]
|
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):
|
elif isinstance(peer, raw.types.InputPeerSelf):
|
||||||
from_user = client.me
|
from_user = client.me
|
||||||
else:
|
else:
|
||||||
|
|
@ -261,6 +271,7 @@ class Story(Object, Update):
|
||||||
|
|
||||||
return Story(
|
return Story(
|
||||||
id=stories.id,
|
id=stories.id,
|
||||||
|
chat=chat,
|
||||||
from_user=from_user,
|
from_user=from_user,
|
||||||
sender_chat=sender_chat,
|
sender_chat=sender_chat,
|
||||||
date=utils.timestamp_to_datetime(stories.date),
|
date=utils.timestamp_to_datetime(stories.date),
|
||||||
|
|
|
||||||
|
|
@ -472,9 +472,9 @@ async def get_reply_to(
|
||||||
quote_entities=entities
|
quote_entities=entities
|
||||||
)
|
)
|
||||||
if reply_to_story_id:
|
if reply_to_story_id:
|
||||||
user_id = await client.resolve_peer(chat_id)
|
peer = await client.resolve_peer(chat_id)
|
||||||
reply_to = types.InputReplyToStory(
|
reply_to = types.InputReplyToStory(
|
||||||
user_id=user_id,
|
peer=peer,
|
||||||
story_id=reply_to_story_id
|
story_id=reply_to_story_id
|
||||||
)
|
)
|
||||||
return reply_to
|
return reply_to
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue