Improve documentation for Message

Co-authored-by: Lonami <totufals@hotmail.com>
This commit is contained in:
apepenkov 2023-11-10 09:18:36 +03:00 committed by GitHub
parent 54cfb7f102
commit 582d8859ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,15 @@ class Message(metaclass=NoPublicConstructor):
You can get a message from :class:`telethon.events.NewMessage`,
or from methods such as :meth:`telethon.Client.get_messages`.
If the message is empty (like when it's not found using :meth:`telethon.Client.get_messages_with_ids`),
Empty messages can occur very rarely when fetching the message history.
In these cases, only the :attr:`id` and :attr`peer` properties are guaranteed to be present.
To determine whether a message is empty, its truthy value can be checked via :meth:`object.__bool__`:
.. code-block:: python
async for message in client.iter_messages(chat):
if not message:
print('Found empty message with ID', message.id)
its ``__bool__`` method will yield :data:`False`.
"""