1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::MessageId;
use crate::types::{InlineKeyboardMarkup, MessageEntity};
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,
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 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_to_message_id: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_sending_without_reply: Option<bool>,
#[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,
from_chat_id,
message_id,
caption: None,
parse_mode: None,
caption_entities: None,
disable_notification: None,
protect_content: None,
reply_to_message_id: None,
allow_sending_without_reply: None,
reply_markup: None,
}
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = chat_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 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_to_message_id(mut self, reply_to_message_id: i64) -> Self {
self.reply_to_message_id = Some(reply_to_message_id);
self
}
pub fn allow_sending_without_reply(mut self, allow_sending_without_reply: bool) -> Self {
self.allow_sending_without_reply = Some(allow_sending_without_reply);
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::<MessageId>("copyMessage", Some(&form)).await
}
}