edit_message_media()#
- Client.edit_message_media()#
Edit animation, audio, document, photo or video messages, or to add media to text messages.
If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. Otherwise, the message type can be changed arbitrarily.
Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
Usable by ✅ Users ✅ Bots- 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.file_name (
str
, optional) – File name of the media to be sent. Not applicable to photos. Defaults to file’s path basename.schedule_date (
datetime
, optional) – Date when the message will be automatically sent.business_connection_id (
str
, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent
- Returns:
Message
– On success, the edited message is returned.
Example
from pyrogram.types import InputMediaPhoto, InputMediaVideo, InputMediaAudio # Replace the current media with a local photo await app.edit_message_media(chat_id, message_id, InputMediaPhoto("new_photo.jpg")) # Replace the current media with a local video await app.edit_message_media(chat_id, message_id, InputMediaVideo("new_video.mp4")) # Replace the current media with a local audio await app.edit_message_media(chat_id, message_id, InputMediaAudio("new_audio.mp3"))