editMessageCaption method

Future<Message> editMessageCaption({
  1. String? businessConnectionId,
  2. String? caption,
  3. ParseMode? parseMode,
  4. List<MessageEntity>? captionEntities,
  5. bool? showCaptionAboveMedia,
  6. InlineKeyboardMarkup? replyMarkup,
})

Edits the current message's caption.

Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned.

Parameters:

  • businessConnectionId: Unique identifier of the business connection
  • caption: New caption of the message, 0-1024 characters after entities parsing
  • parseMode: Mode for parsing entities in the message caption
  • captionEntities: List of special entities that appear in the caption
  • showCaptionAboveMedia: Pass True, if the caption must be shown above the message media
  • replyMarkup: Additional interface options

Returns the edited Message object.

Throws TeleverseException if no message information is found in the current update.

Example:

// Edit caption
await ctx.editMessageCaption(caption: 'Updated caption');

// Edit with formatting
await ctx.editMessageCaption(
  caption: '*Updated caption* with _formatting_',
  parseMode: ParseMode.markdownV2,
);

// Show caption above media
await ctx.editMessageCaption(
  caption: 'Caption above the photo',
  showCaptionAboveMedia: true,
);

Implementation

Future<Message> editMessageCaption({
  String? businessConnectionId,
  String? caption,
  ParseMode? parseMode,
  List<MessageEntity>? captionEntities,
  bool? showCaptionAboveMedia,
  InlineKeyboardMarkup? replyMarkup,
}) async {
  final chatId = _getChatId();
  final msgId = messageId;
  _verifyInfo(
    [chatId, msgId],
    APIMethod.editMessageCaption,
    description:
        "No message or chat information found in the current update.",
  );

  return api.editMessageCaption(
    chatId!,
    msgId!,
    businessConnectionId: _businessConnectionId(businessConnectionId),
    caption: caption,
    parseMode: parseMode,
    captionEntities: captionEntities,
    showCaptionAboveMedia: showCaptionAboveMedia,
    replyMarkup: replyMarkup,
  );
}