Fix editing inline messages of type InputBotInlineMessageID64 (#4082)

This commit is contained in:
Nitan Alexandru Marcel 2023-04-07 18:04:08 +03:00 committed by GitHub
parent 5b1135734b
commit ced36adb03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -51,6 +51,8 @@ Bug fixes
you can actually have a chance to handle them. you can actually have a chance to handle them.
* Update handling should be more resilient. * Update handling should be more resilient.
* ``PhoneCodeExpiredError`` will correctly clear the stored hash if it occurs in ``sign_in``. * ``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 .. _issue 4050: https://github.com/LonamiWebs/Telethon/issues/4050

View File

@ -1064,7 +1064,7 @@ class MessageMethods:
from it, so the next parameter will be assumed to be the from it, so the next parameter will be assumed to be the
message text. 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 which is the only way to edit messages that were sent
after the user selects an inline query result. after the user selects an inline query result.
@ -1136,7 +1136,7 @@ class MessageMethods:
Returns Returns
The edited `Message <telethon.tl.custom.message.Message>`, The edited `Message <telethon.tl.custom.message.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. case this method returns a boolean.
Raises Raises
@ -1162,7 +1162,7 @@ class MessageMethods:
# or # or
await client.edit_message(message, 'hello!!!') await client.edit_message(message, 'hello!!!')
""" """
if isinstance(entity, types.InputBotInlineMessageID): if isinstance(entity, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)):
text = text or message text = text or message
message = entity message = entity
elif isinstance(entity, types.Message): elif isinstance(entity, types.Message):
@ -1178,7 +1178,7 @@ class MessageMethods:
attributes=attributes, attributes=attributes,
force_document=force_document) force_document=force_document)
if isinstance(entity, types.InputBotInlineMessageID): if isinstance(entity, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)):
request = functions.messages.EditInlineBotMessageRequest( request = functions.messages.EditInlineBotMessageRequest(
id=entity, id=entity,
message=text, message=text,

View File

@ -300,7 +300,7 @@ class CallbackQuery(EventBuilder):
""" """
Edits the message. Shorthand for Edits the message. Shorthand for
`telethon.client.messages.MessageMethods.edit_message` with `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. Returns `True` if the edit was successful.
@ -313,7 +313,7 @@ class CallbackQuery(EventBuilder):
since the message object is normally not present. since the message object is normally not present.
""" """
self._client.loop.create_task(self.answer()) 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( return await self._client.edit_message(
self.query.msg_id, *args, **kwargs self.query.msg_id, *args, **kwargs
) )

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440. # Versions should comply with PEP440.
# This line is parsed in setup.py: # This line is parsed in setup.py:
__version__ = '1.28.1' __version__ = '1.28.2'