edit_message_media()

Client.edit_message_media()

Edit animation, audio, document, photo or video messages.

If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, the message type can be changed arbitrarily.

Parameters
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”. For a contact that exists in your Telegram address book you can use his phone number (str).

  • message_id (int) – Message identifier in the chat specified in chat_id.

  • media (InputMedia) – One of the InputMedia objects describing an animation, audio, document, photo or video.

  • reply_markup (InlineKeyboardMarkup, optional) – An InlineKeyboardMarkup object.

Returns

Message – On success, the edited message is returned.

Example

from pyrogram import InputMediaPhoto, InputMediaVideo, InputMediaAudio

# Replace the current media with a local photo
app.edit_message_media(chat_id, message_id, InputMediaPhoto("new_photo.jpg"))

# Replace the current media with a local video
app.edit_message_media(chat_id, message_id, InputMediaVideo("new_video.mp4"))

# Replace the current media with a local audio
app.edit_message_media(chat_id, message_id, InputMediaAudio("new_audio.mp3"))