editMessageMedia method
Future<Message>
editMessageMedia(
- InputMedia media, {
- String? businessConnectionId,
- InlineKeyboardMarkup? replyMarkup,
Edits the current message's media.
Use this method to edit animation, audio, document, photo, or video 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.
Parameters:
media
: New media content of the messagebusinessConnectionId
: Unique identifier of the business connectionreplyMarkup
: Additional interface options
Returns the edited Message object.
Throws TeleverseException if no message information is found in the current update.
Example:
// Edit to a new photo
final newMedia = InputMediaPhoto(
media: InputFile.fromFile(File('new_image.jpg')),
caption: 'Updated image',
);
await ctx.editMessageMedia(newMedia);
// Edit to a video with caption
final videoMedia = InputMediaVideo(
media: InputFile.fromUrl('https://example.com/video.mp4'),
caption: 'New video content',
width: 1280,
height: 720,
);
await ctx.editMessageMedia(videoMedia);
Implementation
Future<Message> editMessageMedia(
InputMedia media, {
String? businessConnectionId,
InlineKeyboardMarkup? replyMarkup,
}) async {
final chatId = _getChatId();
final msgId = messageId;
_verifyInfo(
[chatId, msgId],
APIMethod.editMessageMedia,
description:
"No message or chat information found in the current update.",
);
return api.editMessageMedia(
chatId!,
msgId!,
media,
businessConnectionId: _businessConnectionId(businessConnectionId),
replyMarkup: replyMarkup,
);
}