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
//! Available telegram functions, copied from https://core.telegram.org/bots/api#available-methods
//!
//! telebot-derive implements setter, setter and send methods to each struct

use std::convert::From;

use serde_json;
use failure::{Error, Fail};
use futures::Future;
use erased_serde::Serialize;

use crate::bot::RequestHandle;
use crate::objects::{self, Integer};
use crate::file::{self, MediaFile};
use crate::error::ErrorKind;

/// The strongly typed version of the parse_mode field which indicates the type of text
#[derive(Serialize)]
pub enum ParseMode {
    Markdown,
    HTML,
    Text,
}

impl Into<String> for ParseMode {
    fn into(self) -> String {
        let tmp = match self {
            ParseMode::Markdown => "Markdown",
            ParseMode::HTML => "HTML",
            ParseMode::Text => "Text",
        };

        tmp.into()
    }
}

/// The strongly typed version of the action field which indicates the type of action
pub enum Action {
    Typing,
    UploadPhoto,
    RecordVideo,
    UploadVideo,
    RecordAudio,
    UploadAudio,
    UploadDocument,
    FindLocation,
}

/// Possible types of reply markups
pub enum ReplyMarkup {
    InlineKeyboardMarkup(objects::InlineKeyboardMarkup),
    ReplyKeyboardMarkup(objects::ReplyKeyboardMarkup),
    ReplyKeyboardRemove(objects::ReplyKeyboardRemove),
    ForceReply(objects::ForceReply),
}

impl ::serde::Serialize for ReplyMarkup {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: ::serde::Serializer,
    {
        use self::ReplyMarkup::*;

        match self {
            &InlineKeyboardMarkup(ref x) => x.serialize(serializer),
            &ReplyKeyboardMarkup(ref x) => x.serialize(serializer),
            &ReplyKeyboardRemove(ref x) => x.serialize(serializer),
            &ForceReply(ref x) => x.serialize(serializer),
        }
    }
}

impl From<objects::InlineKeyboardMarkup> for ReplyMarkup {
    fn from(f: objects::InlineKeyboardMarkup) -> Self {
        ReplyMarkup::InlineKeyboardMarkup(f)
    }
}

impl From<objects::ReplyKeyboardMarkup> for ReplyMarkup {
    fn from(f: objects::ReplyKeyboardMarkup) -> Self {
        ReplyMarkup::ReplyKeyboardMarkup(f)
    }
}

impl From<objects::ReplyKeyboardRemove> for ReplyMarkup {
    fn from(f: objects::ReplyKeyboardRemove) -> Self {
        ReplyMarkup::ReplyKeyboardRemove(f)
    }
}

impl From<objects::ForceReply> for ReplyMarkup {
    fn from(f: objects::ForceReply) -> Self {
        ReplyMarkup::ForceReply(f)
    }
}

impl Into<String> for Action {
    fn into(self) -> String {
        let tmp = match self {
            Action::Typing => "Typing",
            Action::UploadPhoto => "UploadPhoto",
            Action::RecordVideo => "RecordVideo",
            Action::UploadVideo => "UploadVideo",
            Action::RecordAudio => "RecordVideo",
            Action::UploadAudio => "UploadAudio",
            Action::UploadDocument => "UploadDocument",
            Action::FindLocation => "FindLocation",
        };

        tmp.into()
    }
}

/// A simple method for testing your bot's auth token. Requires no parameters. Returns basic
/// information about the bot in form of a User object.
#[derive(TelegramFunction, Serialize)]
#[call = "getMe"]
#[answer = "User"]
#[function = "get_me"]
pub struct GetMe;

/// Use this method to receive incoming updates using long polling (wiki). An Array of Update
/// objects is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "getUpdates"]
#[answer = "Updates"]
#[function = "get_updates"]
pub struct GetUpdates {
    #[serde(skip_serializing_if = "Option::is_none")]
    offset: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    limit: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    timeout: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    allowed_updates: Option<Vec<String>>,
}

/// Use this method to send text messages. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendMessage"]
#[answer = "Message"]
#[function = "message"]
pub struct SendMessage {
    chat_id: Integer,
    text: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_web_page_preview: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to forward messages. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "forwardMessage"]
#[answer = "Message"]
#[function = "forward"]
pub struct FowardMessage {
    chat_id: Integer,
    from_chat_id: Integer,
    message_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
}

