From f7222407deb879468523477ad364ad2422532c9b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 2 Jun 2018 12:52:38 +0200 Subject: [PATCH] Document custom.Message --- readthedocs/telethon.tl.custom.rst | 18 ++++++++++++++++++ telethon/events/chataction.py | 4 ++-- telethon/events/messageread.py | 3 ++- telethon/telegram_client.py | 19 +++++++------------ telethon/tl/custom/message.py | 16 +++++++++++++++- telethon/tl/custom/messagebutton.py | 4 ++++ 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/readthedocs/telethon.tl.custom.rst b/readthedocs/telethon.tl.custom.rst index 7f59596c..138811f6 100644 --- a/readthedocs/telethon.tl.custom.rst +++ b/readthedocs/telethon.tl.custom.rst @@ -19,3 +19,21 @@ telethon\.tl\.custom\.dialog module :members: :undoc-members: :show-inheritance: + + +telethon\.tl\.custom\.message module +------------------------------------ + +.. automodule:: telethon.tl.custom.message + :members: + :undoc-members: + :show-inheritance: + + +telethon\.tl\.custom\.messagebutton module +------------------------------------------ + +.. automodule:: telethon.tl.custom.messagebutton + :members: + :undoc-members: + :show-inheritance: diff --git a/telethon/events/chataction.py b/telethon/events/chataction.py index c6fcb374..3e653ddc 100644 --- a/telethon/events/chataction.py +++ b/telethon/events/chataction.py @@ -204,8 +204,8 @@ class ChatAction(EventBuilder): @property def pinned_message(self): """ - If ``new_pin`` is ``True``, this returns the (:tl:`Message`) - object that was pinned. + If ``new_pin`` is ``True``, this returns the + `telethon.tl.custom.message.Message` object that was pinned. """ if self._pinned_message == 0: return None diff --git a/telethon/events/messageread.py b/telethon/events/messageread.py index 3edd8a7f..b9dd6761 100644 --- a/telethon/events/messageread.py +++ b/telethon/events/messageread.py @@ -91,7 +91,8 @@ class MessageRead(EventBuilder): @property def messages(self): """ - The list of :tl:`Message` **which contents'** were read. + The list of `telethon.tl.custom.message.Message` + **which contents'** were read. Use :meth:`is_read` if you need to check whether a message was read instead checking if it's in here. diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index c6f55675..395863f4 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -800,7 +800,7 @@ class TelegramClient(TelegramBareClient): Has no effect when sending a file. Returns: - The sent :tl:`Message`. + The sent `telethon.tl.custom.message.Message`. """ if file is not None: return self.send_file( @@ -880,8 +880,8 @@ class TelegramClient(TelegramBareClient): order for the forward to work. Returns: - The list of forwarded :tl:`Message`, or a single one if a list - wasn't provided as input. + The list of forwarded `telethon.tl.custom.message.Message`, + or a single one if a list wasn't provided as input. """ single = not utils.is_list_like(messages) if single: @@ -974,7 +974,7 @@ class TelegramClient(TelegramBareClient): not modified at all. Returns: - The edited :tl:`Message`. + The edited `telethon.tl.custom.message.Message`. """ if isinstance(entity, Message): text = message # Shift the parameters to the right @@ -1109,12 +1109,7 @@ class TelegramClient(TelegramBareClient): A single-item list to pass the total parameter by reference. Yields: - Instances of :tl:`Message` with extra attributes: - - * ``.sender`` = entity of the sender. - * ``.fwd_from.sender`` = if fwd_from, who sent it originally. - * ``.fwd_from.channel`` = if fwd_from, original channel. - * ``.to`` = entity to which the message was sent. + Instances of `telethon.tl.custom.message.Message`. Notes: Telegram's flood wait limit for :tl:`GetHistoryRequest` seems to @@ -1610,8 +1605,8 @@ class TelegramClient(TelegramBareClient): it will be used to determine metadata from audio and video files. Returns: - The :tl:`Message` (or messages) containing the sent file, - or messages if a list of them was passed. + The `telethon.tl.custom.message.Message` (or messages) containing + the sent file, or messages if a list of them was passed. """ # First check if the user passed an iterable, in which case # we may want to send as an album if all are photo files. diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index e6287962..8150ab46 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -66,6 +66,10 @@ class Message: @property def client(self): + """ + Returns the `telethon.telegram_client.TelegramClient` instance that + created this instance. + """ return self._client @property @@ -176,6 +180,15 @@ class Message: @property def input_chat(self): + """ + This (:tl:`InputPeer`) is the input version of the chat where the + message was sent. Similarly to `input_sender`, this doesn't have + things like username or similar, but still useful in some cases. + + Note that this might not be available if the library doesn't know + where the message came from, and it may fetch the dialogs to try + to find it in the worst case. + """ if self._input_chat is None: if self._chat is None: try: @@ -350,7 +363,8 @@ class Message: @property def reply_message(self): """ - The :tl:`Message` that this message is replying to, or ``None``. + The `telethon.tl.custom.message.Message` that this message is replying + to, or ``None``. Note that this will make a network call to fetch the message and will later be cached. diff --git a/telethon/tl/custom/messagebutton.py b/telethon/tl/custom/messagebutton.py index edbe96f2..cd9b1ffc 100644 --- a/telethon/tl/custom/messagebutton.py +++ b/telethon/tl/custom/messagebutton.py @@ -22,6 +22,10 @@ class MessageButton: @property def client(self): + """ + Returns the `telethon.telegram_client.TelegramClient` instance that + created this instance. + """ return self._client @property