mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-04 20:20:23 +03:00
add __bool__ dunder method to Message
This commit is contained in:
parent
27d6cce8e2
commit
3976988b33
|
@ -45,6 +45,9 @@ 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`),
|
||||
its ``__bool__`` method will yield :data:`False`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
@ -482,6 +485,9 @@ class Message(metaclass=NoPublicConstructor):
|
|||
else:
|
||||
return False
|
||||
|
||||
def __bool__(self):
|
||||
return not isinstance(self._raw, types.MessageEmpty)
|
||||
|
||||
|
||||
def build_msg_map(
|
||||
client: Client, messages: List[abcs.Message], chat_map: Dict[int, Chat]
|
||||
|
|
Loading…
Reference in New Issue
Block a user