sendMessage method
Future<Message>
sendMessage(
- dynamic chat_id,
- String text, {
- String? parse_mode,
- List<
MessageEntity> ? entities, - bool? disable_web_page_preview,
- bool? disable_notification,
- int? reply_to_message_id,
- bool? allow_sending_without_reply,
- ReplyMarkup? reply_markup,
inherited
Use this method to send text messages. On success, the sent Message
is returned.
Implementation
Future<Message> sendMessage(dynamic chat_id, String text,
{String? parse_mode,
List<MessageEntity>? entities,
bool? disable_web_page_preview,
bool? disable_notification,
int? reply_to_message_id,
bool? allow_sending_without_reply,
ReplyMarkup? reply_markup}) async {
if (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('sendMessage');
var body = <String, dynamic>{
'chat_id': chat_id,
'text': text,
'parse_mode': parse_mode,
'entities': entities == null ? null : jsonEncode(entities),
'disable_web_page_preview': disable_web_page_preview,
'disable_notification': disable_notification,
'reply_to_message_id': reply_to_message_id,
'allow_sending_without_reply': allow_sending_without_reply,
'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}