From 72faa893612936d68e49a0cd2ef1efe4390548f8 Mon Sep 17 00:00:00 2001 From: Non Date: Fri, 8 Sep 2023 19:35:25 +0300 Subject: [PATCH] Remove client-side check in message.edit (#4195) Fixes #4193. --- telethon/tl/custom/message.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 4959ed0f..7560dbc6 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -784,12 +784,26 @@ class Message(ChatGetter, SenderGetter, TLObject): async def edit(self, *args, **kwargs): """ - Edits the message iff it's outgoing. Shorthand for + Edits the message if it's outgoing. Shorthand for `telethon.client.messages.MessageMethods.edit_message` with both ``entity`` and ``message`` already set. - Returns `None` if the message was incoming, - or the edited `Message` otherwise. + Returns + The edited `Message `, + unless `entity` was a :tl:`InputBotInlineMessageID` or :tl:`InputBotInlineMessageID64` in which + case this method returns a boolean. + + Raises + ``MessageAuthorRequiredError`` if you're not the author of the + message but tried editing it anyway. + + ``MessageNotModifiedError`` if the contents of the message were + not modified at all. + + ``MessageIdInvalidError`` if the ID of the message is invalid + (the ID itself may be correct, but the message with that ID + cannot be edited). For example, when trying to edit messages + with a reply markup (or clear markup) this error will be raised. .. note:: @@ -803,9 +817,6 @@ class Message(ChatGetter, SenderGetter, TLObject): This is generally the most desired and convenient behaviour, and will work for link previews and message buttons. """ - if self.fwd_from or not self.out or not self._client: - return None # We assume self.out was patched for our chat - if 'link_preview' not in kwargs: kwargs['link_preview'] = bool(self.web_preview)