forwardMessage method
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 messagedisableNotification
: Sends the message silentlymessageThreadId
: Unique identifier for the target message threadprotectContent
: Protects the contents from forwarding and savingvideoStartTimestamp
: 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,
);
}