forwardMessage method

Future<Message> forwardMessage(
  1. dynamic chatId,
  2. int fromChatId,
  3. int messageId, {
  4. int? messageThreadId,
  5. bool? disableNotification,
  6. bool? protectContent,
})

Use this method to forward messages of any kind. On success, the sent Message is returned.

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

Implementation

Future<Message> forwardMessage(dynamic chatId, int fromChatId, int messageId,
    {int? messageThreadId,
    bool? disableNotification,
    bool? protectContent}) 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('forwardMessage');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_thread_id': messageThreadId,
    'from_chat_id': fromChatId,
    'message_id': messageId,
    'disable_notification': disableNotification,
    'protect_content': protectContent,
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}