1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
use std::{error::Error, fmt};

use serde::{Deserialize, Serialize};

use crate::{
    api::{Method, Payload},
    types::{ChatAdministratorRights, ChatId, Integer},
};

#[cfg(test)]
mod tests;

/// Represents information about a bot returned in [`GetBot`].
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
pub struct Bot {
    /// The first name of the bot.
    pub first_name: String,
    /// The unique identifier for the bot.
    pub id: Integer,
    /// The username of the bot.
    pub username: String,
    /// Whether the bot can be connected to a Telegram Business account to receive its messages.
    pub can_connect_to_business: bool,
    /// Indicates whether the bot can be invited to groups.
    pub can_join_groups: bool,
    /// Indicates whether privacy mode is disabled, allowing the bot to read all group messages.
    pub can_read_all_group_messages: bool,
    /// The last name of the bot.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_name: Option<String>,
    /// Indicates whether the bot supports inline queries.
    pub supports_inline_queries: bool,
}

impl Bot {
    /// Creates a new `Bot`.
    ///
    /// # Arguments
    ///
    /// * `id` - The unique identifier for the bot.
    /// * `username` - The username of the bot.
    /// * `first_name` - The first name of the bot.
    pub fn new<A, B>(id: Integer, username: A, first_name: B) -> Self
    where
        A: Into<String>,
        B: Into<String>,
    {
        Self {
            first_name: first_name.into(),
            id,
            username: username.into(),
            can_connect_to_business: false,
            can_join_groups: false,
            can_read_all_group_messages: false,
            last_name: None,
            supports_inline_queries: false,
        }
    }

    /// Sets a new value for a `can_connect_to_business` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - Whether the bot can be connected to a Telegram Business account.
    pub fn with_can_connect_to_business(mut self, value: bool) -> Self {
        self.can_connect_to_business = value;
        self
    }

    /// Sets a new value for a `can_join_groups` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - Indicates whether the bot can be invited to groups.
    pub fn with_can_join_groups(mut self, value: bool) -> Self {
        self.can_join_groups = value;
        self
    }

    /// Sets a new value for a `can_read_all_group_messages` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - Indicates whether privacy mode is disabled.
    pub fn with_can_read_all_group_messages(mut self, value: bool) -> Self {
        self.can_read_all_group_messages = value;
        self
    }

    /// Sets a new value for the last name of the bot.
    ///
    /// # Arguments
    ///
    /// * `value` - The last name of the bot.
    pub fn with_last_name<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.last_name = Some(value.into());
        self
    }

    /// Sets a new value for a `supports_inline_queries` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - Indicates whether the bot supports inline queries.
    pub fn with_supports_inline_queries(mut self, value: bool) -> Self {
        self.supports_inline_queries = value;
        self
    }
}

/// Represents a command of a bot.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BotCommand {
    #[serde(rename = "command")]
    name: String,
    description: String,
}

impl BotCommand {
    const MIN_NAME_LEN: usize = 1;
    const MAX_NAME_LEN: usize = 32;
    const MIN_DESCRIPTION_LEN: usize = 3;
    const MAX_DESCRIPTION_LEN: usize = 256;

    /// Creates a new `BotCommand`.
    ///
    /// # Arguments
    ///
    /// * `name` - The name of the command; 1-32 characters;
    ///            can contain only lowercase English letters, digits and underscores.
    /// * `description` - The description of the command; 3-256 characters.
    pub fn new<C, D>(name: C, description: D) -> Result<Self, BotCommandError>
    where
        C: Into<String>,
        D: Into<String>,
    {
        let name = name.into();
        let description = description.into();
        let name_len = name.len();
        let description_len = description.len();
        if !(Self::MIN_NAME_LEN..=Self::MAX_NAME_LEN).contains(&name_len) {
            Err(BotCommandError::BadNameLen(name_len))
        } else if !(Self::MIN_DESCRIPTION_LEN..=Self::MAX_DESCRIPTION_LEN).contains(&description_len) {
            Err(BotCommandError::BadDescriptionLen(description_len))
        } else {
            Ok(Self { name, description })
        }
    }

    /// Returns the name of the command.
    pub fn name(&self) -> &str {
        &self.name
    }

    /// Sets a new name for the command.
    ///
    /// # Arguments
    ///
    /// * `value` - The new name.
    pub fn with_name<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.name = value.into();
        self
    }

    /// Returns the description of the command.
    pub fn description(&self) -> &str {
        &self.description
    }

    /// Sets a new description for the command.
    ///
    /// # Arguments
    ///
    /// * `value` - The new description.
    pub fn with_description<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.description = value.into();
        self
    }
}

