EditMessageRequest
Both users and bots can use this request. See code examples.
---functions--- messages.editMessage#dfd14005 flags:# no_webpage:flags.1?true invert_media:flags.16?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.15?date quick_reply_shortcut_id:flags.17?int = Updates
Returns
Updates |
This type can be an instance of either:
UpdateShort | UpdateShortChatMessage |
UpdateShortMessage | UpdateShortSentMessage |
Updates | UpdatesCombined |
UpdatesTooLong |
Parameters
peer | InputPeer | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer , User or Channel objects, etc.). |
id | int | |
no_webpage | flag | This argument defaults to None and can be omitted. |
invert_media | flag | This argument defaults to None and can be omitted. |
message | string | This argument defaults to None and can be omitted. |
media | InputMedia | This argument defaults to None and can be omitted. |
reply_markup | ReplyMarkup | This argument defaults to None and can be omitted. |
entities | MessageEntity | This argument defaults to None and can be omitted. Otherwise, a list must be supplied. |
schedule_date | date | This argument defaults to None and can be omitted. |
quick_reply_shortcut_id | int | This argument defaults to None and can be omitted. |
Known RPC errors
This request can cause 15 known errors:
ChannelInvalidError | Invalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited. |
ChannelPrivateError | The channel specified is private and you lack permission to access it. Another reason may be that you were banned from it. |
ChatWriteForbiddenError | You can't write in this chat. |
EntityBoundsInvalidError | Some of provided entities have invalid bounds (length is zero or out of the boundaries of the string). |
InlineBotRequiredError | The action must be performed through an inline bot callback. |
InputUserDeactivatedError | The specified user was deleted. |
MediaGroupedInvalidError | You tried to send media of different types in an album. |
MediaNewInvalidError | The new media to edit the message with is invalid (such as stickers or voice notes). |
MediaPrevInvalidError | The old media cannot be edited with anything else (such as stickers or voice notes). |
MessageAuthorRequiredError | Message author required. |
MessageEditTimeExpiredError | You can't edit this message anymore, too much time has passed since its creation.. |
MessageEmptyError | Empty or invalid UTF-8 message was sent. |
MessageIdInvalidError | The specified message ID is invalid or you can't do that operation on such message. |
MessageNotModifiedError | Content of the message was not modified. |
PeerIdInvalidError | An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations). |
You can import these from telethon.errors
.
Example
Please refer to the documentation of client.edit_message()
to learn about the parameters and see several code examples on how to use it.
The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.
from telethon.sync import TelegramClient from telethon import functions, types with TelegramClient(name, api_id, api_hash) as client: result = client(functions.messages.EditMessageRequest( peer='username', id=42, no_webpage=True, invert_media=True, message='Hello there!', media=types.InputMediaUploadedPhoto( file=client.upload_file('/path/to/file.jpg'), spoiler=True, stickers=[types.InputDocument( id=-12398745604826, access_hash=-12398745604826, file_reference=b'arbitrary\x7f data \xfa here' )], ttl_seconds=42 ), schedule_date=datetime.datetime(2018, 6, 25), quick_reply_shortcut_id=42 )) print(result.stringify())