copyMessage method

Future<MessageId> copyMessage(
  1. dynamic chat_id,
  2. int from_chat_id,
  3. int message_id, {
  4. String? caption,
  5. String? parse_mode,
  6. List<MessageEntity>? caption_entities,
  7. bool? disable_notification,
  8. int? reply_to_message_id,
  9. bool? allow_sending_without_reply,
  10. ReplyMarkup? reply_markup,
})
inherited

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 chat_id,
  int from_chat_id,
  int message_id, {
  String? caption,
  String? parse_mode,
  List<MessageEntity>? caption_entities,
  bool? disable_notification,
  int? reply_to_message_id,
  bool? allow_sending_without_reply,
  ReplyMarkup? reply_markup,
}) 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('copyMessage');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'from_chat_id': from_chat_id,
    'message_id': message_id,
    'caption': caption,
    'parse_mode': parse_mode,
    'caption_entities':
        caption_entities == null ? null : jsonEncode(caption_entities),
    'disable_notification': disable_notification,
    'reply_to_message_id': reply_to_message_id,
    'allow_sending_without_reply': allow_sending_without_reply,
    'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup)
  };
  return MessageId.fromJson(
      await HttpClient.httpPost(requestUrl, body: body));
}