/// Represents an error that can occur when creating a new [`BotCommand`].
#[derive(Debug)]
pub enum BotCommandError {
    /// The provided name has an invalid length.
    BadNameLen(usize),
    /// The provided description has an invalid length.
    BadDescriptionLen(usize),
}

impl Error for BotCommandError {}

impl fmt::Display for BotCommandError {
    fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
        use self::BotCommandError::*;
        match self {
            BadNameLen(len) => write!(
                out,
                "command name can have a length of {} up to {} characters, got {}",
                BotCommand::MIN_NAME_LEN,
                BotCommand::MAX_NAME_LEN,
                len
            ),
            BadDescriptionLen(len) => write!(
                out,
                "command description can have a length of {} up to {} characters, got {}",
                BotCommand::MIN_DESCRIPTION_LEN,
                BotCommand::MAX_DESCRIPTION_LEN,
                len
            ),
        }
    }
}

/// Represents a scope to which bot commands are applied.
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum BotCommandScope {
    /// All group and supergroup chat administrators.
    AllChatAdministrators,
    /// All group and supergroup chats.
    AllGroupChats,
    /// All private chats.
    AllPrivateChats,
    /// A specific chat.
    Chat {
        /// Unique identifier of the target chat.
        chat_id: ChatId,
    },
    /// All administrators of a specific group or supergroup chat.
    ChatAdministrators {
        /// Unique identifier of the target chat.
        chat_id: ChatId,
    },
    /// A specific member of a group or supergroup chat.
    ChatMember {
        /// Unique identifier of the target chat.
        chat_id: ChatId,
        /// Unique identifier of the target user.
        user_id: Integer,
    },
    /// Default scope.
    ///
    /// Default commands are used if no commands with a narrower scope are specified for a user.
    Default,
}

impl BotCommandScope {
    /// Creates a new `BotCommandScope` covering a specific chat.
    ///
    /// # Arguments
    ///
    /// * `value` - Chat ID.
    pub fn chat<T>(value: T) -> Self
    where
        T: Into<ChatId>,
    {
        Self::Chat { chat_id: value.into() }
    }

    /// Creates a new `BotCommandScope` covering all administrators
    /// of a specific group or supergroup chat.
    ///
    /// # Arguments
    ///
    /// * `value` - Chat ID.
    pub fn chat_administrators<T>(value: T) -> Self
    where
        T: Into<ChatId>,
    {
        Self::ChatAdministrators { chat_id: value.into() }
    }

    /// Creates a new `BotCommandScope` covering a specific member of a group or supergroup chat.
    ///
    /// # Arguments
    ///
    /// * `chat_id` - Chat ID.
    /// * `user_id` - User ID.
    pub fn chat_member<A>(chat_id: A, user_id: Integer) -> Self
    where
        A: Into<ChatId>,
    {
        Self::ChatMember {
            chat_id: chat_id.into(),
            user_id,
        }
    }
}

/// Represents a description of a bot.
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
pub struct BotDescription {
    /// The description of the bot.
    pub description: String,
}

impl BotDescription {
    /// Creates a new `BotDescription`.
    ///
    /// # Arguments
    ///
    /// * `value` - The description of the bot.
    pub fn new<T>(value: T) -> Self
    where
        T: Into<String>,
    {
        Self {
            description: value.into(),
        }
    }
}

/// Represents a name of a bot.
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
pub struct BotName {
    /// The name of the bot.
    pub name: String,
}

impl BotName {
    /// Creates a new `BotName`.
    ///
    /// # Arguments
    ///
    /// * `value` - The name of the bot.
    pub fn new<T>(value: T) -> Self
    where
        T: Into<String>,
    {
        Self { name: value.into() }
    }
}

/// Represents a short description of a bot.
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
pub struct BotShortDescription {
    /// The short description of the bot.
    pub short_description: String,
}

impl BotShortDescription {
    /// Creates a new `BotShortDescription`.
    ///
    /// # Arguments
    ///
    /// * `value` - The short description of the bot.
    pub fn new<T>(value: T) -> Self
    where
        T: Into<String>,
    {
        Self {
            short_description: value.into(),
        }
    }
}

