copyMessage method

Future<MessageId> copyMessage(
  1. dynamic chatId,
  2. int fromChatId,
  3. int messageId, {
  4. int? messageThreadId,
  5. String? caption,
  6. String? parseMode,
  7. List<MessageEntity>? captionEntities,
  8. bool? disableNotification,
  9. bool? protectContent,
  10. int? replyToMessageId,
  11. bool? allowSendingWithoutReply,
  12. ReplyMarkup? replyMarkup,
})

Use this method to copy messages of any kind

The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.

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

Implementation

Future<MessageId> copyMessage(dynamic chatId, int fromChatId, int messageId,
    {int? messageThreadId,
    String? caption,
    String? parseMode,
    List<MessageEntity>? captionEntities,
    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('copyMessage');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_thread_id': messageThreadId,
    'from_chat_id': fromChatId,
    'message_id': messageId,
    'caption': caption,
    'parse_mode': parseMode,
    'caption_entities':
        captionEntities == null ? null : jsonEncode(captionEntities),
    'disable_notification': disableNotification,
    'protect_content': protectContent,
    'reply_to_message_id': replyToMessageId,
    'allow_sending_without_reply': allowSendingWithoutReply,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup)
  };
  return MessageId.fromJson(
      await HttpClient.httpPost(requestUrl, body: body));
}