sendVideoNote method
Future<Message>
sendVideoNote(
- dynamic chat_id,
- dynamic video_note, {
- int? duration,
- int? length,
- dynamic thumb,
- bool? disable_notification,
- int? reply_to_message_id,
- bool? allow_sending_without_reply,
- ReplyMarkup? reply_markup,
inherited
Use this method to send video messages
On success, the sent Message is returned.
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
Implementation
Future<Message> sendVideoNote(dynamic chat_id, dynamic video_note,
{int? duration,
int? length,
dynamic thumb,
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('sendVideoNote');
var body = <String, dynamic>{
'chat_id': chat_id,
'duration': duration,
'length': length,
'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),
};
var multiPartFiles = <MultipartFile>[];
if (video_note is io.File) {
multiPartFiles.add(HttpClient.toMultiPartFile(video_note, 'video_note'));
} else if (video_note is String) {
body.addAll({'video_note': video_note});
} else {
return Future.error(TelegramException(
'Attribute \'video_note\' can only be either io.File or String (Telegram file_id or image url)'));
}
if (thumb != null) {
if (thumb is io.File) {
multiPartFiles.add(HttpClient.toMultiPartFile(thumb, 'thumb'));
} else if (thumb is String) {
body.addAll({'thumb': thumb});
} else {
return Future.error(TelegramException(
'Attribute \'thumb\' can only be either io.File or String (Telegram file_id or image url)'));
}
}
return multiPartFiles.isEmpty
? Message.fromJson(await HttpClient.httpPost(requestUrl, body: body))
: Message.fromJson(await HttpClient.httpMultipartPost(
requestUrl, multiPartFiles,
body: body));
}