/// Closes a bot instance before moving it from one local server to another.
///
/// You need to delete the webhook before calling this method to ensure
/// that the bot isn't launched again after server restart.
///
/// The method will return error 429 in the first 10 minutes after the bot is launched.
#[derive(Clone, Copy, Debug)]
pub struct Close;

impl Method for Close {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::empty("close")
    }
}

/// Deletes a list of a bot commands of a given scope and user language.
///
/// After deletion, higher level commands will be shown to affected users.
#[derive(Clone, Debug, Default, Serialize)]
pub struct DeleteBotCommands {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    scope: Option<BotCommandScope>,
}

impl DeleteBotCommands {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }

    /// Sets a new scope of users.
    ///
    /// # Arguments
    ///
    /// * `value` - Scope; default - [`BotCommandScope::Default`].
    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
        self.scope = Some(value);
        self
    }
}

impl Method for DeleteBotCommands {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("deleteMyCommands", self)
    }
}

/// Returns a basic information about a bot.
#[derive(Clone, Copy, Debug)]
pub struct GetBot;

impl Method for GetBot {
    type Response = Bot;

    fn into_payload(self) -> Payload {
        Payload::empty("getMe")
    }
}

/// Returns the current list of bot commands.
#[derive(Clone, Debug, Default, Serialize)]
pub struct GetBotCommands {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    scope: Option<BotCommandScope>,
}

impl GetBotCommands {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }

    /// Sets a new scope.
    ///
    /// # Arguments
    ///
    /// * `value` - Scope of users; default - [`BotCommandScope::Default`].
    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
        self.scope = Some(value);
        self
    }
}

impl Method for GetBotCommands {
    type Response = Vec<BotCommand>;

    fn into_payload(self) -> Payload {
        Payload::json("getMyCommands", self)
    }
}

/// Returns the current default administrator rights of a bot.
#[derive(Clone, Copy, Debug, Default, Serialize)]
pub struct GetBotDefaultAdministratorRights {
    #[serde(skip_serializing_if = "Option::is_none")]
    for_channels: Option<bool>,
}

impl GetBotDefaultAdministratorRights {
    /// Sets a new value of a `for_channels` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - For channels - `true`; for groups and supergroups - `false`.
    pub fn with_for_channels(mut self, value: bool) -> Self {
        self.for_channels = Some(value);
        self
    }
}

impl Method for GetBotDefaultAdministratorRights {
    type Response = ChatAdministratorRights;

    fn into_payload(self) -> Payload {
        Payload::json("getMyDefaultAdministratorRights", self)
    }
}

/// Returns the current description of a bot for a given user language.
#[derive(Clone, Debug, Default, Serialize)]
pub struct GetBotDescription {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
}

impl GetBotDescription {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }
}

impl Method for GetBotDescription {
    type Response = BotDescription;

    fn into_payload(self) -> Payload {
        Payload::json("getMyDescription", self)
    }
}

/// Returns the current name of a bot for a given user language.
#[derive(Clone, Debug, Default, Serialize)]
pub struct GetBotName {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
}

impl GetBotName {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }
}

impl Method for GetBotName {
    type Response = BotName;

    fn into_payload(self) -> Payload {
        Payload::json("getMyName", self)
    }
}

/// Returns the current short description of a bot for a given user language.
#[derive(Clone, Debug, Default, Serialize)]
pub struct GetBotShortDescription {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
}

impl GetBotShortDescription {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code or an empty string.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }
}

impl Method for GetBotShortDescription {
    type Response = BotShortDescription;

    fn into_payload(self) -> Payload {
        Payload::json("getMyShortDescription", self)
    }
}

/// Logs out from the Cloud Bot API.
///
/// You must log out a bot before running it locally,
/// otherwise there is no guarantee that the bot will receive updates.
///
/// After a successful call, you can immediately log in on a local server,
/// but will not be able to log in back to the Cloud Bot API server for 10 minutes.
#[derive(Clone, Copy, Debug)]
pub struct LogOut;

impl Method for LogOut {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::empty("logOut")
    }
}

/// Changes a list of commands of a bot.
#[derive(Clone, Debug, Serialize)]
pub struct SetBotCommands {
    commands: Vec<BotCommand>,
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    scope: Option<BotCommandScope>,
}

