mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Add custom.Message.fwd_from_entity
This commit is contained in:
parent
58f621ba82
commit
66d5443fcd
|
@ -32,6 +32,14 @@ class Message:
|
|||
self._chat = entities.get(get_peer_id(self.original_message.to_id))
|
||||
self._input_sender = None
|
||||
self._input_chat = input_chat
|
||||
self._fwd_from_entity = None
|
||||
if getattr(self.original_message, 'fwd_from', None):
|
||||
fwd = self.original_message.fwd_from
|
||||
if fwd.from_id:
|
||||
self._fwd_from_entity = entities.get(fwd.from_id)
|
||||
elif fwd.channel_id:
|
||||
self._fwd_from_entity = entities.get(get_peer_id(
|
||||
types.PeerChannel(fwd.channel_id)))
|
||||
|
||||
def __getattr__(self, item):
|
||||
return getattr(self.original_message, item)
|
||||
|
@ -166,6 +174,23 @@ class Message:
|
|||
ids=self.original_message.reply_to_msg_id
|
||||
)
|
||||
|
||||
@property
|
||||
def fwd_from_entity(self):
|
||||
"""
|
||||
If the :tl:`Message` is a forwarded message, returns the :tl:`User`
|
||||
or :tl:`Channel` who originally sent the message, or ``None``.
|
||||
"""
|
||||
if self._fwd_from_entity is None:
|
||||
if getattr(self.original_message, 'fwd_from', None):
|
||||
fwd = self.original_message.fwd_from
|
||||
if fwd.from_id:
|
||||
self._fwd_from_entity = self._client.get_entity(
|
||||
fwd.from_id)
|
||||
elif fwd.channel_id:
|
||||
self._fwd_from_entity = self._client.get_entity(
|
||||
get_peer_id(types.PeerChannel(fwd.channel_id)))
|
||||
return self._fwd_from_entity
|
||||
|
||||
def reply(self, *args, **kwargs):
|
||||
"""
|
||||
Replies to the message (as a reply). Shorthand for
|
||||
|
|
Loading…
Reference in New Issue
Block a user