copyMessages method

Future<List<MessageId>> copyMessages(
  1. ID chatId,
  2. ID fromChatId,
  3. List<int> messageIds, {
  4. int? messageThreadId,
  5. bool? disableNotification,
  6. bool? protectContent,
  7. bool? removeCaption,
  8. int? directMessagesTopicId,
})

Copies messages of any kind.

See: https://core.telegram.org/bots/api#copymessages

Implementation

Future<List<MessageId>> copyMessages(
  ID chatId,
  ID fromChatId,
  List<int> messageIds, {
  int? messageThreadId,
  bool? disableNotification,
  bool? protectContent,
  bool? removeCaption,
  int? directMessagesTopicId,
}) async {
  final params = <String, dynamic>{
    'chat_id': chatId,
    'from_chat_id': fromChatId,
    'message_ids': messageIds,
    'message_thread_id': ?messageThreadId,
    'disable_notification': ?disableNotification,
    'protect_content': ?protectContent,
    'remove_caption': ?removeCaption,
    'direct_messages_topic_id': ?directMessagesTopicId,
  };

  final payload = Payload(params);
  final response = await _makeRequest<List<dynamic>>(
    APIMethod.copyMessages.name,
    payload,
  );

  return response.map((json) => MessageId.fromJson(json)).toList();
}