From ced36adb03aac6d11949e256eb4949db1b96ef03 Mon Sep 17 00:00:00 2001 From: Nitan Alexandru Marcel Date: Fri, 7 Apr 2023 18:04:08 +0300 Subject: [PATCH] Fix editing inline messages of type InputBotInlineMessageID64 (#4082) --- readthedocs/misc/changelog.rst | 2 ++ telethon/client/messages.py | 8 ++++---- telethon/events/callbackquery.py | 4 ++-- telethon/version.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/readthedocs/misc/changelog.rst b/readthedocs/misc/changelog.rst index 80d9c987..4b2de63c 100644 --- a/readthedocs/misc/changelog.rst +++ b/readthedocs/misc/changelog.rst @@ -51,6 +51,8 @@ Bug fixes you can actually have a chance to handle them. * Update handling should be more resilient. * ``PhoneCodeExpiredError`` will correctly clear the stored hash if it occurs in ``sign_in``. +* In patch ``v1.28.2``, :tl:`InputBotInlineMessageID64` can now be used + to edit inline messages. .. _issue 4050: https://github.com/LonamiWebs/Telethon/issues/4050 diff --git a/telethon/client/messages.py b/telethon/client/messages.py index d7729a80..871a7655 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -1064,7 +1064,7 @@ class MessageMethods: from it, so the next parameter will be assumed to be the message text. - You may also pass a :tl:`InputBotInlineMessageID`, + You may also pass a :tl:`InputBotInlineMessageID` or :tl:`InputBotInlineMessageID64`, which is the only way to edit messages that were sent after the user selects an inline query result. @@ -1136,7 +1136,7 @@ class MessageMethods: Returns The edited `Message `, - unless `entity` was a :tl:`InputBotInlineMessageID` in which + unless `entity` was a :tl:`InputBotInlineMessageID` or :tl:`InputBotInlineMessageID64` in which case this method returns a boolean. Raises @@ -1162,7 +1162,7 @@ class MessageMethods: # or await client.edit_message(message, 'hello!!!') """ - if isinstance(entity, types.InputBotInlineMessageID): + if isinstance(entity, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)): text = text or message message = entity elif isinstance(entity, types.Message): @@ -1178,7 +1178,7 @@ class MessageMethods: attributes=attributes, force_document=force_document) - if isinstance(entity, types.InputBotInlineMessageID): + if isinstance(entity, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)): request = functions.messages.EditInlineBotMessageRequest( id=entity, message=text, diff --git a/telethon/events/callbackquery.py b/telethon/events/callbackquery.py index ce8f457c..408e3399 100644 --- a/telethon/events/callbackquery.py +++ b/telethon/events/callbackquery.py @@ -300,7 +300,7 @@ class CallbackQuery(EventBuilder): """ Edits the message. Shorthand for `telethon.client.messages.MessageMethods.edit_message` with - the ``entity`` set to the correct :tl:`InputBotInlineMessageID`. + the ``entity`` set to the correct :tl:`InputBotInlineMessageID` or :tl:`InputBotInlineMessageID64`. Returns `True` if the edit was successful. @@ -313,7 +313,7 @@ class CallbackQuery(EventBuilder): since the message object is normally not present. """ self._client.loop.create_task(self.answer()) - if isinstance(self.query.msg_id, types.InputBotInlineMessageID): + if isinstance(self.query.msg_id, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)): return await self._client.edit_message( self.query.msg_id, *args, **kwargs ) diff --git a/telethon/version.py b/telethon/version.py index 074e1b20..7fc03b31 100644 --- a/telethon/version.py +++ b/telethon/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '1.28.1' +__version__ = '1.28.2'