Skip to main content

rust_tg_bot_raw/
bot_builders_4.rs

1//! Builder pattern for Telegram Bot API methods -- batch 4.
2//!
3//! Covers: editing (live location, checklist, stop poll), games, inline,
4//! media group / paid media, core Bot methods (get_me, log_out, close, etc.),
5//! send_checklist, passport, reactions, stories, suggested posts, user profile,
6//! and verification.
7
8#![allow(clippy::too_many_arguments)]
9
10use crate::bot::{Bot, ChatId, MessageOrBool};
11use crate::error::Result;
12use crate::types::{
13    chat_boost, games, input_checklist, message, message_entity, poll, reply, sent_web_app_message,
14    story, suggested_post, update, user, user_profile_audios, user_profile_photos, webhook_info,
15};
16use serde::Serialize;
17
18// ---------------------------------------------------------------------------
19// Macro
20// ---------------------------------------------------------------------------
21
22macro_rules! impl_into_future {
23    ($builder:ident, $output:ty) => {
24        impl<'a> std::future::IntoFuture for $builder<'a> {
25            type Output = Result<$output>;
26            type IntoFuture =
27                std::pin::Pin<Box<dyn std::future::Future<Output = Self::Output> + Send + 'a>>;
28            fn into_future(self) -> Self::IntoFuture {
29                Box::pin(self.send())
30            }
31        }
32    };
33}
34
35// =========================================================================
36// editing.rs builders
37// =========================================================================
38
39// -------------------------------------------------------------------------
40// EditMessageLiveLocationBuilder
41// -------------------------------------------------------------------------
42
43/// Builder for the [`editMessageLiveLocation`] API method.
44pub struct EditMessageLiveLocationBuilder<'a> {
45    bot: &'a Bot,
46    latitude: f64,
47    longitude: f64,
48    chat_id: Option<ChatId>,
49    message_id: Option<i64>,
50    inline_message_id: Option<String>,
51    horizontal_accuracy: Option<f64>,
52    heading: Option<i64>,
53    proximity_alert_radius: Option<i64>,
54    reply_markup: Option<serde_json::Value>,
55    live_period: Option<i64>,
56    business_connection_id: Option<String>,
57}
58
59impl<'a> EditMessageLiveLocationBuilder<'a> {
60    /// Sets the `chat_id` parameter.
61    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
62        self.chat_id = Some(val.into());
63        self
64    }
65    /// Sets the `message_id` parameter.
66    pub fn message_id(mut self, val: i64) -> Self {
67        self.message_id = Some(val);
68        self
69    }
70    /// Sets the `inline_message_id` parameter.
71    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
72        self.inline_message_id = Some(val.into());
73        self
74    }
75    /// Sets the `horizontal_accuracy` parameter.
76    pub fn horizontal_accuracy(mut self, val: f64) -> Self {
77        self.horizontal_accuracy = Some(val);
78        self
79    }
80    /// Sets the `heading` parameter.
81    pub fn heading(mut self, val: i64) -> Self {
82        self.heading = Some(val);
83        self
84    }
85    /// Sets the `proximity_alert_radius` parameter.
86    pub fn proximity_alert_radius(mut self, val: i64) -> Self {
87        self.proximity_alert_radius = Some(val);
88        self
89    }
90    /// Sets the `reply_markup` parameter.
91    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
92        self.reply_markup = Some(val);
93        self
94    }
95    /// Sets the `live_period` parameter.
96    pub fn live_period(mut self, val: i64) -> Self {
97        self.live_period = Some(val);
98        self
99    }
100    /// Sets the `business_connection_id` parameter.
101    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
102        self.business_connection_id = Some(val.into());
103        self
104    }
105
106    /// Sends the request to the Telegram Bot API.
107    pub async fn send(self) -> Result<MessageOrBool> {
108        self.bot
109            .edit_message_live_location_raw(
110                self.latitude,
111                self.longitude,
112                self.chat_id,
113                self.message_id,
114                self.inline_message_id.as_deref(),
115                self.horizontal_accuracy,
116                self.heading,
117                self.proximity_alert_radius,
118                self.reply_markup,
119                self.live_period,
120                self.business_connection_id.as_deref(),
121            )
122            .await
123    }
124}
125
126impl_into_future!(EditMessageLiveLocationBuilder, MessageOrBool);
127
128// -------------------------------------------------------------------------
129// StopMessageLiveLocationBuilder
130// -------------------------------------------------------------------------
131
132/// Builder for the [`stopMessageLiveLocation`] API method.
133pub struct StopMessageLiveLocationBuilder<'a> {
134    bot: &'a Bot,
135    chat_id: Option<ChatId>,
136    message_id: Option<i64>,
137    inline_message_id: Option<String>,
138    reply_markup: Option<serde_json::Value>,
139    business_connection_id: Option<String>,
140}
141
142impl<'a> StopMessageLiveLocationBuilder<'a> {
143    /// Sets the `chat_id` parameter.
144    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
145        self.chat_id = Some(val.into());
146        self
147    }
148    /// Sets the `message_id` parameter.
149    pub fn message_id(mut self, val: i64) -> Self {
150        self.message_id = Some(val);
151        self
152    }
153    /// Sets the `inline_message_id` parameter.
154    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
155        self.inline_message_id = Some(val.into());
156        self
157    }
158    /// Sets the `reply_markup` parameter.
159    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
160        self.reply_markup = Some(val);
161        self
162    }
163    /// Sets the `business_connection_id` parameter.
164    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
165        self.business_connection_id = Some(val.into());
166        self
167    }
168
169    /// Sends the request to the Telegram Bot API.
170    pub async fn send(self) -> Result<MessageOrBool> {
171        self.bot
172            .stop_message_live_location_raw(
173                self.chat_id,
174                self.message_id,
175                self.inline_message_id.as_deref(),
176                self.reply_markup,
177                self.business_connection_id.as_deref(),
178            )
179            .await
180    }
181}
182
183impl_into_future!(StopMessageLiveLocationBuilder, MessageOrBool);
184
185// -------------------------------------------------------------------------
186// EditMessageChecklistBuilder
187// -------------------------------------------------------------------------
188
189/// Builder for the [`editMessageChecklist`] API method.
190pub struct EditMessageChecklistBuilder<'a> {
191    bot: &'a Bot,
192    business_connection_id: String,
193    chat_id: i64,
194    message_id: i64,
195    checklist: input_checklist::InputChecklist,
196    reply_markup: Option<serde_json::Value>,
197}
198
199impl<'a> EditMessageChecklistBuilder<'a> {
200    /// Sets the `reply_markup` parameter.
201    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
202        self.reply_markup = Some(val);
203        self
204    }
205
206    /// Sends the request to the Telegram Bot API.
207    pub async fn send(self) -> Result<message::Message> {
208        self.bot
209            .edit_message_checklist_raw(
210                &self.business_connection_id,
211                self.chat_id,
212                self.message_id,
213                self.checklist,
214                self.reply_markup,
215            )
216            .await
217    }
218}
219
220impl_into_future!(EditMessageChecklistBuilder, message::Message);
221
222// -------------------------------------------------------------------------
223// StopPollBuilder
224// -------------------------------------------------------------------------
225
226/// Builder for the [`stopPoll`] API method.
227pub struct StopPollBuilder<'a> {
228    bot: &'a Bot,
229    chat_id: ChatId,
230    message_id: i64,
231    reply_markup: Option<serde_json::Value>,
232    business_connection_id: Option<String>,
233}
234
235impl<'a> StopPollBuilder<'a> {
236    /// Sets the `reply_markup` parameter.
237    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
238        self.reply_markup = Some(val);
239        self
240    }
241    /// Sets the `business_connection_id` parameter.
242    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
243        self.business_connection_id = Some(val.into());
244        self
245    }
246
247    /// Sends the request to the Telegram Bot API.
248    pub async fn send(self) -> Result<poll::Poll> {
249        self.bot
250            .stop_poll_raw(
251                self.chat_id,
252                self.message_id,
253                self.reply_markup,
254                self.business_connection_id.as_deref(),
255            )
256            .await
257    }
258}
259
260impl_into_future!(StopPollBuilder, poll::Poll);
261
262// =========================================================================
263// games_methods.rs builders
264// =========================================================================
265
266// -------------------------------------------------------------------------
267// SendGameBuilder
268// -------------------------------------------------------------------------
269
270/// Builder for the [`sendGame`] API method.
271pub struct SendGameBuilder<'a> {
272    bot: &'a Bot,
273    chat_id: i64,
274    game_short_name: String,
275    disable_notification: Option<bool>,
276    protect_content: Option<bool>,
277    reply_parameters: Option<reply::ReplyParameters>,
278    reply_markup: Option<serde_json::Value>,
279    message_thread_id: Option<i64>,
280    business_connection_id: Option<String>,
281    message_effect_id: Option<String>,
282    allow_paid_broadcast: Option<bool>,
283}
284
285impl<'a> SendGameBuilder<'a> {
286    /// Sets the `disable_notification` parameter.
287    pub fn disable_notification(mut self, val: bool) -> Self {
288        self.disable_notification = Some(val);
289        self
290    }
291    /// Sets the `protect_content` parameter.
292    pub fn protect_content(mut self, val: bool) -> Self {
293        self.protect_content = Some(val);
294        self
295    }
296    /// Sets the `reply_parameters` parameter.
297    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
298        self.reply_parameters = Some(val);
299        self
300    }
301    /// Sets the `reply_markup` parameter.
302    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
303        self.reply_markup = Some(val);
304        self
305    }
306    /// Sets the `message_thread_id` parameter.
307    pub fn message_thread_id(mut self, val: i64) -> Self {
308        self.message_thread_id = Some(val);
309        self
310    }
311    /// Sets the `business_connection_id` parameter.
312    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
313        self.business_connection_id = Some(val.into());
314        self
315    }
316    /// Sets the `message_effect_id` parameter.
317    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
318        self.message_effect_id = Some(val.into());
319        self
320    }
321    /// Sets the `allow_paid_broadcast` parameter.
322    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
323        self.allow_paid_broadcast = Some(val);
324        self
325    }
326
327    /// Sends the request to the Telegram Bot API.
328    pub async fn send(self) -> Result<message::Message> {
329        self.bot
330            .send_game_raw(
331                self.chat_id,
332                &self.game_short_name,
333                self.disable_notification,
334                self.protect_content,
335                self.reply_parameters,
336                self.reply_markup,
337                self.message_thread_id,
338                self.business_connection_id.as_deref(),
339                self.message_effect_id.as_deref(),
340                self.allow_paid_broadcast,
341            )
342            .await
343    }
344}
345
346impl_into_future!(SendGameBuilder, message::Message);
347
348// -------------------------------------------------------------------------
349// SetGameScoreBuilder
350// -------------------------------------------------------------------------
351
352/// Builder for the [`setGameScore`] API method.
353pub struct SetGameScoreBuilder<'a> {
354    bot: &'a Bot,
355    user_id: i64,
356    score: i64,
357    force: Option<bool>,
358    disable_edit_message: Option<bool>,
359    chat_id: Option<i64>,
360    message_id: Option<i64>,
361    inline_message_id: Option<String>,
362}
363
364impl<'a> SetGameScoreBuilder<'a> {
365    /// Sets the `force` parameter.
366    pub fn force(mut self, val: bool) -> Self {
367        self.force = Some(val);
368        self
369    }
370    /// Sets the `disable_edit_message` parameter.
371    pub fn disable_edit_message(mut self, val: bool) -> Self {
372        self.disable_edit_message = Some(val);
373        self
374    }
375    /// Sets the `chat_id` parameter.
376    pub fn chat_id(mut self, val: i64) -> Self {
377        self.chat_id = Some(val);
378        self
379    }
380    /// Sets the `message_id` parameter.
381    pub fn message_id(mut self, val: i64) -> Self {
382        self.message_id = Some(val);
383        self
384    }
385    /// Sets the `inline_message_id` parameter.
386    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
387        self.inline_message_id = Some(val.into());
388        self
389    }
390
391    /// Sends the request to the Telegram Bot API.
392    pub async fn send(self) -> Result<MessageOrBool> {
393        self.bot
394            .set_game_score_raw(
395                self.user_id,
396                self.score,
397                self.force,
398                self.disable_edit_message,
399                self.chat_id,
400                self.message_id,
401                self.inline_message_id.as_deref(),
402            )
403            .await
404    }
405}
406
407impl_into_future!(SetGameScoreBuilder, MessageOrBool);
408
409// -------------------------------------------------------------------------
410// GetGameHighScoresBuilder
411// -------------------------------------------------------------------------
412
413/// Builder for the [`getGameHighScores`] API method.
414pub struct GetGameHighScoresBuilder<'a> {
415    bot: &'a Bot,
416    user_id: i64,
417    chat_id: Option<i64>,
418    message_id: Option<i64>,
419    inline_message_id: Option<String>,
420}
421
422impl<'a> GetGameHighScoresBuilder<'a> {
423    /// Sets the `chat_id` parameter.
424    pub fn chat_id(mut self, val: i64) -> Self {
425        self.chat_id = Some(val);
426        self
427    }
428    /// Sets the `message_id` parameter.
429    pub fn message_id(mut self, val: i64) -> Self {
430        self.message_id = Some(val);
431        self
432    }
433    /// Sets the `inline_message_id` parameter.
434    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
435        self.inline_message_id = Some(val.into());
436        self
437    }
438
439    /// Sends the request to the Telegram Bot API.
440    pub async fn send(self) -> Result<Vec<games::game_high_score::GameHighScore>> {
441        self.bot
442            .get_game_high_scores_raw(
443                self.user_id,
444                self.chat_id,
445                self.message_id,
446                self.inline_message_id.as_deref(),
447            )
448            .await
449    }
450}
451
452impl_into_future!(
453    GetGameHighScoresBuilder,
454    Vec<games::game_high_score::GameHighScore>
455);
456
457// =========================================================================
458// inline_methods.rs builders
459// =========================================================================
460
461// -------------------------------------------------------------------------
462// SavePreparedInlineMessageBuilder
463// -------------------------------------------------------------------------
464
465/// Builder for the [`savePreparedInlineMessage`] API method.
466pub struct SavePreparedInlineMessageBuilder<'a> {
467    bot: &'a Bot,
468    user_id: i64,
469    result: serde_json::Value,
470    allow_user_chats: Option<bool>,
471    allow_bot_chats: Option<bool>,
472    allow_group_chats: Option<bool>,
473    allow_channel_chats: Option<bool>,
474}
475
476impl<'a> SavePreparedInlineMessageBuilder<'a> {
477    /// Sets the `allow_user_chats` parameter.
478    pub fn allow_user_chats(mut self, val: bool) -> Self {
479        self.allow_user_chats = Some(val);
480        self
481    }
482    /// Sets the `allow_bot_chats` parameter.
483    pub fn allow_bot_chats(mut self, val: bool) -> Self {
484        self.allow_bot_chats = Some(val);
485        self
486    }
487    /// Sets the `allow_group_chats` parameter.
488    pub fn allow_group_chats(mut self, val: bool) -> Self {
489        self.allow_group_chats = Some(val);
490        self
491    }
492    /// Sets the `allow_channel_chats` parameter.
493    pub fn allow_channel_chats(mut self, val: bool) -> Self {
494        self.allow_channel_chats = Some(val);
495        self
496    }
497
498    /// Sends the request to the Telegram Bot API.
499    pub async fn send(self) -> Result<serde_json::Value> {
500        self.bot
501            .save_prepared_inline_message_raw(
502                self.user_id,
503                self.result,
504                self.allow_user_chats,
505                self.allow_bot_chats,
506                self.allow_group_chats,
507                self.allow_channel_chats,
508            )
509            .await
510    }
511}
512
513impl_into_future!(SavePreparedInlineMessageBuilder, serde_json::Value);
514
515// -------------------------------------------------------------------------
516// AnswerWebAppQueryBuilder
517// -------------------------------------------------------------------------
518
519/// Builder for the [`answerWebAppQuery`] API method.
520pub struct AnswerWebAppQueryBuilder<'a> {
521    bot: &'a Bot,
522    web_app_query_id: String,
523    result: serde_json::Value,
524}
525
526impl<'a> AnswerWebAppQueryBuilder<'a> {
527    /// Sends the request to the Telegram Bot API.
528    pub async fn send(self) -> Result<sent_web_app_message::SentWebAppMessage> {
529        self.bot
530            .answer_web_app_query_raw(&self.web_app_query_id, self.result)
531            .await
532    }
533}
534
535impl_into_future!(
536    AnswerWebAppQueryBuilder,
537    sent_web_app_message::SentWebAppMessage
538);
539
540// =========================================================================
541// media.rs builders (send_media_group, send_paid_media)
542// =========================================================================
543
544// -------------------------------------------------------------------------
545// SendMediaGroupBuilder
546// -------------------------------------------------------------------------
547
548/// Builder for the [`sendMediaGroup`] API method.
549pub struct SendMediaGroupBuilder<'a> {
550    bot: &'a Bot,
551    chat_id: ChatId,
552    media: Vec<serde_json::Value>,
553    disable_notification: Option<bool>,
554    protect_content: Option<bool>,
555    message_thread_id: Option<i64>,
556    reply_parameters: Option<reply::ReplyParameters>,
557    business_connection_id: Option<String>,
558    message_effect_id: Option<String>,
559    allow_paid_broadcast: Option<bool>,
560    direct_messages_topic_id: Option<i64>,
561    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
562}
563
564impl<'a> SendMediaGroupBuilder<'a> {
565    /// Sets the `disable_notification` parameter.
566    pub fn disable_notification(mut self, val: bool) -> Self {
567        self.disable_notification = Some(val);
568        self
569    }
570    /// Sets the `protect_content` parameter.
571    pub fn protect_content(mut self, val: bool) -> Self {
572        self.protect_content = Some(val);
573        self
574    }
575    /// Sets the `message_thread_id` parameter.
576    pub fn message_thread_id(mut self, val: i64) -> Self {
577        self.message_thread_id = Some(val);
578        self
579    }
580    /// Sets the `reply_parameters` parameter.
581    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
582        self.reply_parameters = Some(val);
583        self
584    }
585    /// Sets the `business_connection_id` parameter.
586    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
587        self.business_connection_id = Some(val.into());
588        self
589    }
590    /// Sets the `message_effect_id` parameter.
591    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
592        self.message_effect_id = Some(val.into());
593        self
594    }
595    /// Sets the `allow_paid_broadcast` parameter.
596    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
597        self.allow_paid_broadcast = Some(val);
598        self
599    }
600    /// Sets the `direct_messages_topic_id` parameter.
601    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
602        self.direct_messages_topic_id = Some(val);
603        self
604    }
605    /// Sets the `suggested_post_parameters` parameter.
606    pub fn suggested_post_parameters(
607        mut self,
608        val: suggested_post::SuggestedPostParameters,
609    ) -> Self {
610        self.suggested_post_parameters = Some(val);
611        self
612    }
613
614    /// Sends the request to the Telegram Bot API.
615    pub async fn send(self) -> Result<Vec<message::Message>> {
616        self.bot
617            .send_media_group_raw(
618                self.chat_id,
619                self.media,
620                self.disable_notification,
621                self.protect_content,
622                self.message_thread_id,
623                self.reply_parameters,
624                self.business_connection_id.as_deref(),
625                self.message_effect_id.as_deref(),
626                self.allow_paid_broadcast,
627                self.direct_messages_topic_id,
628                self.suggested_post_parameters,
629            )
630            .await
631    }
632}
633
634impl_into_future!(SendMediaGroupBuilder, Vec<message::Message>);
635
636// -------------------------------------------------------------------------
637// SendPaidMediaBuilder
638// -------------------------------------------------------------------------
639
640/// Builder for the [`sendPaidMedia`] API method.
641pub struct SendPaidMediaBuilder<'a> {
642    bot: &'a Bot,
643    chat_id: ChatId,
644    star_count: i64,
645    media: Vec<serde_json::Value>,
646    caption: Option<String>,
647    parse_mode: Option<String>,
648    caption_entities: Option<Vec<message_entity::MessageEntity>>,
649    show_caption_above_media: Option<bool>,
650    disable_notification: Option<bool>,
651    protect_content: Option<bool>,
652    reply_parameters: Option<reply::ReplyParameters>,
653    reply_markup: Option<serde_json::Value>,
654    business_connection_id: Option<String>,
655    payload: Option<String>,
656    allow_paid_broadcast: Option<bool>,
657    direct_messages_topic_id: Option<i64>,
658    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
659    message_thread_id: Option<i64>,
660}
661
662impl<'a> SendPaidMediaBuilder<'a> {
663    /// Sets the `caption` parameter.
664    pub fn caption(mut self, val: impl Into<String>) -> Self {
665        self.caption = Some(val.into());
666        self
667    }
668    /// Sets the `parse_mode` parameter.
669    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
670        self.parse_mode = Some(val.into());
671        self
672    }
673    /// Sets the `caption_entities` parameter.
674    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
675        self.caption_entities = Some(val);
676        self
677    }
678    /// Sets the `show_caption_above_media` parameter.
679    pub fn show_caption_above_media(mut self, val: bool) -> Self {
680        self.show_caption_above_media = Some(val);
681        self
682    }
683    /// Sets the `disable_notification` parameter.
684    pub fn disable_notification(mut self, val: bool) -> Self {
685        self.disable_notification = Some(val);
686        self
687    }
688    /// Sets the `protect_content` parameter.
689    pub fn protect_content(mut self, val: bool) -> Self {
690        self.protect_content = Some(val);
691        self
692    }
693    /// Sets the `reply_parameters` parameter.
694    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
695        self.reply_parameters = Some(val);
696        self
697    }
698    /// Sets the `reply_markup` parameter.
699    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
700        self.reply_markup = Some(val);
701        self
702    }
703    /// Sets the `business_connection_id` parameter.
704    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
705        self.business_connection_id = Some(val.into());
706        self
707    }
708    /// Sets the `payload` parameter.
709    pub fn payload(mut self, val: impl Into<String>) -> Self {
710        self.payload = Some(val.into());
711        self
712    }
713    /// Sets the `allow_paid_broadcast` parameter.
714    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
715        self.allow_paid_broadcast = Some(val);
716        self
717    }
718    /// Sets the `direct_messages_topic_id` parameter.
719    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
720        self.direct_messages_topic_id = Some(val);
721        self
722    }
723    /// Sets the `suggested_post_parameters` parameter.
724    pub fn suggested_post_parameters(
725        mut self,
726        val: suggested_post::SuggestedPostParameters,
727    ) -> Self {
728        self.suggested_post_parameters = Some(val);
729        self
730    }
731    /// Sets the `message_thread_id` parameter.
732    pub fn message_thread_id(mut self, val: i64) -> Self {
733        self.message_thread_id = Some(val);
734        self
735    }
736
737    /// Sends the request to the Telegram Bot API.
738    pub async fn send(self) -> Result<message::Message> {
739        self.bot
740            .send_paid_media_raw(
741                self.chat_id,
742                self.star_count,
743                self.media,
744                self.caption.as_deref(),
745                self.parse_mode.as_deref(),
746                self.caption_entities,
747                self.show_caption_above_media,
748                self.disable_notification,
749                self.protect_content,
750                self.reply_parameters,
751                self.reply_markup,
752                self.business_connection_id.as_deref(),
753                self.payload.as_deref(),
754                self.allow_paid_broadcast,
755                self.direct_messages_topic_id,
756                self.suggested_post_parameters,
757                self.message_thread_id,
758            )
759            .await
760    }
761}
762
763impl_into_future!(SendPaidMediaBuilder, message::Message);
764
765// =========================================================================
766// mod.rs builders (core Bot methods)
767// =========================================================================
768
769// -------------------------------------------------------------------------
770// GetMeBuilder
771// -------------------------------------------------------------------------
772
773/// Builder for the [`getMe`] API method.
774#[derive(Serialize)]
775pub struct GetMeBuilder<'a> {
776    #[serde(skip)]
777    bot: &'a Bot,
778}
779
780impl<'a> GetMeBuilder<'a> {
781    /// Sends the request to the Telegram Bot API.
782    pub async fn send(self) -> Result<user::User> {
783        self.bot.get_me_raw().await
784    }
785}
786
787impl_into_future!(GetMeBuilder, user::User);
788
789// -------------------------------------------------------------------------
790// LogOutBuilder
791// -------------------------------------------------------------------------
792
793/// Builder for the [`logOut`] API method.
794#[derive(Serialize)]
795pub struct LogOutBuilder<'a> {
796    #[serde(skip)]
797    bot: &'a Bot,
798}
799
800impl<'a> LogOutBuilder<'a> {
801    /// Sends the request to the Telegram Bot API.
802    pub async fn send(self) -> Result<bool> {
803        self.bot.log_out_raw().await
804    }
805}
806
807impl_into_future!(LogOutBuilder, bool);
808
809// -------------------------------------------------------------------------
810// CloseBuilder
811// -------------------------------------------------------------------------
812
813/// Builder for the [`close`] API method.
814#[derive(Serialize)]
815pub struct CloseBuilder<'a> {
816    #[serde(skip)]
817    bot: &'a Bot,
818}
819
820impl<'a> CloseBuilder<'a> {
821    /// Sends the request to the Telegram Bot API.
822    pub async fn send(self) -> Result<bool> {
823        self.bot.close_raw().await
824    }
825}
826
827impl_into_future!(CloseBuilder, bool);
828
829// -------------------------------------------------------------------------
830// GetUpdatesBuilder
831// -------------------------------------------------------------------------
832
833/// Builder for the [`getUpdates`] API method.
834pub struct GetUpdatesBuilder<'a> {
835    bot: &'a Bot,
836    offset: Option<i64>,
837    limit: Option<i32>,
838    timeout: Option<i32>,
839    allowed_updates: Option<Vec<String>>,
840}
841
842impl<'a> GetUpdatesBuilder<'a> {
843    /// Sets the `offset` parameter.
844    pub fn offset(mut self, val: i64) -> Self {
845        self.offset = Some(val);
846        self
847    }
848    /// Sets the `limit` parameter.
849    pub fn limit(mut self, val: i32) -> Self {
850        self.limit = Some(val);
851        self
852    }
853    /// Sets the `timeout` parameter.
854    pub fn timeout(mut self, val: i32) -> Self {
855        self.timeout = Some(val);
856        self
857    }
858    /// Sets the `allowed_updates` parameter.
859    pub fn allowed_updates(mut self, val: Vec<String>) -> Self {
860        self.allowed_updates = Some(val);
861        self
862    }
863
864    /// Sends the request to the Telegram Bot API.
865    pub async fn send(self) -> Result<Vec<update::Update>> {
866        self.bot
867            .get_updates_raw(self.offset, self.limit, self.timeout, self.allowed_updates)
868            .await
869    }
870}
871
872impl_into_future!(GetUpdatesBuilder, Vec<update::Update>);
873
874// -------------------------------------------------------------------------
875// GetWebhookInfoBuilder
876// -------------------------------------------------------------------------
877
878/// Builder for the [`getWebhookInfo`] API method.
879#[derive(Serialize)]
880pub struct GetWebhookInfoBuilder<'a> {
881    #[serde(skip)]
882    bot: &'a Bot,
883}
884
885impl<'a> GetWebhookInfoBuilder<'a> {
886    /// Sends the request to the Telegram Bot API.
887    pub async fn send(self) -> Result<webhook_info::WebhookInfo> {
888        self.bot.get_webhook_info_raw().await
889    }
890}
891
892impl_into_future!(GetWebhookInfoBuilder, webhook_info::WebhookInfo);
893
894// -------------------------------------------------------------------------
895// DownloadFileBuilder
896// -------------------------------------------------------------------------
897
898/// Builder for the `download_file` method.
899pub struct DownloadFileBuilder<'a> {
900    bot: &'a Bot,
901    file_path: String,
902}
903
904impl<'a> DownloadFileBuilder<'a> {
905    /// Sends the request to the Telegram Bot API.
906    pub async fn send(self) -> Result<Vec<u8>> {
907        self.bot.download_file_raw(&self.file_path).await
908    }
909}
910
911impl_into_future!(DownloadFileBuilder, Vec<u8>);
912
913// =========================================================================
914// other_content.rs builder (send_checklist)
915// =========================================================================
916
917// -------------------------------------------------------------------------
918// SendChecklistBuilder
919// -------------------------------------------------------------------------
920
921/// Builder for the [`sendChecklist`] API method.
922pub struct SendChecklistBuilder<'a> {
923    bot: &'a Bot,
924    business_connection_id: String,
925    chat_id: i64,
926    checklist: input_checklist::InputChecklist,
927    disable_notification: Option<bool>,
928    protect_content: Option<bool>,
929    message_effect_id: Option<String>,
930    reply_parameters: Option<reply::ReplyParameters>,
931    reply_markup: Option<serde_json::Value>,
932}
933
934impl<'a> SendChecklistBuilder<'a> {
935    /// Sets the `disable_notification` parameter.
936    pub fn disable_notification(mut self, val: bool) -> Self {
937        self.disable_notification = Some(val);
938        self
939    }
940    /// Sets the `protect_content` parameter.
941    pub fn protect_content(mut self, val: bool) -> Self {
942        self.protect_content = Some(val);
943        self
944    }
945    /// Sets the `message_effect_id` parameter.
946    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
947        self.message_effect_id = Some(val.into());
948        self
949    }
950    /// Sets the `reply_parameters` parameter.
951    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
952        self.reply_parameters = Some(val);
953        self
954    }
955    /// Sets the `reply_markup` parameter.
956    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
957        self.reply_markup = Some(val);
958        self
959    }
960
961    /// Sends the request to the Telegram Bot API.
962    pub async fn send(self) -> Result<message::Message> {
963        self.bot
964            .send_checklist_raw(
965                &self.business_connection_id,
966                self.chat_id,
967                self.checklist,
968                self.disable_notification,
969                self.protect_content,
970                self.message_effect_id.as_deref(),
971                self.reply_parameters,
972                self.reply_markup,
973            )
974            .await
975    }
976}
977
978impl_into_future!(SendChecklistBuilder, message::Message);
979
980// =========================================================================
981// passport.rs builder
982// =========================================================================
983
984// -------------------------------------------------------------------------
985// SetPassportDataErrorsBuilder
986// -------------------------------------------------------------------------
987
988/// Builder for the [`setPassportDataErrors`] API method.
989pub struct SetPassportDataErrorsBuilder<'a> {
990    bot: &'a Bot,
991    user_id: i64,
992    errors: Vec<serde_json::Value>,
993}
994
995impl<'a> SetPassportDataErrorsBuilder<'a> {
996    /// Sends the request to the Telegram Bot API.
997    pub async fn send(self) -> Result<bool> {
998        self.bot
999            .set_passport_data_errors_raw(self.user_id, self.errors)
1000            .await
1001    }
1002}
1003
1004impl_into_future!(SetPassportDataErrorsBuilder, bool);
1005
1006// =========================================================================
1007// reactions.rs builders
1008// =========================================================================
1009
1010// -------------------------------------------------------------------------
1011// SetMessageReactionBuilder
1012// -------------------------------------------------------------------------
1013
1014/// Builder for the [`setMessageReaction`] API method.
1015pub struct SetMessageReactionBuilder<'a> {
1016    bot: &'a Bot,
1017    chat_id: ChatId,
1018    message_id: i64,
1019    reaction: Option<Vec<serde_json::Value>>,
1020    is_big: Option<bool>,
1021}
1022
1023impl<'a> SetMessageReactionBuilder<'a> {
1024    /// Sets the `reaction` parameter.
1025    pub fn reaction(mut self, val: Vec<serde_json::Value>) -> Self {
1026        self.reaction = Some(val);
1027        self
1028    }
1029    /// Sets the `is_big` parameter.
1030    pub fn is_big(mut self, val: bool) -> Self {
1031        self.is_big = Some(val);
1032        self
1033    }
1034
1035    /// Sends the request to the Telegram Bot API.
1036    pub async fn send(self) -> Result<bool> {
1037        self.bot
1038            .set_message_reaction_raw(self.chat_id, self.message_id, self.reaction, self.is_big)
1039            .await
1040    }
1041}
1042
1043impl_into_future!(SetMessageReactionBuilder, bool);
1044
1045// -------------------------------------------------------------------------
1046// GetUserChatBoostsBuilder
1047// -------------------------------------------------------------------------
1048
1049/// Builder for the [`getUserChatBoosts`] API method.
1050pub struct GetUserChatBoostsBuilder<'a> {
1051    bot: &'a Bot,
1052    chat_id: ChatId,
1053    user_id: i64,
1054}
1055
1056impl<'a> GetUserChatBoostsBuilder<'a> {
1057    /// Sends the request to the Telegram Bot API.
1058    pub async fn send(self) -> Result<chat_boost::UserChatBoosts> {
1059        self.bot
1060            .get_user_chat_boosts_raw(self.chat_id, self.user_id)
1061            .await
1062    }
1063}
1064
1065impl_into_future!(GetUserChatBoostsBuilder, chat_boost::UserChatBoosts);
1066
1067// =========================================================================
1068// stories.rs builders
1069// =========================================================================
1070
1071// -------------------------------------------------------------------------
1072// PostStoryBuilder
1073// -------------------------------------------------------------------------
1074
1075/// Builder for the [`postStory`] API method.
1076pub struct PostStoryBuilder<'a> {
1077    bot: &'a Bot,
1078    business_connection_id: String,
1079    content: serde_json::Value,
1080    active_period: i64,
1081    caption: Option<String>,
1082    parse_mode: Option<String>,
1083    caption_entities: Option<Vec<message_entity::MessageEntity>>,
1084    areas: Option<Vec<serde_json::Value>>,
1085    post_to_chat_page: Option<bool>,
1086    protect_content: Option<bool>,
1087}
1088
1089impl<'a> PostStoryBuilder<'a> {
1090    /// Sets the `caption` parameter.
1091    pub fn caption(mut self, val: impl Into<String>) -> Self {
1092        self.caption = Some(val.into());
1093        self
1094    }
1095    /// Sets the `parse_mode` parameter.
1096    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
1097        self.parse_mode = Some(val.into());
1098        self
1099    }
1100    /// Sets the `caption_entities` parameter.
1101    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
1102        self.caption_entities = Some(val);
1103        self
1104    }
1105    /// Sets the `areas` parameter.
1106    pub fn areas(mut self, val: Vec<serde_json::Value>) -> Self {
1107        self.areas = Some(val);
1108        self
1109    }
1110    /// Sets the `post_to_chat_page` parameter.
1111    pub fn post_to_chat_page(mut self, val: bool) -> Self {
1112        self.post_to_chat_page = Some(val);
1113        self
1114    }
1115    /// Sets the `protect_content` parameter.
1116    pub fn protect_content(mut self, val: bool) -> Self {
1117        self.protect_content = Some(val);
1118        self
1119    }
1120
1121    /// Sends the request to the Telegram Bot API.
1122    pub async fn send(self) -> Result<story::Story> {
1123        self.bot
1124            .post_story_raw(
1125                &self.business_connection_id,
1126                self.content,
1127                self.active_period,
1128                self.caption.as_deref(),
1129                self.parse_mode.as_deref(),
1130                self.caption_entities,
1131                self.areas,
1132                self.post_to_chat_page,
1133                self.protect_content,
1134            )
1135            .await
1136    }
1137}
1138
1139impl_into_future!(PostStoryBuilder, story::Story);
1140
1141// -------------------------------------------------------------------------
1142// EditStoryBuilder
1143// -------------------------------------------------------------------------
1144
1145/// Builder for the [`editStory`] API method.
1146pub struct EditStoryBuilder<'a> {
1147    bot: &'a Bot,
1148    business_connection_id: String,
1149    story_id: i64,
1150    content: serde_json::Value,
1151    caption: Option<String>,
1152    parse_mode: Option<String>,
1153    caption_entities: Option<Vec<message_entity::MessageEntity>>,
1154    areas: Option<Vec<serde_json::Value>>,
1155}
1156
1157impl<'a> EditStoryBuilder<'a> {
1158    /// Sets the `caption` parameter.
1159    pub fn caption(mut self, val: impl Into<String>) -> Self {
1160        self.caption = Some(val.into());
1161        self
1162    }
1163    /// Sets the `parse_mode` parameter.
1164    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
1165        self.parse_mode = Some(val.into());
1166        self
1167    }
1168    /// Sets the `caption_entities` parameter.
1169    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
1170        self.caption_entities = Some(val);
1171        self
1172    }
1173    /// Sets the `areas` parameter.
1174    pub fn areas(mut self, val: Vec<serde_json::Value>) -> Self {
1175        self.areas = Some(val);
1176        self
1177    }
1178
1179    /// Sends the request to the Telegram Bot API.
1180    pub async fn send(self) -> Result<story::Story> {
1181        self.bot
1182            .edit_story_raw(
1183                &self.business_connection_id,
1184                self.story_id,
1185                self.content,
1186                self.caption.as_deref(),
1187                self.parse_mode.as_deref(),
1188                self.caption_entities,
1189                self.areas,
1190            )
1191            .await
1192    }
1193}
1194
1195impl_into_future!(EditStoryBuilder, story::Story);
1196
1197// -------------------------------------------------------------------------
1198// DeleteStoryBuilder
1199// -------------------------------------------------------------------------
1200
1201/// Builder for the [`deleteStory`] API method.
1202pub struct DeleteStoryBuilder<'a> {
1203    bot: &'a Bot,
1204    business_connection_id: String,
1205    story_id: i64,
1206}
1207
1208impl<'a> DeleteStoryBuilder<'a> {
1209    /// Sends the request to the Telegram Bot API.
1210    pub async fn send(self) -> Result<bool> {
1211        self.bot
1212            .delete_story_raw(&self.business_connection_id, self.story_id)
1213            .await
1214    }
1215}
1216
1217impl_into_future!(DeleteStoryBuilder, bool);
1218
1219// -------------------------------------------------------------------------
1220// RepostStoryBuilder
1221// -------------------------------------------------------------------------
1222
1223/// Builder for the [`repostStory`] API method.
1224pub struct RepostStoryBuilder<'a> {
1225    bot: &'a Bot,
1226    business_connection_id: String,
1227    from_chat_id: i64,
1228    from_story_id: i64,
1229    active_period: i64,
1230    post_to_chat_page: Option<bool>,
1231    protect_content: Option<bool>,
1232}
1233
1234impl<'a> RepostStoryBuilder<'a> {
1235    /// Sets the `post_to_chat_page` parameter.
1236    pub fn post_to_chat_page(mut self, val: bool) -> Self {
1237        self.post_to_chat_page = Some(val);
1238        self
1239    }
1240    /// Sets the `protect_content` parameter.
1241    pub fn protect_content(mut self, val: bool) -> Self {
1242        self.protect_content = Some(val);
1243        self
1244    }
1245
1246    /// Sends the request to the Telegram Bot API.
1247    pub async fn send(self) -> Result<story::Story> {
1248        self.bot
1249            .repost_story_raw(
1250                &self.business_connection_id,
1251                self.from_chat_id,
1252                self.from_story_id,
1253                self.active_period,
1254                self.post_to_chat_page,
1255                self.protect_content,
1256            )
1257            .await
1258    }
1259}
1260
1261impl_into_future!(RepostStoryBuilder, story::Story);
1262
1263// =========================================================================
1264// suggested_posts.rs builders
1265// =========================================================================
1266
1267// -------------------------------------------------------------------------
1268// ApproveSuggestedPostBuilder
1269// -------------------------------------------------------------------------
1270
1271/// Builder for the [`approveSuggestedPost`] API method.
1272pub struct ApproveSuggestedPostBuilder<'a> {
1273    bot: &'a Bot,
1274    chat_id: i64,
1275    message_id: i64,
1276    send_date: Option<i64>,
1277}
1278
1279impl<'a> ApproveSuggestedPostBuilder<'a> {
1280    /// Sets the `send_date` parameter.
1281    pub fn send_date(mut self, val: i64) -> Self {
1282        self.send_date = Some(val);
1283        self
1284    }
1285
1286    /// Sends the request to the Telegram Bot API.
1287    pub async fn send(self) -> Result<bool> {
1288        self.bot
1289            .approve_suggested_post_raw(self.chat_id, self.message_id, self.send_date)
1290            .await
1291    }
1292}
1293
1294impl_into_future!(ApproveSuggestedPostBuilder, bool);
1295
1296// -------------------------------------------------------------------------
1297// DeclineSuggestedPostBuilder
1298// -------------------------------------------------------------------------
1299
1300/// Builder for the [`declineSuggestedPost`] API method.
1301pub struct DeclineSuggestedPostBuilder<'a> {
1302    bot: &'a Bot,
1303    chat_id: i64,
1304    message_id: i64,
1305    comment: Option<String>,
1306}
1307
1308impl<'a> DeclineSuggestedPostBuilder<'a> {
1309    /// Sets the `comment` parameter.
1310    pub fn comment(mut self, val: impl Into<String>) -> Self {
1311        self.comment = Some(val.into());
1312        self
1313    }
1314
1315    /// Sends the request to the Telegram Bot API.
1316    pub async fn send(self) -> Result<bool> {
1317        self.bot
1318            .decline_suggested_post_raw(self.chat_id, self.message_id, self.comment.as_deref())
1319            .await
1320    }
1321}
1322
1323impl_into_future!(DeclineSuggestedPostBuilder, bool);
1324
1325// =========================================================================
1326// user_profile.rs builders
1327// =========================================================================
1328
1329// -------------------------------------------------------------------------
1330// GetUserProfilePhotosBuilder
1331// -------------------------------------------------------------------------
1332
1333/// Builder for the [`getUserProfilePhotos`] API method.
1334pub struct GetUserProfilePhotosBuilder<'a> {
1335    bot: &'a Bot,
1336    user_id: i64,
1337    offset: Option<i64>,
1338    limit: Option<i64>,
1339}
1340
1341impl<'a> GetUserProfilePhotosBuilder<'a> {
1342    /// Sets the `offset` parameter.
1343    pub fn offset(mut self, val: i64) -> Self {
1344        self.offset = Some(val);
1345        self
1346    }
1347    /// Sets the `limit` parameter.
1348    pub fn limit(mut self, val: i64) -> Self {
1349        self.limit = Some(val);
1350        self
1351    }
1352
1353    /// Sends the request to the Telegram Bot API.
1354    pub async fn send(self) -> Result<user_profile_photos::UserProfilePhotos> {
1355        self.bot
1356            .get_user_profile_photos_raw(self.user_id, self.offset, self.limit)
1357            .await
1358    }
1359}
1360
1361impl_into_future!(
1362    GetUserProfilePhotosBuilder,
1363    user_profile_photos::UserProfilePhotos
1364);
1365
1366// -------------------------------------------------------------------------
1367// GetUserProfileAudiosBuilder
1368// -------------------------------------------------------------------------
1369
1370/// Builder for the [`getUserProfileAudios`] API method.
1371pub struct GetUserProfileAudiosBuilder<'a> {
1372    bot: &'a Bot,
1373    user_id: i64,
1374    offset: Option<i64>,
1375    limit: Option<i64>,
1376}
1377
1378impl<'a> GetUserProfileAudiosBuilder<'a> {
1379    /// Sets the `offset` parameter.
1380    pub fn offset(mut self, val: i64) -> Self {
1381        self.offset = Some(val);
1382        self
1383    }
1384    /// Sets the `limit` parameter.
1385    pub fn limit(mut self, val: i64) -> Self {
1386        self.limit = Some(val);
1387        self
1388    }
1389
1390    /// Sends the request to the Telegram Bot API.
1391    pub async fn send(self) -> Result<user_profile_audios::UserProfileAudios> {
1392        self.bot
1393            .get_user_profile_audios_raw(self.user_id, self.offset, self.limit)
1394            .await
1395    }
1396}
1397
1398impl_into_future!(
1399    GetUserProfileAudiosBuilder,
1400    user_profile_audios::UserProfileAudios
1401);
1402
1403// -------------------------------------------------------------------------
1404// SetUserEmojiStatusBuilder
1405// -------------------------------------------------------------------------
1406
1407/// Builder for the [`setUserEmojiStatus`] API method.
1408pub struct SetUserEmojiStatusBuilder<'a> {
1409    bot: &'a Bot,
1410    user_id: i64,
1411    emoji_status_custom_emoji_id: Option<String>,
1412    emoji_status_expiration_date: Option<i64>,
1413}
1414
1415impl<'a> SetUserEmojiStatusBuilder<'a> {
1416    /// Sets the `emoji_status_custom_emoji_id` parameter.
1417    pub fn emoji_status_custom_emoji_id(mut self, val: impl Into<String>) -> Self {
1418        self.emoji_status_custom_emoji_id = Some(val.into());
1419        self
1420    }
1421    /// Sets the `emoji_status_expiration_date` parameter.
1422    pub fn emoji_status_expiration_date(mut self, val: i64) -> Self {
1423        self.emoji_status_expiration_date = Some(val);
1424        self
1425    }
1426
1427    /// Sends the request to the Telegram Bot API.
1428    pub async fn send(self) -> Result<bool> {
1429        self.bot
1430            .set_user_emoji_status_raw(
1431                self.user_id,
1432                self.emoji_status_custom_emoji_id.as_deref(),
1433                self.emoji_status_expiration_date,
1434            )
1435            .await
1436    }
1437}
1438
1439impl_into_future!(SetUserEmojiStatusBuilder, bool);
1440
1441// -------------------------------------------------------------------------
1442// SetMyProfilePhotoBuilder
1443// -------------------------------------------------------------------------
1444
1445/// Builder for the [`setMyProfilePhoto`] API method.
1446pub struct SetMyProfilePhotoBuilder<'a> {
1447    bot: &'a Bot,
1448    photo: serde_json::Value,
1449}
1450
1451impl<'a> SetMyProfilePhotoBuilder<'a> {
1452    /// Sends the request to the Telegram Bot API.
1453    pub async fn send(self) -> Result<bool> {
1454        self.bot.set_my_profile_photo_raw(self.photo).await
1455    }
1456}
1457
1458impl_into_future!(SetMyProfilePhotoBuilder, bool);
1459
1460// -------------------------------------------------------------------------
1461// RemoveMyProfilePhotoBuilder
1462// -------------------------------------------------------------------------
1463
1464/// Builder for the [`removeMyProfilePhoto`] API method.
1465#[derive(Serialize)]
1466pub struct RemoveMyProfilePhotoBuilder<'a> {
1467    #[serde(skip)]
1468    bot: &'a Bot,
1469}
1470
1471impl<'a> RemoveMyProfilePhotoBuilder<'a> {
1472    /// Sends the request to the Telegram Bot API.
1473    pub async fn send(self) -> Result<bool> {
1474        self.bot.remove_my_profile_photo_raw().await
1475    }
1476}
1477
1478impl_into_future!(RemoveMyProfilePhotoBuilder, bool);
1479
1480// =========================================================================
1481// verification.rs builders
1482// =========================================================================
1483
1484// -------------------------------------------------------------------------
1485// VerifyChatBuilder
1486// -------------------------------------------------------------------------
1487
1488/// Builder for the [`verifyChat`] API method.
1489pub struct VerifyChatBuilder<'a> {
1490    bot: &'a Bot,
1491    chat_id: ChatId,
1492    custom_description: Option<String>,
1493}
1494
1495impl<'a> VerifyChatBuilder<'a> {
1496    /// Sets the `custom_description` parameter.
1497    pub fn custom_description(mut self, val: impl Into<String>) -> Self {
1498        self.custom_description = Some(val.into());
1499        self
1500    }
1501
1502    /// Sends the request to the Telegram Bot API.
1503    pub async fn send(self) -> Result<bool> {
1504        self.bot
1505            .verify_chat_raw(self.chat_id, self.custom_description.as_deref())
1506            .await
1507    }
1508}
1509
1510impl_into_future!(VerifyChatBuilder, bool);
1511
1512// -------------------------------------------------------------------------
1513// VerifyUserBuilder
1514// -------------------------------------------------------------------------
1515
1516/// Builder for the [`verifyUser`] API method.
1517pub struct VerifyUserBuilder<'a> {
1518    bot: &'a Bot,
1519    user_id: i64,
1520    custom_description: Option<String>,
1521}
1522
1523impl<'a> VerifyUserBuilder<'a> {
1524    /// Sets the `custom_description` parameter.
1525    pub fn custom_description(mut self, val: impl Into<String>) -> Self {
1526        self.custom_description = Some(val.into());
1527        self
1528    }
1529
1530    /// Sends the request to the Telegram Bot API.
1531    pub async fn send(self) -> Result<bool> {
1532        self.bot
1533            .verify_user_raw(self.user_id, self.custom_description.as_deref())
1534            .await
1535    }
1536}
1537
1538impl_into_future!(VerifyUserBuilder, bool);
1539
1540// -------------------------------------------------------------------------
1541// RemoveChatVerificationBuilder
1542// -------------------------------------------------------------------------
1543
1544/// Builder for the [`removeChatVerification`] API method.
1545pub struct RemoveChatVerificationBuilder<'a> {
1546    bot: &'a Bot,
1547    chat_id: ChatId,
1548}
1549
1550impl<'a> RemoveChatVerificationBuilder<'a> {
1551    /// Sends the request to the Telegram Bot API.
1552    pub async fn send(self) -> Result<bool> {
1553        self.bot.remove_chat_verification_raw(self.chat_id).await
1554    }
1555}
1556
1557impl_into_future!(RemoveChatVerificationBuilder, bool);
1558
1559// -------------------------------------------------------------------------
1560// RemoveUserVerificationBuilder
1561// -------------------------------------------------------------------------
1562
1563/// Builder for the [`removeUserVerification`] API method.
1564pub struct RemoveUserVerificationBuilder<'a> {
1565    bot: &'a Bot,
1566    user_id: i64,
1567}
1568
1569impl<'a> RemoveUserVerificationBuilder<'a> {
1570    /// Sends the request to the Telegram Bot API.
1571    pub async fn send(self) -> Result<bool> {
1572        self.bot.remove_user_verification_raw(self.user_id).await
1573    }
1574}
1575
1576impl_into_future!(RemoveUserVerificationBuilder, bool);
1577
1578// =========================================================================
1579// Factory methods on Bot
1580// =========================================================================
1581
1582impl Bot {
1583    // -- Editing methods --------------------------------------------------
1584
1585    /// Build an `editMessageLiveLocation` request.
1586    pub fn edit_message_live_location(
1587        &self,
1588        latitude: f64,
1589        longitude: f64,
1590    ) -> EditMessageLiveLocationBuilder<'_> {
1591        EditMessageLiveLocationBuilder {
1592            bot: self,
1593            latitude,
1594            longitude,
1595            chat_id: None,
1596            message_id: None,
1597            inline_message_id: None,
1598            horizontal_accuracy: None,
1599            heading: None,
1600            proximity_alert_radius: None,
1601            reply_markup: None,
1602            live_period: None,
1603            business_connection_id: None,
1604        }
1605    }
1606
1607    /// Build a `stopMessageLiveLocation` request.
1608    pub fn stop_message_live_location(&self) -> StopMessageLiveLocationBuilder<'_> {
1609        StopMessageLiveLocationBuilder {
1610            bot: self,
1611            chat_id: None,
1612            message_id: None,
1613            inline_message_id: None,
1614            reply_markup: None,
1615            business_connection_id: None,
1616        }
1617    }
1618
1619    /// Build an `editMessageChecklist` request.
1620    pub fn edit_message_checklist(
1621        &self,
1622        business_connection_id: impl Into<String>,
1623        chat_id: i64,
1624        message_id: i64,
1625        checklist: input_checklist::InputChecklist,
1626    ) -> EditMessageChecklistBuilder<'_> {
1627        EditMessageChecklistBuilder {
1628            bot: self,
1629            business_connection_id: business_connection_id.into(),
1630            chat_id,
1631            message_id,
1632            checklist,
1633            reply_markup: None,
1634        }
1635    }
1636
1637    /// Build a `stopPoll` request.
1638    pub fn stop_poll(&self, chat_id: impl Into<ChatId>, message_id: i64) -> StopPollBuilder<'_> {
1639        StopPollBuilder {
1640            bot: self,
1641            chat_id: chat_id.into(),
1642            message_id,
1643            reply_markup: None,
1644            business_connection_id: None,
1645        }
1646    }
1647
1648    // -- Games methods ----------------------------------------------------
1649
1650    /// Build a `sendGame` request.
1651    pub fn send_game(
1652        &self,
1653        chat_id: i64,
1654        game_short_name: impl Into<String>,
1655    ) -> SendGameBuilder<'_> {
1656        SendGameBuilder {
1657            bot: self,
1658            chat_id,
1659            game_short_name: game_short_name.into(),
1660            disable_notification: None,
1661            protect_content: None,
1662            reply_parameters: None,
1663            reply_markup: None,
1664            message_thread_id: None,
1665            business_connection_id: None,
1666            message_effect_id: None,
1667            allow_paid_broadcast: None,
1668        }
1669    }
1670
1671    /// Build a `setGameScore` request.
1672    pub fn set_game_score(&self, user_id: i64, score: i64) -> SetGameScoreBuilder<'_> {
1673        SetGameScoreBuilder {
1674            bot: self,
1675            user_id,
1676            score,
1677            force: None,
1678            disable_edit_message: None,
1679            chat_id: None,
1680            message_id: None,
1681            inline_message_id: None,
1682        }
1683    }
1684
1685    /// Build a `getGameHighScores` request.
1686    pub fn get_game_high_scores(&self, user_id: i64) -> GetGameHighScoresBuilder<'_> {
1687        GetGameHighScoresBuilder {
1688            bot: self,
1689            user_id,
1690            chat_id: None,
1691            message_id: None,
1692            inline_message_id: None,
1693        }
1694    }
1695
1696    // -- Inline methods ---------------------------------------------------
1697
1698    /// Build a `savePreparedInlineMessage` request.
1699    pub fn save_prepared_inline_message(
1700        &self,
1701        user_id: i64,
1702        result: serde_json::Value,
1703    ) -> SavePreparedInlineMessageBuilder<'_> {
1704        SavePreparedInlineMessageBuilder {
1705            bot: self,
1706            user_id,
1707            result,
1708            allow_user_chats: None,
1709            allow_bot_chats: None,
1710            allow_group_chats: None,
1711            allow_channel_chats: None,
1712        }
1713    }
1714
1715    /// Build an `answerWebAppQuery` request.
1716    pub fn answer_web_app_query(
1717        &self,
1718        web_app_query_id: impl Into<String>,
1719        result: serde_json::Value,
1720    ) -> AnswerWebAppQueryBuilder<'_> {
1721        AnswerWebAppQueryBuilder {
1722            bot: self,
1723            web_app_query_id: web_app_query_id.into(),
1724            result,
1725        }
1726    }
1727
1728    // -- Media group / paid media -----------------------------------------
1729
1730    /// Build a `sendMediaGroup` request.
1731    pub fn send_media_group(
1732        &self,
1733        chat_id: impl Into<ChatId>,
1734        media: Vec<serde_json::Value>,
1735    ) -> SendMediaGroupBuilder<'_> {
1736        SendMediaGroupBuilder {
1737            bot: self,
1738            chat_id: chat_id.into(),
1739            media,
1740            disable_notification: None,
1741            protect_content: None,
1742            message_thread_id: None,
1743            reply_parameters: None,
1744            business_connection_id: None,
1745            message_effect_id: None,
1746            allow_paid_broadcast: None,
1747            direct_messages_topic_id: None,
1748            suggested_post_parameters: None,
1749        }
1750    }
1751
1752    /// Build a `sendPaidMedia` request.
1753    pub fn send_paid_media(
1754        &self,
1755        chat_id: impl Into<ChatId>,
1756        star_count: i64,
1757        media: Vec<serde_json::Value>,
1758    ) -> SendPaidMediaBuilder<'_> {
1759        SendPaidMediaBuilder {
1760            bot: self,
1761            chat_id: chat_id.into(),
1762            star_count,
1763            media,
1764            caption: None,
1765            parse_mode: None,
1766            caption_entities: None,
1767            show_caption_above_media: None,
1768            disable_notification: None,
1769            protect_content: None,
1770            reply_parameters: None,
1771            reply_markup: None,
1772            business_connection_id: None,
1773            payload: None,
1774            allow_paid_broadcast: None,
1775            direct_messages_topic_id: None,
1776            suggested_post_parameters: None,
1777            message_thread_id: None,
1778        }
1779    }
1780
1781    // -- Core Bot methods -------------------------------------------------
1782
1783    /// Build a `getMe` request.
1784    pub fn get_me(&self) -> GetMeBuilder<'_> {
1785        GetMeBuilder { bot: self }
1786    }
1787
1788    /// Build a `logOut` request.
1789    pub fn log_out(&self) -> LogOutBuilder<'_> {
1790        LogOutBuilder { bot: self }
1791    }
1792
1793    /// Build a `close` request.
1794    pub fn close(&self) -> CloseBuilder<'_> {
1795        CloseBuilder { bot: self }
1796    }
1797
1798    /// Build a `getUpdates` request.
1799    pub fn get_updates(&self) -> GetUpdatesBuilder<'_> {
1800        GetUpdatesBuilder {
1801            bot: self,
1802            offset: None,
1803            limit: None,
1804            timeout: None,
1805            allowed_updates: None,
1806        }
1807    }
1808
1809    /// Build a `getWebhookInfo` request.
1810    pub fn get_webhook_info(&self) -> GetWebhookInfoBuilder<'_> {
1811        GetWebhookInfoBuilder { bot: self }
1812    }
1813
1814    /// Build a `downloadFile` request.
1815    pub fn download_file(&self, file_path: impl Into<String>) -> DownloadFileBuilder<'_> {
1816        DownloadFileBuilder {
1817            bot: self,
1818            file_path: file_path.into(),
1819        }
1820    }
1821
1822    // -- Other content (send_checklist) -----------------------------------
1823
1824    /// Build a `sendChecklist` request.
1825    pub fn send_checklist(
1826        &self,
1827        business_connection_id: impl Into<String>,
1828        chat_id: i64,
1829        checklist: input_checklist::InputChecklist,
1830    ) -> SendChecklistBuilder<'_> {
1831        SendChecklistBuilder {
1832            bot: self,
1833            business_connection_id: business_connection_id.into(),
1834            chat_id,
1835            checklist,
1836            disable_notification: None,
1837            protect_content: None,
1838            message_effect_id: None,
1839            reply_parameters: None,
1840            reply_markup: None,
1841        }
1842    }
1843
1844    // -- Passport ---------------------------------------------------------
1845
1846    /// Build a `setPassportDataErrors` request.
1847    pub fn set_passport_data_errors(
1848        &self,
1849        user_id: i64,
1850        errors: Vec<serde_json::Value>,
1851    ) -> SetPassportDataErrorsBuilder<'_> {
1852        SetPassportDataErrorsBuilder {
1853            bot: self,
1854            user_id,
1855            errors,
1856        }
1857    }
1858
1859    // -- Reactions ---------------------------------------------------------
1860
1861    /// Build a `setMessageReaction` request.
1862    pub fn set_message_reaction(
1863        &self,
1864        chat_id: impl Into<ChatId>,
1865        message_id: i64,
1866    ) -> SetMessageReactionBuilder<'_> {
1867        SetMessageReactionBuilder {
1868            bot: self,
1869            chat_id: chat_id.into(),
1870            message_id,
1871            reaction: None,
1872            is_big: None,
1873        }
1874    }
1875
1876    /// Build a `getUserChatBoosts` request.
1877    pub fn get_user_chat_boosts(
1878        &self,
1879        chat_id: impl Into<ChatId>,
1880        user_id: i64,
1881    ) -> GetUserChatBoostsBuilder<'_> {
1882        GetUserChatBoostsBuilder {
1883            bot: self,
1884            chat_id: chat_id.into(),
1885            user_id,
1886        }
1887    }
1888
1889    // -- Stories ----------------------------------------------------------
1890
1891    /// Build a `postStory` request.
1892    pub fn post_story(
1893        &self,
1894        business_connection_id: impl Into<String>,
1895        content: serde_json::Value,
1896        active_period: i64,
1897    ) -> PostStoryBuilder<'_> {
1898        PostStoryBuilder {
1899            bot: self,
1900            business_connection_id: business_connection_id.into(),
1901            content,
1902            active_period,
1903            caption: None,
1904            parse_mode: None,
1905            caption_entities: None,
1906            areas: None,
1907            post_to_chat_page: None,
1908            protect_content: None,
1909        }
1910    }
1911
1912    /// Build an `editStory` request.
1913    pub fn edit_story(
1914        &self,
1915        business_connection_id: impl Into<String>,
1916        story_id: i64,
1917        content: serde_json::Value,
1918    ) -> EditStoryBuilder<'_> {
1919        EditStoryBuilder {
1920            bot: self,
1921            business_connection_id: business_connection_id.into(),
1922            story_id,
1923            content,
1924            caption: None,
1925            parse_mode: None,
1926            caption_entities: None,
1927            areas: None,
1928        }
1929    }
1930
1931    /// Build a `deleteStory` request.
1932    pub fn delete_story(
1933        &self,
1934        business_connection_id: impl Into<String>,
1935        story_id: i64,
1936    ) -> DeleteStoryBuilder<'_> {
1937        DeleteStoryBuilder {
1938            bot: self,
1939            business_connection_id: business_connection_id.into(),
1940            story_id,
1941        }
1942    }
1943
1944    /// Build a `repostStory` request.
1945    pub fn repost_story(
1946        &self,
1947        business_connection_id: impl Into<String>,
1948        from_chat_id: i64,
1949        from_story_id: i64,
1950        active_period: i64,
1951    ) -> RepostStoryBuilder<'_> {
1952        RepostStoryBuilder {
1953            bot: self,
1954            business_connection_id: business_connection_id.into(),
1955            from_chat_id,
1956            from_story_id,
1957            active_period,
1958            post_to_chat_page: None,
1959            protect_content: None,
1960        }
1961    }
1962
1963    // -- Suggested posts --------------------------------------------------
1964
1965    /// Build an `approveSuggestedPost` request.
1966    pub fn approve_suggested_post(
1967        &self,
1968        chat_id: i64,
1969        message_id: i64,
1970    ) -> ApproveSuggestedPostBuilder<'_> {
1971        ApproveSuggestedPostBuilder {
1972            bot: self,
1973            chat_id,
1974            message_id,
1975            send_date: None,
1976        }
1977    }
1978
1979    /// Build a `declineSuggestedPost` request.
1980    pub fn decline_suggested_post(
1981        &self,
1982        chat_id: i64,
1983        message_id: i64,
1984    ) -> DeclineSuggestedPostBuilder<'_> {
1985        DeclineSuggestedPostBuilder {
1986            bot: self,
1987            chat_id,
1988            message_id,
1989            comment: None,
1990        }
1991    }
1992
1993    // -- User profile -----------------------------------------------------
1994
1995    /// Build a `getUserProfilePhotos` request.
1996    pub fn get_user_profile_photos(&self, user_id: i64) -> GetUserProfilePhotosBuilder<'_> {
1997        GetUserProfilePhotosBuilder {
1998            bot: self,
1999            user_id,
2000            offset: None,
2001            limit: None,
2002        }
2003    }
2004
2005    /// Build a `getUserProfileAudios` request.
2006    pub fn get_user_profile_audios(&self, user_id: i64) -> GetUserProfileAudiosBuilder<'_> {
2007        GetUserProfileAudiosBuilder {
2008            bot: self,
2009            user_id,
2010            offset: None,
2011            limit: None,
2012        }
2013    }
2014
2015    /// Build a `setUserEmojiStatus` request.
2016    pub fn set_user_emoji_status(&self, user_id: i64) -> SetUserEmojiStatusBuilder<'_> {
2017        SetUserEmojiStatusBuilder {
2018            bot: self,
2019            user_id,
2020            emoji_status_custom_emoji_id: None,
2021            emoji_status_expiration_date: None,
2022        }
2023    }
2024
2025    /// Build a `setMyProfilePhoto` request.
2026    pub fn set_my_profile_photo(&self, photo: serde_json::Value) -> SetMyProfilePhotoBuilder<'_> {
2027        SetMyProfilePhotoBuilder { bot: self, photo }
2028    }
2029
2030    /// Build a `removeMyProfilePhoto` request.
2031    pub fn remove_my_profile_photo(&self) -> RemoveMyProfilePhotoBuilder<'_> {
2032        RemoveMyProfilePhotoBuilder { bot: self }
2033    }
2034
2035    // -- Verification -----------------------------------------------------
2036
2037    /// Build a `verifyChat` request.
2038    pub fn verify_chat(&self, chat_id: impl Into<ChatId>) -> VerifyChatBuilder<'_> {
2039        VerifyChatBuilder {
2040            bot: self,
2041            chat_id: chat_id.into(),
2042            custom_description: None,
2043        }
2044    }
2045
2046    /// Build a `verifyUser` request.
2047    pub fn verify_user(&self, user_id: i64) -> VerifyUserBuilder<'_> {
2048        VerifyUserBuilder {
2049            bot: self,
2050            user_id,
2051            custom_description: None,
2052        }
2053    }
2054
2055    /// Build a `removeChatVerification` request.
2056    pub fn remove_chat_verification(
2057        &self,
2058        chat_id: impl Into<ChatId>,
2059    ) -> RemoveChatVerificationBuilder<'_> {
2060        RemoveChatVerificationBuilder {
2061            bot: self,
2062            chat_id: chat_id.into(),
2063        }
2064    }
2065
2066    /// Build a `removeUserVerification` request.
2067    pub fn remove_user_verification(&self, user_id: i64) -> RemoveUserVerificationBuilder<'_> {
2068        RemoveUserVerificationBuilder { bot: self, user_id }
2069    }
2070}