edit_message_text()

async Client.edit_message_text()

Edit the text of a message.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • message_id (int) – Unique identifier of the message to edit.

  • text (str) – New text of the message. If rich_text is provided, this is ignored.

  • parse_mode (ParseMode, optional) – By default, texts are parsed using both Markdown and HTML styles. You can combine both syntaxes.

  • entities (List of MessageEntity, optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • link_preview_options (LinkPreviewOptions, optional) – Link preview generation options for the message.

  • show_caption_above_media (bool, optional) – Pass True to show the caption above the media.

  • disable_web_page_preview (bool, optional) – Disables link previews for links in this message.

  • business_connection_id (str, optional) – Unique identifier of the business connection.

  • rich_text (str, optional) – Rich text (Markdown or HTML) to render a styled message. Overrides text.

  • rich_text_parse_mode (ParseMode, optional) – Parse mode for rich_text. Defaults to Markdown.

  • reply_markup (InlineKeyboardMarkup, optional) – An inline keyboard for the message.

Returns:

Message – On success, the edited message is returned.

Example

# Edit a message text
await app.edit_message_text(chat_id, message_id, "New text")