Telethon/telethon/tl/custom/forward.py

54 lines
1.8 KiB
Python
Raw Normal View History

2018-07-10 16:15:22 +03:00
from .chatgetter import ChatGetter
from .sendergetter import SenderGetter
from ... import utils
from ...tl import types
2018-06-25 12:34:10 +03:00
2018-07-10 16:15:22 +03:00
class Forward(ChatGetter, SenderGetter):
2018-06-25 12:34:10 +03:00
"""
Custom class that encapsulates a :tl:`MessageFwdHeader` providing an
abstraction to easily access information like the original sender.
2018-07-10 16:15:22 +03:00
Remember that this class implements `ChatGetter
<telethon.tl.custom.chatgetter.ChatGetter>` and `SenderGetter
<telethon.tl.custom.sendergetter.SenderGetter>` which means you
have access to all their sender and chat properties and methods.
2018-06-25 12:34:10 +03:00
Attributes:
original_fwd (:tl:`MessageFwdHeader`):
The original :tl:`MessageFwdHeader` instance.
Any other attribute:
Attributes not described here are the same as those available
in the original :tl:`MessageFwdHeader`.
"""
def __init__(self, client, original, entities):
self.__dict__ = original.__dict__
self._client = client
self.original_fwd = original
2018-07-10 16:15:22 +03:00
self._sender_id = original.from_id
self._sender = entities.get(original.from_id)
try:
self._input_sender =\
utils.get_input_peer(self._sender) if self._sender else None
except TypeError:
self._input_sender = None
2018-06-25 12:34:10 +03:00
2018-07-10 16:15:22 +03:00
self._broadcast = None
if original.channel_id:
self._chat_peer = types.PeerChannel(original.channel_id)
self._chat = entities.get(utils.get_peer_id(self._chat_peer))
else:
self._chat_peer = None
self._chat = None
2018-06-25 12:34:10 +03:00
try:
self._input_chat = \
utils.get_input_peer(self._chat) if self._chat else None
except TypeError:
self._input_chat = None
2018-06-25 12:34:10 +03:00
2018-07-10 16:15:22 +03:00
# TODO We could reload the message