2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 04:48:06 +00:00

Add reply_to_message_id and reply_to_top_message_id to Message

This commit is contained in:
Dan 2022-02-17 11:41:14 +01:00
parent 54f8ca25fb
commit bca7e6461e

View File

@ -95,6 +95,12 @@ class Message(Object, Update):
forward_date (``int``, *optional*): forward_date (``int``, *optional*):
For forwarded messages, date the original message was sent in Unix time. For forwarded messages, date the original message was sent in Unix time.
reply_to_message_id (``int``, *optional*):
The id of the message which this message directly replied to.
reply_to_top_message_id (``int``, *optional*):
The id of the first message which started this message thread.
reply_to_message (:obj:`~pyrogram.types.Message`, *optional*): reply_to_message (:obj:`~pyrogram.types.Message`, *optional*):
For replies, the original message. Note that the Message object in this field will not contain For replies, the original message. Note that the Message object in this field will not contain
further reply_to_message fields even if it itself is a reply. further reply_to_message fields even if it itself is a reply.
@ -308,6 +314,8 @@ class Message(Object, Update):
forward_from_message_id: int = None, forward_from_message_id: int = None,
forward_signature: str = None, forward_signature: str = None,
forward_date: int = None, forward_date: int = None,
reply_to_message_id: int = None,
reply_to_top_message_id: int = None,
reply_to_message: "Message" = None, reply_to_message: "Message" = None,
mentioned: bool = None, mentioned: bool = None,
empty: bool = None, empty: bool = None,
@ -380,6 +388,8 @@ class Message(Object, Update):
self.forward_from_message_id = forward_from_message_id self.forward_from_message_id = forward_from_message_id
self.forward_signature = forward_signature self.forward_signature = forward_signature
self.forward_date = forward_date self.forward_date = forward_date
self.reply_to_message_id = reply_to_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.mentioned = mentioned self.mentioned = mentioned
self.empty = empty self.empty = empty
@ -792,15 +802,19 @@ class Message(Object, Update):
client=client client=client
) )
if message.reply_to and replies: if message.reply_to:
try: if replies:
parsed_message.reply_to_message = await client.get_messages( try:
parsed_message.chat.id, parsed_message.reply_to_message = await client.get_messages(
reply_to_message_ids=message.id, parsed_message.chat.id,
replies=replies - 1 reply_to_message_ids=message.id,
) replies=replies - 1
except MessageIdsEmpty: )
pass except MessageIdsEmpty:
pass
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
return parsed_message return parsed_message