#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::MessageId;
use crate::types::{InlineKeyboardMarkup, MessageEntity, ReplyParameters};
use crate::Bot;
impl Bot {
pub fn copy_message(
&self,
chat_id: i64,
from_chat_id: i64,
message_id: i64,
) -> CopyMessageBuilder {
CopyMessageBuilder::new(self, chat_id, from_chat_id, message_id)
}
}
#[derive(Serialize)]
pub struct CopyMessageBuilder<'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_id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub caption_entities: Option<Vec<MessageEntity>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub show_caption_above_media: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_notification: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub protect_content: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_parameters: Option<ReplyParameters>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>,
}
impl<'a> CopyMessageBuilder<'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,
message_id,
caption: None,
parse_mode: None,
caption_entities: None,
show_caption_above_media: None,
disable_notification: None,
protect_content: None,
reply_parameters: None,
reply_markup: 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_id(mut self, message_id: i64) -> Self {
self.message_id = message_id;
self
}
pub fn caption(mut self, caption: String) -> Self {
self.caption = Some(caption);
self
}
pub fn parse_mode(mut self, parse_mode: String) -> Self {
self.parse_mode = Some(parse_mode);
self
}
pub fn caption_entities(mut self, caption_entities: Vec<MessageEntity>) -> Self {
self.caption_entities = Some(caption_entities);
self
}
pub fn show_caption_above_media(mut self, show_caption_above_media: bool) -> Self {
self.show_caption_above_media = Some(show_caption_above_media);
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 reply_parameters(mut self, reply_parameters: ReplyParameters) -> Self {
self.reply_parameters = Some(reply_parameters);
self
}
pub fn reply_markup(mut self, reply_markup: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(reply_markup);
self
}
pub async fn send(self) -> Result<MessageId> {
let form = serde_json::to_value(&self)?;
self.bot.get("copyMessage", Some(&form)).await
}
}