Document custom.Message

This commit is contained in:
Lonami Exo 2018-06-02 12:52:38 +02:00
parent 5c76af34aa
commit f7222407de
6 changed files with 48 additions and 16 deletions

View File

@ -19,3 +19,21 @@ telethon\.tl\.custom\.dialog module
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :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:

View File

@ -204,8 +204,8 @@ class ChatAction(EventBuilder):
@property @property
def pinned_message(self): def pinned_message(self):
""" """
If ``new_pin`` is ``True``, this returns the (:tl:`Message`) If ``new_pin`` is ``True``, this returns the
object that was pinned. `telethon.tl.custom.message.Message` object that was pinned.
""" """
if self._pinned_message == 0: if self._pinned_message == 0:
return None return None

View File

@ -91,7 +91,8 @@ class MessageRead(EventBuilder):
@property @property
def messages(self): 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 Use :meth:`is_read` if you need to check whether a message
was read instead checking if it's in here. was read instead checking if it's in here.

View File

@ -800,7 +800,7 @@ class TelegramClient(TelegramBareClient):
Has no effect when sending a file. Has no effect when sending a file.
Returns: Returns:
The sent :tl:`Message`. The sent `telethon.tl.custom.message.Message`.
""" """
if file is not None: if file is not None:
return self.send_file( return self.send_file(
@ -880,8 +880,8 @@ class TelegramClient(TelegramBareClient):
order for the forward to work. order for the forward to work.
Returns: Returns:
The list of forwarded :tl:`Message`, or a single one if a list The list of forwarded `telethon.tl.custom.message.Message`,
wasn't provided as input. or a single one if a list wasn't provided as input.
""" """
single = not utils.is_list_like(messages) single = not utils.is_list_like(messages)
if single: if single:
@ -974,7 +974,7 @@ class TelegramClient(TelegramBareClient):
not modified at all. not modified at all.
Returns: Returns:
The edited :tl:`Message`. The edited `telethon.tl.custom.message.Message`.
""" """
if isinstance(entity, Message): if isinstance(entity, Message):
text = message # Shift the parameters to the right 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. A single-item list to pass the total parameter by reference.
Yields: Yields:
Instances of :tl:`Message` with extra attributes: Instances of `telethon.tl.custom.message.Message`.
* ``.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.
Notes: Notes:
Telegram's flood wait limit for :tl:`GetHistoryRequest` seems to 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. it will be used to determine metadata from audio and video files.
Returns: Returns:
The :tl:`Message` (or messages) containing the sent file, The `telethon.tl.custom.message.Message` (or messages) containing
or messages if a list of them was passed. the sent file, or messages if a list of them was passed.
""" """
# First check if the user passed an iterable, in which case # First check if the user passed an iterable, in which case
# we may want to send as an album if all are photo files. # we may want to send as an album if all are photo files.

View File

@ -66,6 +66,10 @@ class Message:
@property @property
def client(self): def client(self):
"""
Returns the `telethon.telegram_client.TelegramClient` instance that
created this instance.
"""
return self._client return self._client
@property @property
@ -176,6 +180,15 @@ class Message:
@property @property
def input_chat(self): 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._input_chat is None:
if self._chat is None: if self._chat is None:
try: try:
@ -350,7 +363,8 @@ class Message:
@property @property
def reply_message(self): 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 Note that this will make a network call to fetch the message and
will later be cached. will later be cached.

View File

@ -22,6 +22,10 @@ class MessageButton:
@property @property
def client(self): def client(self):
"""
Returns the `telethon.telegram_client.TelegramClient` instance that
created this instance.
"""
return self._client return self._client
@property @property