#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::Message;
use crate::Bot;
impl Bot {
pub fn forward_message(
&self,
chat_id: i64,
from_chat_id: i64,
message_id: i64,
) -> ForwardMessageBuilder {
ForwardMessageBuilder::new(self, chat_id, from_chat_id, message_id)
}
}
#[derive(Serialize)]
pub struct ForwardMessageBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
pub chat_id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub message_thread_id: Option<i64>,
pub from_chat_id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_notification: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub protect_content: Option<bool>,
pub message_id: i64,
}
impl<'a> ForwardMessageBuilder<'a> {
pub fn new(bot: &'a Bot, chat_id: i64, from_chat_id: i64, message_id: i64) -> Self {
Self {
bot,
chat_id,
message_thread_id: None,
from_chat_id,
disable_notification: None,
protect_content: None,
message_id,
}
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = chat_id;
self
}
pub fn message_thread_id(mut self, message_thread_id: i64) -> Self {
self.message_thread_id = Some(message_thread_id);
self
}
pub fn from_chat_id(mut self, from_chat_id: i64) -> Self {
self.from_chat_id = from_chat_id;
self
}
pub fn disable_notification(mut self, disable_notification: bool) -> Self {
self.disable_notification = Some(disable_notification);
self
}
pub fn protect_content(mut self, protect_content: bool) -> Self {
self.protect_content = Some(protect_content);
self
}
pub fn message_id(mut self, message_id: i64) -> Self {
self.message_id = message_id;
self
}
pub async fn send(self) -> Result<Message> {
let form = serde_json::to_value(&self)?;
self.bot.get("forwardMessage", Some(&form)).await
}
}