editMessageText method

Future<Message> editMessageText(
  1. String text, {
  2. dynamic chat_id,
  3. int? message_id,
  4. String? inline_message_id,
  5. String? parse_mode,
  6. bool? disable_web_page_preview,
  7. InlineKeyboardMarkup? reply_markup,
})
inherited

Use this method to edit text and Game messages sent by the bot or via the bot (for inline bots).

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

https://core.telegram.org/bots/api#editmessagetext

Implementation

Future<Message> editMessageText(String text,
    {dynamic chat_id,
    int? message_id,
    String? inline_message_id,
    String? parse_mode,
    bool? disable_web_page_preview,
    InlineKeyboardMarkup? reply_markup}) async {
  if (inline_message_id == null && (chat_id == null || message_id == null)) {
    return Future.error(TelegramException(
        'Require either \'chat_id\' and \'message_id\', or \'inline_message_id\''));
  }
  if (chat_id != null && (chat_id is! String && chat_id is! int)) {
    return Future.error(TelegramException(
        'Attribute \'chat_id\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('editMessageText');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'message_id': message_id,
    'inline_message_id': inline_message_id,
    'text': text,
    'parse_mode': parse_mode,
    'disable_web_page_preview': disable_web_page_preview,
    'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
  };
  var res = await HttpClient.httpPost(requestUrl, body: body);
  if (res == true) {
    return Future.error(
        TelegramException('Edited message is NOT sent by the bot'));
  } else {
    return Message.fromJson(res);
  }
}