forwardMessage method

Future<Message> forwardMessage(
  1. ID toChatId, {
  2. bool? disableNotification,
  3. int? messageThreadId,
  4. bool? protectContent,
  5. int? videoStartTimestamp,
  6. int? directMessagesTopicId,
  7. SuggestedPostParameters? suggestedPostParameters,
})

Forwards the current message to another chat.

This method forwards the message from the current context to the specified chat. All original message content and metadata are preserved in the forwarded message.

Parameters:

  • toChatId: Target chat for forwarding the message
  • disableNotification: Sends the message silently
  • messageThreadId: Unique identifier for the target message thread
  • protectContent: Protects the contents from forwarding and saving
  • videoStartTimestamp: Timestamp in seconds for video forwarding

Returns the forwarded Message object.

Throws TeleverseException if no message information is found in the current update.

Example:

// Forward to another chat
await ctx.forwardMessage(ChatID(123456789));

// Forward with options
await ctx.forwardMessage(
  ChatID(123456789),
  disableNotification: true,
  protectContent: true,
);

Implementation

Future<Message> forwardMessage(
  ID toChatId, {
  bool? disableNotification,
  int? messageThreadId,
  bool? protectContent,
  int? videoStartTimestamp,
  int? directMessagesTopicId,
  SuggestedPostParameters? suggestedPostParameters,
}) async {
  final fromChatId = _getChatId();
  final msgId = messageId;
  _verifyInfo(
    [fromChatId, msgId],
    APIMethod.forwardMessage,
    description:
        "No message or chat information found in the current update.",
  );

  return api.forwardMessage(
    toChatId,
    fromChatId!,
    msgId!,
    disableNotification: disableNotification,
    messageThreadId: _threadId(messageThreadId),
    protectContent: protectContent,
    videoStartTimestamp: videoStartTimestamp,
    directMessagesTopicId: directMessagesTopicId,
    suggestedPostParameters: suggestedPostParameters,
  );
}