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:

UpdateShortUpdateShortChatMessage
UpdateShortMessageUpdateShortSentMessage
UpdatesUpdatesCombined
UpdatesTooLong

Parameters

peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
idint
no_webpageflagThis argument defaults to None and can be omitted.
invert_mediaflagThis argument defaults to None and can be omitted.
messagestringThis argument defaults to None and can be omitted.
mediaInputMediaThis argument defaults to None and can be omitted.
reply_markupReplyMarkupThis argument defaults to None and can be omitted.
entitiesMessageEntityThis argument defaults to None and can be omitted. Otherwise, a list must be supplied.
schedule_datedateThis argument defaults to None and can be omitted.
quick_reply_shortcut_idintThis argument defaults to None and can be omitted.

Known RPC errors

This request can cause 15 known errors:

ChannelInvalidErrorInvalid 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.
ChannelPrivateErrorThe channel specified is private and you lack permission to access it. Another reason may be that you were banned from it.
ChatWriteForbiddenErrorYou can't write in this chat.
EntityBoundsInvalidErrorSome of provided entities have invalid bounds (length is zero or out of the boundaries of the string).
InlineBotRequiredErrorThe action must be performed through an inline bot callback.
InputUserDeactivatedErrorThe specified user was deleted.
MediaGroupedInvalidErrorYou tried to send media of different types in an album.
MediaNewInvalidErrorThe new media to edit the message with is invalid (such as stickers or voice notes).
MediaPrevInvalidErrorThe old media cannot be edited with anything else (such as stickers or voice notes).
MessageAuthorRequiredErrorMessage author required.
MessageEditTimeExpiredErrorYou can't edit this message anymore, too much time has passed since its creation..
MessageEmptyErrorEmpty or invalid UTF-8 message was sent.
MessageIdInvalidErrorThe specified message ID is invalid or you can't do that operation on such message.
MessageNotModifiedErrorContent of the message was not modified.
PeerIdInvalidErrorAn 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())