1#![allow(clippy::too_many_arguments)]
9
10use crate::bot::{Bot, ChatId};
11use crate::error::Result;
12use crate::request::request_parameter::{InputFileRef, RequestParameter};
13use crate::types::{
14 bot_command, bot_command_scope, bot_description, bot_name, chat_administrator_rights, files,
15 forum_topic, menu_button,
16};
17use serde::Serialize;
18
19fn push_opt_file(
24 params: &mut Vec<RequestParameter>,
25 name: &'static str,
26 val: Option<files::input_file::InputFile>,
27) {
28 if let Some(f) = val {
29 params.push(input_file_param(name, f));
30 }
31}
32
33fn input_file_param(name: &'static str, file: files::input_file::InputFile) -> RequestParameter {
34 match file {
35 files::input_file::InputFile::FileId(id) => {
36 RequestParameter::new(name, serde_json::Value::String(id))
37 }
38 files::input_file::InputFile::Url(url) => {
39 RequestParameter::new(name, serde_json::Value::String(url))
40 }
41 files::input_file::InputFile::Bytes { filename, data } => {
42 let file_ref = InputFileRef {
43 attach_name: None,
44 bytes: data,
45 mime_type: None,
46 file_name: Some(filename),
47 };
48 RequestParameter::file_only(name, file_ref)
49 }
50 files::input_file::InputFile::Path(path) => {
51 let filename = path
52 .file_name()
53 .unwrap_or_default()
54 .to_string_lossy()
55 .to_string();
56 let path_str = path.to_string_lossy().to_string();
57 let file_ref = InputFileRef {
58 attach_name: None,
59 bytes: Vec::new(),
60 mime_type: None,
61 file_name: Some(filename),
62 };
63 RequestParameter {
64 name: std::borrow::Cow::Borrowed(name),
65 value: Some(serde_json::Value::String(format!(
66 "__filepath__:{path_str}"
67 ))),
68 input_files: Some(vec![file_ref]),
69 }
70 }
71 }
72}
73
74macro_rules! impl_into_future {
75 ($builder:ident, $output:ty) => {
76 impl<'a> std::future::IntoFuture for $builder<'a> {
77 type Output = Result<$output>;
78 type IntoFuture =
79 std::pin::Pin<Box<dyn std::future::Future<Output = Self::Output> + Send + 'a>>;
80 fn into_future(self) -> Self::IntoFuture {
81 Box::pin(self.send())
82 }
83 }
84 };
85}
86
87#[derive(Serialize)]
97pub struct SetChatMenuButtonBuilder<'a> {
98 #[serde(skip)]
99 bot: &'a Bot,
100 #[serde(skip_serializing_if = "Option::is_none")]
101 chat_id: Option<i64>,
102 #[serde(skip_serializing_if = "Option::is_none")]
103 menu_button: Option<menu_button::MenuButton>,
104}
105
106impl<'a> SetChatMenuButtonBuilder<'a> {
107 pub fn chat_id(mut self, val: i64) -> Self {
109 self.chat_id = Some(val);
110 self
111 }
112 pub fn menu_button(mut self, val: menu_button::MenuButton) -> Self {
114 self.menu_button = Some(val);
115 self
116 }
117
118 pub async fn send(self) -> Result<bool> {
120 let payload = serde_json::to_vec(&self)?;
121 self.bot.do_post_json("setChatMenuButton", &payload).await
122 }
123}
124
125impl_into_future!(SetChatMenuButtonBuilder, bool);
126
127#[derive(Serialize)]
133pub struct GetChatMenuButtonBuilder<'a> {
134 #[serde(skip)]
135 bot: &'a Bot,
136 #[serde(skip_serializing_if = "Option::is_none")]
137 chat_id: Option<i64>,
138}
139
140impl<'a> GetChatMenuButtonBuilder<'a> {
141 pub fn chat_id(mut self, val: i64) -> Self {
143 self.chat_id = Some(val);
144 self
145 }
146
147 pub async fn send(self) -> Result<menu_button::MenuButton> {
149 let payload = serde_json::to_vec(&self)?;
150 self.bot.do_post_json("getChatMenuButton", &payload).await
151 }
152}
153
154impl_into_future!(GetChatMenuButtonBuilder, menu_button::MenuButton);
155
156#[derive(Serialize)]
162pub struct SetMyCommandsBuilder<'a> {
163 #[serde(skip)]
164 bot: &'a Bot,
165 commands: Vec<bot_command::BotCommand>,
166 #[serde(skip_serializing_if = "Option::is_none")]
167 scope: Option<bot_command_scope::BotCommandScope>,
168 #[serde(skip_serializing_if = "Option::is_none")]
169 language_code: Option<String>,
170}
171
172impl<'a> SetMyCommandsBuilder<'a> {
173 pub fn scope(mut self, val: bot_command_scope::BotCommandScope) -> Self {
175 self.scope = Some(val);
176 self
177 }
178 pub fn language_code(mut self, val: impl Into<String>) -> Self {
180 self.language_code = Some(val.into());
181 self
182 }
183
184 pub async fn send(self) -> Result<bool> {
186 let payload = serde_json::to_vec(&self)?;
187 self.bot.do_post_json("setMyCommands", &payload).await
188 }
189}
190
191impl_into_future!(SetMyCommandsBuilder, bool);
192
193#[derive(Serialize)]
199pub struct GetMyCommandsBuilder<'a> {
200 #[serde(skip)]
201 bot: &'a Bot,
202 #[serde(skip_serializing_if = "Option::is_none")]
203 scope: Option<bot_command_scope::BotCommandScope>,
204 #[serde(skip_serializing_if = "Option::is_none")]
205 language_code: Option<String>,
206}
207
208impl<'a> GetMyCommandsBuilder<'a> {
209 pub fn scope(mut self, val: bot_command_scope::BotCommandScope) -> Self {
211 self.scope = Some(val);
212 self
213 }
214 pub fn language_code(mut self, val: impl Into<String>) -> Self {
216 self.language_code = Some(val.into());
217 self
218 }
219
220 pub async fn send(self) -> Result<Vec<bot_command::BotCommand>> {
222 let payload = serde_json::to_vec(&self)?;
223 self.bot.do_post_json("getMyCommands", &payload).await
224 }
225}
226
227impl_into_future!(GetMyCommandsBuilder, Vec<bot_command::BotCommand>);
228
229#[derive(Serialize)]
235pub struct DeleteMyCommandsBuilder<'a> {
236 #[serde(skip)]
237 bot: &'a Bot,
238 #[serde(skip_serializing_if = "Option::is_none")]
239 scope: Option<bot_command_scope::BotCommandScope>,
240 #[serde(skip_serializing_if = "Option::is_none")]
241 language_code: Option<String>,
242}
243
244impl<'a> DeleteMyCommandsBuilder<'a> {
245 pub fn scope(mut self, val: bot_command_scope::BotCommandScope) -> Self {
247 self.scope = Some(val);
248 self
249 }
250 pub fn language_code(mut self, val: impl Into<String>) -> Self {
252 self.language_code = Some(val.into());
253 self
254 }
255
256 pub async fn send(self) -> Result<bool> {
258 let payload = serde_json::to_vec(&self)?;
259 self.bot.do_post_json("deleteMyCommands", &payload).await
260 }
261}
262
263impl_into_future!(DeleteMyCommandsBuilder, bool);
264
265#[derive(Serialize)]
271pub struct SetMyDefaultAdministratorRightsBuilder<'a> {
272 #[serde(skip)]
273 bot: &'a Bot,
274 #[serde(skip_serializing_if = "Option::is_none")]
275 rights: Option<chat_administrator_rights::ChatAdministratorRights>,
276 #[serde(skip_serializing_if = "Option::is_none")]
277 for_channels: Option<bool>,
278}
279
280impl<'a> SetMyDefaultAdministratorRightsBuilder<'a> {
281 pub fn rights(mut self, val: chat_administrator_rights::ChatAdministratorRights) -> Self {
283 self.rights = Some(val);
284 self
285 }
286 pub fn for_channels(mut self, val: bool) -> Self {
288 self.for_channels = Some(val);
289 self
290 }
291
292 pub async fn send(self) -> Result<bool> {
294 let payload = serde_json::to_vec(&self)?;
295 self.bot
296 .do_post_json("setMyDefaultAdministratorRights", &payload)
297 .await
298 }
299}
300
301impl_into_future!(SetMyDefaultAdministratorRightsBuilder, bool);
302
303#[derive(Serialize)]
309pub struct GetMyDefaultAdministratorRightsBuilder<'a> {
310 #[serde(skip)]
311 bot: &'a Bot,
312 #[serde(skip_serializing_if = "Option::is_none")]
313 for_channels: Option<bool>,
314}
315
316impl<'a> GetMyDefaultAdministratorRightsBuilder<'a> {
317 pub fn for_channels(mut self, val: bool) -> Self {
319 self.for_channels = Some(val);
320 self
321 }
322
323 pub async fn send(self) -> Result<chat_administrator_rights::ChatAdministratorRights> {
325 let payload = serde_json::to_vec(&self)?;
326 self.bot
327 .do_post_json("getMyDefaultAdministratorRights", &payload)
328 .await
329 }
330}
331
332impl_into_future!(
333 GetMyDefaultAdministratorRightsBuilder,
334 chat_administrator_rights::ChatAdministratorRights
335);
336
337#[derive(Serialize)]
343pub struct SetMyDescriptionBuilder<'a> {
344 #[serde(skip)]
345 bot: &'a Bot,
346 #[serde(skip_serializing_if = "Option::is_none")]
347 description: Option<String>,
348 #[serde(skip_serializing_if = "Option::is_none")]
349 language_code: Option<String>,
350}
351
352impl<'a> SetMyDescriptionBuilder<'a> {
353 pub fn description(mut self, val: impl Into<String>) -> Self {
355 self.description = Some(val.into());
356 self
357 }
358 pub fn language_code(mut self, val: impl Into<String>) -> Self {
360 self.language_code = Some(val.into());
361 self
362 }
363
364 pub async fn send(self) -> Result<bool> {
366 let payload = serde_json::to_vec(&self)?;
367 self.bot.do_post_json("setMyDescription", &payload).await
368 }
369}
370
371impl_into_future!(SetMyDescriptionBuilder, bool);
372
373#[derive(Serialize)]
379pub struct GetMyDescriptionBuilder<'a> {
380 #[serde(skip)]
381 bot: &'a Bot,
382 #[serde(skip_serializing_if = "Option::is_none")]
383 language_code: Option<String>,
384}
385
386impl<'a> GetMyDescriptionBuilder<'a> {
387 pub fn language_code(mut self, val: impl Into<String>) -> Self {
389 self.language_code = Some(val.into());
390 self
391 }
392
393 pub async fn send(self) -> Result<bot_description::BotDescription> {
395 let payload = serde_json::to_vec(&self)?;
396 self.bot.do_post_json("getMyDescription", &payload).await
397 }
398}
399
400impl_into_future!(GetMyDescriptionBuilder, bot_description::BotDescription);
401
402#[derive(Serialize)]
408pub struct SetMyShortDescriptionBuilder<'a> {
409 #[serde(skip)]
410 bot: &'a Bot,
411 #[serde(skip_serializing_if = "Option::is_none")]
412 short_description: Option<String>,
413 #[serde(skip_serializing_if = "Option::is_none")]
414 language_code: Option<String>,
415}
416
417impl<'a> SetMyShortDescriptionBuilder<'a> {
418 pub fn short_description(mut self, val: impl Into<String>) -> Self {
420 self.short_description = Some(val.into());
421 self
422 }
423 pub fn language_code(mut self, val: impl Into<String>) -> Self {
425 self.language_code = Some(val.into());
426 self
427 }
428
429 pub async fn send(self) -> Result<bool> {
431 let payload = serde_json::to_vec(&self)?;
432 self.bot
433 .do_post_json("setMyShortDescription", &payload)
434 .await
435 }
436}
437
438impl_into_future!(SetMyShortDescriptionBuilder, bool);
439
440#[derive(Serialize)]
446pub struct GetMyShortDescriptionBuilder<'a> {
447 #[serde(skip)]
448 bot: &'a Bot,
449 #[serde(skip_serializing_if = "Option::is_none")]
450 language_code: Option<String>,
451}
452
453impl<'a> GetMyShortDescriptionBuilder<'a> {
454 pub fn language_code(mut self, val: impl Into<String>) -> Self {
456 self.language_code = Some(val.into());
457 self
458 }
459
460 pub async fn send(self) -> Result<bot_description::BotShortDescription> {
462 let payload = serde_json::to_vec(&self)?;
463 self.bot
464 .do_post_json("getMyShortDescription", &payload)
465 .await
466 }
467}
468
469impl_into_future!(
470 GetMyShortDescriptionBuilder,
471 bot_description::BotShortDescription
472);
473
474#[derive(Serialize)]
480pub struct SetMyNameBuilder<'a> {
481 #[serde(skip)]
482 bot: &'a Bot,
483 #[serde(skip_serializing_if = "Option::is_none")]
484 name: Option<String>,
485 #[serde(skip_serializing_if = "Option::is_none")]
486 language_code: Option<String>,
487}
488
489impl<'a> SetMyNameBuilder<'a> {
490 pub fn name(mut self, val: impl Into<String>) -> Self {
492 self.name = Some(val.into());
493 self
494 }
495 pub fn language_code(mut self, val: impl Into<String>) -> Self {
497 self.language_code = Some(val.into());
498 self
499 }
500
501 pub async fn send(self) -> Result<bool> {
503 let payload = serde_json::to_vec(&self)?;
504 self.bot.do_post_json("setMyName", &payload).await
505 }
506}
507
508impl_into_future!(SetMyNameBuilder, bool);
509
510#[derive(Serialize)]
516pub struct GetMyNameBuilder<'a> {
517 #[serde(skip)]
518 bot: &'a Bot,
519 #[serde(skip_serializing_if = "Option::is_none")]
520 language_code: Option<String>,
521}
522
523impl<'a> GetMyNameBuilder<'a> {
524 pub fn language_code(mut self, val: impl Into<String>) -> Self {
526 self.language_code = Some(val.into());
527 self
528 }
529
530 pub async fn send(self) -> Result<bot_name::BotName> {
532 let payload = serde_json::to_vec(&self)?;
533 self.bot.do_post_json("getMyName", &payload).await
534 }
535}
536
537impl_into_future!(GetMyNameBuilder, bot_name::BotName);
538
539#[derive(Serialize)]
549pub struct CreateForumTopicBuilder<'a> {
550 #[serde(skip)]
551 bot: &'a Bot,
552 chat_id: ChatId,
553 name: String,
554 #[serde(skip_serializing_if = "Option::is_none")]
555 icon_color: Option<i64>,
556 #[serde(skip_serializing_if = "Option::is_none")]
557 icon_custom_emoji_id: Option<String>,
558}
559
560impl<'a> CreateForumTopicBuilder<'a> {
561 pub fn icon_color(mut self, val: i64) -> Self {
563 self.icon_color = Some(val);
564 self
565 }
566 pub fn icon_custom_emoji_id(mut self, val: impl Into<String>) -> Self {
568 self.icon_custom_emoji_id = Some(val.into());
569 self
570 }
571
572 pub async fn send(self) -> Result<forum_topic::ForumTopic> {
574 let payload = serde_json::to_vec(&self)?;
575 self.bot.do_post_json("createForumTopic", &payload).await
576 }
577}
578
579impl_into_future!(CreateForumTopicBuilder, forum_topic::ForumTopic);
580
581#[derive(Serialize)]
587pub struct EditForumTopicBuilder<'a> {
588 #[serde(skip)]
589 bot: &'a Bot,
590 chat_id: ChatId,
591 message_thread_id: i64,
592 #[serde(skip_serializing_if = "Option::is_none")]
593 name: Option<String>,
594 #[serde(skip_serializing_if = "Option::is_none")]
595 icon_custom_emoji_id: Option<String>,
596}
597
598impl<'a> EditForumTopicBuilder<'a> {
599 pub fn name(mut self, val: impl Into<String>) -> Self {
601 self.name = Some(val.into());
602 self
603 }
604 pub fn icon_custom_emoji_id(mut self, val: impl Into<String>) -> Self {
606 self.icon_custom_emoji_id = Some(val.into());
607 self
608 }
609
610 pub async fn send(self) -> Result<bool> {
612 let payload = serde_json::to_vec(&self)?;
613 self.bot.do_post_json("editForumTopic", &payload).await
614 }
615}
616
617impl_into_future!(EditForumTopicBuilder, bool);
618
619#[derive(Serialize)]
625pub struct CloseForumTopicBuilder<'a> {
626 #[serde(skip)]
627 bot: &'a Bot,
628 chat_id: ChatId,
629 message_thread_id: i64,
630}
631
632impl<'a> CloseForumTopicBuilder<'a> {
633 pub async fn send(self) -> Result<bool> {
635 let payload = serde_json::to_vec(&self)?;
636 self.bot.do_post_json("closeForumTopic", &payload).await
637 }
638}
639
640impl_into_future!(CloseForumTopicBuilder, bool);
641
642#[derive(Serialize)]
648pub struct ReopenForumTopicBuilder<'a> {
649 #[serde(skip)]
650 bot: &'a Bot,
651 chat_id: ChatId,
652 message_thread_id: i64,
653}
654
655impl<'a> ReopenForumTopicBuilder<'a> {
656 pub async fn send(self) -> Result<bool> {
658 let payload = serde_json::to_vec(&self)?;
659 self.bot.do_post_json("reopenForumTopic", &payload).await
660 }
661}
662
663impl_into_future!(ReopenForumTopicBuilder, bool);
664
665#[derive(Serialize)]
671pub struct DeleteForumTopicBuilder<'a> {
672 #[serde(skip)]
673 bot: &'a Bot,
674 chat_id: ChatId,
675 message_thread_id: i64,
676}
677
678impl<'a> DeleteForumTopicBuilder<'a> {
679 pub async fn send(self) -> Result<bool> {
681 let payload = serde_json::to_vec(&self)?;
682 self.bot.do_post_json("deleteForumTopic", &payload).await
683 }
684}
685
686impl_into_future!(DeleteForumTopicBuilder, bool);
687
688#[derive(Serialize)]
694pub struct UnpinAllForumTopicMessagesBuilder<'a> {
695 #[serde(skip)]
696 bot: &'a Bot,
697 chat_id: ChatId,
698 message_thread_id: i64,
699}
700
701impl<'a> UnpinAllForumTopicMessagesBuilder<'a> {
702 pub async fn send(self) -> Result<bool> {
704 let payload = serde_json::to_vec(&self)?;
705 self.bot
706 .do_post_json("unpinAllForumTopicMessages", &payload)
707 .await
708 }
709}
710
711impl_into_future!(UnpinAllForumTopicMessagesBuilder, bool);
712
713#[derive(Serialize)]
719pub struct UnpinAllGeneralForumTopicMessagesBuilder<'a> {
720 #[serde(skip)]
721 bot: &'a Bot,
722 chat_id: ChatId,
723}
724
725impl<'a> UnpinAllGeneralForumTopicMessagesBuilder<'a> {
726 pub async fn send(self) -> Result<bool> {
728 let payload = serde_json::to_vec(&self)?;
729 self.bot
730 .do_post_json("unpinAllGeneralForumTopicMessages", &payload)
731 .await
732 }
733}
734
735impl_into_future!(UnpinAllGeneralForumTopicMessagesBuilder, bool);
736
737#[derive(Serialize)]
743pub struct EditGeneralForumTopicBuilder<'a> {
744 #[serde(skip)]
745 bot: &'a Bot,
746 chat_id: ChatId,
747 name: String,
748}
749
750impl<'a> EditGeneralForumTopicBuilder<'a> {
751 pub async fn send(self) -> Result<bool> {
753 let payload = serde_json::to_vec(&self)?;
754 self.bot
755 .do_post_json("editGeneralForumTopic", &payload)
756 .await
757 }
758}
759
760impl_into_future!(EditGeneralForumTopicBuilder, bool);
761
762#[derive(Serialize)]
768pub struct CloseGeneralForumTopicBuilder<'a> {
769 #[serde(skip)]
770 bot: &'a Bot,
771 chat_id: ChatId,
772}
773
774impl<'a> CloseGeneralForumTopicBuilder<'a> {
775 pub async fn send(self) -> Result<bool> {
777 let payload = serde_json::to_vec(&self)?;
778 self.bot
779 .do_post_json("closeGeneralForumTopic", &payload)
780 .await
781 }
782}
783
784impl_into_future!(CloseGeneralForumTopicBuilder, bool);
785
786#[derive(Serialize)]
792pub struct ReopenGeneralForumTopicBuilder<'a> {
793 #[serde(skip)]
794 bot: &'a Bot,
795 chat_id: ChatId,
796}
797
798impl<'a> ReopenGeneralForumTopicBuilder<'a> {
799 pub async fn send(self) -> Result<bool> {
801 let payload = serde_json::to_vec(&self)?;
802 self.bot
803 .do_post_json("reopenGeneralForumTopic", &payload)
804 .await
805 }
806}
807
808impl_into_future!(ReopenGeneralForumTopicBuilder, bool);
809
810#[derive(Serialize)]
816pub struct HideGeneralForumTopicBuilder<'a> {
817 #[serde(skip)]
818 bot: &'a Bot,
819 chat_id: ChatId,
820}
821
822impl<'a> HideGeneralForumTopicBuilder<'a> {
823 pub async fn send(self) -> Result<bool> {
825 let payload = serde_json::to_vec(&self)?;
826 self.bot
827 .do_post_json("hideGeneralForumTopic", &payload)
828 .await
829 }
830}
831
832impl_into_future!(HideGeneralForumTopicBuilder, bool);
833
834#[derive(Serialize)]
840pub struct UnhideGeneralForumTopicBuilder<'a> {
841 #[serde(skip)]
842 bot: &'a Bot,
843 chat_id: ChatId,
844}
845
846impl<'a> UnhideGeneralForumTopicBuilder<'a> {
847 pub async fn send(self) -> Result<bool> {
849 let payload = serde_json::to_vec(&self)?;
850 self.bot
851 .do_post_json("unhideGeneralForumTopic", &payload)
852 .await
853 }
854}
855
856impl_into_future!(UnhideGeneralForumTopicBuilder, bool);
857
858#[derive(Serialize)]
868pub struct GetStickerSetBuilder<'a> {
869 #[serde(skip)]
870 bot: &'a Bot,
871 name: String,
872}
873
874impl<'a> GetStickerSetBuilder<'a> {
875 pub async fn send(self) -> Result<files::sticker::StickerSet> {
877 let payload = serde_json::to_vec(&self)?;
878 self.bot.do_post_json("getStickerSet", &payload).await
879 }
880}
881
882impl_into_future!(GetStickerSetBuilder, files::sticker::StickerSet);
883
884#[derive(Serialize)]
890pub struct GetCustomEmojiStickersBuilder<'a> {
891 #[serde(skip)]
892 bot: &'a Bot,
893 custom_emoji_ids: Vec<String>,
894}
895
896impl<'a> GetCustomEmojiStickersBuilder<'a> {
897 pub async fn send(self) -> Result<Vec<files::sticker::Sticker>> {
899 let payload = serde_json::to_vec(&self)?;
900 self.bot
901 .do_post_json("getCustomEmojiStickers", &payload)
902 .await
903 }
904}
905
906impl_into_future!(GetCustomEmojiStickersBuilder, Vec<files::sticker::Sticker>);
907
908pub struct UploadStickerFileBuilder<'a> {
914 bot: &'a Bot,
915 user_id: i64,
916 sticker: files::input_file::InputFile,
917 sticker_format: String,
918}
919
920impl<'a> UploadStickerFileBuilder<'a> {
921 pub async fn send(self) -> Result<files::file::File> {
923 let params = vec![
924 RequestParameter::new("user_id", serde_json::to_value(self.user_id)?),
925 input_file_param("sticker", self.sticker),
926 RequestParameter::new(
927 "sticker_format",
928 serde_json::Value::String(self.sticker_format),
929 ),
930 ];
931 self.bot.do_api_request("uploadStickerFile", params).await
932 }
933}
934
935impl_into_future!(UploadStickerFileBuilder, files::file::File);
936
937#[derive(Serialize)]
943pub struct CreateNewStickerSetBuilder<'a> {
944 #[serde(skip)]
945 bot: &'a Bot,
946 user_id: i64,
947 name: String,
948 title: String,
949 stickers: Vec<serde_json::Value>,
950 #[serde(skip_serializing_if = "Option::is_none")]
951 sticker_type: Option<String>,
952 #[serde(skip_serializing_if = "Option::is_none")]
953 needs_repainting: Option<bool>,
954}
955
956impl<'a> CreateNewStickerSetBuilder<'a> {
957 pub fn sticker_type(mut self, val: impl Into<String>) -> Self {
959 self.sticker_type = Some(val.into());
960 self
961 }
962 pub fn needs_repainting(mut self, val: bool) -> Self {
964 self.needs_repainting = Some(val);
965 self
966 }
967
968 pub async fn send(self) -> Result<bool> {
970 let payload = serde_json::to_vec(&self)?;
971 self.bot.do_post_json("createNewStickerSet", &payload).await
972 }
973}
974
975impl_into_future!(CreateNewStickerSetBuilder, bool);
976
977#[derive(Serialize)]
983pub struct AddStickerToSetBuilder<'a> {
984 #[serde(skip)]
985 bot: &'a Bot,
986 user_id: i64,
987 name: String,
988 sticker: serde_json::Value,
989}
990
991impl<'a> AddStickerToSetBuilder<'a> {
992 pub async fn send(self) -> Result<bool> {
994 let payload = serde_json::to_vec(&self)?;
995 self.bot.do_post_json("addStickerToSet", &payload).await
996 }
997}
998
999impl_into_future!(AddStickerToSetBuilder, bool);
1000
1001#[derive(Serialize)]
1007pub struct SetStickerPositionInSetBuilder<'a> {
1008 #[serde(skip)]
1009 bot: &'a Bot,
1010 sticker: String,
1011 position: i64,
1012}
1013
1014impl<'a> SetStickerPositionInSetBuilder<'a> {
1015 pub async fn send(self) -> Result<bool> {
1017 let payload = serde_json::to_vec(&self)?;
1018 self.bot
1019 .do_post_json("setStickerPositionInSet", &payload)
1020 .await
1021 }
1022}
1023
1024impl_into_future!(SetStickerPositionInSetBuilder, bool);
1025
1026#[derive(Serialize)]
1032pub struct DeleteStickerFromSetBuilder<'a> {
1033 #[serde(skip)]
1034 bot: &'a Bot,
1035 sticker: String,
1036}
1037
1038impl<'a> DeleteStickerFromSetBuilder<'a> {
1039 pub async fn send(self) -> Result<bool> {
1041 let payload = serde_json::to_vec(&self)?;
1042 self.bot
1043 .do_post_json("deleteStickerFromSet", &payload)
1044 .await
1045 }
1046}
1047
1048impl_into_future!(DeleteStickerFromSetBuilder, bool);
1049
1050#[derive(Serialize)]
1056pub struct ReplaceStickerInSetBuilder<'a> {
1057 #[serde(skip)]
1058 bot: &'a Bot,
1059 user_id: i64,
1060 name: String,
1061 old_sticker: String,
1062 sticker: serde_json::Value,
1063}
1064
1065impl<'a> ReplaceStickerInSetBuilder<'a> {
1066 pub async fn send(self) -> Result<bool> {
1068 let payload = serde_json::to_vec(&self)?;
1069 self.bot.do_post_json("replaceStickerInSet", &payload).await
1070 }
1071}
1072
1073impl_into_future!(ReplaceStickerInSetBuilder, bool);
1074
1075#[derive(Serialize)]
1081pub struct SetStickerEmojiListBuilder<'a> {
1082 #[serde(skip)]
1083 bot: &'a Bot,
1084 sticker: String,
1085 emoji_list: Vec<String>,
1086}
1087
1088impl<'a> SetStickerEmojiListBuilder<'a> {
1089 pub async fn send(self) -> Result<bool> {
1091 let payload = serde_json::to_vec(&self)?;
1092 self.bot.do_post_json("setStickerEmojiList", &payload).await
1093 }
1094}
1095
1096impl_into_future!(SetStickerEmojiListBuilder, bool);
1097
1098#[derive(Serialize)]
1104pub struct SetStickerKeywordsBuilder<'a> {
1105 #[serde(skip)]
1106 bot: &'a Bot,
1107 sticker: String,
1108 #[serde(skip_serializing_if = "Option::is_none")]
1109 keywords: Option<Vec<String>>,
1110}
1111
1112impl<'a> SetStickerKeywordsBuilder<'a> {
1113 pub fn keywords(mut self, val: Vec<String>) -> Self {
1115 self.keywords = Some(val);
1116 self
1117 }
1118
1119 pub async fn send(self) -> Result<bool> {
1121 let payload = serde_json::to_vec(&self)?;
1122 self.bot.do_post_json("setStickerKeywords", &payload).await
1123 }
1124}
1125
1126impl_into_future!(SetStickerKeywordsBuilder, bool);
1127
1128#[derive(Serialize)]
1134pub struct SetStickerMaskPositionBuilder<'a> {
1135 #[serde(skip)]
1136 bot: &'a Bot,
1137 sticker: String,
1138 #[serde(skip_serializing_if = "Option::is_none")]
1139 mask_position: Option<files::sticker::MaskPosition>,
1140}
1141
1142impl<'a> SetStickerMaskPositionBuilder<'a> {
1143 pub fn mask_position(mut self, val: files::sticker::MaskPosition) -> Self {
1145 self.mask_position = Some(val);
1146 self
1147 }
1148
1149 pub async fn send(self) -> Result<bool> {
1151 let payload = serde_json::to_vec(&self)?;
1152 self.bot
1153 .do_post_json("setStickerMaskPosition", &payload)
1154 .await
1155 }
1156}
1157
1158impl_into_future!(SetStickerMaskPositionBuilder, bool);
1159
1160pub struct SetStickerSetThumbnailBuilder<'a> {
1169 bot: &'a Bot,
1170 name: String,
1171 user_id: i64,
1172 format: String,
1173 thumbnail: Option<files::input_file::InputFile>,
1174}
1175
1176impl<'a> SetStickerSetThumbnailBuilder<'a> {
1177 pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
1179 self.thumbnail = Some(val);
1180 self
1181 }
1182
1183 pub async fn send(self) -> Result<bool> {
1185 let mut params = vec![
1186 RequestParameter::new("name", serde_json::Value::String(self.name)),
1187 RequestParameter::new("user_id", serde_json::to_value(self.user_id)?),
1188 RequestParameter::new("format", serde_json::Value::String(self.format)),
1189 ];
1190 push_opt_file(&mut params, "thumbnail", self.thumbnail);
1191 self.bot
1192 .do_api_request("setStickerSetThumbnail", params)
1193 .await
1194 }
1195}
1196
1197impl_into_future!(SetStickerSetThumbnailBuilder, bool);
1198
1199#[derive(Serialize)]
1205pub struct SetStickerSetTitleBuilder<'a> {
1206 #[serde(skip)]
1207 bot: &'a Bot,
1208 name: String,
1209 title: String,
1210}
1211
1212impl<'a> SetStickerSetTitleBuilder<'a> {
1213 pub async fn send(self) -> Result<bool> {
1215 let payload = serde_json::to_vec(&self)?;
1216 self.bot.do_post_json("setStickerSetTitle", &payload).await
1217 }
1218}
1219
1220impl_into_future!(SetStickerSetTitleBuilder, bool);
1221
1222#[derive(Serialize)]
1228pub struct SetCustomEmojiStickerSetThumbnailBuilder<'a> {
1229 #[serde(skip)]
1230 bot: &'a Bot,
1231 name: String,
1232 #[serde(skip_serializing_if = "Option::is_none")]
1233 custom_emoji_id: Option<String>,
1234}
1235
1236impl<'a> SetCustomEmojiStickerSetThumbnailBuilder<'a> {
1237 pub fn custom_emoji_id(mut self, val: impl Into<String>) -> Self {
1239 self.custom_emoji_id = Some(val.into());
1240 self
1241 }
1242
1243 pub async fn send(self) -> Result<bool> {
1245 let payload = serde_json::to_vec(&self)?;
1246 self.bot
1247 .do_post_json("setCustomEmojiStickerSetThumbnail", &payload)
1248 .await
1249 }
1250}
1251
1252impl_into_future!(SetCustomEmojiStickerSetThumbnailBuilder, bool);
1253
1254#[derive(Serialize)]
1260pub struct DeleteStickerSetBuilder<'a> {
1261 #[serde(skip)]
1262 bot: &'a Bot,
1263 name: String,
1264}
1265
1266impl<'a> DeleteStickerSetBuilder<'a> {
1267 pub async fn send(self) -> Result<bool> {
1269 let payload = serde_json::to_vec(&self)?;
1270 self.bot.do_post_json("deleteStickerSet", &payload).await
1271 }
1272}
1273
1274impl_into_future!(DeleteStickerSetBuilder, bool);
1275
1276#[derive(Serialize)]
1282pub struct GetForumTopicIconStickersBuilder<'a> {
1283 #[serde(skip)]
1284 bot: &'a Bot,
1285}
1286
1287impl<'a> GetForumTopicIconStickersBuilder<'a> {
1288 pub async fn send(self) -> Result<Vec<files::sticker::Sticker>> {
1290 let payload = serde_json::to_vec(&self)?;
1291 self.bot
1292 .do_post_json("getForumTopicIconStickers", &payload)
1293 .await
1294 }
1295}
1296
1297impl_into_future!(
1298 GetForumTopicIconStickersBuilder,
1299 Vec<files::sticker::Sticker>
1300);
1301
1302impl Bot {
1307 pub fn set_chat_menu_button(&self) -> SetChatMenuButtonBuilder<'_> {
1313 SetChatMenuButtonBuilder {
1314 bot: self,
1315 chat_id: None,
1316 menu_button: None,
1317 }
1318 }
1319
1320 pub fn get_chat_menu_button(&self) -> GetChatMenuButtonBuilder<'_> {
1322 GetChatMenuButtonBuilder {
1323 bot: self,
1324 chat_id: None,
1325 }
1326 }
1327
1328 pub fn set_my_commands(
1330 &self,
1331 commands: Vec<bot_command::BotCommand>,
1332 ) -> SetMyCommandsBuilder<'_> {
1333 SetMyCommandsBuilder {
1334 bot: self,
1335 commands,
1336 scope: None,
1337 language_code: None,
1338 }
1339 }
1340
1341 pub fn get_my_commands(&self) -> GetMyCommandsBuilder<'_> {
1343 GetMyCommandsBuilder {
1344 bot: self,
1345 scope: None,
1346 language_code: None,
1347 }
1348 }
1349
1350 pub fn delete_my_commands(&self) -> DeleteMyCommandsBuilder<'_> {
1352 DeleteMyCommandsBuilder {
1353 bot: self,
1354 scope: None,
1355 language_code: None,
1356 }
1357 }
1358
1359 pub fn set_my_default_administrator_rights(
1361 &self,
1362 ) -> SetMyDefaultAdministratorRightsBuilder<'_> {
1363 SetMyDefaultAdministratorRightsBuilder {
1364 bot: self,
1365 rights: None,
1366 for_channels: None,
1367 }
1368 }
1369
1370 pub fn get_my_default_administrator_rights(
1372 &self,
1373 ) -> GetMyDefaultAdministratorRightsBuilder<'_> {
1374 GetMyDefaultAdministratorRightsBuilder {
1375 bot: self,
1376 for_channels: None,
1377 }
1378 }
1379
1380 pub fn set_my_description(&self) -> SetMyDescriptionBuilder<'_> {
1382 SetMyDescriptionBuilder {
1383 bot: self,
1384 description: None,
1385 language_code: None,
1386 }
1387 }
1388
1389 pub fn get_my_description(&self) -> GetMyDescriptionBuilder<'_> {
1391 GetMyDescriptionBuilder {
1392 bot: self,
1393 language_code: None,
1394 }
1395 }
1396
1397 pub fn set_my_short_description(&self) -> SetMyShortDescriptionBuilder<'_> {
1399 SetMyShortDescriptionBuilder {
1400 bot: self,
1401 short_description: None,
1402 language_code: None,
1403 }
1404 }
1405
1406 pub fn get_my_short_description(&self) -> GetMyShortDescriptionBuilder<'_> {
1408 GetMyShortDescriptionBuilder {
1409 bot: self,
1410 language_code: None,
1411 }
1412 }
1413
1414 pub fn set_my_name(&self) -> SetMyNameBuilder<'_> {
1416 SetMyNameBuilder {
1417 bot: self,
1418 name: None,
1419 language_code: None,
1420 }
1421 }
1422
1423 pub fn get_my_name(&self) -> GetMyNameBuilder<'_> {
1425 GetMyNameBuilder {
1426 bot: self,
1427 language_code: None,
1428 }
1429 }
1430
1431 pub fn create_forum_topic(
1437 &self,
1438 chat_id: impl Into<ChatId>,
1439 name: impl Into<String>,
1440 ) -> CreateForumTopicBuilder<'_> {
1441 CreateForumTopicBuilder {
1442 bot: self,
1443 chat_id: chat_id.into(),
1444 name: name.into(),
1445 icon_color: None,
1446 icon_custom_emoji_id: None,
1447 }
1448 }
1449
1450 pub fn edit_forum_topic(
1452 &self,
1453 chat_id: impl Into<ChatId>,
1454 message_thread_id: i64,
1455 ) -> EditForumTopicBuilder<'_> {
1456 EditForumTopicBuilder {
1457 bot: self,
1458 chat_id: chat_id.into(),
1459 message_thread_id,
1460 name: None,
1461 icon_custom_emoji_id: None,
1462 }
1463 }
1464
1465 pub fn close_forum_topic(
1467 &self,
1468 chat_id: impl Into<ChatId>,
1469 message_thread_id: i64,
1470 ) -> CloseForumTopicBuilder<'_> {
1471 CloseForumTopicBuilder {
1472 bot: self,
1473 chat_id: chat_id.into(),
1474 message_thread_id,
1475 }
1476 }
1477
1478 pub fn reopen_forum_topic(
1480 &self,
1481 chat_id: impl Into<ChatId>,
1482 message_thread_id: i64,
1483 ) -> ReopenForumTopicBuilder<'_> {
1484 ReopenForumTopicBuilder {
1485 bot: self,
1486 chat_id: chat_id.into(),
1487 message_thread_id,
1488 }
1489 }
1490
1491 pub fn delete_forum_topic(
1493 &self,
1494 chat_id: impl Into<ChatId>,
1495 message_thread_id: i64,
1496 ) -> DeleteForumTopicBuilder<'_> {
1497 DeleteForumTopicBuilder {
1498 bot: self,
1499 chat_id: chat_id.into(),
1500 message_thread_id,
1501 }
1502 }
1503
1504 pub fn unpin_all_forum_topic_messages(
1506 &self,
1507 chat_id: impl Into<ChatId>,
1508 message_thread_id: i64,
1509 ) -> UnpinAllForumTopicMessagesBuilder<'_> {
1510 UnpinAllForumTopicMessagesBuilder {
1511 bot: self,
1512 chat_id: chat_id.into(),
1513 message_thread_id,
1514 }
1515 }
1516
1517 pub fn unpin_all_general_forum_topic_messages(
1519 &self,
1520 chat_id: impl Into<ChatId>,
1521 ) -> UnpinAllGeneralForumTopicMessagesBuilder<'_> {
1522 UnpinAllGeneralForumTopicMessagesBuilder {
1523 bot: self,
1524 chat_id: chat_id.into(),
1525 }
1526 }
1527
1528 pub fn edit_general_forum_topic(
1530 &self,
1531 chat_id: impl Into<ChatId>,
1532 name: impl Into<String>,
1533 ) -> EditGeneralForumTopicBuilder<'_> {
1534 EditGeneralForumTopicBuilder {
1535 bot: self,
1536 chat_id: chat_id.into(),
1537 name: name.into(),
1538 }
1539 }
1540
1541 pub fn close_general_forum_topic(
1543 &self,
1544 chat_id: impl Into<ChatId>,
1545 ) -> CloseGeneralForumTopicBuilder<'_> {
1546 CloseGeneralForumTopicBuilder {
1547 bot: self,
1548 chat_id: chat_id.into(),
1549 }
1550 }
1551
1552 pub fn reopen_general_forum_topic(
1554 &self,
1555 chat_id: impl Into<ChatId>,
1556 ) -> ReopenGeneralForumTopicBuilder<'_> {
1557 ReopenGeneralForumTopicBuilder {
1558 bot: self,
1559 chat_id: chat_id.into(),
1560 }
1561 }
1562
1563 pub fn hide_general_forum_topic(
1565 &self,
1566 chat_id: impl Into<ChatId>,
1567 ) -> HideGeneralForumTopicBuilder<'_> {
1568 HideGeneralForumTopicBuilder {
1569 bot: self,
1570 chat_id: chat_id.into(),
1571 }
1572 }
1573
1574 pub fn unhide_general_forum_topic(
1576 &self,
1577 chat_id: impl Into<ChatId>,
1578 ) -> UnhideGeneralForumTopicBuilder<'_> {
1579 UnhideGeneralForumTopicBuilder {
1580 bot: self,
1581 chat_id: chat_id.into(),
1582 }
1583 }
1584
1585 pub fn get_sticker_set(&self, name: impl Into<String>) -> GetStickerSetBuilder<'_> {
1591 GetStickerSetBuilder {
1592 bot: self,
1593 name: name.into(),
1594 }
1595 }
1596
1597 pub fn get_custom_emoji_stickers(
1599 &self,
1600 custom_emoji_ids: Vec<String>,
1601 ) -> GetCustomEmojiStickersBuilder<'_> {
1602 GetCustomEmojiStickersBuilder {
1603 bot: self,
1604 custom_emoji_ids,
1605 }
1606 }
1607
1608 pub fn upload_sticker_file(
1610 &self,
1611 user_id: i64,
1612 sticker: files::input_file::InputFile,
1613 sticker_format: impl Into<String>,
1614 ) -> UploadStickerFileBuilder<'_> {
1615 UploadStickerFileBuilder {
1616 bot: self,
1617 user_id,
1618 sticker,
1619 sticker_format: sticker_format.into(),
1620 }
1621 }
1622
1623 pub fn create_new_sticker_set(
1625 &self,
1626 user_id: i64,
1627 name: impl Into<String>,
1628 title: impl Into<String>,
1629 stickers: Vec<serde_json::Value>,
1630 ) -> CreateNewStickerSetBuilder<'_> {
1631 CreateNewStickerSetBuilder {
1632 bot: self,
1633 user_id,
1634 name: name.into(),
1635 title: title.into(),
1636 stickers,
1637 sticker_type: None,
1638 needs_repainting: None,
1639 }
1640 }
1641
1642 pub fn add_sticker_to_set(
1644 &self,
1645 user_id: i64,
1646 name: impl Into<String>,
1647 sticker: serde_json::Value,
1648 ) -> AddStickerToSetBuilder<'_> {
1649 AddStickerToSetBuilder {
1650 bot: self,
1651 user_id,
1652 name: name.into(),
1653 sticker,
1654 }
1655 }
1656
1657 pub fn set_sticker_position_in_set(
1659 &self,
1660 sticker: impl Into<String>,
1661 position: i64,
1662 ) -> SetStickerPositionInSetBuilder<'_> {
1663 SetStickerPositionInSetBuilder {
1664 bot: self,
1665 sticker: sticker.into(),
1666 position,
1667 }
1668 }
1669
1670 pub fn delete_sticker_from_set(
1672 &self,
1673 sticker: impl Into<String>,
1674 ) -> DeleteStickerFromSetBuilder<'_> {
1675 DeleteStickerFromSetBuilder {
1676 bot: self,
1677 sticker: sticker.into(),
1678 }
1679 }
1680
1681 pub fn replace_sticker_in_set(
1683 &self,
1684 user_id: i64,
1685 name: impl Into<String>,
1686 old_sticker: impl Into<String>,
1687 sticker: serde_json::Value,
1688 ) -> ReplaceStickerInSetBuilder<'_> {
1689 ReplaceStickerInSetBuilder {
1690 bot: self,
1691 user_id,
1692 name: name.into(),
1693 old_sticker: old_sticker.into(),
1694 sticker,
1695 }
1696 }
1697
1698 pub fn set_sticker_emoji_list(
1700 &self,
1701 sticker: impl Into<String>,
1702 emoji_list: Vec<String>,
1703 ) -> SetStickerEmojiListBuilder<'_> {
1704 SetStickerEmojiListBuilder {
1705 bot: self,
1706 sticker: sticker.into(),
1707 emoji_list,
1708 }
1709 }
1710
1711 pub fn set_sticker_keywords(
1713 &self,
1714 sticker: impl Into<String>,
1715 ) -> SetStickerKeywordsBuilder<'_> {
1716 SetStickerKeywordsBuilder {
1717 bot: self,
1718 sticker: sticker.into(),
1719 keywords: None,
1720 }
1721 }
1722
1723 pub fn set_sticker_mask_position(
1725 &self,
1726 sticker: impl Into<String>,
1727 ) -> SetStickerMaskPositionBuilder<'_> {
1728 SetStickerMaskPositionBuilder {
1729 bot: self,
1730 sticker: sticker.into(),
1731 mask_position: None,
1732 }
1733 }
1734
1735 pub fn set_sticker_set_thumbnail(
1737 &self,
1738 name: impl Into<String>,
1739 user_id: i64,
1740 format: impl Into<String>,
1741 ) -> SetStickerSetThumbnailBuilder<'_> {
1742 SetStickerSetThumbnailBuilder {
1743 bot: self,
1744 name: name.into(),
1745 user_id,
1746 format: format.into(),
1747 thumbnail: None,
1748 }
1749 }
1750
1751 pub fn set_sticker_set_title(
1753 &self,
1754 name: impl Into<String>,
1755 title: impl Into<String>,
1756 ) -> SetStickerSetTitleBuilder<'_> {
1757 SetStickerSetTitleBuilder {
1758 bot: self,
1759 name: name.into(),
1760 title: title.into(),
1761 }
1762 }
1763
1764 pub fn set_custom_emoji_sticker_set_thumbnail(
1766 &self,
1767 name: impl Into<String>,
1768 ) -> SetCustomEmojiStickerSetThumbnailBuilder<'_> {
1769 SetCustomEmojiStickerSetThumbnailBuilder {
1770 bot: self,
1771 name: name.into(),
1772 custom_emoji_id: None,
1773 }
1774 }
1775
1776 pub fn delete_sticker_set(&self, name: impl Into<String>) -> DeleteStickerSetBuilder<'_> {
1778 DeleteStickerSetBuilder {
1779 bot: self,
1780 name: name.into(),
1781 }
1782 }
1783
1784 pub fn get_forum_topic_icon_stickers(&self) -> GetForumTopicIconStickersBuilder<'_> {
1786 GetForumTopicIconStickersBuilder { bot: self }
1787 }
1788}