From 94471c149e222351b245568747012973bebb38d8 Mon Sep 17 00:00:00 2001 From: Nick80835 <24271245+Nick80835@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:43:06 -0500 Subject: [PATCH] Improve edit_message message type hint This also allows utils.get_message_id to get the ID of InputMessageID. --- telethon/client/messages.py | 4 ++-- telethon/utils.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 468962953..5f0afc61f 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -1066,7 +1066,7 @@ def get_key(m): async def edit_message( self: 'TelegramClient', entity: 'typing.Union[hints.EntityLike, types.Message]', - message: 'hints.MessageLike' = None, + message: 'typing.Union[int, types.Message, types.InputMessageID, str]' = None, text: str = None, *, parse_mode: str = (), @@ -1096,7 +1096,7 @@ async def edit_message( which is the only way to edit messages that were sent after the user selects an inline query result. - message (`int` | `Message ` | `str`): + message (`int` | `Message ` | :tl:`InputMessageID` | `str`): The ID of the message (or `Message ` itself) to be edited. If the `entity` was a `Message diff --git a/telethon/utils.py b/telethon/utils.py index 1c939e98c..7f5e3e230 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -600,6 +600,9 @@ def get_message_id(message): if isinstance(message, int): return message + if isinstance(message, types.InputMessageID): + return message.id + try: if message.SUBCLASS_OF_ID == 0x790009e3: # hex(crc32(b'Message')) = 0x790009e3