impl SetBotCommands {
    /// Creates a new `SetBotCommands`.
    ///
    /// # Arguments
    ///
    /// * `commands` - Commands to set.
    pub fn new(commands: impl IntoIterator<Item = BotCommand>) -> Self {
        Self {
            commands: commands.into_iter().collect(),
            language_code: None,
            scope: None,
        }
    }

    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code;
    ///             if empty, commands will be applied to all users from the given scope,
    ///             for whose language there are no dedicated commands.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }

    /// Sets a new scope.
    ///
    /// # Arguments
    ///
    /// * `value` - Scope of users for which the commands are relevant;
    ///             default - [`BotCommandScope::Default`].
    pub fn with_scope(mut self, value: BotCommandScope) -> Self {
        self.scope = Some(value);
        self
    }
}

impl Method for SetBotCommands {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("setMyCommands", self)
    }
}

/// Changes default administrator rights requested by a bot
/// when it's added as an administrator to groups or channels.
///
/// These rights will be suggested to users,
/// but they are free to modify the list before adding the bot.
#[derive(Clone, Copy, Debug, Default, Serialize)]
pub struct SetBotDefaultAdministratorRights {
    #[serde(skip_serializing_if = "Option::is_none")]
    for_channels: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    rights: Option<ChatAdministratorRights>,
}

impl SetBotDefaultAdministratorRights {
    /// Sets a new value of a `for_channels` flag.
    ///
    /// # Arguments
    ///
    /// * `value` - For channels - `true`; for groups and supergroups - `false`.
    pub fn with_for_channels(mut self, value: bool) -> Self {
        self.for_channels = Some(value);
        self
    }

    /// Sets new default administrator rights
    ///
    /// # Arguments
    ///
    /// * `value` - Default administrator rights;
    ///             if not specified, the default administrator rights will be cleared.
    pub fn with_rights(mut self, value: ChatAdministratorRights) -> Self {
        self.rights = Some(value);
        self
    }
}

impl Method for SetBotDefaultAdministratorRights {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("setMyDefaultAdministratorRights", self)
    }
}

/// Changes the description of a bot, which is shown in a chat with the bot if the chat is empty.
#[derive(Clone, Debug, Default, Serialize)]
pub struct SetBotDescription {
    #[serde(skip_serializing_if = "Option::is_none")]
    description: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
}

impl SetBotDescription {
    /// Sets a new description.
    ///
    /// # Arguments
    ///
    /// * `value` - Description of the bot; 0-512 characters;
    ///             pass an empty string to remove the dedicated description
    ///             of the given language.
    pub fn with_description<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.description = Some(value.into());
        self
    }

    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code;
    ///             if empty, the description will be applied to all users
    ///             for whose language there is no dedicated description.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }
}

impl Method for SetBotDescription {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("setMyDescription", self)
    }
}

/// Changes the name of a bot.
#[derive(Clone, Debug, Default, Serialize)]
pub struct SetBotName {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    name: Option<String>,
}

impl SetBotName {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code;
    ///             if empty, the name will be shown to all users
    ///             for whose language there is no dedicated name.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }

    /// Sets a new name of a bot.
    ///
    /// # Arguments
    ///
    /// * `value` - New name of the bot; 0-64 characters;
    ///             pass an empty string to remove the dedicated name
    ///             of the given language.
    pub fn with_name<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.name = Some(value.into());
        self
    }
}

impl Method for SetBotName {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("setMyName", self)
    }
}

/// Changes the short description of a bot, which is shown on the bot profile page
/// and is sent together with the link when users share the bot.
#[derive(Clone, Debug, Default, Serialize)]
pub struct SetBotShortDescription {
    #[serde(skip_serializing_if = "Option::is_none")]
    language_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    short_description: Option<String>,
}

impl SetBotShortDescription {
    /// Sets a new language code.
    ///
    /// # Arguments
    ///
    /// * `value` - Two-letter ISO 639-1 language code;
    ///             if empty, the short description will be applied
    ///             to all users for whose language there is no dedicated short description.
    pub fn with_language_code<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.language_code = Some(value.into());
        self
    }

    /// Sets a new short description.
    ///
    /// # Arguments
    ///
    /// * `value` - Short description of a bot; 0-120 characters;
    ///             pass an empty string to remove the dedicated short description
    ///             of the given language.
    pub fn with_short_description<T>(mut self, value: T) -> Self
    where
        T: Into<String>,
    {
        self.short_description = Some(value.into());
        self
    }
}

impl Method for SetBotShortDescription {
    type Response = bool;

    fn into_payload(self) -> Payload {
        Payload::json("setMyShortDescription", self)
    }
}