editMessageText method
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.
Implementation
Future<Message> editMessageText(String text,
{dynamic chatId,
int? messageId,
String? inlineMessageId,
String? parseMode,
bool? disableWebPagePreview,
InlineKeyboardMarkup? replyMarkup}) async {
if (inlineMessageId == null && (chatId == null || messageId == null)) {
return Future.error(TelegramException(
'Require either \'chatId\' and \'messageId\', or \'inlineMessageId\''));
}
if (chatId != null && (chatId is! String && chatId is! int)) {
return Future.error(TelegramException(
'Attribute \'chatId\' can only be either type of String or int'));
}
var requestUrl = _apiUri('editMessageText');
var body = <String, dynamic>{
'chat_id': chatId,
'message_id': messageId,
'inline_message_id': inlineMessageId,
'text': text,
'parse_mode': parseMode,
'disable_web_page_preview': disableWebPagePreview,
'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
};
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);
}
}