/// Use this method to send photos. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendPhoto"]
#[answer = "Message"]
#[function = "photo"]
#[file_kind = "photo"]
pub struct SendPhoto {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    photo: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send audio files, if you want Telegram clients to display them in the music
/// player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots
/// can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
///
/// For sending voice messages, use the sendVoice method instead.
#[derive(TelegramFunction, Serialize)]
#[call = "sendAudio"]
#[answer = "Message"]
#[function = "audio"]
#[file_kind = "audio"]
pub struct SendAudio {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    audio: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    performer: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    title: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send general files. On success, the sent Message is returned. Bots can
/// currently send files of any type of up to 50 MB in size, this limit may be changed in the
/// future.
#[derive(TelegramFunction, Serialize)]
#[call = "sendDocument"]
#[answer = "Message"]
#[function = "document"]
#[file_kind = "document"]
pub struct SendDocument {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    document: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send .webp stickers. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendSticker"]
#[answer = "Message"]
#[function = "sticker"]
#[file_kind = "sticker"]
pub struct SendSticker {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    sticker: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send video files, Telegram clients support mp4 videos (other formats may be
/// sent as Document). On success, the sent Message is returned. Bots can currently send video
/// files of up to 50 MB in size, this limit may be changed in the future.
#[derive(TelegramFunction, Serialize)]
#[call = "sendVideo"]
#[answer = "Message"]
#[function = "video"]
#[file_kind = "video"]
pub struct SendVideo {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    video: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    width: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    height: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send audio files, if you want Telegram clients to display the file as a
/// playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
/// (other formats may be sent as Audio or Document). On success, the sent Message is returned.
/// Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the
/// future.
#[derive(TelegramFunction, Serialize)]
#[call = "sendVoice"]
#[answer = "Message"]
#[function = "voice"]
#[file_kind = "voice"]
pub struct SendVoice {
    chat_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    voice: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

#[derive(TelegramFunction, Serialize)]
#[call = "sendMediaGroup"]
#[answer = "Messages"]
#[function = "mediagroup"]
#[file_kind = "media"]
pub struct SendMediaGroup {
    chat_id: Integer,
    media: Option<MediaFile>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>
}

/// Use this method to send point on the map. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendLocation"]
#[answer = "Message"]
#[function = "location"]
pub struct SendLocation {
    chat_id: Integer,
    latitude: f32,
    longitude: f32,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send information about a venue. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendVenue"]
#[answer = "Message"]
#[function = "venue"]
pub struct SendVenue {
    chat_id: Integer,
    latitude: f32,
    longitude: f32,
    title: String,
    address: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    foursquare_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method to send phone contacts. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendContact"]
#[answer = "Message"]
#[function = "contact"]
pub struct SendContact {
    chat_id: Integer,
    phone_number: String,
    first_name: String,
    last_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<ReplyMarkup>,
}

/// Use this method when you need to tell the user that something is happening on the bot's side.
/// The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients
/// clear its typing status). Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "sendChatAction"]
#[answer = "Boolean"]
#[function = "chat_action"]
pub struct SendAction {
    chat_id: Integer,
    action: String,
}

/// Use this method to send a game. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendGame"]
#[answer = "Message"]
#[function = "send_game"]
pub struct SendGame {
    chat_id: Integer,
    game_short_name: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_to_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<objects::InlineKeyboardMarkup>,
}

/// Use this method to set the score of the specified user in a game. On success, if the message
/// was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if
/// the new score is not greater than the user's current score in the chat and force is False.
#[derive(TelegramFunction, Serialize)]
#[call = "setGameScore"]
#[answer = "Message"]
#[function = "set_game_score"]
pub struct SetGameScore {
    user_id: Integer,
    score: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    force: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_edit_message: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    chat_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    inline_message_id: Option<String>,
}

/// Use this method to get data for high score tables. Will return the score of the specified user
/// and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
///
/// This method will currently return scores for the target user, plus two of his closest neighbors
/// on each side. Will also return the top three users if the user and his neighbors are not among
/// them. Please note that this behavior is subject to change.
#[derive(TelegramFunction, Serialize)]
#[call = "getGameHighScores"]
#[answer = "GameHighScore"]
#[function = "get_game_high_scores"]
pub struct GetGameHighScores {
    user_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    chat_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    inline_message_id: Option<String>,
}

/// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos
/// object.
#[derive(TelegramFunction, Serialize)]
#[call = "getUserProfilePhotos"]
#[answer = "UserProfilePhotos"]
#[function = "get_user_profile_photos"]
pub struct GetUserProfilePhotos {
    user_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    offset: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    limit: Option<Integer>,
}

/// Use this method to get basic info about a file and prepare it for downloading. For the moment,
/// bots can download files of up to 20MB in size. On success, a File object is returned. The file
/// can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where
/// <file_path> is taken from the response. It is guaranteed that the link will be valid for at
/// least 1 hour. When the link expires, a new one can be requested by calling getFile again.
#[derive(TelegramFunction, Serialize)]
#[call = "getFile"]
#[answer = "File"]
#[function = "get_file"]
pub struct GetFile {
    file_id: String,
}

/// Use this method to kick a user from a group or a supergroup. In the case of supergroups, the
/// user will not be able to return to the group on their own using invite links, etc., unless
/// unbanned first. The bot must be an administrator in the group for this to work. Returns True on
/// success.
#[derive(TelegramFunction, Serialize)]
#[call = "kickChatMember"]
#[answer = "Boolean"]
#[function = "kick_chat_member"]
pub struct KickChatMember {
    chat_id: Integer,
    user_id: Integer,
}

/// Use this method for your bot to leave a group, supergroup or channel. Returns True on
/// success.
#[derive(TelegramFunction, Serialize)]
#[call = "leaveChat"]
#[answer = "Boolean"]
#[function = "leave_chat"]
pub struct LeaveChat {
    chat_id: Integer,
}

/// Use this method to unban a previously kicked user in a supergroup. The user will not return to
/// the group automatically, but will be able to join via link, etc. The bot must be an
/// administrator in the group for this to work. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "unbanChatMember"]
#[answer = "Boolean"]
#[function = "unban_chat_member"]
pub struct UnbanChatMember {
    chat_id: Integer,
    user_id: Integer,
}

/// Use this method to restrict a user in a supergroup. The bot must be an administrator in the
/// supergroup for this to work and must have the appropriate admin rights. Pass True for all
/// boolean parameters to lift restrictions from a user. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "restrictChatMember"]
#[answer = "Boolean"]
#[function = "restrict_chat_member"]
pub struct RestrictChatMember {
    chat_id: Integer,
    user_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    until_date: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_send_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_send_media_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_send_other_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_add_web_previews: Option<bool>,
}

/// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an
/// administrator in the chat for this to work and must have the appropriate admin rights. Pass
/// False for all boolean parameters to demote a user. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "promoteChatMember"]
#[answer = "Boolean"]
#[function = "promote_chat_member"]
pub struct PromoteChatMember {
    chat_id: Integer,
    user_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_change_into: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_post_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_edit_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_delete_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_invite_users: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_restrict_members: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_pin_messages: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    can_promote_members: Option<bool>,
}

/// Use this method to generate a new invite link for a chat; any previously generated link is
/// revoked. The bot must be an administrator in the chat for this to work and must have the
/// appropriate admin rights. Returns the new invite link as String on success.
#[derive(TelegramFunction, Serialize)]
#[call = "exportChatInviteLink"]
#[answer = "Link"]
#[function = "export_chat_invite_link"]
pub struct ExportChatInviteLink {
    chat_id: Integer,
}

/// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must
/// be an administrator in the chat for this to work and must have the appropriate admin rights.
/// Returns True on success.
///
/// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are
/// Admins’ setting is off in the target group.
#[derive(TelegramFunction, Serialize)]
#[call = "deleteChatPhoto"]
#[answer = "Boolean"]
#[function = "delete_chat_photo"]
pub struct DeleteChatPhoto {
    chat_id: Integer,
}

/// Use this method to change the title of a chat. Titles can't be changed for private chats. The
/// bot must be an administrator in the chat for this to work and must have the appropriate admin
/// rights. Returns True on success.
///
/// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are
/// Admins’ setting is off in the target group.
#[derive(TelegramFunction, Serialize)]
#[call = "setChatTitle"]
#[answer = "Boolean"]
#[function = "set_chat_title"]
pub struct SetChatTitle {
    chat_id: Integer,
    title: String,
}

/// Use this method to change the description of a supergroup or a channel. The bot must be an
/// administrator in the chat for this to work and must have the appropriate admin rights. Returns
/// True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "setChatDescription"]
#[answer = "Boolean"]
#[function = "set_chat_description"]
pub struct SetChatDescription {
    chat_id: Integer,
    description: String,
}

/// Use this method to pin a message in a supergroup or a channel. The bot must be an administrator
/// in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup
/// or ‘can_edit_messages’ admin right in the channel. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "pinChatMessage"]
#[answer = "Boolean"]
#[function = "pin_chat_message"]
pub struct PinChatMessage {
    chat_id: Integer,
    message_id: Integer,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_notification: Option<bool>,
}

/// Use this method to unpin a message in a supergroup or a channel. The bot must be an
/// administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in
/// the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "unpinChatMessage"]
#[answer = "Boolean"]
#[function = "unpin_chat_message"]
pub struct UnpinChatMessage {
    chat_id: Integer,
}

/// Use this method to get up to date information about the chat (current name of the user for
/// one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat
/// object on success.
#[derive(TelegramFunction, Serialize)]
#[call = "getChat"]
#[answer = "Chat"]
#[function = "get_chat"]
pub struct GetChat {
    chat_id: Integer,
}

/// Use this method to get a list of administrators in a chat. On success, returns an Array of
/// ChatMember objects that contains information about all chat administrators except other bots.
/// If the chat is a group or a supergroup and no administrators were appointed, only the creator
/// will be returned.
#[derive(TelegramFunction, Serialize)]
#[call = "getChatAdministrators"]
#[answer = "Vector<objects::ChatMember>"]
#[function = "unban_chat_administrators"]
pub struct GetChatAdministrators {
    chat_id: Integer,
}

/// Use this method to get the number of members in a chat. Returns Int on success.
#[derive(TelegramFunction, Serialize)]
#[call = "getChatMembersCount"]
#[answer = "Integer"]
#[function = "get_chat_members_count"]
pub struct GetChatMemberCounts {
    chat_id: Integer,
}

/// Use this method to get information about a member of a chat. Returns a ChatMember object on
/// success.
#[derive(TelegramFunction, Serialize)]
#[call = "getChatMember"]
#[answer = "ChatMember"]
#[function = "get_chat_member"]
pub struct GetChatMember {
    chat_id: Integer,
    user_id: Integer,
}

/// Use this method to send answers to callback queries sent from inline keyboards. The answer will
/// be displayed to the user as a notification at the top of the chat screen or as an alert. On
/// success, True is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "answerCallbackQuery"]
#[answer = "Boolean"]
#[function = "answer_callback_query"]
pub struct AnswerCallbackQuery {
    callback_query_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    text: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    show_alert: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    cache_time: Option<Integer>,
}

/// Use this method to send answers to an inline query. On success, True is returned.
/// No more than 50 results per query are allowed.
#[derive(TelegramFunction, Serialize)]
#[call = "answerInlineQuery"]
#[answer = "Boolean"]
#[function = "answer_inline_query"]
pub struct AnswerInlineQuery {
    inline_query_id: String,
    results: Vec<Box<Serialize + Send>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    cache_time: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    is_personal: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    next_offset: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    switch_pm_text: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    switch_pm_parameter: Option<String>,
}

/// Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
/// On success, if edited message is sent by the bot, the edited Message is returned, otherwise True
/// is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "editMessageText"]
#[answer = "EditResponse"]
#[function = "edit_message_text"]
pub struct EditMessageText {
    text: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    chat_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    inline_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    disable_web_page_preview: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<objects::InlineKeyboardMarkup>,
}

/// Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
/// On success, if edited message is sent by the bot, the edited Message is returned, otherwise
/// True is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "editMessageCaption"]
#[answer = "EditResponse"]
#[function = "edit_message_caption"]
pub struct EditMessageCaption {
    #[serde(skip_serializing_if = "Option::is_none")]
    chat_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    inline_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    caption: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    parse_mode: Option<ParseMode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<objects::InlineKeyboardMarkup>,
}

/// Use this method to edit only the reply markup of messages sent by the bot or via the bot (for
/// inline bots). On success, if edited message is sent by the bot, the edited Message is returned,
/// otherwise True is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "editMessageReplyMarkup"]
#[answer = "EditResponse"]
#[function = "edit_message_reply_markup"]
pub struct EditMessageReplyMarkup {
    #[serde(skip_serializing_if = "Option::is_none")]
    chat_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    inline_message_id: Option<Integer>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reply_markup: Option<objects::InlineKeyboardMarkup>,
}

/// Use this method to delete a message, including service messages, with the following limitations:
/// - A message can only be deleted if it was sent less than 48 hours ago.
/// - Bots can delete outgoing messages in groups and supergroups.
/// - Bots granted can_post_messages permissions can delete outgoing messages in channels.
/// - If the bot is an administrator of a group, it can delete any message there.
/// - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any
///		message there.
/// Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "deleteMessage"]
#[answer = "Boolean"]
#[function = "delete_message"]
pub struct DeleteMessage {
    chat_id: Integer,
    message_id: Integer,
}

///Use this method to create new sticker set owned by a user.
///The bot will be able to edit the created sticker set. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "createNewStickerSet"]
#[answer = "Boolean"]
#[function = "create_new_sticker_set"]
#[file_kind = "png_sticker"]
pub struct CreateNewStickerSet {
    user_id: Integer,
    name: String,
    title: String,
    emojis: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    png_sticker: Option<MediaFile>,
}

///Use this method to add a new sticker to a set created by the bot. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "addStickerToSet"]
#[answer = "Boolean"]
#[function = "add_sticker_to_set"]
#[file_kind = "png_sticker"]
pub struct AddStickerToSet {
    user_id: Integer,
    name: String,
    emojis: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    png_sticker: Option<MediaFile>,
}

///Use this method to add a new sticker to a set created by the bot. Returns True on success.
#[derive(TelegramFunction, Serialize)]
#[call = "deleteStickerFromSet"]
#[answer = "Boolean"]
#[function = "delete_sticker_from_set"]
pub struct DeleteStickerFromSet {
    sticker: String,
}