Skip to main content

rust_tg_bot_raw/
bot_builders.rs

1//! Builder pattern for Telegram Bot API methods.
2//!
3//! Instead of passing a long list of optional parameters, builders let callers
4//! set only the parameters they care about:
5//!
6//! ```ignore
7//! bot.send_message(chat_id, "Hello!")
8//!     .parse_mode(ParseMode::Html)
9//!     .disable_notification(true)
10//!     .await?;
11//! ```
12//!
13//! Every builder follows the same pattern:
14//! 1. Created via the corresponding `Bot` factory method with only required parameters.
15//! 2. Chained setter calls for optional parameters.
16//! 3. `.await?` (or `.send().await?`) to execute the request.
17
18#![allow(clippy::too_many_arguments)]
19
20use crate::bot::{Bot, ChatId, MessageOrBool};
21use crate::error::Result;
22use crate::request::request_parameter::{InputFileRef, RequestParameter};
23use crate::types::{
24    chat_full_info, chat_invite_link, chat_member, chat_permissions, files, inline,
25    link_preview_options, message, message_entity, message_id, prepared_keyboard_button, reply,
26    suggested_post,
27};
28use serde::Serialize;
29
30macro_rules! impl_into_future {
31    ($builder:ident, $output:ty) => {
32        impl<'a> std::future::IntoFuture for $builder<'a> {
33            type Output = Result<$output>;
34            type IntoFuture =
35                std::pin::Pin<Box<dyn std::future::Future<Output = Self::Output> + Send + 'a>>;
36            fn into_future(self) -> Self::IntoFuture {
37                Box::pin(self.send())
38            }
39        }
40    };
41}
42
43// ---------------------------------------------------------------------------
44// Private helpers (duplicated from bot.rs since those are private)
45// ---------------------------------------------------------------------------
46
47fn push_opt<T: Serialize>(
48    params: &mut Vec<RequestParameter>,
49    name: &'static str,
50    val: &Option<T>,
51) -> std::result::Result<(), serde_json::Error> {
52    if let Some(v) = val {
53        params.push(RequestParameter::new(name, serde_json::to_value(v)?));
54    }
55    Ok(())
56}
57
58fn push_opt_str(params: &mut Vec<RequestParameter>, name: &'static str, val: &Option<String>) {
59    if let Some(v) = val {
60        params.push(RequestParameter::new(
61            name,
62            serde_json::Value::String(v.clone()),
63        ));
64    }
65}
66
67fn push_opt_file(
68    params: &mut Vec<RequestParameter>,
69    name: &'static str,
70    val: Option<files::input_file::InputFile>,
71) {
72    if let Some(f) = val {
73        params.push(input_file_param(name, f));
74    }
75}
76
77fn input_file_param(name: &'static str, file: files::input_file::InputFile) -> RequestParameter {
78    match file {
79        files::input_file::InputFile::FileId(id) => {
80            RequestParameter::new(name, serde_json::Value::String(id))
81        }
82        files::input_file::InputFile::Url(url) => {
83            RequestParameter::new(name, serde_json::Value::String(url))
84        }
85        files::input_file::InputFile::Bytes { filename, data } => {
86            let file_ref = InputFileRef {
87                attach_name: None,
88                bytes: data,
89                mime_type: None,
90                file_name: Some(filename),
91            };
92            RequestParameter::file_only(name, file_ref)
93        }
94        files::input_file::InputFile::Path(path) => {
95            let filename = path
96                .file_name()
97                .unwrap_or_default()
98                .to_string_lossy()
99                .to_string();
100            let path_str = path.to_string_lossy().to_string();
101            let file_ref = InputFileRef {
102                attach_name: None,
103                bytes: Vec::new(),
104                mime_type: None,
105                file_name: Some(filename),
106            };
107            RequestParameter {
108                name: std::borrow::Cow::Borrowed(name),
109                value: Some(serde_json::Value::String(format!(
110                    "__filepath__:{path_str}"
111                ))),
112                input_files: Some(vec![file_ref]),
113            }
114        }
115    }
116}
117
118// =========================================================================
119// SendMessageBuilder
120// =========================================================================
121
122/// Builder for the [`sendMessage`] API method.
123#[derive(Serialize)]
124pub struct SendMessageBuilder<'a> {
125    #[serde(skip)]
126    bot: &'a Bot,
127    chat_id: ChatId,
128    text: String,
129    #[serde(skip_serializing_if = "Option::is_none")]
130    parse_mode: Option<String>,
131    #[serde(skip_serializing_if = "Option::is_none")]
132    entities: Option<Vec<message_entity::MessageEntity>>,
133    #[serde(skip_serializing_if = "Option::is_none")]
134    link_preview_options: Option<link_preview_options::LinkPreviewOptions>,
135    #[serde(skip_serializing_if = "Option::is_none")]
136    disable_notification: Option<bool>,
137    #[serde(skip_serializing_if = "Option::is_none")]
138    protect_content: Option<bool>,
139    #[serde(skip_serializing_if = "Option::is_none")]
140    reply_parameters: Option<reply::ReplyParameters>,
141    #[serde(skip_serializing_if = "Option::is_none")]
142    reply_markup: Option<serde_json::Value>,
143    #[serde(skip_serializing_if = "Option::is_none")]
144    message_thread_id: Option<i64>,
145    #[serde(skip_serializing_if = "Option::is_none")]
146    business_connection_id: Option<String>,
147    #[serde(skip_serializing_if = "Option::is_none")]
148    message_effect_id: Option<String>,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    allow_paid_broadcast: Option<bool>,
151    #[serde(skip_serializing_if = "Option::is_none")]
152    direct_messages_topic_id: Option<i64>,
153    #[serde(skip_serializing_if = "Option::is_none")]
154    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
155}
156
157impl<'a> SendMessageBuilder<'a> {
158    /// Sets the `parse_mode` parameter.
159    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
160        self.parse_mode = Some(val.into());
161        self
162    }
163    /// Sets the `entities` parameter.
164    pub fn entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
165        self.entities = Some(val);
166        self
167    }
168    /// Sets the `link_preview_options` parameter.
169    pub fn link_preview_options(mut self, val: link_preview_options::LinkPreviewOptions) -> Self {
170        self.link_preview_options = Some(val);
171        self
172    }
173    /// Sets the `disable_notification` parameter.
174    pub fn disable_notification(mut self, val: bool) -> Self {
175        self.disable_notification = Some(val);
176        self
177    }
178    /// Sets the `protect_content` parameter.
179    pub fn protect_content(mut self, val: bool) -> Self {
180        self.protect_content = Some(val);
181        self
182    }
183    /// Sets the `reply_parameters` parameter.
184    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
185        self.reply_parameters = Some(val);
186        self
187    }
188    /// Sets the `reply_markup` parameter.
189    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
190        self.reply_markup = Some(val);
191        self
192    }
193    /// Sets the `message_thread_id` parameter.
194    pub fn message_thread_id(mut self, val: i64) -> Self {
195        self.message_thread_id = Some(val);
196        self
197    }
198    /// Sets the `business_connection_id` parameter.
199    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
200        self.business_connection_id = Some(val.into());
201        self
202    }
203    /// Sets the `message_effect_id` parameter.
204    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
205        self.message_effect_id = Some(val.into());
206        self
207    }
208    /// Sets the `allow_paid_broadcast` parameter.
209    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
210        self.allow_paid_broadcast = Some(val);
211        self
212    }
213    /// Sets the `direct_messages_topic_id` parameter.
214    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
215        self.direct_messages_topic_id = Some(val);
216        self
217    }
218    /// Sets the `suggested_post_parameters` parameter.
219    pub fn suggested_post_parameters(
220        mut self,
221        val: suggested_post::SuggestedPostParameters,
222    ) -> Self {
223        self.suggested_post_parameters = Some(val);
224        self
225    }
226
227    /// Sends the request to the Telegram Bot API.
228    pub async fn send(self) -> Result<message::Message> {
229        let payload = serde_json::to_vec(&self)?;
230        self.bot.do_post_json("sendMessage", &payload).await
231    }
232}
233
234impl_into_future!(SendMessageBuilder, message::Message);
235
236// =========================================================================
237// SendPhotoBuilder
238// =========================================================================
239
240/// Builder for the [`sendPhoto`] API method.
241pub struct SendPhotoBuilder<'a> {
242    bot: &'a Bot,
243    chat_id: ChatId,
244    photo: files::input_file::InputFile,
245    caption: Option<String>,
246    parse_mode: Option<String>,
247    caption_entities: Option<Vec<message_entity::MessageEntity>>,
248    disable_notification: Option<bool>,
249    protect_content: Option<bool>,
250    reply_parameters: Option<reply::ReplyParameters>,
251    reply_markup: Option<serde_json::Value>,
252    message_thread_id: Option<i64>,
253    has_spoiler: Option<bool>,
254    business_connection_id: Option<String>,
255    message_effect_id: Option<String>,
256    allow_paid_broadcast: Option<bool>,
257    show_caption_above_media: Option<bool>,
258    direct_messages_topic_id: Option<i64>,
259    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
260}
261
262impl<'a> SendPhotoBuilder<'a> {
263    /// Sets the `caption` parameter.
264    pub fn caption(mut self, val: impl Into<String>) -> Self {
265        self.caption = Some(val.into());
266        self
267    }
268    /// Sets the `parse_mode` parameter.
269    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
270        self.parse_mode = Some(val.into());
271        self
272    }
273    /// Sets the `caption_entities` parameter.
274    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
275        self.caption_entities = Some(val);
276        self
277    }
278    /// Sets the `disable_notification` parameter.
279    pub fn disable_notification(mut self, val: bool) -> Self {
280        self.disable_notification = Some(val);
281        self
282    }
283    /// Sets the `protect_content` parameter.
284    pub fn protect_content(mut self, val: bool) -> Self {
285        self.protect_content = Some(val);
286        self
287    }
288    /// Sets the `reply_parameters` parameter.
289    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
290        self.reply_parameters = Some(val);
291        self
292    }
293    /// Sets the `reply_markup` parameter.
294    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
295        self.reply_markup = Some(val);
296        self
297    }
298    /// Sets the `message_thread_id` parameter.
299    pub fn message_thread_id(mut self, val: i64) -> Self {
300        self.message_thread_id = Some(val);
301        self
302    }
303    /// Sets the `has_spoiler` parameter.
304    pub fn has_spoiler(mut self, val: bool) -> Self {
305        self.has_spoiler = Some(val);
306        self
307    }
308    /// Sets the `business_connection_id` parameter.
309    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
310        self.business_connection_id = Some(val.into());
311        self
312    }
313    /// Sets the `message_effect_id` parameter.
314    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
315        self.message_effect_id = Some(val.into());
316        self
317    }
318    /// Sets the `allow_paid_broadcast` parameter.
319    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
320        self.allow_paid_broadcast = Some(val);
321        self
322    }
323    /// Sets the `show_caption_above_media` parameter.
324    pub fn show_caption_above_media(mut self, val: bool) -> Self {
325        self.show_caption_above_media = Some(val);
326        self
327    }
328    /// Sets the `direct_messages_topic_id` parameter.
329    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
330        self.direct_messages_topic_id = Some(val);
331        self
332    }
333    /// Sets the `suggested_post_parameters` parameter.
334    pub fn suggested_post_parameters(
335        mut self,
336        val: suggested_post::SuggestedPostParameters,
337    ) -> Self {
338        self.suggested_post_parameters = Some(val);
339        self
340    }
341
342    /// Sends the request to the Telegram Bot API.
343    pub async fn send(self) -> Result<message::Message> {
344        let mut params = vec![
345            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
346            input_file_param("photo", self.photo),
347        ];
348        push_opt_str(&mut params, "caption", &self.caption);
349        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
350        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
351        push_opt(
352            &mut params,
353            "disable_notification",
354            &self.disable_notification,
355        )?;
356        push_opt(&mut params, "protect_content", &self.protect_content)?;
357        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
358        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
359        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
360        push_opt(&mut params, "has_spoiler", &self.has_spoiler)?;
361        push_opt_str(
362            &mut params,
363            "business_connection_id",
364            &self.business_connection_id,
365        );
366        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
367        push_opt(
368            &mut params,
369            "allow_paid_broadcast",
370            &self.allow_paid_broadcast,
371        )?;
372        push_opt(
373            &mut params,
374            "show_caption_above_media",
375            &self.show_caption_above_media,
376        )?;
377        push_opt(
378            &mut params,
379            "direct_messages_topic_id",
380            &self.direct_messages_topic_id,
381        )?;
382        push_opt(
383            &mut params,
384            "suggested_post_parameters",
385            &self.suggested_post_parameters,
386        )?;
387        self.bot.do_api_request("sendPhoto", params).await
388    }
389}
390
391impl_into_future!(SendPhotoBuilder, message::Message);
392
393// =========================================================================
394// SendDocumentBuilder
395// =========================================================================
396
397/// Builder for the [`sendDocument`] API method.
398pub struct SendDocumentBuilder<'a> {
399    bot: &'a Bot,
400    chat_id: ChatId,
401    document: files::input_file::InputFile,
402    caption: Option<String>,
403    parse_mode: Option<String>,
404    caption_entities: Option<Vec<message_entity::MessageEntity>>,
405    disable_content_type_detection: Option<bool>,
406    thumbnail: Option<files::input_file::InputFile>,
407    disable_notification: Option<bool>,
408    protect_content: Option<bool>,
409    reply_parameters: Option<reply::ReplyParameters>,
410    reply_markup: Option<serde_json::Value>,
411    message_thread_id: Option<i64>,
412    business_connection_id: Option<String>,
413    message_effect_id: Option<String>,
414    allow_paid_broadcast: Option<bool>,
415    direct_messages_topic_id: Option<i64>,
416    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
417}
418
419impl<'a> SendDocumentBuilder<'a> {
420    /// Sets the `caption` parameter.
421    pub fn caption(mut self, val: impl Into<String>) -> Self {
422        self.caption = Some(val.into());
423        self
424    }
425    /// Sets the `parse_mode` parameter.
426    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
427        self.parse_mode = Some(val.into());
428        self
429    }
430    /// Sets the `caption_entities` parameter.
431    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
432        self.caption_entities = Some(val);
433        self
434    }
435    /// Sets the `disable_content_type_detection` parameter.
436    pub fn disable_content_type_detection(mut self, val: bool) -> Self {
437        self.disable_content_type_detection = Some(val);
438        self
439    }
440    /// Sets the `thumbnail` parameter.
441    pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
442        self.thumbnail = Some(val);
443        self
444    }
445    /// Sets the `disable_notification` parameter.
446    pub fn disable_notification(mut self, val: bool) -> Self {
447        self.disable_notification = Some(val);
448        self
449    }
450    /// Sets the `protect_content` parameter.
451    pub fn protect_content(mut self, val: bool) -> Self {
452        self.protect_content = Some(val);
453        self
454    }
455    /// Sets the `reply_parameters` parameter.
456    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
457        self.reply_parameters = Some(val);
458        self
459    }
460    /// Sets the `reply_markup` parameter.
461    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
462        self.reply_markup = Some(val);
463        self
464    }
465    /// Sets the `message_thread_id` parameter.
466    pub fn message_thread_id(mut self, val: i64) -> Self {
467        self.message_thread_id = Some(val);
468        self
469    }
470    /// Sets the `business_connection_id` parameter.
471    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
472        self.business_connection_id = Some(val.into());
473        self
474    }
475    /// Sets the `message_effect_id` parameter.
476    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
477        self.message_effect_id = Some(val.into());
478        self
479    }
480    /// Sets the `allow_paid_broadcast` parameter.
481    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
482        self.allow_paid_broadcast = Some(val);
483        self
484    }
485    /// Sets the `direct_messages_topic_id` parameter.
486    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
487        self.direct_messages_topic_id = Some(val);
488        self
489    }
490    /// Sets the `suggested_post_parameters` parameter.
491    pub fn suggested_post_parameters(
492        mut self,
493        val: suggested_post::SuggestedPostParameters,
494    ) -> Self {
495        self.suggested_post_parameters = Some(val);
496        self
497    }
498
499    /// Sends the request to the Telegram Bot API.
500    pub async fn send(self) -> Result<message::Message> {
501        let mut params = vec![
502            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
503            input_file_param("document", self.document),
504        ];
505        push_opt_str(&mut params, "caption", &self.caption);
506        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
507        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
508        push_opt(
509            &mut params,
510            "disable_content_type_detection",
511            &self.disable_content_type_detection,
512        )?;
513        push_opt_file(&mut params, "thumbnail", self.thumbnail);
514        push_opt(
515            &mut params,
516            "disable_notification",
517            &self.disable_notification,
518        )?;
519        push_opt(&mut params, "protect_content", &self.protect_content)?;
520        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
521        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
522        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
523        push_opt_str(
524            &mut params,
525            "business_connection_id",
526            &self.business_connection_id,
527        );
528        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
529        push_opt(
530            &mut params,
531            "allow_paid_broadcast",
532            &self.allow_paid_broadcast,
533        )?;
534        push_opt(
535            &mut params,
536            "direct_messages_topic_id",
537            &self.direct_messages_topic_id,
538        )?;
539        push_opt(
540            &mut params,
541            "suggested_post_parameters",
542            &self.suggested_post_parameters,
543        )?;
544        self.bot.do_api_request("sendDocument", params).await
545    }
546}
547
548impl_into_future!(SendDocumentBuilder, message::Message);
549
550// =========================================================================
551// SendVideoBuilder
552// =========================================================================
553
554/// Builder for the [`sendVideo`] API method.
555pub struct SendVideoBuilder<'a> {
556    bot: &'a Bot,
557    chat_id: ChatId,
558    video: files::input_file::InputFile,
559    duration: Option<i64>,
560    width: Option<i64>,
561    height: Option<i64>,
562    caption: Option<String>,
563    parse_mode: Option<String>,
564    caption_entities: Option<Vec<message_entity::MessageEntity>>,
565    supports_streaming: Option<bool>,
566    thumbnail: Option<files::input_file::InputFile>,
567    has_spoiler: Option<bool>,
568    show_caption_above_media: Option<bool>,
569    cover: Option<files::input_file::InputFile>,
570    start_timestamp: Option<i64>,
571    disable_notification: Option<bool>,
572    protect_content: Option<bool>,
573    reply_parameters: Option<reply::ReplyParameters>,
574    reply_markup: Option<serde_json::Value>,
575    message_thread_id: Option<i64>,
576    business_connection_id: Option<String>,
577    message_effect_id: Option<String>,
578    allow_paid_broadcast: Option<bool>,
579    direct_messages_topic_id: Option<i64>,
580    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
581}
582
583impl<'a> SendVideoBuilder<'a> {
584    /// Sets the `duration` parameter.
585    pub fn duration(mut self, val: i64) -> Self {
586        self.duration = Some(val);
587        self
588    }
589    /// Sets the `width` parameter.
590    pub fn width(mut self, val: i64) -> Self {
591        self.width = Some(val);
592        self
593    }
594    /// Sets the `height` parameter.
595    pub fn height(mut self, val: i64) -> Self {
596        self.height = Some(val);
597        self
598    }
599    /// Sets the `caption` parameter.
600    pub fn caption(mut self, val: impl Into<String>) -> Self {
601        self.caption = Some(val.into());
602        self
603    }
604    /// Sets the `parse_mode` parameter.
605    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
606        self.parse_mode = Some(val.into());
607        self
608    }
609    /// Sets the `caption_entities` parameter.
610    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
611        self.caption_entities = Some(val);
612        self
613    }
614    /// Sets the `supports_streaming` parameter.
615    pub fn supports_streaming(mut self, val: bool) -> Self {
616        self.supports_streaming = Some(val);
617        self
618    }
619    /// Sets the `thumbnail` parameter.
620    pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
621        self.thumbnail = Some(val);
622        self
623    }
624    /// Sets the `has_spoiler` parameter.
625    pub fn has_spoiler(mut self, val: bool) -> Self {
626        self.has_spoiler = Some(val);
627        self
628    }
629    /// Sets the `show_caption_above_media` parameter.
630    pub fn show_caption_above_media(mut self, val: bool) -> Self {
631        self.show_caption_above_media = Some(val);
632        self
633    }
634    /// Sets the `cover` parameter.
635    pub fn cover(mut self, val: files::input_file::InputFile) -> Self {
636        self.cover = Some(val);
637        self
638    }
639    /// Sets the `start_timestamp` parameter.
640    pub fn start_timestamp(mut self, val: i64) -> Self {
641        self.start_timestamp = Some(val);
642        self
643    }
644    /// Sets the `disable_notification` parameter.
645    pub fn disable_notification(mut self, val: bool) -> Self {
646        self.disable_notification = Some(val);
647        self
648    }
649    /// Sets the `protect_content` parameter.
650    pub fn protect_content(mut self, val: bool) -> Self {
651        self.protect_content = Some(val);
652        self
653    }
654    /// Sets the `reply_parameters` parameter.
655    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
656        self.reply_parameters = Some(val);
657        self
658    }
659    /// Sets the `reply_markup` parameter.
660    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
661        self.reply_markup = Some(val);
662        self
663    }
664    /// Sets the `message_thread_id` parameter.
665    pub fn message_thread_id(mut self, val: i64) -> Self {
666        self.message_thread_id = Some(val);
667        self
668    }
669    /// Sets the `business_connection_id` parameter.
670    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
671        self.business_connection_id = Some(val.into());
672        self
673    }
674    /// Sets the `message_effect_id` parameter.
675    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
676        self.message_effect_id = Some(val.into());
677        self
678    }
679    /// Sets the `allow_paid_broadcast` parameter.
680    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
681        self.allow_paid_broadcast = Some(val);
682        self
683    }
684    /// Sets the `direct_messages_topic_id` parameter.
685    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
686        self.direct_messages_topic_id = Some(val);
687        self
688    }
689    /// Sets the `suggested_post_parameters` parameter.
690    pub fn suggested_post_parameters(
691        mut self,
692        val: suggested_post::SuggestedPostParameters,
693    ) -> Self {
694        self.suggested_post_parameters = Some(val);
695        self
696    }
697
698    /// Sends the request to the Telegram Bot API.
699    pub async fn send(self) -> Result<message::Message> {
700        let mut params = vec![
701            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
702            input_file_param("video", self.video),
703        ];
704        push_opt(&mut params, "duration", &self.duration)?;
705        push_opt(&mut params, "width", &self.width)?;
706        push_opt(&mut params, "height", &self.height)?;
707        push_opt_str(&mut params, "caption", &self.caption);
708        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
709        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
710        push_opt(&mut params, "supports_streaming", &self.supports_streaming)?;
711        push_opt_file(&mut params, "thumbnail", self.thumbnail);
712        push_opt(&mut params, "has_spoiler", &self.has_spoiler)?;
713        push_opt(
714            &mut params,
715            "show_caption_above_media",
716            &self.show_caption_above_media,
717        )?;
718        push_opt_file(&mut params, "cover", self.cover);
719        push_opt(&mut params, "start_timestamp", &self.start_timestamp)?;
720        push_opt(
721            &mut params,
722            "disable_notification",
723            &self.disable_notification,
724        )?;
725        push_opt(&mut params, "protect_content", &self.protect_content)?;
726        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
727        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
728        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
729        push_opt_str(
730            &mut params,
731            "business_connection_id",
732            &self.business_connection_id,
733        );
734        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
735        push_opt(
736            &mut params,
737            "allow_paid_broadcast",
738            &self.allow_paid_broadcast,
739        )?;
740        push_opt(
741            &mut params,
742            "direct_messages_topic_id",
743            &self.direct_messages_topic_id,
744        )?;
745        push_opt(
746            &mut params,
747            "suggested_post_parameters",
748            &self.suggested_post_parameters,
749        )?;
750        self.bot.do_api_request("sendVideo", params).await
751    }
752}
753
754impl_into_future!(SendVideoBuilder, message::Message);
755
756// =========================================================================
757// SendAudioBuilder
758// =========================================================================
759
760/// Builder for the [`sendAudio`] API method.
761pub struct SendAudioBuilder<'a> {
762    bot: &'a Bot,
763    chat_id: ChatId,
764    audio: files::input_file::InputFile,
765    caption: Option<String>,
766    parse_mode: Option<String>,
767    caption_entities: Option<Vec<message_entity::MessageEntity>>,
768    duration: Option<i64>,
769    performer: Option<String>,
770    title: Option<String>,
771    thumbnail: Option<files::input_file::InputFile>,
772    disable_notification: Option<bool>,
773    protect_content: Option<bool>,
774    reply_parameters: Option<reply::ReplyParameters>,
775    reply_markup: Option<serde_json::Value>,
776    message_thread_id: Option<i64>,
777    business_connection_id: Option<String>,
778    message_effect_id: Option<String>,
779    allow_paid_broadcast: Option<bool>,
780    direct_messages_topic_id: Option<i64>,
781    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
782}
783
784impl<'a> SendAudioBuilder<'a> {
785    /// Sets the `caption` parameter.
786    pub fn caption(mut self, val: impl Into<String>) -> Self {
787        self.caption = Some(val.into());
788        self
789    }
790    /// Sets the `parse_mode` parameter.
791    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
792        self.parse_mode = Some(val.into());
793        self
794    }
795    /// Sets the `caption_entities` parameter.
796    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
797        self.caption_entities = Some(val);
798        self
799    }
800    /// Sets the `duration` parameter.
801    pub fn duration(mut self, val: i64) -> Self {
802        self.duration = Some(val);
803        self
804    }
805    /// Sets the `performer` parameter.
806    pub fn performer(mut self, val: impl Into<String>) -> Self {
807        self.performer = Some(val.into());
808        self
809    }
810    /// Sets the `title` parameter.
811    pub fn title(mut self, val: impl Into<String>) -> Self {
812        self.title = Some(val.into());
813        self
814    }
815    /// Sets the `thumbnail` parameter.
816    pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
817        self.thumbnail = Some(val);
818        self
819    }
820    /// Sets the `disable_notification` parameter.
821    pub fn disable_notification(mut self, val: bool) -> Self {
822        self.disable_notification = Some(val);
823        self
824    }
825    /// Sets the `protect_content` parameter.
826    pub fn protect_content(mut self, val: bool) -> Self {
827        self.protect_content = Some(val);
828        self
829    }
830    /// Sets the `reply_parameters` parameter.
831    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
832        self.reply_parameters = Some(val);
833        self
834    }
835    /// Sets the `reply_markup` parameter.
836    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
837        self.reply_markup = Some(val);
838        self
839    }
840    /// Sets the `message_thread_id` parameter.
841    pub fn message_thread_id(mut self, val: i64) -> Self {
842        self.message_thread_id = Some(val);
843        self
844    }
845    /// Sets the `business_connection_id` parameter.
846    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
847        self.business_connection_id = Some(val.into());
848        self
849    }
850    /// Sets the `message_effect_id` parameter.
851    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
852        self.message_effect_id = Some(val.into());
853        self
854    }
855    /// Sets the `allow_paid_broadcast` parameter.
856    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
857        self.allow_paid_broadcast = Some(val);
858        self
859    }
860    /// Sets the `direct_messages_topic_id` parameter.
861    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
862        self.direct_messages_topic_id = Some(val);
863        self
864    }
865    /// Sets the `suggested_post_parameters` parameter.
866    pub fn suggested_post_parameters(
867        mut self,
868        val: suggested_post::SuggestedPostParameters,
869    ) -> Self {
870        self.suggested_post_parameters = Some(val);
871        self
872    }
873
874    /// Sends the request to the Telegram Bot API.
875    pub async fn send(self) -> Result<message::Message> {
876        let mut params = vec![
877            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
878            input_file_param("audio", self.audio),
879        ];
880        push_opt_str(&mut params, "caption", &self.caption);
881        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
882        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
883        push_opt(&mut params, "duration", &self.duration)?;
884        push_opt_str(&mut params, "performer", &self.performer);
885        push_opt_str(&mut params, "title", &self.title);
886        push_opt_file(&mut params, "thumbnail", self.thumbnail);
887        push_opt(
888            &mut params,
889            "disable_notification",
890            &self.disable_notification,
891        )?;
892        push_opt(&mut params, "protect_content", &self.protect_content)?;
893        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
894        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
895        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
896        push_opt_str(
897            &mut params,
898            "business_connection_id",
899            &self.business_connection_id,
900        );
901        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
902        push_opt(
903            &mut params,
904            "allow_paid_broadcast",
905            &self.allow_paid_broadcast,
906        )?;
907        push_opt(
908            &mut params,
909            "direct_messages_topic_id",
910            &self.direct_messages_topic_id,
911        )?;
912        push_opt(
913            &mut params,
914            "suggested_post_parameters",
915            &self.suggested_post_parameters,
916        )?;
917        self.bot.do_api_request("sendAudio", params).await
918    }
919}
920
921impl_into_future!(SendAudioBuilder, message::Message);
922
923// =========================================================================
924// SendAnimationBuilder
925// =========================================================================
926
927/// Builder for the [`sendAnimation`] API method.
928pub struct SendAnimationBuilder<'a> {
929    bot: &'a Bot,
930    chat_id: ChatId,
931    animation: files::input_file::InputFile,
932    duration: Option<i64>,
933    width: Option<i64>,
934    height: Option<i64>,
935    caption: Option<String>,
936    parse_mode: Option<String>,
937    caption_entities: Option<Vec<message_entity::MessageEntity>>,
938    thumbnail: Option<files::input_file::InputFile>,
939    has_spoiler: Option<bool>,
940    show_caption_above_media: Option<bool>,
941    disable_notification: Option<bool>,
942    protect_content: Option<bool>,
943    reply_parameters: Option<reply::ReplyParameters>,
944    reply_markup: Option<serde_json::Value>,
945    message_thread_id: Option<i64>,
946    business_connection_id: Option<String>,
947    message_effect_id: Option<String>,
948    allow_paid_broadcast: Option<bool>,
949    direct_messages_topic_id: Option<i64>,
950    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
951}
952
953impl<'a> SendAnimationBuilder<'a> {
954    /// Sets the `duration` parameter.
955    pub fn duration(mut self, val: i64) -> Self {
956        self.duration = Some(val);
957        self
958    }
959    /// Sets the `width` parameter.
960    pub fn width(mut self, val: i64) -> Self {
961        self.width = Some(val);
962        self
963    }
964    /// Sets the `height` parameter.
965    pub fn height(mut self, val: i64) -> Self {
966        self.height = Some(val);
967        self
968    }
969    /// Sets the `caption` parameter.
970    pub fn caption(mut self, val: impl Into<String>) -> Self {
971        self.caption = Some(val.into());
972        self
973    }
974    /// Sets the `parse_mode` parameter.
975    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
976        self.parse_mode = Some(val.into());
977        self
978    }
979    /// Sets the `caption_entities` parameter.
980    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
981        self.caption_entities = Some(val);
982        self
983    }
984    /// Sets the `thumbnail` parameter.
985    pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
986        self.thumbnail = Some(val);
987        self
988    }
989    /// Sets the `has_spoiler` parameter.
990    pub fn has_spoiler(mut self, val: bool) -> Self {
991        self.has_spoiler = Some(val);
992        self
993    }
994    /// Sets the `show_caption_above_media` parameter.
995    pub fn show_caption_above_media(mut self, val: bool) -> Self {
996        self.show_caption_above_media = Some(val);
997        self
998    }
999    /// Sets the `disable_notification` parameter.
1000    pub fn disable_notification(mut self, val: bool) -> Self {
1001        self.disable_notification = Some(val);
1002        self
1003    }
1004    /// Sets the `protect_content` parameter.
1005    pub fn protect_content(mut self, val: bool) -> Self {
1006        self.protect_content = Some(val);
1007        self
1008    }
1009    /// Sets the `reply_parameters` parameter.
1010    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1011        self.reply_parameters = Some(val);
1012        self
1013    }
1014    /// Sets the `reply_markup` parameter.
1015    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1016        self.reply_markup = Some(val);
1017        self
1018    }
1019    /// Sets the `message_thread_id` parameter.
1020    pub fn message_thread_id(mut self, val: i64) -> Self {
1021        self.message_thread_id = Some(val);
1022        self
1023    }
1024    /// Sets the `business_connection_id` parameter.
1025    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1026        self.business_connection_id = Some(val.into());
1027        self
1028    }
1029    /// Sets the `message_effect_id` parameter.
1030    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1031        self.message_effect_id = Some(val.into());
1032        self
1033    }
1034    /// Sets the `allow_paid_broadcast` parameter.
1035    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1036        self.allow_paid_broadcast = Some(val);
1037        self
1038    }
1039    /// Sets the `direct_messages_topic_id` parameter.
1040    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1041        self.direct_messages_topic_id = Some(val);
1042        self
1043    }
1044    /// Sets the `suggested_post_parameters` parameter.
1045    pub fn suggested_post_parameters(
1046        mut self,
1047        val: suggested_post::SuggestedPostParameters,
1048    ) -> Self {
1049        self.suggested_post_parameters = Some(val);
1050        self
1051    }
1052
1053    /// Sends the request to the Telegram Bot API.
1054    pub async fn send(self) -> Result<message::Message> {
1055        let mut params = vec![
1056            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
1057            input_file_param("animation", self.animation),
1058        ];
1059        push_opt(&mut params, "duration", &self.duration)?;
1060        push_opt(&mut params, "width", &self.width)?;
1061        push_opt(&mut params, "height", &self.height)?;
1062        push_opt_str(&mut params, "caption", &self.caption);
1063        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
1064        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
1065        push_opt_file(&mut params, "thumbnail", self.thumbnail);
1066        push_opt(&mut params, "has_spoiler", &self.has_spoiler)?;
1067        push_opt(
1068            &mut params,
1069            "show_caption_above_media",
1070            &self.show_caption_above_media,
1071        )?;
1072        push_opt(
1073            &mut params,
1074            "disable_notification",
1075            &self.disable_notification,
1076        )?;
1077        push_opt(&mut params, "protect_content", &self.protect_content)?;
1078        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
1079        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
1080        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
1081        push_opt_str(
1082            &mut params,
1083            "business_connection_id",
1084            &self.business_connection_id,
1085        );
1086        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
1087        push_opt(
1088            &mut params,
1089            "allow_paid_broadcast",
1090            &self.allow_paid_broadcast,
1091        )?;
1092        push_opt(
1093            &mut params,
1094            "direct_messages_topic_id",
1095            &self.direct_messages_topic_id,
1096        )?;
1097        push_opt(
1098            &mut params,
1099            "suggested_post_parameters",
1100            &self.suggested_post_parameters,
1101        )?;
1102        self.bot.do_api_request("sendAnimation", params).await
1103    }
1104}
1105
1106impl_into_future!(SendAnimationBuilder, message::Message);
1107
1108// =========================================================================
1109// SendVoiceBuilder
1110// =========================================================================
1111
1112/// Builder for the [`sendVoice`] API method.
1113pub struct SendVoiceBuilder<'a> {
1114    bot: &'a Bot,
1115    chat_id: ChatId,
1116    voice: files::input_file::InputFile,
1117    caption: Option<String>,
1118    parse_mode: Option<String>,
1119    caption_entities: Option<Vec<message_entity::MessageEntity>>,
1120    duration: Option<i64>,
1121    disable_notification: Option<bool>,
1122    protect_content: Option<bool>,
1123    reply_parameters: Option<reply::ReplyParameters>,
1124    reply_markup: Option<serde_json::Value>,
1125    message_thread_id: Option<i64>,
1126    business_connection_id: Option<String>,
1127    message_effect_id: Option<String>,
1128    allow_paid_broadcast: Option<bool>,
1129    direct_messages_topic_id: Option<i64>,
1130    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1131}
1132
1133impl<'a> SendVoiceBuilder<'a> {
1134    /// Sets the `caption` parameter.
1135    pub fn caption(mut self, val: impl Into<String>) -> Self {
1136        self.caption = Some(val.into());
1137        self
1138    }
1139    /// Sets the `parse_mode` parameter.
1140    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
1141        self.parse_mode = Some(val.into());
1142        self
1143    }
1144    /// Sets the `caption_entities` parameter.
1145    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
1146        self.caption_entities = Some(val);
1147        self
1148    }
1149    /// Sets the `duration` parameter.
1150    pub fn duration(mut self, val: i64) -> Self {
1151        self.duration = Some(val);
1152        self
1153    }
1154    /// Sets the `disable_notification` parameter.
1155    pub fn disable_notification(mut self, val: bool) -> Self {
1156        self.disable_notification = Some(val);
1157        self
1158    }
1159    /// Sets the `protect_content` parameter.
1160    pub fn protect_content(mut self, val: bool) -> Self {
1161        self.protect_content = Some(val);
1162        self
1163    }
1164    /// Sets the `reply_parameters` parameter.
1165    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1166        self.reply_parameters = Some(val);
1167        self
1168    }
1169    /// Sets the `reply_markup` parameter.
1170    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1171        self.reply_markup = Some(val);
1172        self
1173    }
1174    /// Sets the `message_thread_id` parameter.
1175    pub fn message_thread_id(mut self, val: i64) -> Self {
1176        self.message_thread_id = Some(val);
1177        self
1178    }
1179    /// Sets the `business_connection_id` parameter.
1180    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1181        self.business_connection_id = Some(val.into());
1182        self
1183    }
1184    /// Sets the `message_effect_id` parameter.
1185    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1186        self.message_effect_id = Some(val.into());
1187        self
1188    }
1189    /// Sets the `allow_paid_broadcast` parameter.
1190    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1191        self.allow_paid_broadcast = Some(val);
1192        self
1193    }
1194    /// Sets the `direct_messages_topic_id` parameter.
1195    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1196        self.direct_messages_topic_id = Some(val);
1197        self
1198    }
1199    /// Sets the `suggested_post_parameters` parameter.
1200    pub fn suggested_post_parameters(
1201        mut self,
1202        val: suggested_post::SuggestedPostParameters,
1203    ) -> Self {
1204        self.suggested_post_parameters = Some(val);
1205        self
1206    }
1207
1208    /// Sends the request to the Telegram Bot API.
1209    pub async fn send(self) -> Result<message::Message> {
1210        let mut params = vec![
1211            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
1212            input_file_param("voice", self.voice),
1213        ];
1214        push_opt_str(&mut params, "caption", &self.caption);
1215        push_opt_str(&mut params, "parse_mode", &self.parse_mode);
1216        push_opt(&mut params, "caption_entities", &self.caption_entities)?;
1217        push_opt(&mut params, "duration", &self.duration)?;
1218        push_opt(
1219            &mut params,
1220            "disable_notification",
1221            &self.disable_notification,
1222        )?;
1223        push_opt(&mut params, "protect_content", &self.protect_content)?;
1224        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
1225        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
1226        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
1227        push_opt_str(
1228            &mut params,
1229            "business_connection_id",
1230            &self.business_connection_id,
1231        );
1232        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
1233        push_opt(
1234            &mut params,
1235            "allow_paid_broadcast",
1236            &self.allow_paid_broadcast,
1237        )?;
1238        push_opt(
1239            &mut params,
1240            "direct_messages_topic_id",
1241            &self.direct_messages_topic_id,
1242        )?;
1243        push_opt(
1244            &mut params,
1245            "suggested_post_parameters",
1246            &self.suggested_post_parameters,
1247        )?;
1248        self.bot.do_api_request("sendVoice", params).await
1249    }
1250}
1251
1252impl_into_future!(SendVoiceBuilder, message::Message);
1253
1254// =========================================================================
1255// SendVideoNoteBuilder
1256// =========================================================================
1257
1258/// Builder for the [`sendVideoNote`] API method.
1259pub struct SendVideoNoteBuilder<'a> {
1260    bot: &'a Bot,
1261    chat_id: ChatId,
1262    video_note: files::input_file::InputFile,
1263    duration: Option<i64>,
1264    length: Option<i64>,
1265    thumbnail: Option<files::input_file::InputFile>,
1266    disable_notification: Option<bool>,
1267    protect_content: Option<bool>,
1268    reply_parameters: Option<reply::ReplyParameters>,
1269    reply_markup: Option<serde_json::Value>,
1270    message_thread_id: Option<i64>,
1271    business_connection_id: Option<String>,
1272    message_effect_id: Option<String>,
1273    allow_paid_broadcast: Option<bool>,
1274    direct_messages_topic_id: Option<i64>,
1275    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1276}
1277
1278impl<'a> SendVideoNoteBuilder<'a> {
1279    /// Sets the `duration` parameter.
1280    pub fn duration(mut self, val: i64) -> Self {
1281        self.duration = Some(val);
1282        self
1283    }
1284    /// Sets the `length` parameter.
1285    pub fn length(mut self, val: i64) -> Self {
1286        self.length = Some(val);
1287        self
1288    }
1289    /// Sets the `thumbnail` parameter.
1290    pub fn thumbnail(mut self, val: files::input_file::InputFile) -> Self {
1291        self.thumbnail = Some(val);
1292        self
1293    }
1294    /// Sets the `disable_notification` parameter.
1295    pub fn disable_notification(mut self, val: bool) -> Self {
1296        self.disable_notification = Some(val);
1297        self
1298    }
1299    /// Sets the `protect_content` parameter.
1300    pub fn protect_content(mut self, val: bool) -> Self {
1301        self.protect_content = Some(val);
1302        self
1303    }
1304    /// Sets the `reply_parameters` parameter.
1305    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1306        self.reply_parameters = Some(val);
1307        self
1308    }
1309    /// Sets the `reply_markup` parameter.
1310    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1311        self.reply_markup = Some(val);
1312        self
1313    }
1314    /// Sets the `message_thread_id` parameter.
1315    pub fn message_thread_id(mut self, val: i64) -> Self {
1316        self.message_thread_id = Some(val);
1317        self
1318    }
1319    /// Sets the `business_connection_id` parameter.
1320    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1321        self.business_connection_id = Some(val.into());
1322        self
1323    }
1324    /// Sets the `message_effect_id` parameter.
1325    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1326        self.message_effect_id = Some(val.into());
1327        self
1328    }
1329    /// Sets the `allow_paid_broadcast` parameter.
1330    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1331        self.allow_paid_broadcast = Some(val);
1332        self
1333    }
1334    /// Sets the `direct_messages_topic_id` parameter.
1335    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1336        self.direct_messages_topic_id = Some(val);
1337        self
1338    }
1339    /// Sets the `suggested_post_parameters` parameter.
1340    pub fn suggested_post_parameters(
1341        mut self,
1342        val: suggested_post::SuggestedPostParameters,
1343    ) -> Self {
1344        self.suggested_post_parameters = Some(val);
1345        self
1346    }
1347
1348    /// Sends the request to the Telegram Bot API.
1349    pub async fn send(self) -> Result<message::Message> {
1350        let mut params = vec![
1351            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
1352            input_file_param("video_note", self.video_note),
1353        ];
1354        push_opt(&mut params, "duration", &self.duration)?;
1355        push_opt(&mut params, "length", &self.length)?;
1356        push_opt_file(&mut params, "thumbnail", self.thumbnail);
1357        push_opt(
1358            &mut params,
1359            "disable_notification",
1360            &self.disable_notification,
1361        )?;
1362        push_opt(&mut params, "protect_content", &self.protect_content)?;
1363        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
1364        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
1365        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
1366        push_opt_str(
1367            &mut params,
1368            "business_connection_id",
1369            &self.business_connection_id,
1370        );
1371        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
1372        push_opt(
1373            &mut params,
1374            "allow_paid_broadcast",
1375            &self.allow_paid_broadcast,
1376        )?;
1377        push_opt(
1378            &mut params,
1379            "direct_messages_topic_id",
1380            &self.direct_messages_topic_id,
1381        )?;
1382        push_opt(
1383            &mut params,
1384            "suggested_post_parameters",
1385            &self.suggested_post_parameters,
1386        )?;
1387        self.bot.do_api_request("sendVideoNote", params).await
1388    }
1389}
1390
1391impl_into_future!(SendVideoNoteBuilder, message::Message);
1392
1393// =========================================================================
1394// SendLocationBuilder
1395// =========================================================================
1396
1397/// Builder for the [`sendLocation`] API method.
1398#[derive(Serialize)]
1399pub struct SendLocationBuilder<'a> {
1400    #[serde(skip)]
1401    bot: &'a Bot,
1402    chat_id: ChatId,
1403    latitude: f64,
1404    longitude: f64,
1405    #[serde(skip_serializing_if = "Option::is_none")]
1406    horizontal_accuracy: Option<f64>,
1407    #[serde(skip_serializing_if = "Option::is_none")]
1408    live_period: Option<i64>,
1409    #[serde(skip_serializing_if = "Option::is_none")]
1410    heading: Option<i64>,
1411    #[serde(skip_serializing_if = "Option::is_none")]
1412    proximity_alert_radius: Option<i64>,
1413    #[serde(skip_serializing_if = "Option::is_none")]
1414    disable_notification: Option<bool>,
1415    #[serde(skip_serializing_if = "Option::is_none")]
1416    protect_content: Option<bool>,
1417    #[serde(skip_serializing_if = "Option::is_none")]
1418    reply_parameters: Option<reply::ReplyParameters>,
1419    #[serde(skip_serializing_if = "Option::is_none")]
1420    reply_markup: Option<serde_json::Value>,
1421    #[serde(skip_serializing_if = "Option::is_none")]
1422    message_thread_id: Option<i64>,
1423    #[serde(skip_serializing_if = "Option::is_none")]
1424    business_connection_id: Option<String>,
1425    #[serde(skip_serializing_if = "Option::is_none")]
1426    message_effect_id: Option<String>,
1427    #[serde(skip_serializing_if = "Option::is_none")]
1428    allow_paid_broadcast: Option<bool>,
1429    #[serde(skip_serializing_if = "Option::is_none")]
1430    direct_messages_topic_id: Option<i64>,
1431    #[serde(skip_serializing_if = "Option::is_none")]
1432    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1433}
1434
1435impl<'a> SendLocationBuilder<'a> {
1436    /// Sets the `horizontal_accuracy` parameter.
1437    pub fn horizontal_accuracy(mut self, val: f64) -> Self {
1438        self.horizontal_accuracy = Some(val);
1439        self
1440    }
1441    /// Sets the `live_period` parameter.
1442    pub fn live_period(mut self, val: i64) -> Self {
1443        self.live_period = Some(val);
1444        self
1445    }
1446    /// Sets the `heading` parameter.
1447    pub fn heading(mut self, val: i64) -> Self {
1448        self.heading = Some(val);
1449        self
1450    }
1451    /// Sets the `proximity_alert_radius` parameter.
1452    pub fn proximity_alert_radius(mut self, val: i64) -> Self {
1453        self.proximity_alert_radius = Some(val);
1454        self
1455    }
1456    /// Sets the `disable_notification` parameter.
1457    pub fn disable_notification(mut self, val: bool) -> Self {
1458        self.disable_notification = Some(val);
1459        self
1460    }
1461    /// Sets the `protect_content` parameter.
1462    pub fn protect_content(mut self, val: bool) -> Self {
1463        self.protect_content = Some(val);
1464        self
1465    }
1466    /// Sets the `reply_parameters` parameter.
1467    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1468        self.reply_parameters = Some(val);
1469        self
1470    }
1471    /// Sets the `reply_markup` parameter.
1472    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1473        self.reply_markup = Some(val);
1474        self
1475    }
1476    /// Sets the `message_thread_id` parameter.
1477    pub fn message_thread_id(mut self, val: i64) -> Self {
1478        self.message_thread_id = Some(val);
1479        self
1480    }
1481    /// Sets the `business_connection_id` parameter.
1482    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1483        self.business_connection_id = Some(val.into());
1484        self
1485    }
1486    /// Sets the `message_effect_id` parameter.
1487    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1488        self.message_effect_id = Some(val.into());
1489        self
1490    }
1491    /// Sets the `allow_paid_broadcast` parameter.
1492    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1493        self.allow_paid_broadcast = Some(val);
1494        self
1495    }
1496    /// Sets the `direct_messages_topic_id` parameter.
1497    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1498        self.direct_messages_topic_id = Some(val);
1499        self
1500    }
1501    /// Sets the `suggested_post_parameters` parameter.
1502    pub fn suggested_post_parameters(
1503        mut self,
1504        val: suggested_post::SuggestedPostParameters,
1505    ) -> Self {
1506        self.suggested_post_parameters = Some(val);
1507        self
1508    }
1509
1510    /// Sends the request to the Telegram Bot API.
1511    pub async fn send(self) -> Result<message::Message> {
1512        let payload = serde_json::to_vec(&self)?;
1513        self.bot.do_post_json("sendLocation", &payload).await
1514    }
1515}
1516
1517impl_into_future!(SendLocationBuilder, message::Message);
1518
1519// =========================================================================
1520// SendVenueBuilder
1521// =========================================================================
1522
1523/// Builder for the [`sendVenue`] API method.
1524#[derive(Serialize)]
1525pub struct SendVenueBuilder<'a> {
1526    #[serde(skip)]
1527    bot: &'a Bot,
1528    chat_id: ChatId,
1529    latitude: f64,
1530    longitude: f64,
1531    title: String,
1532    address: String,
1533    #[serde(skip_serializing_if = "Option::is_none")]
1534    foursquare_id: Option<String>,
1535    #[serde(skip_serializing_if = "Option::is_none")]
1536    foursquare_type: Option<String>,
1537    #[serde(skip_serializing_if = "Option::is_none")]
1538    google_place_id: Option<String>,
1539    #[serde(skip_serializing_if = "Option::is_none")]
1540    google_place_type: Option<String>,
1541    #[serde(skip_serializing_if = "Option::is_none")]
1542    disable_notification: Option<bool>,
1543    #[serde(skip_serializing_if = "Option::is_none")]
1544    protect_content: Option<bool>,
1545    #[serde(skip_serializing_if = "Option::is_none")]
1546    reply_parameters: Option<reply::ReplyParameters>,
1547    #[serde(skip_serializing_if = "Option::is_none")]
1548    reply_markup: Option<serde_json::Value>,
1549    #[serde(skip_serializing_if = "Option::is_none")]
1550    message_thread_id: Option<i64>,
1551    #[serde(skip_serializing_if = "Option::is_none")]
1552    business_connection_id: Option<String>,
1553    #[serde(skip_serializing_if = "Option::is_none")]
1554    message_effect_id: Option<String>,
1555    #[serde(skip_serializing_if = "Option::is_none")]
1556    allow_paid_broadcast: Option<bool>,
1557    #[serde(skip_serializing_if = "Option::is_none")]
1558    direct_messages_topic_id: Option<i64>,
1559    #[serde(skip_serializing_if = "Option::is_none")]
1560    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1561}
1562
1563impl<'a> SendVenueBuilder<'a> {
1564    /// Sets the `foursquare_id` parameter.
1565    pub fn foursquare_id(mut self, val: impl Into<String>) -> Self {
1566        self.foursquare_id = Some(val.into());
1567        self
1568    }
1569    /// Sets the `foursquare_type` parameter.
1570    pub fn foursquare_type(mut self, val: impl Into<String>) -> Self {
1571        self.foursquare_type = Some(val.into());
1572        self
1573    }
1574    /// Sets the `google_place_id` parameter.
1575    pub fn google_place_id(mut self, val: impl Into<String>) -> Self {
1576        self.google_place_id = Some(val.into());
1577        self
1578    }
1579    /// Sets the `google_place_type` parameter.
1580    pub fn google_place_type(mut self, val: impl Into<String>) -> Self {
1581        self.google_place_type = Some(val.into());
1582        self
1583    }
1584    /// Sets the `disable_notification` parameter.
1585    pub fn disable_notification(mut self, val: bool) -> Self {
1586        self.disable_notification = Some(val);
1587        self
1588    }
1589    /// Sets the `protect_content` parameter.
1590    pub fn protect_content(mut self, val: bool) -> Self {
1591        self.protect_content = Some(val);
1592        self
1593    }
1594    /// Sets the `reply_parameters` parameter.
1595    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1596        self.reply_parameters = Some(val);
1597        self
1598    }
1599    /// Sets the `reply_markup` parameter.
1600    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1601        self.reply_markup = Some(val);
1602        self
1603    }
1604    /// Sets the `message_thread_id` parameter.
1605    pub fn message_thread_id(mut self, val: i64) -> Self {
1606        self.message_thread_id = Some(val);
1607        self
1608    }
1609    /// Sets the `business_connection_id` parameter.
1610    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1611        self.business_connection_id = Some(val.into());
1612        self
1613    }
1614    /// Sets the `message_effect_id` parameter.
1615    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1616        self.message_effect_id = Some(val.into());
1617        self
1618    }
1619    /// Sets the `allow_paid_broadcast` parameter.
1620    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1621        self.allow_paid_broadcast = Some(val);
1622        self
1623    }
1624    /// Sets the `direct_messages_topic_id` parameter.
1625    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1626        self.direct_messages_topic_id = Some(val);
1627        self
1628    }
1629    /// Sets the `suggested_post_parameters` parameter.
1630    pub fn suggested_post_parameters(
1631        mut self,
1632        val: suggested_post::SuggestedPostParameters,
1633    ) -> Self {
1634        self.suggested_post_parameters = Some(val);
1635        self
1636    }
1637
1638    /// Sends the request to the Telegram Bot API.
1639    pub async fn send(self) -> Result<message::Message> {
1640        let payload = serde_json::to_vec(&self)?;
1641        self.bot.do_post_json("sendVenue", &payload).await
1642    }
1643}
1644
1645impl_into_future!(SendVenueBuilder, message::Message);
1646
1647// =========================================================================
1648// SendContactBuilder
1649// =========================================================================
1650
1651/// Builder for the [`sendContact`] API method.
1652#[derive(Serialize)]
1653pub struct SendContactBuilder<'a> {
1654    #[serde(skip)]
1655    bot: &'a Bot,
1656    chat_id: ChatId,
1657    phone_number: String,
1658    first_name: String,
1659    #[serde(skip_serializing_if = "Option::is_none")]
1660    last_name: Option<String>,
1661    #[serde(skip_serializing_if = "Option::is_none")]
1662    vcard: Option<String>,
1663    #[serde(skip_serializing_if = "Option::is_none")]
1664    disable_notification: Option<bool>,
1665    #[serde(skip_serializing_if = "Option::is_none")]
1666    protect_content: Option<bool>,
1667    #[serde(skip_serializing_if = "Option::is_none")]
1668    reply_parameters: Option<reply::ReplyParameters>,
1669    #[serde(skip_serializing_if = "Option::is_none")]
1670    reply_markup: Option<serde_json::Value>,
1671    #[serde(skip_serializing_if = "Option::is_none")]
1672    message_thread_id: Option<i64>,
1673    #[serde(skip_serializing_if = "Option::is_none")]
1674    business_connection_id: Option<String>,
1675    #[serde(skip_serializing_if = "Option::is_none")]
1676    message_effect_id: Option<String>,
1677    #[serde(skip_serializing_if = "Option::is_none")]
1678    allow_paid_broadcast: Option<bool>,
1679    #[serde(skip_serializing_if = "Option::is_none")]
1680    direct_messages_topic_id: Option<i64>,
1681    #[serde(skip_serializing_if = "Option::is_none")]
1682    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1683}
1684
1685impl<'a> SendContactBuilder<'a> {
1686    /// Sets the `last_name` parameter.
1687    pub fn last_name(mut self, val: impl Into<String>) -> Self {
1688        self.last_name = Some(val.into());
1689        self
1690    }
1691    /// Sets the `vcard` parameter.
1692    pub fn vcard(mut self, val: impl Into<String>) -> Self {
1693        self.vcard = Some(val.into());
1694        self
1695    }
1696    /// Sets the `disable_notification` parameter.
1697    pub fn disable_notification(mut self, val: bool) -> Self {
1698        self.disable_notification = Some(val);
1699        self
1700    }
1701    /// Sets the `protect_content` parameter.
1702    pub fn protect_content(mut self, val: bool) -> Self {
1703        self.protect_content = Some(val);
1704        self
1705    }
1706    /// Sets the `reply_parameters` parameter.
1707    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1708        self.reply_parameters = Some(val);
1709        self
1710    }
1711    /// Sets the `reply_markup` parameter.
1712    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1713        self.reply_markup = Some(val);
1714        self
1715    }
1716    /// Sets the `message_thread_id` parameter.
1717    pub fn message_thread_id(mut self, val: i64) -> Self {
1718        self.message_thread_id = Some(val);
1719        self
1720    }
1721    /// Sets the `business_connection_id` parameter.
1722    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1723        self.business_connection_id = Some(val.into());
1724        self
1725    }
1726    /// Sets the `message_effect_id` parameter.
1727    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1728        self.message_effect_id = Some(val.into());
1729        self
1730    }
1731    /// Sets the `allow_paid_broadcast` parameter.
1732    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1733        self.allow_paid_broadcast = Some(val);
1734        self
1735    }
1736    /// Sets the `direct_messages_topic_id` parameter.
1737    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1738        self.direct_messages_topic_id = Some(val);
1739        self
1740    }
1741    /// Sets the `suggested_post_parameters` parameter.
1742    pub fn suggested_post_parameters(
1743        mut self,
1744        val: suggested_post::SuggestedPostParameters,
1745    ) -> Self {
1746        self.suggested_post_parameters = Some(val);
1747        self
1748    }
1749
1750    /// Sends the request to the Telegram Bot API.
1751    pub async fn send(self) -> Result<message::Message> {
1752        let payload = serde_json::to_vec(&self)?;
1753        self.bot.do_post_json("sendContact", &payload).await
1754    }
1755}
1756
1757impl_into_future!(SendContactBuilder, message::Message);
1758
1759// =========================================================================
1760// SendPollBuilder
1761// =========================================================================
1762
1763/// Builder for the [`sendPoll`] API method.
1764#[derive(Serialize)]
1765pub struct SendPollBuilder<'a> {
1766    #[serde(skip)]
1767    bot: &'a Bot,
1768    chat_id: ChatId,
1769    question: String,
1770    options: Vec<serde_json::Value>,
1771    #[serde(skip_serializing_if = "Option::is_none")]
1772    is_anonymous: Option<bool>,
1773    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
1774    poll_type: Option<String>,
1775    #[serde(skip_serializing_if = "Option::is_none")]
1776    allows_multiple_answers: Option<bool>,
1777    #[serde(skip_serializing_if = "Option::is_none")]
1778    correct_option_id: Option<i64>,
1779    #[serde(skip_serializing_if = "Option::is_none")]
1780    explanation: Option<String>,
1781    #[serde(skip_serializing_if = "Option::is_none")]
1782    explanation_parse_mode: Option<String>,
1783    #[serde(skip_serializing_if = "Option::is_none")]
1784    explanation_entities: Option<Vec<message_entity::MessageEntity>>,
1785    #[serde(skip_serializing_if = "Option::is_none")]
1786    open_period: Option<i64>,
1787    #[serde(skip_serializing_if = "Option::is_none")]
1788    close_date: Option<i64>,
1789    #[serde(skip_serializing_if = "Option::is_none")]
1790    is_closed: Option<bool>,
1791    #[serde(skip_serializing_if = "Option::is_none")]
1792    disable_notification: Option<bool>,
1793    #[serde(skip_serializing_if = "Option::is_none")]
1794    protect_content: Option<bool>,
1795    #[serde(skip_serializing_if = "Option::is_none")]
1796    reply_parameters: Option<reply::ReplyParameters>,
1797    #[serde(skip_serializing_if = "Option::is_none")]
1798    reply_markup: Option<serde_json::Value>,
1799    #[serde(skip_serializing_if = "Option::is_none")]
1800    message_thread_id: Option<i64>,
1801    #[serde(skip_serializing_if = "Option::is_none")]
1802    business_connection_id: Option<String>,
1803    #[serde(skip_serializing_if = "Option::is_none")]
1804    question_parse_mode: Option<String>,
1805    #[serde(skip_serializing_if = "Option::is_none")]
1806    question_entities: Option<Vec<message_entity::MessageEntity>>,
1807    #[serde(skip_serializing_if = "Option::is_none")]
1808    message_effect_id: Option<String>,
1809    #[serde(skip_serializing_if = "Option::is_none")]
1810    allow_paid_broadcast: Option<bool>,
1811    #[serde(skip_serializing_if = "Option::is_none")]
1812    direct_messages_topic_id: Option<i64>,
1813    #[serde(skip_serializing_if = "Option::is_none")]
1814    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1815}
1816
1817impl<'a> SendPollBuilder<'a> {
1818    /// Sets the `is_anonymous` parameter.
1819    pub fn is_anonymous(mut self, val: bool) -> Self {
1820        self.is_anonymous = Some(val);
1821        self
1822    }
1823    /// Sets the `poll_type` parameter.
1824    pub fn poll_type(mut self, val: impl Into<String>) -> Self {
1825        self.poll_type = Some(val.into());
1826        self
1827    }
1828    /// Sets the `allows_multiple_answers` parameter.
1829    pub fn allows_multiple_answers(mut self, val: bool) -> Self {
1830        self.allows_multiple_answers = Some(val);
1831        self
1832    }
1833    /// Sets the `correct_option_id` parameter.
1834    pub fn correct_option_id(mut self, val: i64) -> Self {
1835        self.correct_option_id = Some(val);
1836        self
1837    }
1838    /// Sets the `explanation` parameter.
1839    pub fn explanation(mut self, val: impl Into<String>) -> Self {
1840        self.explanation = Some(val.into());
1841        self
1842    }
1843    /// Sets the `explanation_parse_mode` parameter.
1844    pub fn explanation_parse_mode(mut self, val: impl Into<String>) -> Self {
1845        self.explanation_parse_mode = Some(val.into());
1846        self
1847    }
1848    /// Sets the `explanation_entities` parameter.
1849    pub fn explanation_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
1850        self.explanation_entities = Some(val);
1851        self
1852    }
1853    /// Sets the `open_period` parameter.
1854    pub fn open_period(mut self, val: i64) -> Self {
1855        self.open_period = Some(val);
1856        self
1857    }
1858    /// Sets the `close_date` parameter.
1859    pub fn close_date(mut self, val: i64) -> Self {
1860        self.close_date = Some(val);
1861        self
1862    }
1863    /// Sets the `is_closed` parameter.
1864    pub fn is_closed(mut self, val: bool) -> Self {
1865        self.is_closed = Some(val);
1866        self
1867    }
1868    /// Sets the `disable_notification` parameter.
1869    pub fn disable_notification(mut self, val: bool) -> Self {
1870        self.disable_notification = Some(val);
1871        self
1872    }
1873    /// Sets the `protect_content` parameter.
1874    pub fn protect_content(mut self, val: bool) -> Self {
1875        self.protect_content = Some(val);
1876        self
1877    }
1878    /// Sets the `reply_parameters` parameter.
1879    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1880        self.reply_parameters = Some(val);
1881        self
1882    }
1883    /// Sets the `reply_markup` parameter.
1884    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1885        self.reply_markup = Some(val);
1886        self
1887    }
1888    /// Sets the `message_thread_id` parameter.
1889    pub fn message_thread_id(mut self, val: i64) -> Self {
1890        self.message_thread_id = Some(val);
1891        self
1892    }
1893    /// Sets the `business_connection_id` parameter.
1894    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
1895        self.business_connection_id = Some(val.into());
1896        self
1897    }
1898    /// Sets the `question_parse_mode` parameter.
1899    pub fn question_parse_mode(mut self, val: impl Into<String>) -> Self {
1900        self.question_parse_mode = Some(val.into());
1901        self
1902    }
1903    /// Sets the `question_entities` parameter.
1904    pub fn question_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
1905        self.question_entities = Some(val);
1906        self
1907    }
1908    /// Sets the `message_effect_id` parameter.
1909    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
1910        self.message_effect_id = Some(val.into());
1911        self
1912    }
1913    /// Sets the `allow_paid_broadcast` parameter.
1914    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
1915        self.allow_paid_broadcast = Some(val);
1916        self
1917    }
1918    /// Sets the `direct_messages_topic_id` parameter.
1919    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
1920        self.direct_messages_topic_id = Some(val);
1921        self
1922    }
1923    /// Sets the `suggested_post_parameters` parameter.
1924    pub fn suggested_post_parameters(
1925        mut self,
1926        val: suggested_post::SuggestedPostParameters,
1927    ) -> Self {
1928        self.suggested_post_parameters = Some(val);
1929        self
1930    }
1931
1932    /// Sends the request to the Telegram Bot API.
1933    pub async fn send(self) -> Result<message::Message> {
1934        let payload = serde_json::to_vec(&self)?;
1935        self.bot.do_post_json("sendPoll", &payload).await
1936    }
1937}
1938
1939impl_into_future!(SendPollBuilder, message::Message);
1940
1941// =========================================================================
1942// SendDiceBuilder
1943// =========================================================================
1944
1945/// Builder for the [`sendDice`] API method.
1946#[derive(Serialize)]
1947pub struct SendDiceBuilder<'a> {
1948    #[serde(skip)]
1949    bot: &'a Bot,
1950    chat_id: ChatId,
1951    #[serde(skip_serializing_if = "Option::is_none")]
1952    emoji: Option<String>,
1953    #[serde(skip_serializing_if = "Option::is_none")]
1954    disable_notification: Option<bool>,
1955    #[serde(skip_serializing_if = "Option::is_none")]
1956    protect_content: Option<bool>,
1957    #[serde(skip_serializing_if = "Option::is_none")]
1958    reply_parameters: Option<reply::ReplyParameters>,
1959    #[serde(skip_serializing_if = "Option::is_none")]
1960    reply_markup: Option<serde_json::Value>,
1961    #[serde(skip_serializing_if = "Option::is_none")]
1962    message_thread_id: Option<i64>,
1963    #[serde(skip_serializing_if = "Option::is_none")]
1964    business_connection_id: Option<String>,
1965    #[serde(skip_serializing_if = "Option::is_none")]
1966    message_effect_id: Option<String>,
1967    #[serde(skip_serializing_if = "Option::is_none")]
1968    allow_paid_broadcast: Option<bool>,
1969    #[serde(skip_serializing_if = "Option::is_none")]
1970    direct_messages_topic_id: Option<i64>,
1971    #[serde(skip_serializing_if = "Option::is_none")]
1972    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
1973}
1974
1975impl<'a> SendDiceBuilder<'a> {
1976    /// Sets the `emoji` parameter.
1977    pub fn emoji(mut self, val: impl Into<String>) -> Self {
1978        self.emoji = Some(val.into());
1979        self
1980    }
1981    /// Sets the `disable_notification` parameter.
1982    pub fn disable_notification(mut self, val: bool) -> Self {
1983        self.disable_notification = Some(val);
1984        self
1985    }
1986    /// Sets the `protect_content` parameter.
1987    pub fn protect_content(mut self, val: bool) -> Self {
1988        self.protect_content = Some(val);
1989        self
1990    }
1991    /// Sets the `reply_parameters` parameter.
1992    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
1993        self.reply_parameters = Some(val);
1994        self
1995    }
1996    /// Sets the `reply_markup` parameter.
1997    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
1998        self.reply_markup = Some(val);
1999        self
2000    }
2001    /// Sets the `message_thread_id` parameter.
2002    pub fn message_thread_id(mut self, val: i64) -> Self {
2003        self.message_thread_id = Some(val);
2004        self
2005    }
2006    /// Sets the `business_connection_id` parameter.
2007    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2008        self.business_connection_id = Some(val.into());
2009        self
2010    }
2011    /// Sets the `message_effect_id` parameter.
2012    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
2013        self.message_effect_id = Some(val.into());
2014        self
2015    }
2016    /// Sets the `allow_paid_broadcast` parameter.
2017    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
2018        self.allow_paid_broadcast = Some(val);
2019        self
2020    }
2021    /// Sets the `direct_messages_topic_id` parameter.
2022    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
2023        self.direct_messages_topic_id = Some(val);
2024        self
2025    }
2026    /// Sets the `suggested_post_parameters` parameter.
2027    pub fn suggested_post_parameters(
2028        mut self,
2029        val: suggested_post::SuggestedPostParameters,
2030    ) -> Self {
2031        self.suggested_post_parameters = Some(val);
2032        self
2033    }
2034
2035    /// Sends the request to the Telegram Bot API.
2036    pub async fn send(self) -> Result<message::Message> {
2037        let payload = serde_json::to_vec(&self)?;
2038        self.bot.do_post_json("sendDice", &payload).await
2039    }
2040}
2041
2042impl_into_future!(SendDiceBuilder, message::Message);
2043
2044// =========================================================================
2045// SendStickerBuilder
2046// =========================================================================
2047
2048/// Builder for the [`sendSticker`] API method.
2049pub struct SendStickerBuilder<'a> {
2050    bot: &'a Bot,
2051    chat_id: ChatId,
2052    sticker: files::input_file::InputFile,
2053    emoji: Option<String>,
2054    disable_notification: Option<bool>,
2055    protect_content: Option<bool>,
2056    reply_parameters: Option<reply::ReplyParameters>,
2057    reply_markup: Option<serde_json::Value>,
2058    message_thread_id: Option<i64>,
2059    business_connection_id: Option<String>,
2060    message_effect_id: Option<String>,
2061    allow_paid_broadcast: Option<bool>,
2062    direct_messages_topic_id: Option<i64>,
2063    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
2064}
2065
2066impl<'a> SendStickerBuilder<'a> {
2067    /// Sets the `emoji` parameter.
2068    pub fn emoji(mut self, val: impl Into<String>) -> Self {
2069        self.emoji = Some(val.into());
2070        self
2071    }
2072    /// Sets the `disable_notification` parameter.
2073    pub fn disable_notification(mut self, val: bool) -> Self {
2074        self.disable_notification = Some(val);
2075        self
2076    }
2077    /// Sets the `protect_content` parameter.
2078    pub fn protect_content(mut self, val: bool) -> Self {
2079        self.protect_content = Some(val);
2080        self
2081    }
2082    /// Sets the `reply_parameters` parameter.
2083    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
2084        self.reply_parameters = Some(val);
2085        self
2086    }
2087    /// Sets the `reply_markup` parameter.
2088    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2089        self.reply_markup = Some(val);
2090        self
2091    }
2092    /// Sets the `message_thread_id` parameter.
2093    pub fn message_thread_id(mut self, val: i64) -> Self {
2094        self.message_thread_id = Some(val);
2095        self
2096    }
2097    /// Sets the `business_connection_id` parameter.
2098    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2099        self.business_connection_id = Some(val.into());
2100        self
2101    }
2102    /// Sets the `message_effect_id` parameter.
2103    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
2104        self.message_effect_id = Some(val.into());
2105        self
2106    }
2107    /// Sets the `allow_paid_broadcast` parameter.
2108    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
2109        self.allow_paid_broadcast = Some(val);
2110        self
2111    }
2112    /// Sets the `direct_messages_topic_id` parameter.
2113    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
2114        self.direct_messages_topic_id = Some(val);
2115        self
2116    }
2117    /// Sets the `suggested_post_parameters` parameter.
2118    pub fn suggested_post_parameters(
2119        mut self,
2120        val: suggested_post::SuggestedPostParameters,
2121    ) -> Self {
2122        self.suggested_post_parameters = Some(val);
2123        self
2124    }
2125
2126    /// Sends the request to the Telegram Bot API.
2127    pub async fn send(self) -> Result<message::Message> {
2128        let mut params = vec![
2129            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
2130            input_file_param("sticker", self.sticker),
2131        ];
2132        push_opt_str(&mut params, "emoji", &self.emoji);
2133        push_opt(
2134            &mut params,
2135            "disable_notification",
2136            &self.disable_notification,
2137        )?;
2138        push_opt(&mut params, "protect_content", &self.protect_content)?;
2139        push_opt(&mut params, "reply_parameters", &self.reply_parameters)?;
2140        push_opt(&mut params, "reply_markup", &self.reply_markup)?;
2141        push_opt(&mut params, "message_thread_id", &self.message_thread_id)?;
2142        push_opt_str(
2143            &mut params,
2144            "business_connection_id",
2145            &self.business_connection_id,
2146        );
2147        push_opt_str(&mut params, "message_effect_id", &self.message_effect_id);
2148        push_opt(
2149            &mut params,
2150            "allow_paid_broadcast",
2151            &self.allow_paid_broadcast,
2152        )?;
2153        push_opt(
2154            &mut params,
2155            "direct_messages_topic_id",
2156            &self.direct_messages_topic_id,
2157        )?;
2158        push_opt(
2159            &mut params,
2160            "suggested_post_parameters",
2161            &self.suggested_post_parameters,
2162        )?;
2163        self.bot.do_api_request("sendSticker", params).await
2164    }
2165}
2166
2167impl_into_future!(SendStickerBuilder, message::Message);
2168
2169// =========================================================================
2170// EditMessageTextBuilder
2171// =========================================================================
2172
2173/// Builder for the [`editMessageText`] API method.
2174#[derive(Serialize)]
2175pub struct EditMessageTextBuilder<'a> {
2176    #[serde(skip)]
2177    bot: &'a Bot,
2178    text: String,
2179    #[serde(skip_serializing_if = "Option::is_none")]
2180    chat_id: Option<ChatId>,
2181    #[serde(skip_serializing_if = "Option::is_none")]
2182    message_id: Option<i64>,
2183    #[serde(skip_serializing_if = "Option::is_none")]
2184    inline_message_id: Option<String>,
2185    #[serde(skip_serializing_if = "Option::is_none")]
2186    parse_mode: Option<String>,
2187    #[serde(skip_serializing_if = "Option::is_none")]
2188    entities: Option<Vec<message_entity::MessageEntity>>,
2189    #[serde(skip_serializing_if = "Option::is_none")]
2190    link_preview_options: Option<link_preview_options::LinkPreviewOptions>,
2191    #[serde(skip_serializing_if = "Option::is_none")]
2192    reply_markup: Option<serde_json::Value>,
2193    #[serde(skip_serializing_if = "Option::is_none")]
2194    business_connection_id: Option<String>,
2195}
2196
2197impl<'a> EditMessageTextBuilder<'a> {
2198    /// Sets the `chat_id` parameter.
2199    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
2200        self.chat_id = Some(val.into());
2201        self
2202    }
2203    /// Sets the `message_id` parameter.
2204    pub fn message_id(mut self, val: i64) -> Self {
2205        self.message_id = Some(val);
2206        self
2207    }
2208    /// Sets the `inline_message_id` parameter.
2209    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
2210        self.inline_message_id = Some(val.into());
2211        self
2212    }
2213    /// Sets the `parse_mode` parameter.
2214    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
2215        self.parse_mode = Some(val.into());
2216        self
2217    }
2218    /// Sets the `entities` parameter.
2219    pub fn entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
2220        self.entities = Some(val);
2221        self
2222    }
2223    /// Sets the `link_preview_options` parameter.
2224    pub fn link_preview_options(mut self, val: link_preview_options::LinkPreviewOptions) -> Self {
2225        self.link_preview_options = Some(val);
2226        self
2227    }
2228    /// Sets the `reply_markup` parameter.
2229    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2230        self.reply_markup = Some(val);
2231        self
2232    }
2233    /// Sets the `business_connection_id` parameter.
2234    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2235        self.business_connection_id = Some(val.into());
2236        self
2237    }
2238
2239    /// Sends the request to the Telegram Bot API.
2240    pub async fn send(self) -> Result<MessageOrBool> {
2241        let payload = serde_json::to_vec(&self)?;
2242        self.bot.do_post_json("editMessageText", &payload).await
2243    }
2244}
2245
2246impl_into_future!(EditMessageTextBuilder, MessageOrBool);
2247
2248// =========================================================================
2249// EditMessageCaptionBuilder
2250// =========================================================================
2251
2252/// Builder for the [`editMessageCaption`] API method.
2253#[derive(Serialize)]
2254pub struct EditMessageCaptionBuilder<'a> {
2255    #[serde(skip)]
2256    bot: &'a Bot,
2257    #[serde(skip_serializing_if = "Option::is_none")]
2258    chat_id: Option<ChatId>,
2259    #[serde(skip_serializing_if = "Option::is_none")]
2260    message_id: Option<i64>,
2261    #[serde(skip_serializing_if = "Option::is_none")]
2262    inline_message_id: Option<String>,
2263    #[serde(skip_serializing_if = "Option::is_none")]
2264    caption: Option<String>,
2265    #[serde(skip_serializing_if = "Option::is_none")]
2266    parse_mode: Option<String>,
2267    #[serde(skip_serializing_if = "Option::is_none")]
2268    caption_entities: Option<Vec<message_entity::MessageEntity>>,
2269    #[serde(skip_serializing_if = "Option::is_none")]
2270    reply_markup: Option<serde_json::Value>,
2271    #[serde(skip_serializing_if = "Option::is_none")]
2272    show_caption_above_media: Option<bool>,
2273    #[serde(skip_serializing_if = "Option::is_none")]
2274    business_connection_id: Option<String>,
2275}
2276
2277impl<'a> EditMessageCaptionBuilder<'a> {
2278    /// Sets the `chat_id` parameter.
2279    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
2280        self.chat_id = Some(val.into());
2281        self
2282    }
2283    /// Sets the `message_id` parameter.
2284    pub fn message_id(mut self, val: i64) -> Self {
2285        self.message_id = Some(val);
2286        self
2287    }
2288    /// Sets the `inline_message_id` parameter.
2289    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
2290        self.inline_message_id = Some(val.into());
2291        self
2292    }
2293    /// Sets the `caption` parameter.
2294    pub fn caption(mut self, val: impl Into<String>) -> Self {
2295        self.caption = Some(val.into());
2296        self
2297    }
2298    /// Sets the `parse_mode` parameter.
2299    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
2300        self.parse_mode = Some(val.into());
2301        self
2302    }
2303    /// Sets the `caption_entities` parameter.
2304    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
2305        self.caption_entities = Some(val);
2306        self
2307    }
2308    /// Sets the `reply_markup` parameter.
2309    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2310        self.reply_markup = Some(val);
2311        self
2312    }
2313    /// Sets the `show_caption_above_media` parameter.
2314    pub fn show_caption_above_media(mut self, val: bool) -> Self {
2315        self.show_caption_above_media = Some(val);
2316        self
2317    }
2318    /// Sets the `business_connection_id` parameter.
2319    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2320        self.business_connection_id = Some(val.into());
2321        self
2322    }
2323
2324    /// Sends the request to the Telegram Bot API.
2325    pub async fn send(self) -> Result<MessageOrBool> {
2326        let payload = serde_json::to_vec(&self)?;
2327        self.bot.do_post_json("editMessageCaption", &payload).await
2328    }
2329}
2330
2331impl_into_future!(EditMessageCaptionBuilder, MessageOrBool);
2332
2333// =========================================================================
2334// EditMessageMediaBuilder
2335// =========================================================================
2336
2337/// Builder for the [`editMessageMedia`] API method.
2338#[derive(Serialize)]
2339pub struct EditMessageMediaBuilder<'a> {
2340    #[serde(skip)]
2341    bot: &'a Bot,
2342    media: serde_json::Value,
2343    #[serde(skip_serializing_if = "Option::is_none")]
2344    chat_id: Option<ChatId>,
2345    #[serde(skip_serializing_if = "Option::is_none")]
2346    message_id: Option<i64>,
2347    #[serde(skip_serializing_if = "Option::is_none")]
2348    inline_message_id: Option<String>,
2349    #[serde(skip_serializing_if = "Option::is_none")]
2350    reply_markup: Option<serde_json::Value>,
2351    #[serde(skip_serializing_if = "Option::is_none")]
2352    business_connection_id: Option<String>,
2353}
2354
2355impl<'a> EditMessageMediaBuilder<'a> {
2356    /// Sets the `chat_id` parameter.
2357    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
2358        self.chat_id = Some(val.into());
2359        self
2360    }
2361    /// Sets the `message_id` parameter.
2362    pub fn message_id(mut self, val: i64) -> Self {
2363        self.message_id = Some(val);
2364        self
2365    }
2366    /// Sets the `inline_message_id` parameter.
2367    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
2368        self.inline_message_id = Some(val.into());
2369        self
2370    }
2371    /// Sets the `reply_markup` parameter.
2372    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2373        self.reply_markup = Some(val);
2374        self
2375    }
2376    /// Sets the `business_connection_id` parameter.
2377    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2378        self.business_connection_id = Some(val.into());
2379        self
2380    }
2381
2382    /// Sends the request to the Telegram Bot API.
2383    pub async fn send(self) -> Result<MessageOrBool> {
2384        let payload = serde_json::to_vec(&self)?;
2385        self.bot.do_post_json("editMessageMedia", &payload).await
2386    }
2387}
2388
2389impl_into_future!(EditMessageMediaBuilder, MessageOrBool);
2390
2391// =========================================================================
2392// EditMessageReplyMarkupBuilder
2393// =========================================================================
2394
2395/// Builder for the [`editMessageReplyMarkup`] API method.
2396#[derive(Serialize)]
2397pub struct EditMessageReplyMarkupBuilder<'a> {
2398    #[serde(skip)]
2399    bot: &'a Bot,
2400    #[serde(skip_serializing_if = "Option::is_none")]
2401    chat_id: Option<ChatId>,
2402    #[serde(skip_serializing_if = "Option::is_none")]
2403    message_id: Option<i64>,
2404    #[serde(skip_serializing_if = "Option::is_none")]
2405    inline_message_id: Option<String>,
2406    #[serde(skip_serializing_if = "Option::is_none")]
2407    reply_markup: Option<serde_json::Value>,
2408    #[serde(skip_serializing_if = "Option::is_none")]
2409    business_connection_id: Option<String>,
2410}
2411
2412impl<'a> EditMessageReplyMarkupBuilder<'a> {
2413    /// Sets the `chat_id` parameter.
2414    pub fn chat_id(mut self, val: impl Into<ChatId>) -> Self {
2415        self.chat_id = Some(val.into());
2416        self
2417    }
2418    /// Sets the `message_id` parameter.
2419    pub fn message_id(mut self, val: i64) -> Self {
2420        self.message_id = Some(val);
2421        self
2422    }
2423    /// Sets the `inline_message_id` parameter.
2424    pub fn inline_message_id(mut self, val: impl Into<String>) -> Self {
2425        self.inline_message_id = Some(val.into());
2426        self
2427    }
2428    /// Sets the `reply_markup` parameter.
2429    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2430        self.reply_markup = Some(val);
2431        self
2432    }
2433    /// Sets the `business_connection_id` parameter.
2434    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
2435        self.business_connection_id = Some(val.into());
2436        self
2437    }
2438
2439    /// Sends the request to the Telegram Bot API.
2440    pub async fn send(self) -> Result<MessageOrBool> {
2441        let payload = serde_json::to_vec(&self)?;
2442        self.bot
2443            .do_post_json("editMessageReplyMarkup", &payload)
2444            .await
2445    }
2446}
2447
2448impl_into_future!(EditMessageReplyMarkupBuilder, MessageOrBool);
2449
2450// =========================================================================
2451// AnswerCallbackQueryBuilder
2452// =========================================================================
2453
2454/// Builder for the [`answerCallbackQuery`] API method.
2455#[derive(Serialize)]
2456pub struct AnswerCallbackQueryBuilder<'a> {
2457    #[serde(skip)]
2458    bot: &'a Bot,
2459    callback_query_id: String,
2460    #[serde(skip_serializing_if = "Option::is_none")]
2461    text: Option<String>,
2462    #[serde(skip_serializing_if = "Option::is_none")]
2463    show_alert: Option<bool>,
2464    #[serde(skip_serializing_if = "Option::is_none")]
2465    url: Option<String>,
2466    #[serde(skip_serializing_if = "Option::is_none")]
2467    cache_time: Option<i64>,
2468}
2469
2470impl<'a> AnswerCallbackQueryBuilder<'a> {
2471    /// Sets the `text` parameter.
2472    pub fn text(mut self, val: impl Into<String>) -> Self {
2473        self.text = Some(val.into());
2474        self
2475    }
2476    /// Sets the `show_alert` parameter.
2477    pub fn show_alert(mut self, val: bool) -> Self {
2478        self.show_alert = Some(val);
2479        self
2480    }
2481    /// Sets the `url` parameter.
2482    pub fn url(mut self, val: impl Into<String>) -> Self {
2483        self.url = Some(val.into());
2484        self
2485    }
2486    /// Sets the `cache_time` parameter.
2487    pub fn cache_time(mut self, val: i64) -> Self {
2488        self.cache_time = Some(val);
2489        self
2490    }
2491
2492    /// Sends the request to the Telegram Bot API.
2493    pub async fn send(self) -> Result<bool> {
2494        let payload = serde_json::to_vec(&self)?;
2495        self.bot.do_post_json("answerCallbackQuery", &payload).await
2496    }
2497}
2498
2499impl_into_future!(AnswerCallbackQueryBuilder, bool);
2500
2501// =========================================================================
2502// AnswerInlineQueryBuilder
2503// =========================================================================
2504
2505/// Builder for the [`answerInlineQuery`] API method.
2506#[derive(Serialize)]
2507pub struct AnswerInlineQueryBuilder<'a> {
2508    #[serde(skip)]
2509    bot: &'a Bot,
2510    inline_query_id: String,
2511    results: Vec<serde_json::Value>,
2512    #[serde(skip_serializing_if = "Option::is_none")]
2513    cache_time: Option<i64>,
2514    #[serde(skip_serializing_if = "Option::is_none")]
2515    is_personal: Option<bool>,
2516    #[serde(skip_serializing_if = "Option::is_none")]
2517    next_offset: Option<String>,
2518    #[serde(skip_serializing_if = "Option::is_none")]
2519    button: Option<serde_json::Value>,
2520}
2521
2522impl<'a> AnswerInlineQueryBuilder<'a> {
2523    /// Sets the `cache_time` parameter.
2524    pub fn cache_time(mut self, val: i64) -> Self {
2525        self.cache_time = Some(val);
2526        self
2527    }
2528    /// Sets the `is_personal` parameter.
2529    pub fn is_personal(mut self, val: bool) -> Self {
2530        self.is_personal = Some(val);
2531        self
2532    }
2533    /// Sets the `next_offset` parameter.
2534    pub fn next_offset(mut self, val: impl Into<String>) -> Self {
2535        self.next_offset = Some(val.into());
2536        self
2537    }
2538    /// Sets the `button` parameter.
2539    pub fn button(mut self, val: serde_json::Value) -> Self {
2540        self.button = Some(val);
2541        self
2542    }
2543
2544    /// Sends the request to the Telegram Bot API.
2545    pub async fn send(self) -> Result<bool> {
2546        let payload = serde_json::to_vec(&self)?;
2547        self.bot.do_post_json("answerInlineQuery", &payload).await
2548    }
2549}
2550
2551impl_into_future!(AnswerInlineQueryBuilder, bool);
2552
2553// =========================================================================
2554// SetWebhookBuilder
2555// =========================================================================
2556
2557/// Builder for the [`setWebhook`] API method.
2558pub struct SetWebhookBuilder<'a> {
2559    bot: &'a Bot,
2560    url: String,
2561    certificate: Option<files::input_file::InputFile>,
2562    ip_address: Option<String>,
2563    max_connections: Option<i32>,
2564    allowed_updates: Option<Vec<String>>,
2565    drop_pending_updates: Option<bool>,
2566    secret_token: Option<String>,
2567}
2568
2569impl<'a> SetWebhookBuilder<'a> {
2570    /// Sets the `certificate` parameter.
2571    pub fn certificate(mut self, val: files::input_file::InputFile) -> Self {
2572        self.certificate = Some(val);
2573        self
2574    }
2575    /// Sets the `ip_address` parameter.
2576    pub fn ip_address(mut self, val: impl Into<String>) -> Self {
2577        self.ip_address = Some(val.into());
2578        self
2579    }
2580    /// Sets the `max_connections` parameter.
2581    pub fn max_connections(mut self, val: i32) -> Self {
2582        self.max_connections = Some(val);
2583        self
2584    }
2585    /// Sets the `allowed_updates` parameter.
2586    pub fn allowed_updates(mut self, val: Vec<String>) -> Self {
2587        self.allowed_updates = Some(val);
2588        self
2589    }
2590    /// Sets the `drop_pending_updates` parameter.
2591    pub fn drop_pending_updates(mut self, val: bool) -> Self {
2592        self.drop_pending_updates = Some(val);
2593        self
2594    }
2595    /// Sets the `secret_token` parameter.
2596    pub fn secret_token(mut self, val: impl Into<String>) -> Self {
2597        self.secret_token = Some(val.into());
2598        self
2599    }
2600
2601    /// Sends the request to the Telegram Bot API.
2602    pub async fn send(self) -> Result<bool> {
2603        let mut params = vec![RequestParameter::new(
2604            "url",
2605            serde_json::Value::String(self.url),
2606        )];
2607        push_opt_file(&mut params, "certificate", self.certificate);
2608        push_opt_str(&mut params, "ip_address", &self.ip_address);
2609        push_opt(&mut params, "max_connections", &self.max_connections)?;
2610        push_opt(&mut params, "allowed_updates", &self.allowed_updates)?;
2611        push_opt(
2612            &mut params,
2613            "drop_pending_updates",
2614            &self.drop_pending_updates,
2615        )?;
2616        push_opt_str(&mut params, "secret_token", &self.secret_token);
2617        self.bot.do_api_request("setWebhook", params).await
2618    }
2619}
2620
2621impl_into_future!(SetWebhookBuilder, bool);
2622
2623// =========================================================================
2624// DeleteWebhookBuilder
2625// =========================================================================
2626
2627/// Builder for the [`deleteWebhook`] API method.
2628#[derive(Serialize)]
2629pub struct DeleteWebhookBuilder<'a> {
2630    #[serde(skip)]
2631    bot: &'a Bot,
2632    #[serde(skip_serializing_if = "Option::is_none")]
2633    drop_pending_updates: Option<bool>,
2634}
2635
2636impl<'a> DeleteWebhookBuilder<'a> {
2637    /// Sets the `drop_pending_updates` parameter.
2638    pub fn drop_pending_updates(mut self, val: bool) -> Self {
2639        self.drop_pending_updates = Some(val);
2640        self
2641    }
2642
2643    /// Sends the request to the Telegram Bot API.
2644    pub async fn send(self) -> Result<bool> {
2645        let payload = serde_json::to_vec(&self)?;
2646        self.bot.do_post_json("deleteWebhook", &payload).await
2647    }
2648}
2649
2650impl_into_future!(DeleteWebhookBuilder, bool);
2651
2652// =========================================================================
2653// GetFileBuilder
2654// =========================================================================
2655
2656/// Builder for the [`getFile`] API method.
2657#[derive(Serialize)]
2658pub struct GetFileBuilder<'a> {
2659    #[serde(skip)]
2660    bot: &'a Bot,
2661    file_id: String,
2662}
2663
2664impl<'a> GetFileBuilder<'a> {
2665    /// Sends the request to the Telegram Bot API.
2666    pub async fn send(self) -> Result<files::file::File> {
2667        let payload = serde_json::to_vec(&self)?;
2668        self.bot.do_post_json("getFile", &payload).await
2669    }
2670}
2671
2672impl_into_future!(GetFileBuilder, files::file::File);
2673
2674// =========================================================================
2675// SendInvoiceBuilder
2676// =========================================================================
2677
2678/// Builder for the [`sendInvoice`] API method.
2679#[derive(Serialize)]
2680pub struct SendInvoiceBuilder<'a> {
2681    #[serde(skip)]
2682    bot: &'a Bot,
2683    chat_id: ChatId,
2684    title: String,
2685    description: String,
2686    payload: String,
2687    currency: String,
2688    prices: Vec<serde_json::Value>,
2689    #[serde(skip_serializing_if = "Option::is_none")]
2690    provider_token: Option<String>,
2691    #[serde(skip_serializing_if = "Option::is_none")]
2692    max_tip_amount: Option<i64>,
2693    #[serde(skip_serializing_if = "Option::is_none")]
2694    suggested_tip_amounts: Option<Vec<i64>>,
2695    #[serde(skip_serializing_if = "Option::is_none")]
2696    start_parameter: Option<String>,
2697    #[serde(skip_serializing_if = "Option::is_none")]
2698    provider_data: Option<String>,
2699    #[serde(skip_serializing_if = "Option::is_none")]
2700    photo_url: Option<String>,
2701    #[serde(skip_serializing_if = "Option::is_none")]
2702    photo_size: Option<i64>,
2703    #[serde(skip_serializing_if = "Option::is_none")]
2704    photo_width: Option<i64>,
2705    #[serde(skip_serializing_if = "Option::is_none")]
2706    photo_height: Option<i64>,
2707    #[serde(skip_serializing_if = "Option::is_none")]
2708    need_name: Option<bool>,
2709    #[serde(skip_serializing_if = "Option::is_none")]
2710    need_phone_number: Option<bool>,
2711    #[serde(skip_serializing_if = "Option::is_none")]
2712    need_email: Option<bool>,
2713    #[serde(skip_serializing_if = "Option::is_none")]
2714    need_shipping_address: Option<bool>,
2715    #[serde(skip_serializing_if = "Option::is_none")]
2716    send_phone_number_to_provider: Option<bool>,
2717    #[serde(skip_serializing_if = "Option::is_none")]
2718    send_email_to_provider: Option<bool>,
2719    #[serde(skip_serializing_if = "Option::is_none")]
2720    is_flexible: Option<bool>,
2721    #[serde(skip_serializing_if = "Option::is_none")]
2722    disable_notification: Option<bool>,
2723    #[serde(skip_serializing_if = "Option::is_none")]
2724    protect_content: Option<bool>,
2725    #[serde(skip_serializing_if = "Option::is_none")]
2726    reply_parameters: Option<reply::ReplyParameters>,
2727    #[serde(skip_serializing_if = "Option::is_none")]
2728    reply_markup: Option<serde_json::Value>,
2729    #[serde(skip_serializing_if = "Option::is_none")]
2730    message_thread_id: Option<i64>,
2731    #[serde(skip_serializing_if = "Option::is_none")]
2732    message_effect_id: Option<String>,
2733    #[serde(skip_serializing_if = "Option::is_none")]
2734    allow_paid_broadcast: Option<bool>,
2735    #[serde(skip_serializing_if = "Option::is_none")]
2736    direct_messages_topic_id: Option<i64>,
2737    #[serde(skip_serializing_if = "Option::is_none")]
2738    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
2739}
2740
2741impl<'a> SendInvoiceBuilder<'a> {
2742    /// Sets the `provider_token` parameter.
2743    pub fn provider_token(mut self, val: impl Into<String>) -> Self {
2744        self.provider_token = Some(val.into());
2745        self
2746    }
2747    /// Sets the `max_tip_amount` parameter.
2748    pub fn max_tip_amount(mut self, val: i64) -> Self {
2749        self.max_tip_amount = Some(val);
2750        self
2751    }
2752    /// Sets the `suggested_tip_amounts` parameter.
2753    pub fn suggested_tip_amounts(mut self, val: Vec<i64>) -> Self {
2754        self.suggested_tip_amounts = Some(val);
2755        self
2756    }
2757    /// Sets the `start_parameter` parameter.
2758    pub fn start_parameter(mut self, val: impl Into<String>) -> Self {
2759        self.start_parameter = Some(val.into());
2760        self
2761    }
2762    /// Sets the `provider_data` parameter.
2763    pub fn provider_data(mut self, val: impl Into<String>) -> Self {
2764        self.provider_data = Some(val.into());
2765        self
2766    }
2767    /// Sets the `photo_url` parameter.
2768    pub fn photo_url(mut self, val: impl Into<String>) -> Self {
2769        self.photo_url = Some(val.into());
2770        self
2771    }
2772    /// Sets the `photo_size` parameter.
2773    pub fn photo_size(mut self, val: i64) -> Self {
2774        self.photo_size = Some(val);
2775        self
2776    }
2777    /// Sets the `photo_width` parameter.
2778    pub fn photo_width(mut self, val: i64) -> Self {
2779        self.photo_width = Some(val);
2780        self
2781    }
2782    /// Sets the `photo_height` parameter.
2783    pub fn photo_height(mut self, val: i64) -> Self {
2784        self.photo_height = Some(val);
2785        self
2786    }
2787    /// Sets the `need_name` parameter.
2788    pub fn need_name(mut self, val: bool) -> Self {
2789        self.need_name = Some(val);
2790        self
2791    }
2792    /// Sets the `need_phone_number` parameter.
2793    pub fn need_phone_number(mut self, val: bool) -> Self {
2794        self.need_phone_number = Some(val);
2795        self
2796    }
2797    /// Sets the `need_email` parameter.
2798    pub fn need_email(mut self, val: bool) -> Self {
2799        self.need_email = Some(val);
2800        self
2801    }
2802    /// Sets the `need_shipping_address` parameter.
2803    pub fn need_shipping_address(mut self, val: bool) -> Self {
2804        self.need_shipping_address = Some(val);
2805        self
2806    }
2807    /// Sets the `send_phone_number_to_provider` parameter.
2808    pub fn send_phone_number_to_provider(mut self, val: bool) -> Self {
2809        self.send_phone_number_to_provider = Some(val);
2810        self
2811    }
2812    /// Sets the `send_email_to_provider` parameter.
2813    pub fn send_email_to_provider(mut self, val: bool) -> Self {
2814        self.send_email_to_provider = Some(val);
2815        self
2816    }
2817    /// Sets the `is_flexible` parameter.
2818    pub fn is_flexible(mut self, val: bool) -> Self {
2819        self.is_flexible = Some(val);
2820        self
2821    }
2822    /// Sets the `disable_notification` parameter.
2823    pub fn disable_notification(mut self, val: bool) -> Self {
2824        self.disable_notification = Some(val);
2825        self
2826    }
2827    /// Sets the `protect_content` parameter.
2828    pub fn protect_content(mut self, val: bool) -> Self {
2829        self.protect_content = Some(val);
2830        self
2831    }
2832    /// Sets the `reply_parameters` parameter.
2833    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
2834        self.reply_parameters = Some(val);
2835        self
2836    }
2837    /// Sets the `reply_markup` parameter.
2838    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
2839        self.reply_markup = Some(val);
2840        self
2841    }
2842    /// Sets the `message_thread_id` parameter.
2843    pub fn message_thread_id(mut self, val: i64) -> Self {
2844        self.message_thread_id = Some(val);
2845        self
2846    }
2847    /// Sets the `message_effect_id` parameter.
2848    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
2849        self.message_effect_id = Some(val.into());
2850        self
2851    }
2852    /// Sets the `allow_paid_broadcast` parameter.
2853    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
2854        self.allow_paid_broadcast = Some(val);
2855        self
2856    }
2857    /// Sets the `direct_messages_topic_id` parameter.
2858    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
2859        self.direct_messages_topic_id = Some(val);
2860        self
2861    }
2862    /// Sets the `suggested_post_parameters` parameter.
2863    pub fn suggested_post_parameters(
2864        mut self,
2865        val: suggested_post::SuggestedPostParameters,
2866    ) -> Self {
2867        self.suggested_post_parameters = Some(val);
2868        self
2869    }
2870
2871    /// Sends the request to the Telegram Bot API.
2872    pub async fn send(self) -> Result<message::Message> {
2873        let payload = serde_json::to_vec(&self)?;
2874        self.bot.do_post_json("sendInvoice", &payload).await
2875    }
2876}
2877
2878impl_into_future!(SendInvoiceBuilder, message::Message);
2879
2880// =========================================================================
2881// AnswerShippingQueryBuilder
2882// =========================================================================
2883
2884/// Builder for the [`answerShippingQuery`] API method.
2885#[derive(Serialize)]
2886pub struct AnswerShippingQueryBuilder<'a> {
2887    #[serde(skip)]
2888    bot: &'a Bot,
2889    shipping_query_id: String,
2890    ok: bool,
2891    #[serde(skip_serializing_if = "Option::is_none")]
2892    shipping_options: Option<Vec<serde_json::Value>>,
2893    #[serde(skip_serializing_if = "Option::is_none")]
2894    error_message: Option<String>,
2895}
2896
2897impl<'a> AnswerShippingQueryBuilder<'a> {
2898    /// Sets the `shipping_options` parameter.
2899    pub fn shipping_options(mut self, val: Vec<serde_json::Value>) -> Self {
2900        self.shipping_options = Some(val);
2901        self
2902    }
2903    /// Sets the `error_message` parameter.
2904    pub fn error_message(mut self, val: impl Into<String>) -> Self {
2905        self.error_message = Some(val.into());
2906        self
2907    }
2908
2909    /// Sends the request to the Telegram Bot API.
2910    pub async fn send(self) -> Result<bool> {
2911        let payload = serde_json::to_vec(&self)?;
2912        self.bot.do_post_json("answerShippingQuery", &payload).await
2913    }
2914}
2915
2916impl_into_future!(AnswerShippingQueryBuilder, bool);
2917
2918// =========================================================================
2919// AnswerPreCheckoutQueryBuilder
2920// =========================================================================
2921
2922/// Builder for the [`answerPreCheckoutQuery`] API method.
2923#[derive(Serialize)]
2924pub struct AnswerPreCheckoutQueryBuilder<'a> {
2925    #[serde(skip)]
2926    bot: &'a Bot,
2927    pre_checkout_query_id: String,
2928    ok: bool,
2929    #[serde(skip_serializing_if = "Option::is_none")]
2930    error_message: Option<String>,
2931}
2932
2933impl<'a> AnswerPreCheckoutQueryBuilder<'a> {
2934    /// Sets the `error_message` parameter.
2935    pub fn error_message(mut self, val: impl Into<String>) -> Self {
2936        self.error_message = Some(val.into());
2937        self
2938    }
2939
2940    /// Sends the request to the Telegram Bot API.
2941    pub async fn send(self) -> Result<bool> {
2942        let payload = serde_json::to_vec(&self)?;
2943        self.bot
2944            .do_post_json("answerPreCheckoutQuery", &payload)
2945            .await
2946    }
2947}
2948
2949impl_into_future!(AnswerPreCheckoutQueryBuilder, bool);
2950
2951// =========================================================================
2952// Bot convenience methods that return builders
2953// =========================================================================
2954
2955impl Bot {
2956    // -- Sending messages -------------------------------------------------
2957
2958    /// Build a `sendMessage` request.
2959    pub fn send_message(
2960        &self,
2961        chat_id: impl Into<ChatId>,
2962        text: impl Into<String>,
2963    ) -> SendMessageBuilder<'_> {
2964        SendMessageBuilder {
2965            bot: self,
2966            chat_id: chat_id.into(),
2967            text: text.into(),
2968            parse_mode: None,
2969            entities: None,
2970            link_preview_options: None,
2971            disable_notification: None,
2972            protect_content: None,
2973            reply_parameters: None,
2974            reply_markup: None,
2975            message_thread_id: None,
2976            business_connection_id: None,
2977            message_effect_id: None,
2978            allow_paid_broadcast: None,
2979            direct_messages_topic_id: None,
2980            suggested_post_parameters: None,
2981        }
2982    }
2983
2984    // -- Sending media ----------------------------------------------------
2985
2986    /// Build a `sendPhoto` request.
2987    pub fn send_photo(
2988        &self,
2989        chat_id: impl Into<ChatId>,
2990        photo: files::input_file::InputFile,
2991    ) -> SendPhotoBuilder<'_> {
2992        SendPhotoBuilder {
2993            bot: self,
2994            chat_id: chat_id.into(),
2995            photo,
2996            caption: None,
2997            parse_mode: None,
2998            caption_entities: None,
2999            disable_notification: None,
3000            protect_content: None,
3001            reply_parameters: None,
3002            reply_markup: None,
3003            message_thread_id: None,
3004            has_spoiler: None,
3005            business_connection_id: None,
3006            message_effect_id: None,
3007            allow_paid_broadcast: None,
3008            show_caption_above_media: None,
3009            direct_messages_topic_id: None,
3010            suggested_post_parameters: None,
3011        }
3012    }
3013
3014    /// Build a `sendDocument` request.
3015    pub fn send_document(
3016        &self,
3017        chat_id: impl Into<ChatId>,
3018        document: files::input_file::InputFile,
3019    ) -> SendDocumentBuilder<'_> {
3020        SendDocumentBuilder {
3021            bot: self,
3022            chat_id: chat_id.into(),
3023            document,
3024            caption: None,
3025            parse_mode: None,
3026            caption_entities: None,
3027            disable_content_type_detection: None,
3028            thumbnail: None,
3029            disable_notification: None,
3030            protect_content: None,
3031            reply_parameters: None,
3032            reply_markup: None,
3033            message_thread_id: None,
3034            business_connection_id: None,
3035            message_effect_id: None,
3036            allow_paid_broadcast: None,
3037            direct_messages_topic_id: None,
3038            suggested_post_parameters: None,
3039        }
3040    }
3041
3042    /// Build a `sendVideo` request.
3043    pub fn send_video(
3044        &self,
3045        chat_id: impl Into<ChatId>,
3046        video: files::input_file::InputFile,
3047    ) -> SendVideoBuilder<'_> {
3048        SendVideoBuilder {
3049            bot: self,
3050            chat_id: chat_id.into(),
3051            video,
3052            duration: None,
3053            width: None,
3054            height: None,
3055            caption: None,
3056            parse_mode: None,
3057            caption_entities: None,
3058            supports_streaming: None,
3059            thumbnail: None,
3060            has_spoiler: None,
3061            show_caption_above_media: None,
3062            cover: None,
3063            start_timestamp: None,
3064            disable_notification: None,
3065            protect_content: None,
3066            reply_parameters: None,
3067            reply_markup: None,
3068            message_thread_id: None,
3069            business_connection_id: None,
3070            message_effect_id: None,
3071            allow_paid_broadcast: None,
3072            direct_messages_topic_id: None,
3073            suggested_post_parameters: None,
3074        }
3075    }
3076
3077    /// Build a `sendAudio` request.
3078    pub fn send_audio(
3079        &self,
3080        chat_id: impl Into<ChatId>,
3081        audio: files::input_file::InputFile,
3082    ) -> SendAudioBuilder<'_> {
3083        SendAudioBuilder {
3084            bot: self,
3085            chat_id: chat_id.into(),
3086            audio,
3087            caption: None,
3088            parse_mode: None,
3089            caption_entities: None,
3090            duration: None,
3091            performer: None,
3092            title: None,
3093            thumbnail: None,
3094            disable_notification: None,
3095            protect_content: None,
3096            reply_parameters: None,
3097            reply_markup: None,
3098            message_thread_id: None,
3099            business_connection_id: None,
3100            message_effect_id: None,
3101            allow_paid_broadcast: None,
3102            direct_messages_topic_id: None,
3103            suggested_post_parameters: None,
3104        }
3105    }
3106
3107    /// Build a `sendAnimation` request.
3108    pub fn send_animation(
3109        &self,
3110        chat_id: impl Into<ChatId>,
3111        animation: files::input_file::InputFile,
3112    ) -> SendAnimationBuilder<'_> {
3113        SendAnimationBuilder {
3114            bot: self,
3115            chat_id: chat_id.into(),
3116            animation,
3117            duration: None,
3118            width: None,
3119            height: None,
3120            caption: None,
3121            parse_mode: None,
3122            caption_entities: None,
3123            thumbnail: None,
3124            has_spoiler: None,
3125            show_caption_above_media: None,
3126            disable_notification: None,
3127            protect_content: None,
3128            reply_parameters: None,
3129            reply_markup: None,
3130            message_thread_id: None,
3131            business_connection_id: None,
3132            message_effect_id: None,
3133            allow_paid_broadcast: None,
3134            direct_messages_topic_id: None,
3135            suggested_post_parameters: None,
3136        }
3137    }
3138
3139    /// Build a `sendVoice` request.
3140    pub fn send_voice(
3141        &self,
3142        chat_id: impl Into<ChatId>,
3143        voice: files::input_file::InputFile,
3144    ) -> SendVoiceBuilder<'_> {
3145        SendVoiceBuilder {
3146            bot: self,
3147            chat_id: chat_id.into(),
3148            voice,
3149            caption: None,
3150            parse_mode: None,
3151            caption_entities: None,
3152            duration: None,
3153            disable_notification: None,
3154            protect_content: None,
3155            reply_parameters: None,
3156            reply_markup: None,
3157            message_thread_id: None,
3158            business_connection_id: None,
3159            message_effect_id: None,
3160            allow_paid_broadcast: None,
3161            direct_messages_topic_id: None,
3162            suggested_post_parameters: None,
3163        }
3164    }
3165
3166    /// Build a `sendVideoNote` request.
3167    pub fn send_video_note(
3168        &self,
3169        chat_id: impl Into<ChatId>,
3170        video_note: files::input_file::InputFile,
3171    ) -> SendVideoNoteBuilder<'_> {
3172        SendVideoNoteBuilder {
3173            bot: self,
3174            chat_id: chat_id.into(),
3175            video_note,
3176            duration: None,
3177            length: None,
3178            thumbnail: None,
3179            disable_notification: None,
3180            protect_content: None,
3181            reply_parameters: None,
3182            reply_markup: None,
3183            message_thread_id: None,
3184            business_connection_id: None,
3185            message_effect_id: None,
3186            allow_paid_broadcast: None,
3187            direct_messages_topic_id: None,
3188            suggested_post_parameters: None,
3189        }
3190    }
3191
3192    // -- Sending other content --------------------------------------------
3193
3194    /// Build a `sendLocation` request.
3195    pub fn send_location(
3196        &self,
3197        chat_id: impl Into<ChatId>,
3198        latitude: f64,
3199        longitude: f64,
3200    ) -> SendLocationBuilder<'_> {
3201        SendLocationBuilder {
3202            bot: self,
3203            chat_id: chat_id.into(),
3204            latitude,
3205            longitude,
3206            horizontal_accuracy: None,
3207            live_period: None,
3208            heading: None,
3209            proximity_alert_radius: None,
3210            disable_notification: None,
3211            protect_content: None,
3212            reply_parameters: None,
3213            reply_markup: None,
3214            message_thread_id: None,
3215            business_connection_id: None,
3216            message_effect_id: None,
3217            allow_paid_broadcast: None,
3218            direct_messages_topic_id: None,
3219            suggested_post_parameters: None,
3220        }
3221    }
3222
3223    /// Build a `sendVenue` request.
3224    pub fn send_venue(
3225        &self,
3226        chat_id: impl Into<ChatId>,
3227        latitude: f64,
3228        longitude: f64,
3229        title: impl Into<String>,
3230        address: impl Into<String>,
3231    ) -> SendVenueBuilder<'_> {
3232        SendVenueBuilder {
3233            bot: self,
3234            chat_id: chat_id.into(),
3235            latitude,
3236            longitude,
3237            title: title.into(),
3238            address: address.into(),
3239            foursquare_id: None,
3240            foursquare_type: None,
3241            google_place_id: None,
3242            google_place_type: None,
3243            disable_notification: None,
3244            protect_content: None,
3245            reply_parameters: None,
3246            reply_markup: None,
3247            message_thread_id: None,
3248            business_connection_id: None,
3249            message_effect_id: None,
3250            allow_paid_broadcast: None,
3251            direct_messages_topic_id: None,
3252            suggested_post_parameters: None,
3253        }
3254    }
3255
3256    /// Build a `sendContact` request.
3257    pub fn send_contact(
3258        &self,
3259        chat_id: impl Into<ChatId>,
3260        phone_number: impl Into<String>,
3261        first_name: impl Into<String>,
3262    ) -> SendContactBuilder<'_> {
3263        SendContactBuilder {
3264            bot: self,
3265            chat_id: chat_id.into(),
3266            phone_number: phone_number.into(),
3267            first_name: first_name.into(),
3268            last_name: None,
3269            vcard: None,
3270            disable_notification: None,
3271            protect_content: None,
3272            reply_parameters: None,
3273            reply_markup: None,
3274            message_thread_id: None,
3275            business_connection_id: None,
3276            message_effect_id: None,
3277            allow_paid_broadcast: None,
3278            direct_messages_topic_id: None,
3279            suggested_post_parameters: None,
3280        }
3281    }
3282
3283    /// Build a `sendPoll` request.
3284    pub fn send_poll(
3285        &self,
3286        chat_id: impl Into<ChatId>,
3287        question: impl Into<String>,
3288        options: Vec<serde_json::Value>,
3289    ) -> SendPollBuilder<'_> {
3290        SendPollBuilder {
3291            bot: self,
3292            chat_id: chat_id.into(),
3293            question: question.into(),
3294            options,
3295            is_anonymous: None,
3296            poll_type: None,
3297            allows_multiple_answers: None,
3298            correct_option_id: None,
3299            explanation: None,
3300            explanation_parse_mode: None,
3301            explanation_entities: None,
3302            open_period: None,
3303            close_date: None,
3304            is_closed: None,
3305            disable_notification: None,
3306            protect_content: None,
3307            reply_parameters: None,
3308            reply_markup: None,
3309            message_thread_id: None,
3310            business_connection_id: None,
3311            question_parse_mode: None,
3312            question_entities: None,
3313            message_effect_id: None,
3314            allow_paid_broadcast: None,
3315            direct_messages_topic_id: None,
3316            suggested_post_parameters: None,
3317        }
3318    }
3319
3320    /// Build a `sendDice` request.
3321    pub fn send_dice(&self, chat_id: impl Into<ChatId>) -> SendDiceBuilder<'_> {
3322        SendDiceBuilder {
3323            bot: self,
3324            chat_id: chat_id.into(),
3325            emoji: None,
3326            disable_notification: None,
3327            protect_content: None,
3328            reply_parameters: None,
3329            reply_markup: None,
3330            message_thread_id: None,
3331            business_connection_id: None,
3332            message_effect_id: None,
3333            allow_paid_broadcast: None,
3334            direct_messages_topic_id: None,
3335            suggested_post_parameters: None,
3336        }
3337    }
3338
3339    // -- Stickers ---------------------------------------------------------
3340
3341    /// Build a `sendSticker` request.
3342    pub fn send_sticker(
3343        &self,
3344        chat_id: impl Into<ChatId>,
3345        sticker: files::input_file::InputFile,
3346    ) -> SendStickerBuilder<'_> {
3347        SendStickerBuilder {
3348            bot: self,
3349            chat_id: chat_id.into(),
3350            sticker,
3351            emoji: None,
3352            disable_notification: None,
3353            protect_content: None,
3354            reply_parameters: None,
3355            reply_markup: None,
3356            message_thread_id: None,
3357            business_connection_id: None,
3358            message_effect_id: None,
3359            allow_paid_broadcast: None,
3360            direct_messages_topic_id: None,
3361            suggested_post_parameters: None,
3362        }
3363    }
3364
3365    // -- Editing messages -------------------------------------------------
3366
3367    /// Build an `editMessageText` request.
3368    pub fn edit_message_text(&self, text: impl Into<String>) -> EditMessageTextBuilder<'_> {
3369        EditMessageTextBuilder {
3370            bot: self,
3371            text: text.into(),
3372            chat_id: None,
3373            message_id: None,
3374            inline_message_id: None,
3375            parse_mode: None,
3376            entities: None,
3377            link_preview_options: None,
3378            reply_markup: None,
3379            business_connection_id: None,
3380        }
3381    }
3382
3383    /// Build an `editMessageCaption` request.
3384    pub fn edit_message_caption(&self) -> EditMessageCaptionBuilder<'_> {
3385        EditMessageCaptionBuilder {
3386            bot: self,
3387            chat_id: None,
3388            message_id: None,
3389            inline_message_id: None,
3390            caption: None,
3391            parse_mode: None,
3392            caption_entities: None,
3393            reply_markup: None,
3394            show_caption_above_media: None,
3395            business_connection_id: None,
3396        }
3397    }
3398
3399    /// Build an `editMessageMedia` request.
3400    pub fn edit_message_media(&self, media: serde_json::Value) -> EditMessageMediaBuilder<'_> {
3401        EditMessageMediaBuilder {
3402            bot: self,
3403            media,
3404            chat_id: None,
3405            message_id: None,
3406            inline_message_id: None,
3407            reply_markup: None,
3408            business_connection_id: None,
3409        }
3410    }
3411
3412    /// Build an `editMessageReplyMarkup` request.
3413    pub fn edit_message_reply_markup(&self) -> EditMessageReplyMarkupBuilder<'_> {
3414        EditMessageReplyMarkupBuilder {
3415            bot: self,
3416            chat_id: None,
3417            message_id: None,
3418            inline_message_id: None,
3419            reply_markup: None,
3420            business_connection_id: None,
3421        }
3422    }
3423
3424    // -- Callback & inline queries ----------------------------------------
3425
3426    /// Build an `answerCallbackQuery` request.
3427    pub fn answer_callback_query(
3428        &self,
3429        callback_query_id: impl Into<String>,
3430    ) -> AnswerCallbackQueryBuilder<'_> {
3431        AnswerCallbackQueryBuilder {
3432            bot: self,
3433            callback_query_id: callback_query_id.into(),
3434            text: None,
3435            show_alert: None,
3436            url: None,
3437            cache_time: None,
3438        }
3439    }
3440
3441    /// Build an `answerInlineQuery` request.
3442    pub fn answer_inline_query(
3443        &self,
3444        inline_query_id: impl Into<String>,
3445        results: Vec<serde_json::Value>,
3446    ) -> AnswerInlineQueryBuilder<'_> {
3447        AnswerInlineQueryBuilder {
3448            bot: self,
3449            inline_query_id: inline_query_id.into(),
3450            results,
3451            cache_time: None,
3452            is_personal: None,
3453            next_offset: None,
3454            button: None,
3455        }
3456    }
3457
3458    // -- Webhooks ------------------------------------------------------------
3459
3460    /// Build a `setWebhook` request.
3461    pub fn set_webhook(&self, url: impl Into<String>) -> SetWebhookBuilder<'_> {
3462        SetWebhookBuilder {
3463            bot: self,
3464            url: url.into(),
3465            certificate: None,
3466            ip_address: None,
3467            max_connections: None,
3468            allowed_updates: None,
3469            drop_pending_updates: None,
3470            secret_token: None,
3471        }
3472    }
3473
3474    /// Build a `deleteWebhook` request.
3475    pub fn delete_webhook(&self) -> DeleteWebhookBuilder<'_> {
3476        DeleteWebhookBuilder {
3477            bot: self,
3478            drop_pending_updates: None,
3479        }
3480    }
3481
3482    // -- Files ---------------------------------------------------------------
3483
3484    /// Build a `getFile` request.
3485    pub fn get_file(&self, file_id: impl Into<String>) -> GetFileBuilder<'_> {
3486        GetFileBuilder {
3487            bot: self,
3488            file_id: file_id.into(),
3489        }
3490    }
3491
3492    // -- Payments ------------------------------------------------------------
3493
3494    /// Build a `sendInvoice` request.
3495    pub fn send_invoice(
3496        &self,
3497        chat_id: impl Into<ChatId>,
3498        title: impl Into<String>,
3499        description: impl Into<String>,
3500        payload: impl Into<String>,
3501        currency: impl Into<String>,
3502        prices: Vec<serde_json::Value>,
3503    ) -> SendInvoiceBuilder<'_> {
3504        SendInvoiceBuilder {
3505            bot: self,
3506            chat_id: chat_id.into(),
3507            title: title.into(),
3508            description: description.into(),
3509            payload: payload.into(),
3510            currency: currency.into(),
3511            prices,
3512            provider_token: None,
3513            max_tip_amount: None,
3514            suggested_tip_amounts: None,
3515            start_parameter: None,
3516            provider_data: None,
3517            photo_url: None,
3518            photo_size: None,
3519            photo_width: None,
3520            photo_height: None,
3521            need_name: None,
3522            need_phone_number: None,
3523            need_email: None,
3524            need_shipping_address: None,
3525            send_phone_number_to_provider: None,
3526            send_email_to_provider: None,
3527            is_flexible: None,
3528            disable_notification: None,
3529            protect_content: None,
3530            reply_parameters: None,
3531            reply_markup: None,
3532            message_thread_id: None,
3533            message_effect_id: None,
3534            allow_paid_broadcast: None,
3535            direct_messages_topic_id: None,
3536            suggested_post_parameters: None,
3537        }
3538    }
3539
3540    /// Build an `answerShippingQuery` request.
3541    pub fn answer_shipping_query(
3542        &self,
3543        shipping_query_id: impl Into<String>,
3544        ok: bool,
3545    ) -> AnswerShippingQueryBuilder<'_> {
3546        AnswerShippingQueryBuilder {
3547            bot: self,
3548            shipping_query_id: shipping_query_id.into(),
3549            ok,
3550            shipping_options: None,
3551            error_message: None,
3552        }
3553    }
3554
3555    /// Build an `answerPreCheckoutQuery` request.
3556    pub fn answer_pre_checkout_query(
3557        &self,
3558        pre_checkout_query_id: impl Into<String>,
3559        ok: bool,
3560    ) -> AnswerPreCheckoutQueryBuilder<'_> {
3561        AnswerPreCheckoutQueryBuilder {
3562            bot: self,
3563            pre_checkout_query_id: pre_checkout_query_id.into(),
3564            ok,
3565            error_message: None,
3566        }
3567    }
3568}
3569
3570// =========================================================================
3571// GetManagedBotTokenBuilder
3572// =========================================================================
3573
3574/// Builder for the [`getManagedBotToken`] API method.
3575#[derive(Serialize)]
3576pub struct GetManagedBotTokenBuilder<'a> {
3577    #[serde(skip)]
3578    bot: &'a Bot,
3579    bot_user_id: i64,
3580}
3581
3582impl<'a> GetManagedBotTokenBuilder<'a> {
3583    /// Sends the request to the Telegram Bot API.
3584    pub async fn send(self) -> Result<String> {
3585        let payload = serde_json::to_vec(&self)?;
3586        self.bot.do_post_json("getManagedBotToken", &payload).await
3587    }
3588}
3589
3590impl_into_future!(GetManagedBotTokenBuilder, String);
3591
3592// =========================================================================
3593// ReplaceManagedBotTokenBuilder
3594// =========================================================================
3595
3596/// Builder for the [`replaceManagedBotToken`] API method.
3597#[derive(Serialize)]
3598pub struct ReplaceManagedBotTokenBuilder<'a> {
3599    #[serde(skip)]
3600    bot: &'a Bot,
3601    bot_user_id: i64,
3602}
3603
3604impl<'a> ReplaceManagedBotTokenBuilder<'a> {
3605    /// Sends the request to the Telegram Bot API.
3606    pub async fn send(self) -> Result<String> {
3607        let payload = serde_json::to_vec(&self)?;
3608        self.bot
3609            .do_post_json("replaceManagedBotToken", &payload)
3610            .await
3611    }
3612}
3613
3614impl_into_future!(ReplaceManagedBotTokenBuilder, String);
3615
3616// =========================================================================
3617// SavePreparedKeyboardButtonBuilder
3618// =========================================================================
3619
3620/// Builder for the [`savePreparedKeyboardButton`] API method.
3621#[derive(Serialize)]
3622pub struct SavePreparedKeyboardButtonBuilder<'a> {
3623    #[serde(skip)]
3624    bot: &'a Bot,
3625    user_id: i64,
3626    button: inline::inline_keyboard_button::InlineKeyboardButton,
3627    #[serde(skip_serializing_if = "Option::is_none")]
3628    allow_user_chats: Option<bool>,
3629    #[serde(skip_serializing_if = "Option::is_none")]
3630    allow_bot_chats: Option<bool>,
3631    #[serde(skip_serializing_if = "Option::is_none")]
3632    allow_group_chats: Option<bool>,
3633    #[serde(skip_serializing_if = "Option::is_none")]
3634    allow_channel_chats: Option<bool>,
3635}
3636
3637impl<'a> SavePreparedKeyboardButtonBuilder<'a> {
3638    /// Sets the `allow_user_chats` parameter.
3639    pub fn allow_user_chats(mut self, val: bool) -> Self {
3640        self.allow_user_chats = Some(val);
3641        self
3642    }
3643    /// Sets the `allow_bot_chats` parameter.
3644    pub fn allow_bot_chats(mut self, val: bool) -> Self {
3645        self.allow_bot_chats = Some(val);
3646        self
3647    }
3648    /// Sets the `allow_group_chats` parameter.
3649    pub fn allow_group_chats(mut self, val: bool) -> Self {
3650        self.allow_group_chats = Some(val);
3651        self
3652    }
3653    /// Sets the `allow_channel_chats` parameter.
3654    pub fn allow_channel_chats(mut self, val: bool) -> Self {
3655        self.allow_channel_chats = Some(val);
3656        self
3657    }
3658
3659    /// Sends the request to the Telegram Bot API.
3660    pub async fn send(self) -> Result<prepared_keyboard_button::PreparedKeyboardButton> {
3661        let payload = serde_json::to_vec(&self)?;
3662        self.bot
3663            .do_post_json("savePreparedKeyboardButton", &payload)
3664            .await
3665    }
3666}
3667
3668impl_into_future!(
3669    SavePreparedKeyboardButtonBuilder,
3670    prepared_keyboard_button::PreparedKeyboardButton
3671);
3672
3673// =========================================================================
3674// Builder factory methods on Bot for the new API methods
3675// =========================================================================
3676
3677impl Bot {
3678    /// Build a `getManagedBotToken` request.
3679    pub fn get_managed_bot_token(&self, bot_user_id: i64) -> GetManagedBotTokenBuilder<'_> {
3680        GetManagedBotTokenBuilder {
3681            bot: self,
3682            bot_user_id,
3683        }
3684    }
3685
3686    /// Build a `replaceManagedBotToken` request.
3687    pub fn replace_managed_bot_token(&self, bot_user_id: i64) -> ReplaceManagedBotTokenBuilder<'_> {
3688        ReplaceManagedBotTokenBuilder {
3689            bot: self,
3690            bot_user_id,
3691        }
3692    }
3693
3694    /// Build a `savePreparedKeyboardButton` request.
3695    pub fn save_prepared_keyboard_button(
3696        &self,
3697        user_id: i64,
3698        button: inline::inline_keyboard_button::InlineKeyboardButton,
3699    ) -> SavePreparedKeyboardButtonBuilder<'_> {
3700        SavePreparedKeyboardButtonBuilder {
3701            bot: self,
3702            user_id,
3703            button,
3704            allow_user_chats: None,
3705            allow_bot_chats: None,
3706            allow_group_chats: None,
3707            allow_channel_chats: None,
3708        }
3709    }
3710
3711    /// Build a `sendChatAction` request.
3712    pub fn send_chat_action(
3713        &self,
3714        chat_id: impl Into<ChatId>,
3715        action: impl Into<String>,
3716    ) -> SendChatActionBuilder<'_> {
3717        SendChatActionBuilder {
3718            bot: self,
3719            chat_id: chat_id.into(),
3720            action: action.into(),
3721            message_thread_id: None,
3722            business_connection_id: None,
3723        }
3724    }
3725}
3726
3727// ---------------------------------------------------------------------------
3728// SendChatActionBuilder
3729// ---------------------------------------------------------------------------
3730
3731/// Builder for the [`sendChatAction`] API method.
3732#[derive(Serialize)]
3733pub struct SendChatActionBuilder<'a> {
3734    #[serde(skip)]
3735    bot: &'a Bot,
3736    chat_id: ChatId,
3737    action: String,
3738    #[serde(skip_serializing_if = "Option::is_none")]
3739    message_thread_id: Option<i64>,
3740    #[serde(skip_serializing_if = "Option::is_none")]
3741    business_connection_id: Option<String>,
3742}
3743
3744impl<'a> SendChatActionBuilder<'a> {
3745    /// Sets the `message_thread_id` parameter.
3746    pub fn message_thread_id(mut self, id: i64) -> Self {
3747        self.message_thread_id = Some(id);
3748        self
3749    }
3750    /// Sets the `business_connection_id` parameter.
3751    pub fn business_connection_id(mut self, id: impl Into<String>) -> Self {
3752        self.business_connection_id = Some(id.into());
3753        self
3754    }
3755
3756    /// Sends the request to the Telegram Bot API.
3757    pub async fn send(self) -> Result<bool> {
3758        let payload = serde_json::to_vec(&self)?;
3759        self.bot.do_post_json("sendChatAction", &payload).await
3760    }
3761}
3762
3763impl_into_future!(SendChatActionBuilder, bool);
3764
3765// =========================================================================
3766// CopyMessageBuilder
3767// =========================================================================
3768
3769/// Builder for the [`copyMessage`] API method.
3770#[derive(Serialize)]
3771pub struct CopyMessageBuilder<'a> {
3772    #[serde(skip)]
3773    bot: &'a Bot,
3774    chat_id: ChatId,
3775    from_chat_id: ChatId,
3776    message_id: i64,
3777    #[serde(skip_serializing_if = "Option::is_none")]
3778    caption: Option<String>,
3779    #[serde(skip_serializing_if = "Option::is_none")]
3780    parse_mode: Option<String>,
3781    #[serde(skip_serializing_if = "Option::is_none")]
3782    caption_entities: Option<Vec<message_entity::MessageEntity>>,
3783    #[serde(skip_serializing_if = "Option::is_none")]
3784    disable_notification: Option<bool>,
3785    #[serde(skip_serializing_if = "Option::is_none")]
3786    protect_content: Option<bool>,
3787    #[serde(skip_serializing_if = "Option::is_none")]
3788    reply_parameters: Option<reply::ReplyParameters>,
3789    #[serde(skip_serializing_if = "Option::is_none")]
3790    reply_markup: Option<serde_json::Value>,
3791    #[serde(skip_serializing_if = "Option::is_none")]
3792    message_thread_id: Option<i64>,
3793    #[serde(skip_serializing_if = "Option::is_none")]
3794    show_caption_above_media: Option<bool>,
3795    #[serde(skip_serializing_if = "Option::is_none")]
3796    allow_paid_broadcast: Option<bool>,
3797    #[serde(skip_serializing_if = "Option::is_none")]
3798    video_start_timestamp: Option<i64>,
3799    #[serde(skip_serializing_if = "Option::is_none")]
3800    direct_messages_topic_id: Option<i64>,
3801    #[serde(skip_serializing_if = "Option::is_none")]
3802    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
3803    #[serde(skip_serializing_if = "Option::is_none")]
3804    message_effect_id: Option<String>,
3805}
3806
3807impl<'a> CopyMessageBuilder<'a> {
3808    /// Sets the `caption` parameter.
3809    pub fn caption(mut self, val: impl Into<String>) -> Self {
3810        self.caption = Some(val.into());
3811        self
3812    }
3813    /// Sets the `parse_mode` parameter.
3814    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
3815        self.parse_mode = Some(val.into());
3816        self
3817    }
3818    /// Sets the `caption_entities` parameter.
3819    pub fn caption_entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
3820        self.caption_entities = Some(val);
3821        self
3822    }
3823    /// Sets the `disable_notification` parameter.
3824    pub fn disable_notification(mut self, val: bool) -> Self {
3825        self.disable_notification = Some(val);
3826        self
3827    }
3828    /// Sets the `protect_content` parameter.
3829    pub fn protect_content(mut self, val: bool) -> Self {
3830        self.protect_content = Some(val);
3831        self
3832    }
3833    /// Sets the `reply_parameters` parameter.
3834    pub fn reply_parameters(mut self, val: reply::ReplyParameters) -> Self {
3835        self.reply_parameters = Some(val);
3836        self
3837    }
3838    /// Sets the `reply_markup` parameter.
3839    pub fn reply_markup(mut self, val: serde_json::Value) -> Self {
3840        self.reply_markup = Some(val);
3841        self
3842    }
3843    /// Sets the `message_thread_id` parameter.
3844    pub fn message_thread_id(mut self, val: i64) -> Self {
3845        self.message_thread_id = Some(val);
3846        self
3847    }
3848    /// Sets the `show_caption_above_media` parameter.
3849    pub fn show_caption_above_media(mut self, val: bool) -> Self {
3850        self.show_caption_above_media = Some(val);
3851        self
3852    }
3853    /// Sets the `allow_paid_broadcast` parameter.
3854    pub fn allow_paid_broadcast(mut self, val: bool) -> Self {
3855        self.allow_paid_broadcast = Some(val);
3856        self
3857    }
3858    /// Sets the `video_start_timestamp` parameter.
3859    pub fn video_start_timestamp(mut self, val: i64) -> Self {
3860        self.video_start_timestamp = Some(val);
3861        self
3862    }
3863    /// Sets the `direct_messages_topic_id` parameter.
3864    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
3865        self.direct_messages_topic_id = Some(val);
3866        self
3867    }
3868    /// Sets the `suggested_post_parameters` parameter.
3869    pub fn suggested_post_parameters(
3870        mut self,
3871        val: suggested_post::SuggestedPostParameters,
3872    ) -> Self {
3873        self.suggested_post_parameters = Some(val);
3874        self
3875    }
3876    /// Sets the `message_effect_id` parameter.
3877    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
3878        self.message_effect_id = Some(val.into());
3879        self
3880    }
3881
3882    /// Sends the request to the Telegram Bot API.
3883    pub async fn send(self) -> Result<message_id::MessageId> {
3884        let payload = serde_json::to_vec(&self)?;
3885        self.bot.do_post_json("copyMessage", &payload).await
3886    }
3887}
3888
3889impl_into_future!(CopyMessageBuilder, message_id::MessageId);
3890
3891// =========================================================================
3892// CopyMessagesBuilder
3893// =========================================================================
3894
3895/// Builder for the [`copyMessages`] API method.
3896#[derive(Serialize)]
3897pub struct CopyMessagesBuilder<'a> {
3898    #[serde(skip)]
3899    bot: &'a Bot,
3900    chat_id: ChatId,
3901    from_chat_id: ChatId,
3902    message_ids: Vec<i64>,
3903    #[serde(skip_serializing_if = "Option::is_none")]
3904    disable_notification: Option<bool>,
3905    #[serde(skip_serializing_if = "Option::is_none")]
3906    protect_content: Option<bool>,
3907    #[serde(skip_serializing_if = "Option::is_none")]
3908    message_thread_id: Option<i64>,
3909    #[serde(skip_serializing_if = "Option::is_none")]
3910    remove_caption: Option<bool>,
3911    #[serde(skip_serializing_if = "Option::is_none")]
3912    direct_messages_topic_id: Option<i64>,
3913}
3914
3915impl<'a> CopyMessagesBuilder<'a> {
3916    /// Sets the `disable_notification` parameter.
3917    pub fn disable_notification(mut self, val: bool) -> Self {
3918        self.disable_notification = Some(val);
3919        self
3920    }
3921    /// Sets the `protect_content` parameter.
3922    pub fn protect_content(mut self, val: bool) -> Self {
3923        self.protect_content = Some(val);
3924        self
3925    }
3926    /// Sets the `message_thread_id` parameter.
3927    pub fn message_thread_id(mut self, val: i64) -> Self {
3928        self.message_thread_id = Some(val);
3929        self
3930    }
3931    /// Sets the `remove_caption` parameter.
3932    pub fn remove_caption(mut self, val: bool) -> Self {
3933        self.remove_caption = Some(val);
3934        self
3935    }
3936    /// Sets the `direct_messages_topic_id` parameter.
3937    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
3938        self.direct_messages_topic_id = Some(val);
3939        self
3940    }
3941
3942    /// Sends the request to the Telegram Bot API.
3943    pub async fn send(self) -> Result<Vec<message_id::MessageId>> {
3944        let payload = serde_json::to_vec(&self)?;
3945        self.bot.do_post_json("copyMessages", &payload).await
3946    }
3947}
3948
3949impl_into_future!(CopyMessagesBuilder, Vec<message_id::MessageId>);
3950
3951// =========================================================================
3952// DeleteMessageBuilder
3953// =========================================================================
3954
3955/// Builder for the [`deleteMessage`] API method.
3956#[derive(Serialize)]
3957pub struct DeleteMessageBuilder<'a> {
3958    #[serde(skip)]
3959    bot: &'a Bot,
3960    chat_id: ChatId,
3961    message_id: i64,
3962}
3963
3964impl<'a> DeleteMessageBuilder<'a> {
3965    /// Sends the request to the Telegram Bot API.
3966    pub async fn send(self) -> Result<bool> {
3967        let payload = serde_json::to_vec(&self)?;
3968        self.bot.do_post_json("deleteMessage", &payload).await
3969    }
3970}
3971
3972impl_into_future!(DeleteMessageBuilder, bool);
3973
3974// =========================================================================
3975// DeleteMessagesBuilder
3976// =========================================================================
3977
3978/// Builder for the [`deleteMessages`] API method.
3979#[derive(Serialize)]
3980pub struct DeleteMessagesBuilder<'a> {
3981    #[serde(skip)]
3982    bot: &'a Bot,
3983    chat_id: ChatId,
3984    message_ids: Vec<i64>,
3985}
3986
3987impl<'a> DeleteMessagesBuilder<'a> {
3988    /// Sends the request to the Telegram Bot API.
3989    pub async fn send(self) -> Result<bool> {
3990        let payload = serde_json::to_vec(&self)?;
3991        self.bot.do_post_json("deleteMessages", &payload).await
3992    }
3993}
3994
3995impl_into_future!(DeleteMessagesBuilder, bool);
3996
3997// =========================================================================
3998// ForwardMessageBuilder
3999// =========================================================================
4000
4001/// Builder for the [`forwardMessage`] API method.
4002#[derive(Serialize)]
4003pub struct ForwardMessageBuilder<'a> {
4004    #[serde(skip)]
4005    bot: &'a Bot,
4006    chat_id: ChatId,
4007    from_chat_id: ChatId,
4008    message_id: i64,
4009    #[serde(skip_serializing_if = "Option::is_none")]
4010    disable_notification: Option<bool>,
4011    #[serde(skip_serializing_if = "Option::is_none")]
4012    protect_content: Option<bool>,
4013    #[serde(skip_serializing_if = "Option::is_none")]
4014    message_thread_id: Option<i64>,
4015    #[serde(skip_serializing_if = "Option::is_none")]
4016    video_start_timestamp: Option<i64>,
4017    #[serde(skip_serializing_if = "Option::is_none")]
4018    direct_messages_topic_id: Option<i64>,
4019    #[serde(skip_serializing_if = "Option::is_none")]
4020    suggested_post_parameters: Option<suggested_post::SuggestedPostParameters>,
4021    #[serde(skip_serializing_if = "Option::is_none")]
4022    message_effect_id: Option<String>,
4023}
4024
4025impl<'a> ForwardMessageBuilder<'a> {
4026    /// Sets the `disable_notification` parameter.
4027    pub fn disable_notification(mut self, val: bool) -> Self {
4028        self.disable_notification = Some(val);
4029        self
4030    }
4031    /// Sets the `protect_content` parameter.
4032    pub fn protect_content(mut self, val: bool) -> Self {
4033        self.protect_content = Some(val);
4034        self
4035    }
4036    /// Sets the `message_thread_id` parameter.
4037    pub fn message_thread_id(mut self, val: i64) -> Self {
4038        self.message_thread_id = Some(val);
4039        self
4040    }
4041    /// Sets the `video_start_timestamp` parameter.
4042    pub fn video_start_timestamp(mut self, val: i64) -> Self {
4043        self.video_start_timestamp = Some(val);
4044        self
4045    }
4046    /// Sets the `direct_messages_topic_id` parameter.
4047    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
4048        self.direct_messages_topic_id = Some(val);
4049        self
4050    }
4051    /// Sets the `suggested_post_parameters` parameter.
4052    pub fn suggested_post_parameters(
4053        mut self,
4054        val: suggested_post::SuggestedPostParameters,
4055    ) -> Self {
4056        self.suggested_post_parameters = Some(val);
4057        self
4058    }
4059    /// Sets the `message_effect_id` parameter.
4060    pub fn message_effect_id(mut self, val: impl Into<String>) -> Self {
4061        self.message_effect_id = Some(val.into());
4062        self
4063    }
4064
4065    /// Sends the request to the Telegram Bot API.
4066    pub async fn send(self) -> Result<message::Message> {
4067        let payload = serde_json::to_vec(&self)?;
4068        self.bot.do_post_json("forwardMessage", &payload).await
4069    }
4070}
4071
4072impl_into_future!(ForwardMessageBuilder, message::Message);
4073
4074// =========================================================================
4075// ForwardMessagesBuilder
4076// =========================================================================
4077
4078/// Builder for the [`forwardMessages`] API method.
4079#[derive(Serialize)]
4080pub struct ForwardMessagesBuilder<'a> {
4081    #[serde(skip)]
4082    bot: &'a Bot,
4083    chat_id: ChatId,
4084    from_chat_id: ChatId,
4085    message_ids: Vec<i64>,
4086    #[serde(skip_serializing_if = "Option::is_none")]
4087    disable_notification: Option<bool>,
4088    #[serde(skip_serializing_if = "Option::is_none")]
4089    protect_content: Option<bool>,
4090    #[serde(skip_serializing_if = "Option::is_none")]
4091    message_thread_id: Option<i64>,
4092    #[serde(skip_serializing_if = "Option::is_none")]
4093    direct_messages_topic_id: Option<i64>,
4094}
4095
4096impl<'a> ForwardMessagesBuilder<'a> {
4097    /// Sets the `disable_notification` parameter.
4098    pub fn disable_notification(mut self, val: bool) -> Self {
4099        self.disable_notification = Some(val);
4100        self
4101    }
4102    /// Sets the `protect_content` parameter.
4103    pub fn protect_content(mut self, val: bool) -> Self {
4104        self.protect_content = Some(val);
4105        self
4106    }
4107    /// Sets the `message_thread_id` parameter.
4108    pub fn message_thread_id(mut self, val: i64) -> Self {
4109        self.message_thread_id = Some(val);
4110        self
4111    }
4112    /// Sets the `direct_messages_topic_id` parameter.
4113    pub fn direct_messages_topic_id(mut self, val: i64) -> Self {
4114        self.direct_messages_topic_id = Some(val);
4115        self
4116    }
4117
4118    /// Sends the request to the Telegram Bot API.
4119    pub async fn send(self) -> Result<Vec<message_id::MessageId>> {
4120        let payload = serde_json::to_vec(&self)?;
4121        self.bot.do_post_json("forwardMessages", &payload).await
4122    }
4123}
4124
4125impl_into_future!(ForwardMessagesBuilder, Vec<message_id::MessageId>);
4126
4127// =========================================================================
4128// SendMessageDraftBuilder
4129// =========================================================================
4130
4131/// Builder for the [`sendMessageDraft`] API method.
4132#[derive(Serialize)]
4133pub struct SendMessageDraftBuilder<'a> {
4134    #[serde(skip)]
4135    bot: &'a Bot,
4136    chat_id: i64,
4137    draft_id: i64,
4138    text: String,
4139    #[serde(skip_serializing_if = "Option::is_none")]
4140    message_thread_id: Option<i64>,
4141    #[serde(skip_serializing_if = "Option::is_none")]
4142    parse_mode: Option<String>,
4143    #[serde(skip_serializing_if = "Option::is_none")]
4144    entities: Option<Vec<message_entity::MessageEntity>>,
4145}
4146
4147impl<'a> SendMessageDraftBuilder<'a> {
4148    /// Sets the `message_thread_id` parameter.
4149    pub fn message_thread_id(mut self, val: i64) -> Self {
4150        self.message_thread_id = Some(val);
4151        self
4152    }
4153    /// Sets the `parse_mode` parameter.
4154    pub fn parse_mode(mut self, val: impl Into<String>) -> Self {
4155        self.parse_mode = Some(val.into());
4156        self
4157    }
4158    /// Sets the `entities` parameter.
4159    pub fn entities(mut self, val: Vec<message_entity::MessageEntity>) -> Self {
4160        self.entities = Some(val);
4161        self
4162    }
4163
4164    /// Sends the request to the Telegram Bot API.
4165    pub async fn send(self) -> Result<bool> {
4166        let payload = serde_json::to_vec(&self)?;
4167        self.bot.do_post_json("sendMessageDraft", &payload).await
4168    }
4169}
4170
4171impl_into_future!(SendMessageDraftBuilder, bool);
4172
4173// =========================================================================
4174// LeaveChatBuilder
4175// =========================================================================
4176
4177/// Builder for the [`leaveChat`] API method.
4178#[derive(Serialize)]
4179pub struct LeaveChatBuilder<'a> {
4180    #[serde(skip)]
4181    bot: &'a Bot,
4182    chat_id: ChatId,
4183}
4184
4185impl<'a> LeaveChatBuilder<'a> {
4186    /// Sends the request to the Telegram Bot API.
4187    pub async fn send(self) -> Result<bool> {
4188        let payload = serde_json::to_vec(&self)?;
4189        self.bot.do_post_json("leaveChat", &payload).await
4190    }
4191}
4192
4193impl_into_future!(LeaveChatBuilder, bool);
4194
4195// =========================================================================
4196// GetChatBuilder
4197// =========================================================================
4198
4199/// Builder for the [`getChat`] API method.
4200#[derive(Serialize)]
4201pub struct GetChatBuilder<'a> {
4202    #[serde(skip)]
4203    bot: &'a Bot,
4204    chat_id: ChatId,
4205}
4206
4207impl<'a> GetChatBuilder<'a> {
4208    /// Sends the request to the Telegram Bot API.
4209    pub async fn send(self) -> Result<chat_full_info::ChatFullInfo> {
4210        let payload = serde_json::to_vec(&self)?;
4211        self.bot.do_post_json("getChat", &payload).await
4212    }
4213}
4214
4215impl_into_future!(GetChatBuilder, chat_full_info::ChatFullInfo);
4216
4217// =========================================================================
4218// GetChatAdministratorsBuilder
4219// =========================================================================
4220
4221/// Builder for the [`getChatAdministrators`] API method.
4222#[derive(Serialize)]
4223pub struct GetChatAdministratorsBuilder<'a> {
4224    #[serde(skip)]
4225    bot: &'a Bot,
4226    chat_id: ChatId,
4227}
4228
4229impl<'a> GetChatAdministratorsBuilder<'a> {
4230    /// Sends the request to the Telegram Bot API.
4231    pub async fn send(self) -> Result<Vec<chat_member::ChatMember>> {
4232        let payload = serde_json::to_vec(&self)?;
4233        self.bot
4234            .do_post_json("getChatAdministrators", &payload)
4235            .await
4236    }
4237}
4238
4239impl_into_future!(GetChatAdministratorsBuilder, Vec<chat_member::ChatMember>);
4240
4241// =========================================================================
4242// GetChatMemberCountBuilder
4243// =========================================================================
4244
4245/// Builder for the [`getChatMemberCount`] API method.
4246#[derive(Serialize)]
4247pub struct GetChatMemberCountBuilder<'a> {
4248    #[serde(skip)]
4249    bot: &'a Bot,
4250    chat_id: ChatId,
4251}
4252
4253impl<'a> GetChatMemberCountBuilder<'a> {
4254    /// Sends the request to the Telegram Bot API.
4255    pub async fn send(self) -> Result<i64> {
4256        let payload = serde_json::to_vec(&self)?;
4257        self.bot.do_post_json("getChatMemberCount", &payload).await
4258    }
4259}
4260
4261impl_into_future!(GetChatMemberCountBuilder, i64);
4262
4263// =========================================================================
4264// GetChatMemberBuilder
4265// =========================================================================
4266
4267/// Builder for the [`getChatMember`] API method.
4268#[derive(Serialize)]
4269pub struct GetChatMemberBuilder<'a> {
4270    #[serde(skip)]
4271    bot: &'a Bot,
4272    chat_id: ChatId,
4273    user_id: i64,
4274}
4275
4276impl<'a> GetChatMemberBuilder<'a> {
4277    /// Sends the request to the Telegram Bot API.
4278    pub async fn send(self) -> Result<chat_member::ChatMember> {
4279        let payload = serde_json::to_vec(&self)?;
4280        self.bot.do_post_json("getChatMember", &payload).await
4281    }
4282}
4283
4284impl_into_future!(GetChatMemberBuilder, chat_member::ChatMember);
4285
4286// =========================================================================
4287// BanChatMemberBuilder
4288// =========================================================================
4289
4290/// Builder for the [`banChatMember`] API method.
4291#[derive(Serialize)]
4292pub struct BanChatMemberBuilder<'a> {
4293    #[serde(skip)]
4294    bot: &'a Bot,
4295    chat_id: ChatId,
4296    user_id: i64,
4297    #[serde(skip_serializing_if = "Option::is_none")]
4298    until_date: Option<i64>,
4299    #[serde(skip_serializing_if = "Option::is_none")]
4300    revoke_messages: Option<bool>,
4301}
4302
4303impl<'a> BanChatMemberBuilder<'a> {
4304    /// Sets the `until_date` parameter.
4305    pub fn until_date(mut self, val: i64) -> Self {
4306        self.until_date = Some(val);
4307        self
4308    }
4309    /// Sets the `revoke_messages` parameter.
4310    pub fn revoke_messages(mut self, val: bool) -> Self {
4311        self.revoke_messages = Some(val);
4312        self
4313    }
4314
4315    /// Sends the request to the Telegram Bot API.
4316    pub async fn send(self) -> Result<bool> {
4317        let payload = serde_json::to_vec(&self)?;
4318        self.bot.do_post_json("banChatMember", &payload).await
4319    }
4320}
4321
4322impl_into_future!(BanChatMemberBuilder, bool);
4323
4324// =========================================================================
4325// UnbanChatMemberBuilder
4326// =========================================================================
4327
4328/// Builder for the [`unbanChatMember`] API method.
4329#[derive(Serialize)]
4330pub struct UnbanChatMemberBuilder<'a> {
4331    #[serde(skip)]
4332    bot: &'a Bot,
4333    chat_id: ChatId,
4334    user_id: i64,
4335    #[serde(skip_serializing_if = "Option::is_none")]
4336    only_if_banned: Option<bool>,
4337}
4338
4339impl<'a> UnbanChatMemberBuilder<'a> {
4340    /// Sets the `only_if_banned` parameter.
4341    pub fn only_if_banned(mut self, val: bool) -> Self {
4342        self.only_if_banned = Some(val);
4343        self
4344    }
4345
4346    /// Sends the request to the Telegram Bot API.
4347    pub async fn send(self) -> Result<bool> {
4348        let payload = serde_json::to_vec(&self)?;
4349        self.bot.do_post_json("unbanChatMember", &payload).await
4350    }
4351}
4352
4353impl_into_future!(UnbanChatMemberBuilder, bool);
4354
4355// =========================================================================
4356// BanChatSenderChatBuilder
4357// =========================================================================
4358
4359/// Builder for the [`banChatSenderChat`] API method.
4360#[derive(Serialize)]
4361pub struct BanChatSenderChatBuilder<'a> {
4362    #[serde(skip)]
4363    bot: &'a Bot,
4364    chat_id: ChatId,
4365    sender_chat_id: i64,
4366}
4367
4368impl<'a> BanChatSenderChatBuilder<'a> {
4369    /// Sends the request to the Telegram Bot API.
4370    pub async fn send(self) -> Result<bool> {
4371        let payload = serde_json::to_vec(&self)?;
4372        self.bot.do_post_json("banChatSenderChat", &payload).await
4373    }
4374}
4375
4376impl_into_future!(BanChatSenderChatBuilder, bool);
4377
4378// =========================================================================
4379// UnbanChatSenderChatBuilder
4380// =========================================================================
4381
4382/// Builder for the [`unbanChatSenderChat`] API method.
4383#[derive(Serialize)]
4384pub struct UnbanChatSenderChatBuilder<'a> {
4385    #[serde(skip)]
4386    bot: &'a Bot,
4387    chat_id: ChatId,
4388    sender_chat_id: i64,
4389}
4390
4391impl<'a> UnbanChatSenderChatBuilder<'a> {
4392    /// Sends the request to the Telegram Bot API.
4393    pub async fn send(self) -> Result<bool> {
4394        let payload = serde_json::to_vec(&self)?;
4395        self.bot.do_post_json("unbanChatSenderChat", &payload).await
4396    }
4397}
4398
4399impl_into_future!(UnbanChatSenderChatBuilder, bool);
4400
4401// =========================================================================
4402// RestrictChatMemberBuilder
4403// =========================================================================
4404
4405/// Builder for the [`restrictChatMember`] API method.
4406#[derive(Serialize)]
4407pub struct RestrictChatMemberBuilder<'a> {
4408    #[serde(skip)]
4409    bot: &'a Bot,
4410    chat_id: ChatId,
4411    user_id: i64,
4412    permissions: chat_permissions::ChatPermissions,
4413    #[serde(skip_serializing_if = "Option::is_none")]
4414    until_date: Option<i64>,
4415    #[serde(skip_serializing_if = "Option::is_none")]
4416    use_independent_chat_permissions: Option<bool>,
4417}
4418
4419impl<'a> RestrictChatMemberBuilder<'a> {
4420    /// Sets the `until_date` parameter.
4421    pub fn until_date(mut self, val: i64) -> Self {
4422        self.until_date = Some(val);
4423        self
4424    }
4425    /// Sets the `use_independent_chat_permissions` parameter.
4426    pub fn use_independent_chat_permissions(mut self, val: bool) -> Self {
4427        self.use_independent_chat_permissions = Some(val);
4428        self
4429    }
4430
4431    /// Sends the request to the Telegram Bot API.
4432    pub async fn send(self) -> Result<bool> {
4433        let payload = serde_json::to_vec(&self)?;
4434        self.bot.do_post_json("restrictChatMember", &payload).await
4435    }
4436}
4437
4438impl_into_future!(RestrictChatMemberBuilder, bool);
4439
4440// =========================================================================
4441// PromoteChatMemberBuilder
4442// =========================================================================
4443
4444/// Builder for the [`promoteChatMember`] API method.
4445#[derive(Serialize)]
4446pub struct PromoteChatMemberBuilder<'a> {
4447    #[serde(skip)]
4448    bot: &'a Bot,
4449    chat_id: ChatId,
4450    user_id: i64,
4451    #[serde(skip_serializing_if = "Option::is_none")]
4452    is_anonymous: Option<bool>,
4453    #[serde(skip_serializing_if = "Option::is_none")]
4454    can_manage_chat: Option<bool>,
4455    #[serde(skip_serializing_if = "Option::is_none")]
4456    can_post_messages: Option<bool>,
4457    #[serde(skip_serializing_if = "Option::is_none")]
4458    can_edit_messages: Option<bool>,
4459    #[serde(skip_serializing_if = "Option::is_none")]
4460    can_delete_messages: Option<bool>,
4461    #[serde(skip_serializing_if = "Option::is_none")]
4462    can_manage_video_chats: Option<bool>,
4463    #[serde(skip_serializing_if = "Option::is_none")]
4464    can_restrict_members: Option<bool>,
4465    #[serde(skip_serializing_if = "Option::is_none")]
4466    can_promote_members: Option<bool>,
4467    #[serde(skip_serializing_if = "Option::is_none")]
4468    can_change_info: Option<bool>,
4469    #[serde(skip_serializing_if = "Option::is_none")]
4470    can_invite_users: Option<bool>,
4471    #[serde(skip_serializing_if = "Option::is_none")]
4472    can_pin_messages: Option<bool>,
4473    #[serde(skip_serializing_if = "Option::is_none")]
4474    can_manage_topics: Option<bool>,
4475    #[serde(skip_serializing_if = "Option::is_none")]
4476    can_post_stories: Option<bool>,
4477    #[serde(skip_serializing_if = "Option::is_none")]
4478    can_edit_stories: Option<bool>,
4479    #[serde(skip_serializing_if = "Option::is_none")]
4480    can_delete_stories: Option<bool>,
4481    #[serde(skip_serializing_if = "Option::is_none")]
4482    can_manage_direct_messages: Option<bool>,
4483    #[serde(skip_serializing_if = "Option::is_none")]
4484    can_manage_tags: Option<bool>,
4485}
4486
4487impl<'a> PromoteChatMemberBuilder<'a> {
4488    /// Sets the `is_anonymous` parameter.
4489    pub fn is_anonymous(mut self, val: bool) -> Self {
4490        self.is_anonymous = Some(val);
4491        self
4492    }
4493    /// Sets the `can_manage_chat` parameter.
4494    pub fn can_manage_chat(mut self, val: bool) -> Self {
4495        self.can_manage_chat = Some(val);
4496        self
4497    }
4498    /// Sets the `can_post_messages` parameter.
4499    pub fn can_post_messages(mut self, val: bool) -> Self {
4500        self.can_post_messages = Some(val);
4501        self
4502    }
4503    /// Sets the `can_edit_messages` parameter.
4504    pub fn can_edit_messages(mut self, val: bool) -> Self {
4505        self.can_edit_messages = Some(val);
4506        self
4507    }
4508    /// Sets the `can_delete_messages` parameter.
4509    pub fn can_delete_messages(mut self, val: bool) -> Self {
4510        self.can_delete_messages = Some(val);
4511        self
4512    }
4513    /// Sets the `can_manage_video_chats` parameter.
4514    pub fn can_manage_video_chats(mut self, val: bool) -> Self {
4515        self.can_manage_video_chats = Some(val);
4516        self
4517    }
4518    /// Sets the `can_restrict_members` parameter.
4519    pub fn can_restrict_members(mut self, val: bool) -> Self {
4520        self.can_restrict_members = Some(val);
4521        self
4522    }
4523    /// Sets the `can_promote_members` parameter.
4524    pub fn can_promote_members(mut self, val: bool) -> Self {
4525        self.can_promote_members = Some(val);
4526        self
4527    }
4528    /// Sets the `can_change_info` parameter.
4529    pub fn can_change_info(mut self, val: bool) -> Self {
4530        self.can_change_info = Some(val);
4531        self
4532    }
4533    /// Sets the `can_invite_users` parameter.
4534    pub fn can_invite_users(mut self, val: bool) -> Self {
4535        self.can_invite_users = Some(val);
4536        self
4537    }
4538    /// Sets the `can_pin_messages` parameter.
4539    pub fn can_pin_messages(mut self, val: bool) -> Self {
4540        self.can_pin_messages = Some(val);
4541        self
4542    }
4543    /// Sets the `can_manage_topics` parameter.
4544    pub fn can_manage_topics(mut self, val: bool) -> Self {
4545        self.can_manage_topics = Some(val);
4546        self
4547    }
4548    /// Sets the `can_post_stories` parameter.
4549    pub fn can_post_stories(mut self, val: bool) -> Self {
4550        self.can_post_stories = Some(val);
4551        self
4552    }
4553    /// Sets the `can_edit_stories` parameter.
4554    pub fn can_edit_stories(mut self, val: bool) -> Self {
4555        self.can_edit_stories = Some(val);
4556        self
4557    }
4558    /// Sets the `can_delete_stories` parameter.
4559    pub fn can_delete_stories(mut self, val: bool) -> Self {
4560        self.can_delete_stories = Some(val);
4561        self
4562    }
4563    /// Sets the `can_manage_direct_messages` parameter.
4564    pub fn can_manage_direct_messages(mut self, val: bool) -> Self {
4565        self.can_manage_direct_messages = Some(val);
4566        self
4567    }
4568    /// Sets the `can_manage_tags` parameter.
4569    pub fn can_manage_tags(mut self, val: bool) -> Self {
4570        self.can_manage_tags = Some(val);
4571        self
4572    }
4573
4574    /// Sends the request to the Telegram Bot API.
4575    pub async fn send(self) -> Result<bool> {
4576        let payload = serde_json::to_vec(&self)?;
4577        self.bot.do_post_json("promoteChatMember", &payload).await
4578    }
4579}
4580
4581impl_into_future!(PromoteChatMemberBuilder, bool);
4582
4583// =========================================================================
4584// SetChatAdministratorCustomTitleBuilder
4585// =========================================================================
4586
4587/// Builder for the [`setChatAdministratorCustomTitle`] API method.
4588#[derive(Serialize)]
4589pub struct SetChatAdministratorCustomTitleBuilder<'a> {
4590    #[serde(skip)]
4591    bot: &'a Bot,
4592    chat_id: ChatId,
4593    user_id: i64,
4594    custom_title: String,
4595}
4596
4597impl<'a> SetChatAdministratorCustomTitleBuilder<'a> {
4598    /// Sends the request to the Telegram Bot API.
4599    pub async fn send(self) -> Result<bool> {
4600        let payload = serde_json::to_vec(&self)?;
4601        self.bot
4602            .do_post_json("setChatAdministratorCustomTitle", &payload)
4603            .await
4604    }
4605}
4606
4607impl_into_future!(SetChatAdministratorCustomTitleBuilder, bool);
4608
4609// =========================================================================
4610// SetChatPermissionsBuilder
4611// =========================================================================
4612
4613/// Builder for the [`setChatPermissions`] API method.
4614#[derive(Serialize)]
4615pub struct SetChatPermissionsBuilder<'a> {
4616    #[serde(skip)]
4617    bot: &'a Bot,
4618    chat_id: ChatId,
4619    permissions: chat_permissions::ChatPermissions,
4620    #[serde(skip_serializing_if = "Option::is_none")]
4621    use_independent_chat_permissions: Option<bool>,
4622}
4623
4624impl<'a> SetChatPermissionsBuilder<'a> {
4625    /// Sets the `use_independent_chat_permissions` parameter.
4626    pub fn use_independent_chat_permissions(mut self, val: bool) -> Self {
4627        self.use_independent_chat_permissions = Some(val);
4628        self
4629    }
4630
4631    /// Sends the request to the Telegram Bot API.
4632    pub async fn send(self) -> Result<bool> {
4633        let payload = serde_json::to_vec(&self)?;
4634        self.bot.do_post_json("setChatPermissions", &payload).await
4635    }
4636}
4637
4638impl_into_future!(SetChatPermissionsBuilder, bool);
4639
4640// =========================================================================
4641// SetChatPhotoBuilder
4642// =========================================================================
4643
4644/// Builder for the [`setChatPhoto`] API method.
4645///
4646/// This builder uses multipart form data since it uploads a file.
4647pub struct SetChatPhotoBuilder<'a> {
4648    bot: &'a Bot,
4649    chat_id: ChatId,
4650    photo: files::input_file::InputFile,
4651}
4652
4653impl<'a> SetChatPhotoBuilder<'a> {
4654    /// Sends the request to the Telegram Bot API.
4655    pub async fn send(self) -> Result<bool> {
4656        let params = vec![
4657            RequestParameter::new("chat_id", serde_json::to_value(&self.chat_id)?),
4658            input_file_param("photo", self.photo),
4659        ];
4660        self.bot.do_api_request("setChatPhoto", params).await
4661    }
4662}
4663
4664impl_into_future!(SetChatPhotoBuilder, bool);
4665
4666// =========================================================================
4667// DeleteChatPhotoBuilder
4668// =========================================================================
4669
4670/// Builder for the [`deleteChatPhoto`] API method.
4671#[derive(Serialize)]
4672pub struct DeleteChatPhotoBuilder<'a> {
4673    #[serde(skip)]
4674    bot: &'a Bot,
4675    chat_id: ChatId,
4676}
4677
4678impl<'a> DeleteChatPhotoBuilder<'a> {
4679    /// Sends the request to the Telegram Bot API.
4680    pub async fn send(self) -> Result<bool> {
4681        let payload = serde_json::to_vec(&self)?;
4682        self.bot.do_post_json("deleteChatPhoto", &payload).await
4683    }
4684}
4685
4686impl_into_future!(DeleteChatPhotoBuilder, bool);
4687
4688// =========================================================================
4689// SetChatTitleBuilder
4690// =========================================================================
4691
4692/// Builder for the [`setChatTitle`] API method.
4693#[derive(Serialize)]
4694pub struct SetChatTitleBuilder<'a> {
4695    #[serde(skip)]
4696    bot: &'a Bot,
4697    chat_id: ChatId,
4698    title: String,
4699}
4700
4701impl<'a> SetChatTitleBuilder<'a> {
4702    /// Sends the request to the Telegram Bot API.
4703    pub async fn send(self) -> Result<bool> {
4704        let payload = serde_json::to_vec(&self)?;
4705        self.bot.do_post_json("setChatTitle", &payload).await
4706    }
4707}
4708
4709impl_into_future!(SetChatTitleBuilder, bool);
4710
4711// =========================================================================
4712// SetChatDescriptionBuilder
4713// =========================================================================
4714
4715/// Builder for the [`setChatDescription`] API method.
4716#[derive(Serialize)]
4717pub struct SetChatDescriptionBuilder<'a> {
4718    #[serde(skip)]
4719    bot: &'a Bot,
4720    chat_id: ChatId,
4721    #[serde(skip_serializing_if = "Option::is_none")]
4722    description: Option<String>,
4723}
4724
4725impl<'a> SetChatDescriptionBuilder<'a> {
4726    /// Sets the `description` parameter.
4727    pub fn description(mut self, val: impl Into<String>) -> Self {
4728        self.description = Some(val.into());
4729        self
4730    }
4731
4732    /// Sends the request to the Telegram Bot API.
4733    pub async fn send(self) -> Result<bool> {
4734        let payload = serde_json::to_vec(&self)?;
4735        self.bot.do_post_json("setChatDescription", &payload).await
4736    }
4737}
4738
4739impl_into_future!(SetChatDescriptionBuilder, bool);
4740
4741// =========================================================================
4742// SetChatStickerSetBuilder
4743// =========================================================================
4744
4745/// Builder for the [`setChatStickerSet`] API method.
4746#[derive(Serialize)]
4747pub struct SetChatStickerSetBuilder<'a> {
4748    #[serde(skip)]
4749    bot: &'a Bot,
4750    chat_id: ChatId,
4751    sticker_set_name: String,
4752}
4753
4754impl<'a> SetChatStickerSetBuilder<'a> {
4755    /// Sends the request to the Telegram Bot API.
4756    pub async fn send(self) -> Result<bool> {
4757        let payload = serde_json::to_vec(&self)?;
4758        self.bot.do_post_json("setChatStickerSet", &payload).await
4759    }
4760}
4761
4762impl_into_future!(SetChatStickerSetBuilder, bool);
4763
4764// =========================================================================
4765// DeleteChatStickerSetBuilder
4766// =========================================================================
4767
4768/// Builder for the [`deleteChatStickerSet`] API method.
4769#[derive(Serialize)]
4770pub struct DeleteChatStickerSetBuilder<'a> {
4771    #[serde(skip)]
4772    bot: &'a Bot,
4773    chat_id: ChatId,
4774}
4775
4776impl<'a> DeleteChatStickerSetBuilder<'a> {
4777    /// Sends the request to the Telegram Bot API.
4778    pub async fn send(self) -> Result<bool> {
4779        let payload = serde_json::to_vec(&self)?;
4780        self.bot
4781            .do_post_json("deleteChatStickerSet", &payload)
4782            .await
4783    }
4784}
4785
4786impl_into_future!(DeleteChatStickerSetBuilder, bool);
4787
4788// =========================================================================
4789// SetChatMemberTagBuilder
4790// =========================================================================
4791
4792/// Builder for the [`setChatMemberTag`] API method.
4793#[derive(Serialize)]
4794pub struct SetChatMemberTagBuilder<'a> {
4795    #[serde(skip)]
4796    bot: &'a Bot,
4797    chat_id: ChatId,
4798    user_id: i64,
4799    #[serde(skip_serializing_if = "Option::is_none")]
4800    tag: Option<String>,
4801}
4802
4803impl<'a> SetChatMemberTagBuilder<'a> {
4804    /// Sets the `tag` parameter.
4805    pub fn tag(mut self, val: impl Into<String>) -> Self {
4806        self.tag = Some(val.into());
4807        self
4808    }
4809
4810    /// Sends the request to the Telegram Bot API.
4811    pub async fn send(self) -> Result<bool> {
4812        let payload = serde_json::to_vec(&self)?;
4813        self.bot.do_post_json("setChatMemberTag", &payload).await
4814    }
4815}
4816
4817impl_into_future!(SetChatMemberTagBuilder, bool);
4818
4819// =========================================================================
4820// PinChatMessageBuilder
4821// =========================================================================
4822
4823/// Builder for the [`pinChatMessage`] API method.
4824#[derive(Serialize)]
4825pub struct PinChatMessageBuilder<'a> {
4826    #[serde(skip)]
4827    bot: &'a Bot,
4828    chat_id: ChatId,
4829    message_id: i64,
4830    #[serde(skip_serializing_if = "Option::is_none")]
4831    disable_notification: Option<bool>,
4832    #[serde(skip_serializing_if = "Option::is_none")]
4833    business_connection_id: Option<String>,
4834}
4835
4836impl<'a> PinChatMessageBuilder<'a> {
4837    /// Sets the `disable_notification` parameter.
4838    pub fn disable_notification(mut self, val: bool) -> Self {
4839        self.disable_notification = Some(val);
4840        self
4841    }
4842    /// Sets the `business_connection_id` parameter.
4843    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
4844        self.business_connection_id = Some(val.into());
4845        self
4846    }
4847
4848    /// Sends the request to the Telegram Bot API.
4849    pub async fn send(self) -> Result<bool> {
4850        let payload = serde_json::to_vec(&self)?;
4851        self.bot.do_post_json("pinChatMessage", &payload).await
4852    }
4853}
4854
4855impl_into_future!(PinChatMessageBuilder, bool);
4856
4857// =========================================================================
4858// UnpinChatMessageBuilder
4859// =========================================================================
4860
4861/// Builder for the [`unpinChatMessage`] API method.
4862#[derive(Serialize)]
4863pub struct UnpinChatMessageBuilder<'a> {
4864    #[serde(skip)]
4865    bot: &'a Bot,
4866    chat_id: ChatId,
4867    #[serde(skip_serializing_if = "Option::is_none")]
4868    message_id: Option<i64>,
4869    #[serde(skip_serializing_if = "Option::is_none")]
4870    business_connection_id: Option<String>,
4871}
4872
4873impl<'a> UnpinChatMessageBuilder<'a> {
4874    /// Sets the `message_id` parameter.
4875    pub fn message_id(mut self, val: i64) -> Self {
4876        self.message_id = Some(val);
4877        self
4878    }
4879    /// Sets the `business_connection_id` parameter.
4880    pub fn business_connection_id(mut self, val: impl Into<String>) -> Self {
4881        self.business_connection_id = Some(val.into());
4882        self
4883    }
4884
4885    /// Sends the request to the Telegram Bot API.
4886    pub async fn send(self) -> Result<bool> {
4887        let payload = serde_json::to_vec(&self)?;
4888        self.bot.do_post_json("unpinChatMessage", &payload).await
4889    }
4890}
4891
4892impl_into_future!(UnpinChatMessageBuilder, bool);
4893
4894// =========================================================================
4895// UnpinAllChatMessagesBuilder
4896// =========================================================================
4897
4898/// Builder for the [`unpinAllChatMessages`] API method.
4899#[derive(Serialize)]
4900pub struct UnpinAllChatMessagesBuilder<'a> {
4901    #[serde(skip)]
4902    bot: &'a Bot,
4903    chat_id: ChatId,
4904}
4905
4906impl<'a> UnpinAllChatMessagesBuilder<'a> {
4907    /// Sends the request to the Telegram Bot API.
4908    pub async fn send(self) -> Result<bool> {
4909        let payload = serde_json::to_vec(&self)?;
4910        self.bot
4911            .do_post_json("unpinAllChatMessages", &payload)
4912            .await
4913    }
4914}
4915
4916impl_into_future!(UnpinAllChatMessagesBuilder, bool);
4917
4918// =========================================================================
4919// ExportChatInviteLinkBuilder
4920// =========================================================================
4921
4922/// Builder for the [`exportChatInviteLink`] API method.
4923#[derive(Serialize)]
4924pub struct ExportChatInviteLinkBuilder<'a> {
4925    #[serde(skip)]
4926    bot: &'a Bot,
4927    chat_id: ChatId,
4928}
4929
4930impl<'a> ExportChatInviteLinkBuilder<'a> {
4931    /// Sends the request to the Telegram Bot API.
4932    pub async fn send(self) -> Result<String> {
4933        let payload = serde_json::to_vec(&self)?;
4934        self.bot
4935            .do_post_json("exportChatInviteLink", &payload)
4936            .await
4937    }
4938}
4939
4940impl_into_future!(ExportChatInviteLinkBuilder, String);
4941
4942// =========================================================================
4943// CreateChatInviteLinkBuilder
4944// =========================================================================
4945
4946/// Builder for the [`createChatInviteLink`] API method.
4947#[derive(Serialize)]
4948pub struct CreateChatInviteLinkBuilder<'a> {
4949    #[serde(skip)]
4950    bot: &'a Bot,
4951    chat_id: ChatId,
4952    #[serde(skip_serializing_if = "Option::is_none")]
4953    expire_date: Option<i64>,
4954    #[serde(skip_serializing_if = "Option::is_none")]
4955    member_limit: Option<i64>,
4956    #[serde(skip_serializing_if = "Option::is_none")]
4957    name: Option<String>,
4958    #[serde(skip_serializing_if = "Option::is_none")]
4959    creates_join_request: Option<bool>,
4960}
4961
4962impl<'a> CreateChatInviteLinkBuilder<'a> {
4963    /// Sets the `expire_date` parameter.
4964    pub fn expire_date(mut self, val: i64) -> Self {
4965        self.expire_date = Some(val);
4966        self
4967    }
4968    /// Sets the `member_limit` parameter.
4969    pub fn member_limit(mut self, val: i64) -> Self {
4970        self.member_limit = Some(val);
4971        self
4972    }
4973    /// Sets the `name` parameter.
4974    pub fn name(mut self, val: impl Into<String>) -> Self {
4975        self.name = Some(val.into());
4976        self
4977    }
4978    /// Sets the `creates_join_request` parameter.
4979    pub fn creates_join_request(mut self, val: bool) -> Self {
4980        self.creates_join_request = Some(val);
4981        self
4982    }
4983
4984    /// Sends the request to the Telegram Bot API.
4985    pub async fn send(self) -> Result<chat_invite_link::ChatInviteLink> {
4986        let payload = serde_json::to_vec(&self)?;
4987        self.bot
4988            .do_post_json("createChatInviteLink", &payload)
4989            .await
4990    }
4991}
4992
4993impl_into_future!(
4994    CreateChatInviteLinkBuilder,
4995    chat_invite_link::ChatInviteLink
4996);
4997
4998// =========================================================================
4999// EditChatInviteLinkBuilder
5000// =========================================================================
5001
5002/// Builder for the [`editChatInviteLink`] API method.
5003#[derive(Serialize)]
5004pub struct EditChatInviteLinkBuilder<'a> {
5005    #[serde(skip)]
5006    bot: &'a Bot,
5007    chat_id: ChatId,
5008    invite_link: String,
5009    #[serde(skip_serializing_if = "Option::is_none")]
5010    expire_date: Option<i64>,
5011    #[serde(skip_serializing_if = "Option::is_none")]
5012    member_limit: Option<i64>,
5013    #[serde(skip_serializing_if = "Option::is_none")]
5014    name: Option<String>,
5015    #[serde(skip_serializing_if = "Option::is_none")]
5016    creates_join_request: Option<bool>,
5017}
5018
5019impl<'a> EditChatInviteLinkBuilder<'a> {
5020    /// Sets the `expire_date` parameter.
5021    pub fn expire_date(mut self, val: i64) -> Self {
5022        self.expire_date = Some(val);
5023        self
5024    }
5025    /// Sets the `member_limit` parameter.
5026    pub fn member_limit(mut self, val: i64) -> Self {
5027        self.member_limit = Some(val);
5028        self
5029    }
5030    /// Sets the `name` parameter.
5031    pub fn name(mut self, val: impl Into<String>) -> Self {
5032        self.name = Some(val.into());
5033        self
5034    }
5035    /// Sets the `creates_join_request` parameter.
5036    pub fn creates_join_request(mut self, val: bool) -> Self {
5037        self.creates_join_request = Some(val);
5038        self
5039    }
5040
5041    /// Sends the request to the Telegram Bot API.
5042    pub async fn send(self) -> Result<chat_invite_link::ChatInviteLink> {
5043        let payload = serde_json::to_vec(&self)?;
5044        self.bot.do_post_json("editChatInviteLink", &payload).await
5045    }
5046}
5047
5048impl_into_future!(EditChatInviteLinkBuilder, chat_invite_link::ChatInviteLink);
5049
5050// =========================================================================
5051// RevokeChatInviteLinkBuilder
5052// =========================================================================
5053
5054/// Builder for the [`revokeChatInviteLink`] API method.
5055#[derive(Serialize)]
5056pub struct RevokeChatInviteLinkBuilder<'a> {
5057    #[serde(skip)]
5058    bot: &'a Bot,
5059    chat_id: ChatId,
5060    invite_link: String,
5061}
5062
5063impl<'a> RevokeChatInviteLinkBuilder<'a> {
5064    /// Sends the request to the Telegram Bot API.
5065    pub async fn send(self) -> Result<chat_invite_link::ChatInviteLink> {
5066        let payload = serde_json::to_vec(&self)?;
5067        self.bot
5068            .do_post_json("revokeChatInviteLink", &payload)
5069            .await
5070    }
5071}
5072
5073impl_into_future!(
5074    RevokeChatInviteLinkBuilder,
5075    chat_invite_link::ChatInviteLink
5076);
5077
5078// =========================================================================
5079// CreateChatSubscriptionInviteLinkBuilder
5080// =========================================================================
5081
5082/// Builder for the [`createChatSubscriptionInviteLink`] API method.
5083#[derive(Serialize)]
5084pub struct CreateChatSubscriptionInviteLinkBuilder<'a> {
5085    #[serde(skip)]
5086    bot: &'a Bot,
5087    chat_id: ChatId,
5088    subscription_period: i64,
5089    subscription_price: i64,
5090    #[serde(skip_serializing_if = "Option::is_none")]
5091    name: Option<String>,
5092}
5093
5094impl<'a> CreateChatSubscriptionInviteLinkBuilder<'a> {
5095    /// Sets the `name` parameter.
5096    pub fn name(mut self, val: impl Into<String>) -> Self {
5097        self.name = Some(val.into());
5098        self
5099    }
5100
5101    /// Sends the request to the Telegram Bot API.
5102    pub async fn send(self) -> Result<chat_invite_link::ChatInviteLink> {
5103        let payload = serde_json::to_vec(&self)?;
5104        self.bot
5105            .do_post_json("createChatSubscriptionInviteLink", &payload)
5106            .await
5107    }
5108}
5109
5110impl_into_future!(
5111    CreateChatSubscriptionInviteLinkBuilder,
5112    chat_invite_link::ChatInviteLink
5113);
5114
5115// =========================================================================
5116// EditChatSubscriptionInviteLinkBuilder
5117// =========================================================================
5118
5119/// Builder for the [`editChatSubscriptionInviteLink`] API method.
5120#[derive(Serialize)]
5121pub struct EditChatSubscriptionInviteLinkBuilder<'a> {
5122    #[serde(skip)]
5123    bot: &'a Bot,
5124    chat_id: ChatId,
5125    invite_link: String,
5126    #[serde(skip_serializing_if = "Option::is_none")]
5127    name: Option<String>,
5128}
5129
5130impl<'a> EditChatSubscriptionInviteLinkBuilder<'a> {
5131    /// Sets the `name` parameter.
5132    pub fn name(mut self, val: impl Into<String>) -> Self {
5133        self.name = Some(val.into());
5134        self
5135    }
5136
5137    /// Sends the request to the Telegram Bot API.
5138    pub async fn send(self) -> Result<chat_invite_link::ChatInviteLink> {
5139        let payload = serde_json::to_vec(&self)?;
5140        self.bot
5141            .do_post_json("editChatSubscriptionInviteLink", &payload)
5142            .await
5143    }
5144}
5145
5146impl_into_future!(
5147    EditChatSubscriptionInviteLinkBuilder,
5148    chat_invite_link::ChatInviteLink
5149);
5150
5151// =========================================================================
5152// ApproveChatJoinRequestBuilder
5153// =========================================================================
5154
5155/// Builder for the [`approveChatJoinRequest`] API method.
5156#[derive(Serialize)]
5157pub struct ApproveChatJoinRequestBuilder<'a> {
5158    #[serde(skip)]
5159    bot: &'a Bot,
5160    chat_id: ChatId,
5161    user_id: i64,
5162}
5163
5164impl<'a> ApproveChatJoinRequestBuilder<'a> {
5165    /// Sends the request to the Telegram Bot API.
5166    pub async fn send(self) -> Result<bool> {
5167        let payload = serde_json::to_vec(&self)?;
5168        self.bot
5169            .do_post_json("approveChatJoinRequest", &payload)
5170            .await
5171    }
5172}
5173
5174impl_into_future!(ApproveChatJoinRequestBuilder, bool);
5175
5176// =========================================================================
5177// DeclineChatJoinRequestBuilder
5178// =========================================================================
5179
5180/// Builder for the [`declineChatJoinRequest`] API method.
5181#[derive(Serialize)]
5182pub struct DeclineChatJoinRequestBuilder<'a> {
5183    #[serde(skip)]
5184    bot: &'a Bot,
5185    chat_id: ChatId,
5186    user_id: i64,
5187}
5188
5189impl<'a> DeclineChatJoinRequestBuilder<'a> {
5190    /// Sends the request to the Telegram Bot API.
5191    pub async fn send(self) -> Result<bool> {
5192        let payload = serde_json::to_vec(&self)?;
5193        self.bot
5194            .do_post_json("declineChatJoinRequest", &payload)
5195            .await
5196    }
5197}
5198
5199impl_into_future!(DeclineChatJoinRequestBuilder, bool);
5200
5201// =========================================================================
5202// Builder factory methods on Bot for messages and chat methods
5203// =========================================================================
5204
5205impl Bot {
5206    // -- Message methods ---------------------------------------------------
5207
5208    /// Build a `copyMessage` request.
5209    pub fn copy_message(
5210        &self,
5211        chat_id: impl Into<ChatId>,
5212        from_chat_id: impl Into<ChatId>,
5213        message_id: i64,
5214    ) -> CopyMessageBuilder<'_> {
5215        CopyMessageBuilder {
5216            bot: self,
5217            chat_id: chat_id.into(),
5218            from_chat_id: from_chat_id.into(),
5219            message_id,
5220            caption: None,
5221            parse_mode: None,
5222            caption_entities: None,
5223            disable_notification: None,
5224            protect_content: None,
5225            reply_parameters: None,
5226            reply_markup: None,
5227            message_thread_id: None,
5228            show_caption_above_media: None,
5229            allow_paid_broadcast: None,
5230            video_start_timestamp: None,
5231            direct_messages_topic_id: None,
5232            suggested_post_parameters: None,
5233            message_effect_id: None,
5234        }
5235    }
5236
5237    /// Build a `copyMessages` request.
5238    pub fn copy_messages(
5239        &self,
5240        chat_id: impl Into<ChatId>,
5241        from_chat_id: impl Into<ChatId>,
5242        message_ids: Vec<i64>,
5243    ) -> CopyMessagesBuilder<'_> {
5244        CopyMessagesBuilder {
5245            bot: self,
5246            chat_id: chat_id.into(),
5247            from_chat_id: from_chat_id.into(),
5248            message_ids,
5249            disable_notification: None,
5250            protect_content: None,
5251            message_thread_id: None,
5252            remove_caption: None,
5253            direct_messages_topic_id: None,
5254        }
5255    }
5256
5257    /// Build a `deleteMessage` request.
5258    pub fn delete_message(
5259        &self,
5260        chat_id: impl Into<ChatId>,
5261        message_id: i64,
5262    ) -> DeleteMessageBuilder<'_> {
5263        DeleteMessageBuilder {
5264            bot: self,
5265            chat_id: chat_id.into(),
5266            message_id,
5267        }
5268    }
5269
5270    /// Build a `deleteMessages` request.
5271    pub fn delete_messages(
5272        &self,
5273        chat_id: impl Into<ChatId>,
5274        message_ids: Vec<i64>,
5275    ) -> DeleteMessagesBuilder<'_> {
5276        DeleteMessagesBuilder {
5277            bot: self,
5278            chat_id: chat_id.into(),
5279            message_ids,
5280        }
5281    }
5282
5283    /// Build a `forwardMessage` request.
5284    pub fn forward_message(
5285        &self,
5286        chat_id: impl Into<ChatId>,
5287        from_chat_id: impl Into<ChatId>,
5288        message_id: i64,
5289    ) -> ForwardMessageBuilder<'_> {
5290        ForwardMessageBuilder {
5291            bot: self,
5292            chat_id: chat_id.into(),
5293            from_chat_id: from_chat_id.into(),
5294            message_id,
5295            disable_notification: None,
5296            protect_content: None,
5297            message_thread_id: None,
5298            video_start_timestamp: None,
5299            direct_messages_topic_id: None,
5300            suggested_post_parameters: None,
5301            message_effect_id: None,
5302        }
5303    }
5304
5305    /// Build a `forwardMessages` request.
5306    pub fn forward_messages(
5307        &self,
5308        chat_id: impl Into<ChatId>,
5309        from_chat_id: impl Into<ChatId>,
5310        message_ids: Vec<i64>,
5311    ) -> ForwardMessagesBuilder<'_> {
5312        ForwardMessagesBuilder {
5313            bot: self,
5314            chat_id: chat_id.into(),
5315            from_chat_id: from_chat_id.into(),
5316            message_ids,
5317            disable_notification: None,
5318            protect_content: None,
5319            message_thread_id: None,
5320            direct_messages_topic_id: None,
5321        }
5322    }
5323
5324    /// Build a `sendMessageDraft` request.
5325    pub fn send_message_draft(
5326        &self,
5327        chat_id: i64,
5328        draft_id: i64,
5329        text: impl Into<String>,
5330    ) -> SendMessageDraftBuilder<'_> {
5331        SendMessageDraftBuilder {
5332            bot: self,
5333            chat_id,
5334            draft_id,
5335            text: text.into(),
5336            message_thread_id: None,
5337            parse_mode: None,
5338            entities: None,
5339        }
5340    }
5341
5342    // -- Chat management methods -------------------------------------------
5343
5344    /// Build a `leaveChat` request.
5345    pub fn leave_chat(&self, chat_id: impl Into<ChatId>) -> LeaveChatBuilder<'_> {
5346        LeaveChatBuilder {
5347            bot: self,
5348            chat_id: chat_id.into(),
5349        }
5350    }
5351
5352    /// Build a `getChat` request.
5353    pub fn get_chat(&self, chat_id: impl Into<ChatId>) -> GetChatBuilder<'_> {
5354        GetChatBuilder {
5355            bot: self,
5356            chat_id: chat_id.into(),
5357        }
5358    }
5359
5360    /// Build a `getChatAdministrators` request.
5361    pub fn get_chat_administrators(
5362        &self,
5363        chat_id: impl Into<ChatId>,
5364    ) -> GetChatAdministratorsBuilder<'_> {
5365        GetChatAdministratorsBuilder {
5366            bot: self,
5367            chat_id: chat_id.into(),
5368        }
5369    }
5370
5371    /// Build a `getChatMemberCount` request.
5372    pub fn get_chat_member_count(
5373        &self,
5374        chat_id: impl Into<ChatId>,
5375    ) -> GetChatMemberCountBuilder<'_> {
5376        GetChatMemberCountBuilder {
5377            bot: self,
5378            chat_id: chat_id.into(),
5379        }
5380    }
5381
5382    /// Build a `getChatMember` request.
5383    pub fn get_chat_member(
5384        &self,
5385        chat_id: impl Into<ChatId>,
5386        user_id: i64,
5387    ) -> GetChatMemberBuilder<'_> {
5388        GetChatMemberBuilder {
5389            bot: self,
5390            chat_id: chat_id.into(),
5391            user_id,
5392        }
5393    }
5394
5395    /// Build a `banChatMember` request.
5396    pub fn ban_chat_member(
5397        &self,
5398        chat_id: impl Into<ChatId>,
5399        user_id: i64,
5400    ) -> BanChatMemberBuilder<'_> {
5401        BanChatMemberBuilder {
5402            bot: self,
5403            chat_id: chat_id.into(),
5404            user_id,
5405            until_date: None,
5406            revoke_messages: None,
5407        }
5408    }
5409
5410    /// Build an `unbanChatMember` request.
5411    pub fn unban_chat_member(
5412        &self,
5413        chat_id: impl Into<ChatId>,
5414        user_id: i64,
5415    ) -> UnbanChatMemberBuilder<'_> {
5416        UnbanChatMemberBuilder {
5417            bot: self,
5418            chat_id: chat_id.into(),
5419            user_id,
5420            only_if_banned: None,
5421        }
5422    }
5423
5424    /// Build a `banChatSenderChat` request.
5425    pub fn ban_chat_sender_chat(
5426        &self,
5427        chat_id: impl Into<ChatId>,
5428        sender_chat_id: i64,
5429    ) -> BanChatSenderChatBuilder<'_> {
5430        BanChatSenderChatBuilder {
5431            bot: self,
5432            chat_id: chat_id.into(),
5433            sender_chat_id,
5434        }
5435    }
5436
5437    /// Build an `unbanChatSenderChat` request.
5438    pub fn unban_chat_sender_chat(
5439        &self,
5440        chat_id: impl Into<ChatId>,
5441        sender_chat_id: i64,
5442    ) -> UnbanChatSenderChatBuilder<'_> {
5443        UnbanChatSenderChatBuilder {
5444            bot: self,
5445            chat_id: chat_id.into(),
5446            sender_chat_id,
5447        }
5448    }
5449
5450    /// Build a `restrictChatMember` request.
5451    pub fn restrict_chat_member(
5452        &self,
5453        chat_id: impl Into<ChatId>,
5454        user_id: i64,
5455        permissions: chat_permissions::ChatPermissions,
5456    ) -> RestrictChatMemberBuilder<'_> {
5457        RestrictChatMemberBuilder {
5458            bot: self,
5459            chat_id: chat_id.into(),
5460            user_id,
5461            permissions,
5462            until_date: None,
5463            use_independent_chat_permissions: None,
5464        }
5465    }
5466
5467    /// Build a `promoteChatMember` request.
5468    pub fn promote_chat_member(
5469        &self,
5470        chat_id: impl Into<ChatId>,
5471        user_id: i64,
5472    ) -> PromoteChatMemberBuilder<'_> {
5473        PromoteChatMemberBuilder {
5474            bot: self,
5475            chat_id: chat_id.into(),
5476            user_id,
5477            is_anonymous: None,
5478            can_manage_chat: None,
5479            can_post_messages: None,
5480            can_edit_messages: None,
5481            can_delete_messages: None,
5482            can_manage_video_chats: None,
5483            can_restrict_members: None,
5484            can_promote_members: None,
5485            can_change_info: None,
5486            can_invite_users: None,
5487            can_pin_messages: None,
5488            can_manage_topics: None,
5489            can_post_stories: None,
5490            can_edit_stories: None,
5491            can_delete_stories: None,
5492            can_manage_direct_messages: None,
5493            can_manage_tags: None,
5494        }
5495    }
5496
5497    /// Build a `setChatAdministratorCustomTitle` request.
5498    pub fn set_chat_administrator_custom_title(
5499        &self,
5500        chat_id: impl Into<ChatId>,
5501        user_id: i64,
5502        custom_title: impl Into<String>,
5503    ) -> SetChatAdministratorCustomTitleBuilder<'_> {
5504        SetChatAdministratorCustomTitleBuilder {
5505            bot: self,
5506            chat_id: chat_id.into(),
5507            user_id,
5508            custom_title: custom_title.into(),
5509        }
5510    }
5511
5512    /// Build a `setChatPermissions` request.
5513    pub fn set_chat_permissions(
5514        &self,
5515        chat_id: impl Into<ChatId>,
5516        permissions: chat_permissions::ChatPermissions,
5517    ) -> SetChatPermissionsBuilder<'_> {
5518        SetChatPermissionsBuilder {
5519            bot: self,
5520            chat_id: chat_id.into(),
5521            permissions,
5522            use_independent_chat_permissions: None,
5523        }
5524    }
5525
5526    /// Build a `setChatPhoto` request.
5527    pub fn set_chat_photo(
5528        &self,
5529        chat_id: impl Into<ChatId>,
5530        photo: files::input_file::InputFile,
5531    ) -> SetChatPhotoBuilder<'_> {
5532        SetChatPhotoBuilder {
5533            bot: self,
5534            chat_id: chat_id.into(),
5535            photo,
5536        }
5537    }
5538
5539    /// Build a `deleteChatPhoto` request.
5540    pub fn delete_chat_photo(&self, chat_id: impl Into<ChatId>) -> DeleteChatPhotoBuilder<'_> {
5541        DeleteChatPhotoBuilder {
5542            bot: self,
5543            chat_id: chat_id.into(),
5544        }
5545    }
5546
5547    /// Build a `setChatTitle` request.
5548    pub fn set_chat_title(
5549        &self,
5550        chat_id: impl Into<ChatId>,
5551        title: impl Into<String>,
5552    ) -> SetChatTitleBuilder<'_> {
5553        SetChatTitleBuilder {
5554            bot: self,
5555            chat_id: chat_id.into(),
5556            title: title.into(),
5557        }
5558    }
5559
5560    /// Build a `setChatDescription` request.
5561    pub fn set_chat_description(
5562        &self,
5563        chat_id: impl Into<ChatId>,
5564    ) -> SetChatDescriptionBuilder<'_> {
5565        SetChatDescriptionBuilder {
5566            bot: self,
5567            chat_id: chat_id.into(),
5568            description: None,
5569        }
5570    }
5571
5572    /// Build a `setChatStickerSet` request.
5573    pub fn set_chat_sticker_set(
5574        &self,
5575        chat_id: impl Into<ChatId>,
5576        sticker_set_name: impl Into<String>,
5577    ) -> SetChatStickerSetBuilder<'_> {
5578        SetChatStickerSetBuilder {
5579            bot: self,
5580            chat_id: chat_id.into(),
5581            sticker_set_name: sticker_set_name.into(),
5582        }
5583    }
5584
5585    /// Build a `deleteChatStickerSet` request.
5586    pub fn delete_chat_sticker_set(
5587        &self,
5588        chat_id: impl Into<ChatId>,
5589    ) -> DeleteChatStickerSetBuilder<'_> {
5590        DeleteChatStickerSetBuilder {
5591            bot: self,
5592            chat_id: chat_id.into(),
5593        }
5594    }
5595
5596    /// Build a `setChatMemberTag` request.
5597    pub fn set_chat_member_tag(
5598        &self,
5599        chat_id: impl Into<ChatId>,
5600        user_id: i64,
5601    ) -> SetChatMemberTagBuilder<'_> {
5602        SetChatMemberTagBuilder {
5603            bot: self,
5604            chat_id: chat_id.into(),
5605            user_id,
5606            tag: None,
5607        }
5608    }
5609
5610    // -- Chat pinning methods ----------------------------------------------
5611
5612    /// Build a `pinChatMessage` request.
5613    pub fn pin_chat_message(
5614        &self,
5615        chat_id: impl Into<ChatId>,
5616        message_id: i64,
5617    ) -> PinChatMessageBuilder<'_> {
5618        PinChatMessageBuilder {
5619            bot: self,
5620            chat_id: chat_id.into(),
5621            message_id,
5622            disable_notification: None,
5623            business_connection_id: None,
5624        }
5625    }
5626
5627    /// Build an `unpinChatMessage` request.
5628    pub fn unpin_chat_message(&self, chat_id: impl Into<ChatId>) -> UnpinChatMessageBuilder<'_> {
5629        UnpinChatMessageBuilder {
5630            bot: self,
5631            chat_id: chat_id.into(),
5632            message_id: None,
5633            business_connection_id: None,
5634        }
5635    }
5636
5637    /// Build an `unpinAllChatMessages` request.
5638    pub fn unpin_all_chat_messages(
5639        &self,
5640        chat_id: impl Into<ChatId>,
5641    ) -> UnpinAllChatMessagesBuilder<'_> {
5642        UnpinAllChatMessagesBuilder {
5643            bot: self,
5644            chat_id: chat_id.into(),
5645        }
5646    }
5647
5648    // -- Chat invite link methods ------------------------------------------
5649
5650    /// Build an `exportChatInviteLink` request.
5651    pub fn export_chat_invite_link(
5652        &self,
5653        chat_id: impl Into<ChatId>,
5654    ) -> ExportChatInviteLinkBuilder<'_> {
5655        ExportChatInviteLinkBuilder {
5656            bot: self,
5657            chat_id: chat_id.into(),
5658        }
5659    }
5660
5661    /// Build a `createChatInviteLink` request.
5662    pub fn create_chat_invite_link(
5663        &self,
5664        chat_id: impl Into<ChatId>,
5665    ) -> CreateChatInviteLinkBuilder<'_> {
5666        CreateChatInviteLinkBuilder {
5667            bot: self,
5668            chat_id: chat_id.into(),
5669            expire_date: None,
5670            member_limit: None,
5671            name: None,
5672            creates_join_request: None,
5673        }
5674    }
5675
5676    /// Build an `editChatInviteLink` request.
5677    pub fn edit_chat_invite_link(
5678        &self,
5679        chat_id: impl Into<ChatId>,
5680        invite_link: impl Into<String>,
5681    ) -> EditChatInviteLinkBuilder<'_> {
5682        EditChatInviteLinkBuilder {
5683            bot: self,
5684            chat_id: chat_id.into(),
5685            invite_link: invite_link.into(),
5686            expire_date: None,
5687            member_limit: None,
5688            name: None,
5689            creates_join_request: None,
5690        }
5691    }
5692
5693    /// Build a `revokeChatInviteLink` request.
5694    pub fn revoke_chat_invite_link(
5695        &self,
5696        chat_id: impl Into<ChatId>,
5697        invite_link: impl Into<String>,
5698    ) -> RevokeChatInviteLinkBuilder<'_> {
5699        RevokeChatInviteLinkBuilder {
5700            bot: self,
5701            chat_id: chat_id.into(),
5702            invite_link: invite_link.into(),
5703        }
5704    }
5705
5706    /// Build a `createChatSubscriptionInviteLink` request.
5707    pub fn create_chat_subscription_invite_link(
5708        &self,
5709        chat_id: impl Into<ChatId>,
5710        subscription_period: i64,
5711        subscription_price: i64,
5712    ) -> CreateChatSubscriptionInviteLinkBuilder<'_> {
5713        CreateChatSubscriptionInviteLinkBuilder {
5714            bot: self,
5715            chat_id: chat_id.into(),
5716            subscription_period,
5717            subscription_price,
5718            name: None,
5719        }
5720    }
5721
5722    /// Build an `editChatSubscriptionInviteLink` request.
5723    pub fn edit_chat_subscription_invite_link(
5724        &self,
5725        chat_id: impl Into<ChatId>,
5726        invite_link: impl Into<String>,
5727    ) -> EditChatSubscriptionInviteLinkBuilder<'_> {
5728        EditChatSubscriptionInviteLinkBuilder {
5729            bot: self,
5730            chat_id: chat_id.into(),
5731            invite_link: invite_link.into(),
5732            name: None,
5733        }
5734    }
5735
5736    /// Build an `approveChatJoinRequest` request.
5737    pub fn approve_chat_join_request(
5738        &self,
5739        chat_id: impl Into<ChatId>,
5740        user_id: i64,
5741    ) -> ApproveChatJoinRequestBuilder<'_> {
5742        ApproveChatJoinRequestBuilder {
5743            bot: self,
5744            chat_id: chat_id.into(),
5745            user_id,
5746        }
5747    }
5748
5749    /// Build a `declineChatJoinRequest` request.
5750    pub fn decline_chat_join_request(
5751        &self,
5752        chat_id: impl Into<ChatId>,
5753        user_id: i64,
5754    ) -> DeclineChatJoinRequestBuilder<'_> {
5755        DeclineChatJoinRequestBuilder {
5756            bot: self,
5757            chat_id: chat_id.into(),
5758            user_id,
5759        }
5760    }
5761}