sendMediaGroup method

Future<List<Message>> sendMediaGroup(
  1. dynamic chat_id,
  2. List<InputMedia> media, {
  3. bool? disable_notification,
  4. int? reply_to_message_id,
  5. bool? allow_sending_without_reply,
})
inherited

Use this method to send a group of photos or videos as an album

On success, an array of the sent Messages is returned.

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

Implementation

Future<List<Message>> sendMediaGroup(dynamic chat_id, List<InputMedia> media,
    {bool? disable_notification,
    int? reply_to_message_id,
    bool? allow_sending_without_reply}) 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('sendMediaGroup');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'media': jsonEncode(media),
    'disable_notification': disable_notification,
    'reply_to_message_id': reply_to_message_id,
    'allow_sending_without_reply': allow_sending_without_reply,
  };
  return (await HttpClient.httpPost(requestUrl, body: body))
      .map<Message>((message) => Message.fromJson(message))
      .toList();
}