#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::MessageId;
use crate::Bot;
impl Bot {
pub fn forward_messages(
&self,
chat_id: i64,
from_chat_id: i64,
message_ids: Vec<i64>,
) -> ForwardMessagesBuilder {
ForwardMessagesBuilder::new(self, chat_id, from_chat_id, message_ids)
}
}
#[derive(Serialize)]
pub struct ForwardMessagesBuilder<'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,
pub message_ids: Vec<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>,
}
impl<'a> ForwardMessagesBuilder<'a> {
pub fn new(bot: &'a Bot, chat_id: i64, from_chat_id: i64, message_ids: Vec<i64>) -> Self {
Self {
bot,
chat_id,
message_thread_id: None,
from_chat_id,
message_ids,
disable_notification: None,
protect_content: None,
}
}
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 message_ids(mut self, message_ids: Vec<i64>) -> Self {
self.message_ids = message_ids;
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 async fn send(self) -> Result<Vec<MessageId>> {
let form = serde_json::to_value(&self)?;
self.bot.get("forwardMessages", Some(&form)).await
}
}