From 0d05d0d8f5a2b508981a3c3b3a0af1c4a5b38ca8 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 23 Feb 2021 19:42:09 +0100 Subject: [PATCH] Update message to include ttl_period --- telethon/client/messages.py | 3 ++- telethon/events/newmessage.py | 6 ++++-- telethon/tl/custom/message.py | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 6604152e..8dd81448 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -833,7 +833,8 @@ class MessageMethods: out=result.out, media=result.media, entities=result.entities, - reply_markup=request.reply_markup + reply_markup=request.reply_markup, + ttl_period=result.ttl_period ) message._finish_init(self, {}, entity) return message diff --git a/telethon/events/newmessage.py b/telethon/events/newmessage.py index dc40ca11..7404cd10 100644 --- a/telethon/events/newmessage.py +++ b/telethon/events/newmessage.py @@ -114,7 +114,8 @@ class NewMessage(EventBuilder): fwd_from=update.fwd_from, via_bot_id=update.via_bot_id, reply_to=update.reply_to, - entities=update.entities + entities=update.entities, + ttl_period=update.ttl_period )) elif isinstance(update, types.UpdateShortChatMessage): event = cls.Event(types.Message( @@ -130,7 +131,8 @@ class NewMessage(EventBuilder): fwd_from=update.fwd_from, via_bot_id=update.via_bot_id, reply_to=update.reply_to, - entities=update.entities + entities=update.entities, + ttl_period=update.ttl_period )) else: return diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index a73566c8..50e03472 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -145,6 +145,12 @@ class Message(ChatGetter, SenderGetter, TLObject): An optional list of reasons why this message was restricted. If the list is `None`, this message has not been restricted. + ttl_period (`int`): + The Time To Live period configured for this message. + The message should be erased from wherever it's stored (memory, a + local database, etc.) when + ``datetime.now() > message.date + timedelta(seconds=message.ttl_period)``. + action (:tl:`MessageAction`): The message action object of the message for :tl:`MessageService` instances, which will be `None` for other types of messages. @@ -168,6 +174,7 @@ class Message(ChatGetter, SenderGetter, TLObject): post: Optional[bool] = None, from_id: Optional[types.TypePeer] = None, reply_to: Optional[types.TypeMessageReplyHeader] = None, + ttl_period: Optional[int] = None, # For Message (mandatory) message: Optional[str] = None, @@ -221,6 +228,7 @@ class Message(ChatGetter, SenderGetter, TLObject): self.post_author = post_author self.grouped_id = grouped_id self.restriction_reason = restriction_reason + self.ttl_period = ttl_period self.action = action # Convenient storage for custom functions