diff --git a/telethon/events/callbackquery.py b/telethon/events/callbackquery.py index 886cca14..142a9d5a 100644 --- a/telethon/events/callbackquery.py +++ b/telethon/events/callbackquery.py @@ -235,6 +235,12 @@ class CallbackQuery(EventBuilder): Returns the edited :tl:`Message`. This method also creates a task to `answer` the callback. + + .. note:: + + This method won't respect the previous message unlike + `Message.edit `, + since the message object is normally not present. """ self._client.loop.create_task(self.answer()) return await self._client.edit_message( diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index c980857c..7a632ba2 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -628,10 +628,28 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC): Returns ``None`` if the message was incoming, or the edited `Message` otherwise. + + .. note:: + + This is different from `client.edit_message + ` + and **will respect** the previous state of the message. + For example, if the message didn't have a link preview, + the edit won't add one by default, and you should force + it by setting it to ``True`` if you want it. + + 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: return None # We assume self.out was patched for our chat + if 'link_preview' not in kwargs: + kwargs['link_preview'] = bool(self.web_preview) + + if 'buttons' not in kwargs: + kwargs['buttons'] = self.buttons + return await self._client.edit_message( await self.get_input_chat(), self.id, *args, **kwargs