tgbot/types/definitions/
bot.rs

1use std::{error::Error, fmt};
2
3use serde::{Deserialize, Serialize};
4
5use crate::{
6    api::{Method, Payload},
7    types::{ChatAdministratorRights, ChatId, Integer, StarAmount},
8};
9
10/// Represents information about a bot returned in [`GetBot`].
11#[serde_with::skip_serializing_none]
12#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
13pub struct Bot {
14    /// The first name of the bot.
15    pub first_name: String,
16    /// The unique identifier for the bot.
17    pub id: Integer,
18    /// The username of the bot.
19    pub username: String,
20    /// Whether the bot can be connected to a Telegram Business account to receive its messages.
21    pub can_connect_to_business: bool,
22    /// Indicates whether the bot can be invited to groups.
23    pub can_join_groups: bool,
24    /// Indicates whether privacy mode is disabled, allowing the bot to read all group messages.
25    pub can_read_all_group_messages: bool,
26    /// Indicates whether the bot has a main Web App.
27    pub has_main_web_app: bool,
28    /// Indicates whether the bot has forum topic mode enabled in private chats.
29    pub has_topics_enabled: bool,
30    /// The last name of the bot.
31    pub last_name: Option<String>,
32    /// Indicates whether the bot supports inline queries.
33    pub supports_inline_queries: bool,
34}
35
36impl Bot {
37    /// Creates a new `Bot`.
38    ///
39    /// # Arguments
40    ///
41    /// * `id` - The unique identifier for the bot.
42    /// * `username` - The username of the bot.
43    /// * `first_name` - The first name of the bot.
44    pub fn new<A, B>(id: Integer, username: A, first_name: B) -> Self
45    where
46        A: Into<String>,
47        B: Into<String>,
48    {
49        Self {
50            first_name: first_name.into(),
51            id,
52            username: username.into(),
53            can_connect_to_business: false,
54            can_join_groups: false,
55            can_read_all_group_messages: false,
56            has_main_web_app: false,
57            has_topics_enabled: false,
58            last_name: None,
59            supports_inline_queries: false,
60        }
61    }
62
63    /// Sets a new value for the `can_connect_to_business` flag.
64    ///
65    /// # Arguments
66    ///
67    /// * `value` - Whether the bot can be connected to a Telegram Business account.
68    pub fn with_can_connect_to_business(mut self, value: bool) -> Self {
69        self.can_connect_to_business = value;
70        self
71    }
72
73    /// Sets a new value for the `can_join_groups` flag.
74    ///
75    /// # Arguments
76    ///
77    /// * `value` - Indicates whether the bot can be invited to groups.
78    pub fn with_can_join_groups(mut self, value: bool) -> Self {
79        self.can_join_groups = value;
80        self
81    }
82
83    /// Sets a new value for the `can_read_all_group_messages` flag.
84    ///
85    /// # Arguments
86    ///
87    /// * `value` - Indicates whether privacy mode is disabled.
88    pub fn with_can_read_all_group_messages(mut self, value: bool) -> Self {
89        self.can_read_all_group_messages = value;
90        self
91    }
92
93    /// Sets a new value for the `has_main_web_app` flag.
94    ///
95    /// # Arguments
96    ///
97    /// * `value` - Indicates whether the bot has a main Web App.
98    pub fn with_has_main_web_app(mut self, value: bool) -> Self {
99        self.has_main_web_app = value;
100        self
101    }
102
103    /// Sets a new value for the `has_topics_enabled` flag.
104    ///
105    /// # Arguments
106    ///
107    /// * `value` - Indicates whether the bot has forum topic mode enabled in private chats.
108    pub fn with_has_topics_enabled(mut self, value: bool) -> Self {
109        self.has_topics_enabled = value;
110        self
111    }
112
113    /// Sets a new value for the last name of the bot.
114    ///
115    /// # Arguments
116    ///
117    /// * `value` - The last name of the bot.
118    pub fn with_last_name<T>(mut self, value: T) -> Self
119    where
120        T: Into<String>,
121    {
122        self.last_name = Some(value.into());
123        self
124    }
125
126    /// Sets a new value for the `supports_inline_queries` flag.
127    ///
128    /// # Arguments
129    ///
130    /// * `value` - Indicates whether the bot supports inline queries.
131    pub fn with_supports_inline_queries(mut self, value: bool) -> Self {
132        self.supports_inline_queries = value;
133        self
134    }
135}
136
137/// Represents a command of a bot.
138#[derive(Clone, Debug, Deserialize, Serialize)]
139pub struct BotCommand {
140    #[serde(rename = "command")]
141    name: String,
142    description: String,
143}
144
145impl BotCommand {
146    const MIN_NAME_LEN: usize = 1;
147    const MAX_NAME_LEN: usize = 32;
148    const MIN_DESCRIPTION_LEN: usize = 3;
149    const MAX_DESCRIPTION_LEN: usize = 256;
150
151    /// Creates a new `BotCommand`.
152    ///
153    /// # Arguments
154    ///
155    /// * `name` - The name of the command; 1-32 characters;
156    ///   can contain only lowercase English letters, digits and underscores.
157    /// * `description` - The description of the command; 3-256 characters.
158    pub fn new<C, D>(name: C, description: D) -> Result<Self, BotCommandError>
159    where
160        C: Into<String>,
161        D: Into<String>,
162    {
163        let name = name.into();
164        let description = description.into();
165        let name_len = name.len();
166        let description_len = description.len();
167        if !(Self::MIN_NAME_LEN..=Self::MAX_NAME_LEN).contains(&name_len) {
168            Err(BotCommandError::BadNameLen(name_len))
169        } else if !(Self::MIN_DESCRIPTION_LEN..=Self::MAX_DESCRIPTION_LEN).contains(&description_len) {
170            Err(BotCommandError::BadDescriptionLen(description_len))
171        } else {
172            Ok(Self { name, description })
173        }
174    }
175
176    /// Returns the name of the command.
177    pub fn name(&self) -> &str {
178        &self.name
179    }
180
181    /// Sets a new name for the command.
182    ///
183    /// # Arguments
184    ///
185    /// * `value` - The new name.
186    pub fn with_name<T>(mut self, value: T) -> Self
187    where
188        T: Into<String>,
189    {
190        self.name = value.into();
191        self
192    }
193
194    /// Returns the description of the command.
195    pub fn description(&self) -> &str {
196        &self.description
197    }
198
199    /// Sets a new description for the command.
200    ///
201    /// # Arguments
202    ///
203    /// * `value` - The new description.
204    pub fn with_description<T>(mut self, value: T) -> Self
205    where
206        T: Into<String>,
207    {
208        self.description = value.into();
209        self
210    }
211}
212
213/// Represents an error that can occur when creating a new [`BotCommand`].
214#[derive(Debug)]
215pub enum BotCommandError {
216    /// The provided name has an invalid length.
217    BadNameLen(usize),
218    /// The provided description has an invalid length.
219    BadDescriptionLen(usize),
220}
221
222impl Error for BotCommandError {}
223
224impl fmt::Display for BotCommandError {
225    fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
226        use self::BotCommandError::*;
227        match self {
228            BadNameLen(len) => write!(
229                out,
230                "command name can have a length of {} up to {} characters, got {}",
231                BotCommand::MIN_NAME_LEN,
232                BotCommand::MAX_NAME_LEN,
233                len
234            ),
235            BadDescriptionLen(len) => write!(
236                out,
237                "command description can have a length of {} up to {} characters, got {}",
238                BotCommand::MIN_DESCRIPTION_LEN,
239                BotCommand::MAX_DESCRIPTION_LEN,
240                len
241            ),
242        }
243    }
244}
245
246/// Represents a scope to which bot commands are applied.
247#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
248#[serde(tag = "type")]
249#[serde(rename_all = "snake_case")]
250pub enum BotCommandScope {
251    /// All group and supergroup chat administrators.
252    AllChatAdministrators,
253    /// All group and supergroup chats.
254    AllGroupChats,
255    /// All private chats.
256    AllPrivateChats,
257    /// A specific chat.
258    Chat {
259        /// Unique identifier of the target chat.
260        chat_id: ChatId,
261    },
262    /// All administrators of a specific group or supergroup chat.
263    ChatAdministrators {
264        /// Unique identifier of the target chat.
265        chat_id: ChatId,
266    },
267    /// A specific member of a group or supergroup chat.
268    ChatMember {
269        /// Unique identifier of the target chat.
270        chat_id: ChatId,
271        /// Unique identifier of the target user.
272        user_id: Integer,
273    },
274    /// Default scope.
275    ///
276    /// Default commands are used if no commands with a narrower scope are specified for a user.
277    Default,
278}
279
280impl BotCommandScope {
281    /// Creates a new `BotCommandScope` covering a specific chat.
282    ///
283    /// # Arguments
284    ///
285    /// * `value` - Chat ID.
286    pub fn chat<T>(value: T) -> Self
287    where
288        T: Into<ChatId>,
289    {
290        Self::Chat { chat_id: value.into() }
291    }
292
293    /// Creates a new `BotCommandScope` covering all administrators
294    /// of a specific group or supergroup chat.
295    ///
296    /// # Arguments
297    ///
298    /// * `value` - Chat ID.
299    pub fn chat_administrators<T>(value: T) -> Self
300    where
301        T: Into<ChatId>,
302    {
303        Self::ChatAdministrators { chat_id: value.into() }
304    }
305
306    /// Creates a new `BotCommandScope` covering a specific member of a group or supergroup chat.
307    ///
308    /// # Arguments
309    ///
310    /// * `chat_id` - Chat ID.
311    /// * `user_id` - User ID.
312    pub fn chat_member<A>(chat_id: A, user_id: Integer) -> Self
313    where
314        A: Into<ChatId>,
315    {
316        Self::ChatMember {
317            chat_id: chat_id.into(),
318            user_id,
319        }
320    }
321}
322
323/// Represents a description of a bot.
324#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
325pub struct BotDescription {
326    /// The description of the bot.
327    pub description: String,
328}
329
330impl BotDescription {
331    /// Creates a new `BotDescription`.
332    ///
333    /// # Arguments
334    ///
335    /// * `value` - The description of the bot.
336    pub fn new<T>(value: T) -> Self
337    where
338        T: Into<String>,
339    {
340        Self {
341            description: value.into(),
342        }
343    }
344}
345
346/// Represents a name of a bot.
347#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
348pub struct BotName {
349    /// The name of the bot.
350    pub name: String,
351}
352
353impl BotName {
354    /// Creates a new `BotName`.
355    ///
356    /// # Arguments
357    ///
358    /// * `value` - The name of the bot.
359    pub fn new<T>(value: T) -> Self
360    where
361        T: Into<String>,
362    {
363        Self { name: value.into() }
364    }
365}
366
367/// Represents a short description of a bot.
368#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
369pub struct BotShortDescription {
370    /// The short description of the bot.
371    pub short_description: String,
372}
373
374impl BotShortDescription {
375    /// Creates a new `BotShortDescription`.
376    ///
377    /// # Arguments
378    ///
379    /// * `value` - The short description of the bot.
380    pub fn new<T>(value: T) -> Self
381    where
382        T: Into<String>,
383    {
384        Self {
385            short_description: value.into(),
386        }
387    }
388}
389
390/// Closes a bot instance before moving it from one local server to another.
391///
392/// You need to delete the webhook before calling this method to ensure
393/// that the bot isn't launched again after server restart.
394///
395/// The method will return error 429 in the first 10 minutes after the bot is launched.
396#[derive(Clone, Copy, Debug)]
397pub struct Close;
398
399impl Method for Close {
400    type Response = bool;
401
402    fn into_payload(self) -> Payload {
403        Payload::empty("close")
404    }
405}
406
407/// Deletes a list of a bot commands of a given scope and user language.
408///
409/// After deletion, higher level commands will be shown to affected users.
410#[serde_with::skip_serializing_none]
411#[derive(Clone, Debug, Default, Serialize)]
412pub struct DeleteBotCommands {
413    language_code: Option<String>,
414    scope: Option<BotCommandScope>,
415}
416
417impl DeleteBotCommands {
418    /// Sets a new language code.
419    ///
420    /// # Arguments
421    ///
422    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
423    pub fn with_language_code<T>(mut self, value: T) -> Self
424    where
425        T: Into<String>,
426    {
427        self.language_code = Some(value.into());
428        self
429    }
430
431    /// Sets a new scope of users.
432    ///
433    /// # Arguments
434    ///
435    /// * `value` - Scope; default - [`BotCommandScope::Default`].
436    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
437        self.scope = Some(value);
438        self
439    }
440}
441
442impl Method for DeleteBotCommands {
443    type Response = bool;
444
445    fn into_payload(self) -> Payload {
446        Payload::json("deleteMyCommands", self)
447    }
448}
449
450/// Returns a basic information about a bot.
451#[derive(Clone, Copy, Debug)]
452pub struct GetBot;
453
454impl Method for GetBot {
455    type Response = Bot;
456
457    fn into_payload(self) -> Payload {
458        Payload::empty("getMe")
459    }
460}
461
462/// Returns the current list of bot commands.
463#[serde_with::skip_serializing_none]
464#[derive(Clone, Debug, Default, Serialize)]
465pub struct GetBotCommands {
466    language_code: Option<String>,
467    scope: Option<BotCommandScope>,
468}
469
470impl GetBotCommands {
471    /// Sets a new language code.
472    ///
473    /// # Arguments
474    ///
475    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
476    pub fn with_language_code<T>(mut self, value: T) -> Self
477    where
478        T: Into<String>,
479    {
480        self.language_code = Some(value.into());
481        self
482    }
483
484    /// Sets a new scope.
485    ///
486    /// # Arguments
487    ///
488    /// * `value` - Scope of users; default - [`BotCommandScope::Default`].
489    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
490        self.scope = Some(value);
491        self
492    }
493}
494
495impl Method for GetBotCommands {
496    type Response = Vec<BotCommand>;
497
498    fn into_payload(self) -> Payload {
499        Payload::json("getMyCommands", self)
500    }
501}
502
503/// Returns the current default administrator rights of a bot.
504#[serde_with::skip_serializing_none]
505#[derive(Clone, Copy, Debug, Default, Serialize)]
506pub struct GetBotDefaultAdministratorRights {
507    for_channels: Option<bool>,
508}
509
510impl GetBotDefaultAdministratorRights {
511    /// Sets a new value of a `for_channels` flag.
512    ///
513    /// # Arguments
514    ///
515    /// * `value` - For channels - `true`; for groups and supergroups - `false`.
516    pub fn with_for_channels(mut self, value: bool) -> Self {
517        self.for_channels = Some(value);
518        self
519    }
520}
521
522impl Method for GetBotDefaultAdministratorRights {
523    type Response = ChatAdministratorRights;
524
525    fn into_payload(self) -> Payload {
526        Payload::json("getMyDefaultAdministratorRights", self)
527    }
528}
529
530/// Returns the current description of a bot for a given user language.
531#[serde_with::skip_serializing_none]
532#[derive(Clone, Debug, Default, Serialize)]
533pub struct GetBotDescription {
534    language_code: Option<String>,
535}
536
537impl GetBotDescription {
538    /// Sets a new language code.
539    ///
540    /// # Arguments
541    ///
542    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
543    pub fn with_language_code<T>(mut self, value: T) -> Self
544    where
545        T: Into<String>,
546    {
547        self.language_code = Some(value.into());
548        self
549    }
550}
551
552impl Method for GetBotDescription {
553    type Response = BotDescription;
554
555    fn into_payload(self) -> Payload {
556        Payload::json("getMyDescription", self)
557    }
558}
559
560/// Returns the current name of a bot for a given user language.
561#[serde_with::skip_serializing_none]
562#[derive(Clone, Debug, Default, Serialize)]
563pub struct GetBotName {
564    language_code: Option<String>,
565}
566
567impl GetBotName {
568    /// Sets a new language code.
569    ///
570    /// # Arguments
571    ///
572    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
573    pub fn with_language_code<T>(mut self, value: T) -> Self
574    where
575        T: Into<String>,
576    {
577        self.language_code = Some(value.into());
578        self
579    }
580}
581
582impl Method for GetBotName {
583    type Response = BotName;
584
585    fn into_payload(self) -> Payload {
586        Payload::json("getMyName", self)
587    }
588}
589
590/// Returns the current short description of a bot for a given user language.
591#[serde_with::skip_serializing_none]
592#[derive(Clone, Debug, Default, Serialize)]
593pub struct GetBotShortDescription {
594    language_code: Option<String>,
595}
596
597impl GetBotShortDescription {
598    /// Sets a new language code.
599    ///
600    /// # Arguments
601    ///
602    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
603    pub fn with_language_code<T>(mut self, value: T) -> Self
604    where
605        T: Into<String>,
606    {
607        self.language_code = Some(value.into());
608        self
609    }
610}
611
612impl Method for GetBotShortDescription {
613    type Response = BotShortDescription;
614
615    fn into_payload(self) -> Payload {
616        Payload::json("getMyShortDescription", self)
617    }
618}
619
620/// Returns the current Telegram Stars balance of the bot.
621#[derive(Clone, Copy, Debug)]
622pub struct GetBotStarBalance;
623
624impl Method for GetBotStarBalance {
625    type Response = StarAmount;
626
627    fn into_payload(self) -> Payload {
628        Payload::empty("getMyStarBalance")
629    }
630}
631
632/// Logs out from the Cloud Bot API.
633///
634/// You must log out a bot before running it locally,
635/// otherwise there is no guarantee that the bot will receive updates.
636///
637/// After a successful call, you can immediately log in on a local server,
638/// but will not be able to log in back to the Cloud Bot API server for 10 minutes.
639#[derive(Clone, Copy, Debug)]
640pub struct LogOut;
641
642impl Method for LogOut {
643    type Response = bool;
644
645    fn into_payload(self) -> Payload {
646        Payload::empty("logOut")
647    }
648}
649
650/// Changes a list of commands of a bot.
651#[serde_with::skip_serializing_none]
652#[derive(Clone, Debug, Serialize)]
653pub struct SetBotCommands {
654    commands: Vec<BotCommand>,
655    language_code: Option<String>,
656    scope: Option<BotCommandScope>,
657}
658
659impl SetBotCommands {
660    /// Creates a new `SetBotCommands`.
661    ///
662    /// # Arguments
663    ///
664    /// * `commands` - Commands to set.
665    pub fn new(commands: impl IntoIterator<Item = BotCommand>) -> Self {
666        Self {
667            commands: commands.into_iter().collect(),
668            language_code: None,
669            scope: None,
670        }
671    }
672
673    /// Sets a new language code.
674    ///
675    /// # Arguments
676    ///
677    /// * `value` - Two-letter ISO 639-1 language code;
678    ///   if empty, commands will be applied to all users from the given scope,
679    ///   for whose language there are no dedicated commands.
680    pub fn with_language_code<T>(mut self, value: T) -> Self
681    where
682        T: Into<String>,
683    {
684        self.language_code = Some(value.into());
685        self
686    }
687
688    /// Sets a new scope.
689    ///
690    /// # Arguments
691    ///
692    /// * `value` - Scope of users for which the commands are relevant;
693    ///   default - [`BotCommandScope::Default`].
694    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
695        self.scope = Some(value);
696        self
697    }
698}
699
700impl Method for SetBotCommands {
701    type Response = bool;
702
703    fn into_payload(self) -> Payload {
704        Payload::json("setMyCommands", self)
705    }
706}
707
708/// Changes default administrator rights requested by a bot
709/// when it's added as an administrator to groups or channels.
710///
711/// These rights will be suggested to users,
712/// but they are free to modify the list before adding the bot.
713#[serde_with::skip_serializing_none]
714#[derive(Clone, Copy, Debug, Default, Serialize)]
715pub struct SetBotDefaultAdministratorRights {
716    for_channels: Option<bool>,
717    rights: Option<ChatAdministratorRights>,
718}
719
720impl SetBotDefaultAdministratorRights {
721    /// Sets a new value of a `for_channels` flag.
722    ///
723    /// # Arguments
724    ///
725    /// * `value` - For channels - `true`; for groups and supergroups - `false`.
726    pub fn with_for_channels(mut self, value: bool) -> Self {
727        self.for_channels = Some(value);
728        self
729    }
730
731    /// Sets new default administrator rights
732    ///
733    /// # Arguments
734    ///
735    /// * `value` - Default administrator rights;
736    ///   if not specified, the default administrator rights will be cleared.
737    pub fn with_rights(mut self, value: ChatAdministratorRights) -> Self {
738        self.rights = Some(value);
739        self
740    }
741}
742
743impl Method for SetBotDefaultAdministratorRights {
744    type Response = bool;
745
746    fn into_payload(self) -> Payload {
747        Payload::json("setMyDefaultAdministratorRights", self)
748    }
749}
750
751/// Changes the description of a bot, which is shown in a chat with the bot if the chat is empty.
752#[serde_with::skip_serializing_none]
753#[derive(Clone, Debug, Default, Serialize)]
754pub struct SetBotDescription {
755    description: Option<String>,
756    language_code: Option<String>,
757}
758
759impl SetBotDescription {
760    /// Sets a new description.
761    ///
762    /// # Arguments
763    ///
764    /// * `value` - Description of the bot; 0-512 characters;
765    ///   pass an empty string to remove the dedicated description
766    ///   of the given language.
767    pub fn with_description<T>(mut self, value: T) -> Self
768    where
769        T: Into<String>,
770    {
771        self.description = Some(value.into());
772        self
773    }
774
775    /// Sets a new language code.
776    ///
777    /// # Arguments
778    ///
779    /// * `value` - Two-letter ISO 639-1 language code;
780    ///   if empty, the description will be applied to all users
781    ///   for whose language there is no dedicated description.
782    pub fn with_language_code<T>(mut self, value: T) -> Self
783    where
784        T: Into<String>,
785    {
786        self.language_code = Some(value.into());
787        self
788    }
789}
790
791impl Method for SetBotDescription {
792    type Response = bool;
793
794    fn into_payload(self) -> Payload {
795        Payload::json("setMyDescription", self)
796    }
797}
798
799/// Changes the name of a bot.
800#[serde_with::skip_serializing_none]
801#[derive(Clone, Debug, Default, Serialize)]
802pub struct SetBotName {
803    language_code: Option<String>,
804    name: Option<String>,
805}
806
807impl SetBotName {
808    /// Sets a new language code.
809    ///
810    /// # Arguments
811    ///
812    /// * `value` - Two-letter ISO 639-1 language code;
813    ///   if empty, the name will be shown to all users
814    ///   for whose language there is no dedicated name.
815    pub fn with_language_code<T>(mut self, value: T) -> Self
816    where
817        T: Into<String>,
818    {
819        self.language_code = Some(value.into());
820        self
821    }
822
823    /// Sets a new name of a bot.
824    ///
825    /// # Arguments
826    ///
827    /// * `value` - New name of the bot; 0-64 characters;
828    ///   pass an empty string to remove the dedicated name
829    ///   of the given language.
830    pub fn with_name<T>(mut self, value: T) -> Self
831    where
832        T: Into<String>,
833    {
834        self.name = Some(value.into());
835        self
836    }
837}
838
839impl Method for SetBotName {
840    type Response = bool;
841
842    fn into_payload(self) -> Payload {
843        Payload::json("setMyName", self)
844    }
845}
846
847/// Changes the short description of a bot, which is shown on the bot profile page
848/// and is sent together with the link when users share the bot.
849#[serde_with::skip_serializing_none]
850#[derive(Clone, Debug, Default, Serialize)]
851pub struct SetBotShortDescription {
852    language_code: Option<String>,
853    short_description: Option<String>,
854}
855
856impl SetBotShortDescription {
857    /// Sets a new language code.
858    ///
859    /// # Arguments
860    ///
861    /// * `value` - Two-letter ISO 639-1 language code;
862    ///   if empty, the short description will be applied
863    ///   to all users for whose language there is no dedicated short description.
864    pub fn with_language_code<T>(mut self, value: T) -> Self
865    where
866        T: Into<String>,
867    {
868        self.language_code = Some(value.into());
869        self
870    }
871
872    /// Sets a new short description.
873    ///
874    /// # Arguments
875    ///
876    /// * `value` - Short description of a bot; 0-120 characters;
877    ///   pass an empty string to remove the dedicated short description
878    ///   of the given language.
879    pub fn with_short_description<T>(mut self, value: T) -> Self
880    where
881        T: Into<String>,
882    {
883        self.short_description = Some(value.into());
884        self
885    }
886}
887
888impl Method for SetBotShortDescription {
889    type Response = bool;
890
891    fn into_payload(self) -> Payload {
892        Payload::json("setMyShortDescription", self)
893    }
894}