Add reply_to_chat and reply_to_sender in Message (#4300)

This commit is contained in:
exovoq 2024-01-18 17:48:22 +00:00 committed by GitHub
parent 32a4cb82ce
commit 6ee2fffce8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -280,6 +280,8 @@ class Message(ChatGetter, SenderGetter, TLObject):
SenderGetter.__init__(self, sender_id)
self._forward = None
self._reply_to_chat = None
self._reply_to_sender = None
def _finish_init(self, client, entities, input_chat):
"""
@ -332,6 +334,14 @@ class Message(ChatGetter, SenderGetter, TLObject):
if self.replies and self.replies.channel_id:
self._linked_chat = entities.get(utils.get_peer_id(
types.PeerChannel(self.replies.channel_id)))
if self.reply_to:
if self.reply_to.reply_to_peer_id:
self._reply_to_chat = entities.get(utils.get_peer_id(self.reply_to.reply_to_peer_id))
if self.reply_to.reply_from:
if self.reply_to.reply_from.from_id:
self._reply_to_sender = entities.get(utils.get_peer_id(self.reply_to.reply_from.from_id))
# endregion Initialization
@ -408,6 +418,22 @@ class Message(ChatGetter, SenderGetter, TLObject):
"""
return self._forward
@property
def reply_to_chat(self):
"""
The :tl:`Channel` in which the replied-to message was sent,
if this message is a reply in another chat
"""
return self._reply_to_chat
@property
def reply_to_sender(self):
"""
The :tl:`User`, :tl:`Channel`, or whatever other entity that
sent the replied-to message, if this message is a reply in another chat.
"""
return self._reply_to_sender
@property
def buttons(self):
"""