sendVideoNote method

Future<Message> sendVideoNote(
  1. dynamic chatId,
  2. dynamic videoNote, {
  3. int? messageThreadId,
  4. int? duration,
  5. int? length,
  6. dynamic thumbnail,
  7. bool? disableNotification,
  8. bool? protectContent,
  9. int? replyToMessageId,
  10. bool? allowSendingWithoutReply,
  11. ReplyMarkup? replyMarkup,
})

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.

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

Implementation

Future<Message> sendVideoNote(dynamic chatId, dynamic videoNote,
    {int? messageThreadId,
    int? duration,
    int? length,
    dynamic thumbnail,
    bool? disableNotification,
    bool? protectContent,
    int? replyToMessageId,
    bool? allowSendingWithoutReply,
    ReplyMarkup? replyMarkup}) async {
  if (chatId is! String && chatId is! int) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('sendVideoNote');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_thread_id': messageThreadId,
    'duration': duration,
    'length': length,
    'disable_notification': disableNotification,
    'protect_content': protectContent,
    'reply_to_message_id': replyToMessageId,
    'allow_sending_without_reply': allowSendingWithoutReply,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
  };

  var multiPartFiles = <MultipartFile>[];

  if (videoNote is io.File) {
    multiPartFiles.add(HttpClient.toMultiPartFile(videoNote, 'video_note'));
  } else if (videoNote is String) {
    body.addAll({'video_note': videoNote});
  } else {
    return Future.error(TelegramException(
        'Attribute \'videoNote\' can only be either io.File or String (Telegram fileId or image url)'));
  }

  if (thumbnail != null) {
    if (thumbnail is io.File) {
      multiPartFiles.add(HttpClient.toMultiPartFile(thumbnail, 'thumbnail'));
    } else if (thumbnail is String) {
      body.addAll({'thumbnail': thumbnail});
    } else {
      return Future.error(TelegramException(
          'Attribute \'thumbnail\' can only be either io.File or String (Telegram fileId or image url)'));
    }
  }

  return multiPartFiles.isEmpty
      ? Message.fromJson(await HttpClient.httpPost(requestUrl, body: body))
      : Message.fromJson(await HttpClient.httpMultipartPost(
          requestUrl, multiPartFiles,
          body: body));
}