Skip to content

Commit

Permalink
pyrofork: Add reply_to_chat_id field to class Message
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <[email protected]>

(cherry picked from commit 430cc9f)
Signed-off-by: eyMarv <[email protected]>
  • Loading branch information
wulan17 authored and eyMarv committed Sep 4, 2024
1 parent c97fdb7 commit 31016d2
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class Message(Object, Update):
is_topic_message (``bool``, *optional*):
True, if the message is sent to a forum topic
reply_to_chat_id (``int``, *optional*):
Unique identifier of the chat where the replied message belongs to.
reply_to_message_id (``int``, *optional*):
The id of the message which this message directly replied to.
Expand Down Expand Up @@ -463,6 +466,7 @@ def __init__(
forward_signature: str = None,
forward_date: datetime = None,
is_topic_message: bool = None,
reply_to_chat_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_story_user_id: int = None,
Expand Down Expand Up @@ -580,6 +584,7 @@ def __init__(
self.forward_signature = forward_signature
self.forward_date = forward_date
self.is_topic_message = is_topic_message
self.reply_to_chat_id = reply_to_chat_id
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
Expand Down Expand Up @@ -1414,35 +1419,20 @@ async def _parse(
message.reply_to.peer.chat_id
)
else:
parsed_message.reply_to_story_chat_id = utils.get_channel_id(
message.reply_to.peer.channel_id
)
parsed_message.reply_to_story_chat_id = utils.get_channel_id(message.reply_to.peer.channel_id)
rtci = getattr(message.reply_to, "reply_to_peer_id", None)
reply_to_chat_id = utils.get_channel_id(utils.get_raw_peer_id(rtci)) if rtci else None
if rtci is not None and parsed_message.chat.id != reply_to_chat_id:
parsed_message.reply_to_chat_id = reply_to_chat_id

if replies:
if parsed_message.reply_to_message_id:
# is_cross_chat = getattr(
# message.reply_to, "reply_to_peer_id", None
# ) and getattr(
# message.reply_to.reply_to_peer_id, "channel_id", None
# )
is_cross_chat = False
if is_cross_chat is True:
key = (
utils.get_channel_id(
message.reply_to.reply_to_peer_id.channel_id
),
message.reply_to.reply_to_msg_id,
)
reply_to_params = {"chat_id": key[0], "message_ids": key[1]}
if rtci is not None and parsed_message.chat.id != reply_to_chat_id:
key = (reply_to_chat_id, message.reply_to.reply_to_msg_id)
reply_to_params = {"chat_id": key[0], 'message_ids': key[1]}
else:
key = (
parsed_message.chat.id,
parsed_message.reply_to_message_id,
)
reply_to_params = {
"chat_id": key[0],
"reply_to_message_ids": message.id,
}
key = (parsed_message.chat.id, parsed_message.reply_to_message_id)
reply_to_params = {'chat_id': key[0], 'reply_to_message_ids': message.id}

try:
reply_to_message = client.message_cache[key]
Expand Down

0 comments on commit 31016d2

Please sign in to comment.