forwardMessage method
Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned.
Required parameters:
chatId- Chat ID can either be ChatID or ChannelID or SupergroupIDfromChatId- Chat ID can either be ChatID or ChannelID or SupergroupIDmessageId- Message identifier in the chat specified infromChatId
You can optionally pass the more parameters as described in the official documentation.
disableNotification- Sends the message silently. Users will receive a notification with no sound.messageThreadId- Unique identifier for the target message thread (topic) of the forum; for forum supergroups onlyprotectContent- Protects the contents of the forwarded message from forwarding and saving
Example:
/// If you're using [ChatID] specify the chat id as an integer
bot.forwardMessage(ChatID(123456789), ChatID(987654321), 123456789);
/// If you're using [ChannelID] or [SupergroupID] specify the chat id as a string
/// Both [ChannelID] and [SupergroupID] are treated the same way
bot.forwardMessage(ChannelID("@myChannel"), ChannelID("@myChannel"), 123456789);
See more at https://core.telegram.org/bots/api#forwardmessage
Implementation
Future<Message> forwardMessage(
ID chatId,
ID fromChatId,
int messageId, {
bool? disableNotification,
int? messageThreadId,
bool? protectContent,
int? videoStartTimestamp,
}) async {
final params = {
"chat_id": chatId.id,
"from_chat_id": fromChatId.id,
"message_id": messageId,
"disable_notification": disableNotification,
"message_thread_id": messageThreadId,
"protect_content": protectContent,
"video_start_timestamp": videoStartTimestamp,
};
final response = await _makeApiJsonCall(
APIMethod.forwardMessage,
payload: Payload.from(params),
);
return Message.fromJson(response);
}