1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::chat::{Chat, ChatId, PinChatMessage, UnpinChatMessage};
6use crate::file::{
7 Animation, Audio, Document, InputFile, InputFileVariant, InputMedia, PhotoSize, Video,
8 VideoNote, Voice,
9};
10use crate::markup::{InlineKeyboardMarkup, MessageEntity, ParseMode, ReplyMarkup};
11use crate::payment::{Invoice, SuccessfulPayment};
12use crate::sticker::Sticker;
13use crate::user::User;
14use crate::{FileMethod, JsonMethod, TelegramMethod};
15
16#[derive(Debug, Deserialize)]
18pub struct Message {
19 pub message_id: i64,
21 pub from: Option<User>,
23 pub sender_chat: Option<Chat>,
28 pub date: u64,
30 pub chat: Chat,
32 pub forward_from: Option<User>,
34 pub forward_from_chat: Option<Chat>,
36 pub forward_from_message_id: Option<i64>,
38 pub forward_signature: Option<String>,
40 pub forward_sender_name: Option<String>,
42 pub forward_date: Option<u64>,
44 pub reply_to_message: Option<Box<Message>>,
47 pub via_bot: Option<User>,
49 pub edit_date: Option<u64>,
51 pub media_group_id: Option<String>,
53 pub author_signature: Option<String>,
56 #[serde(flatten)]
58 pub kind: MessageKind,
59 pub reply_markup: Option<InlineKeyboardMarkup>,
62}
63
64impl Message {
65 pub fn reply_text(&self, text: impl Into<String>) -> SendMessage {
66 SendMessage::new(self.chat.id, text).reply_to(self.message_id)
67 }
68
69 pub fn forward_to(&self, chat_id: impl Into<ChatId>) -> ForwardMessage {
70 ForwardMessage::new(chat_id, self.chat.id, self.message_id)
71 }
72
73 pub fn copy_to(&self, chat_id: impl Into<ChatId>) -> CopyMessage {
74 CopyMessage::new(chat_id, self.chat.id, self.message_id)
75 }
76
77 pub fn pin(&self) -> PinChatMessage {
78 PinChatMessage::new(self.chat.id, self.message_id)
79 }
80
81 pub fn unpin(&self) -> UnpinChatMessage {
82 UnpinChatMessage::new(self.chat.id, self.message_id)
83 }
84
85 pub fn edit_text(&self, text: impl Into<String>) -> EditMessageText {
86 EditMessageText::new(self.chat.id, self.message_id, text)
87 }
88
89 pub fn remove_caption(&self) -> EditMessageCaption {
90 EditMessageCaption::new_empty(self.chat.id, self.message_id)
91 }
92
93 pub fn edit_caption(&self, caption: impl Into<String>) -> EditMessageCaption {
94 EditMessageCaption::new(self.chat.id, self.message_id, caption)
95 }
96
97 pub fn edit_media(&self, media: impl Into<InputMedia>) -> EditMessageMedia {
98 EditMessageMedia::new(self.chat.id, self.message_id, media)
99 }
100
101 pub fn remove_reply_markup(&self) -> EditMessageReplyMarkup {
102 EditMessageReplyMarkup::new_empty(self.chat.id, self.message_id)
103 }
104
105 pub fn edit_reply_markup(
106 &self,
107 reply_markup: impl Into<InlineKeyboardMarkup>,
108 ) -> EditMessageReplyMarkup {
109 EditMessageReplyMarkup::new(self.chat.id, self.message_id, reply_markup)
110 }
111
112 pub fn stop_poll(&self) -> StopPoll {
113 StopPoll::new(self.chat.id, self.message_id)
114 }
115
116 pub fn delete(&self) -> DeleteMessage {
117 DeleteMessage::new(self.chat.id, self.message_id)
118 }
119}
120
121#[derive(Debug, Deserialize)]
123#[serde(untagged)]
124pub enum MessageKind {
125 Text {
127 text: String,
129 entities: Option<Vec<MessageEntity>>,
131 },
132 Animation {
134 animation: Animation,
137 document: Document,
139 caption: Option<String>,
141 caption_entities: Option<Vec<MessageEntity>>,
143 },
144 Audio {
146 audio: Audio,
148 caption: Option<String>,
150 caption_entities: Option<Vec<MessageEntity>>,
152 },
153 Document {
155 document: Document,
157 caption: Option<String>,
159 caption_entities: Option<Vec<MessageEntity>>,
161 },
162 Photo {
164 photo: Vec<PhotoSize>,
166 caption: Option<String>,
168 caption_entities: Option<Vec<MessageEntity>>,
170 },
171 Sticker {
173 sticker: Sticker,
175 },
176 Video {
178 video: Video,
180 caption: Option<String>,
182 caption_entities: Option<Vec<MessageEntity>>,
184 },
185 VideoNote {
187 video_note: VideoNote,
189 },
190 Voice {
192 voice: Voice,
194 caption: Option<String>,
196 caption_entities: Option<Vec<MessageEntity>>,
198 },
199 Contact {
201 contact: Contact,
203 },
204 Dice {
205 dice: Dice,
206 },
207 Game {
208 game: Game,
211 },
212 Poll {
214 poll: Poll,
216 },
217 Venue {
219 venue: Venue,
222 location: Location,
224 },
225 Location {
227 location: Location,
229 },
230 NewChatMembers {
232 new_chat_members: Vec<User>,
235 },
236 LeftChatMember {
238 left_chat_member: User,
241 },
242 NewChatTitle {
244 new_chat_title: String,
246 },
247 DeleteChatPhoto {
249 delete_chat_photo: bool,
251 },
252 GroupChatCreated {
254 group_chat_created: bool,
256 },
257 SupergroupChatCreated {
263 supergroup_chat_created: bool,
265 },
266 ChannelChatCreated {
272 channel_chat_created: bool,
274 },
275 MessageAutoDeleteTimerChanged {
277 message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged,
278 },
279 GroupMigrated {
281 migrate_to_chat_id: i64,
283 migrate_from_chat_id: i64,
285 },
286 MessagePinned {
288 pinned_message: Box<Message>,
291 },
292 Invoice {
294 invoice: Invoice,
297 },
298 SuccessfulPayment {
300 successful_payment: SuccessfulPayment,
303 },
304 Login {
306 connected_website: String,
309 passport_data: PassportData,
311 },
312 ProximityAlertTriggered {
314 proximity_alert_triggered: ProximityAlertTriggered,
315 },
316 VoiceChatScheduled {
318 voice_chat_scheduled: VoiceChatScheduled,
319 },
320 VoiceChatStarted {
322 voice_chat_started: VoiceChatStarted,
323 },
324 VoiceChatEnded {
326 voice_chat_ended: VoiceChatEnded,
327 },
328 VoiceChatParticipantsInvited {
330 voice_chat_participants_invited: VoiceChatParticipantsInvited,
331 },
332}
333
334impl MessageKind {
335 pub fn text(&self) -> Option<&str> {
336 match self {
337 Self::Text { text, .. } => Some(text),
338 _ => None,
339 }
340 }
341
342 pub fn entities(&self) -> Option<&[MessageEntity]> {
343 match self {
344 Self::Text { entities, .. } => entities.as_deref(),
345 _ => None,
346 }
347 }
348
349 pub fn animation(&self) -> Option<&Animation> {
350 match self {
351 Self::Animation { animation, .. } => Some(animation),
352 _ => None,
353 }
354 }
355
356 pub fn document(&self) -> Option<&Document> {
357 match self {
358 Self::Animation { document, .. } | Self::Document { document, .. } => Some(document),
359 _ => None,
360 }
361 }
362
363 pub fn caption(&self) -> Option<&str> {
364 match self {
365 Self::Animation { caption, .. }
366 | Self::Audio { caption, .. }
367 | Self::Document { caption, .. }
368 | Self::Photo { caption, .. }
369 | Self::Video { caption, .. }
370 | Self::Voice { caption, .. } => caption.as_deref(),
371 _ => None,
372 }
373 }
374
375 pub fn caption_entities(&self) -> Option<&[MessageEntity]> {
376 match self {
377 Self::Animation {
378 caption_entities, ..
379 }
380 | Self::Audio {
381 caption_entities, ..
382 }
383 | Self::Document {
384 caption_entities, ..
385 }
386 | Self::Photo {
387 caption_entities, ..
388 }
389 | Self::Video {
390 caption_entities, ..
391 }
392 | Self::Voice {
393 caption_entities, ..
394 } => caption_entities.as_deref(),
395 _ => None,
396 }
397 }
398
399 pub fn audio(&self) -> Option<&Audio> {
400 match self {
401 Self::Audio { audio, .. } => Some(audio),
402 _ => None,
403 }
404 }
405
406 pub fn photo(&self) -> Option<&[PhotoSize]> {
407 match self {
408 Self::Photo { photo, .. } => Some(photo.as_ref()),
409 _ => None,
410 }
411 }
412
413 pub fn sticker(&self) -> Option<&Sticker> {
414 match self {
415 Self::Sticker { sticker } => Some(sticker),
416 _ => None,
417 }
418 }
419
420 pub fn video(&self) -> Option<&Video> {
421 match self {
422 Self::Video { video, .. } => Some(video),
423 _ => None,
424 }
425 }
426
427 pub fn video_note(&self) -> Option<&VideoNote> {
428 match self {
429 Self::VideoNote { video_note } => Some(video_note),
430 _ => None,
431 }
432 }
433
434 pub fn voice(&self) -> Option<&Voice> {
435 match self {
436 Self::Voice { voice, .. } => Some(voice),
437 _ => None,
438 }
439 }
440
441 pub fn contact(&self) -> Option<&Contact> {
442 match self {
443 Self::Contact { contact } => Some(contact),
444 _ => None,
445 }
446 }
447
448 pub fn dice(&self) -> Option<&Dice> {
449 match self {
450 Self::Dice { dice } => Some(dice),
451 _ => None,
452 }
453 }
454
455 pub fn game(&self) -> Option<&Game> {
456 match self {
457 Self::Game { game } => Some(game),
458 _ => None,
459 }
460 }
461
462 pub fn poll(&self) -> Option<&Poll> {
463 match self {
464 Self::Poll { poll } => Some(poll),
465 _ => None,
466 }
467 }
468
469 pub fn venue(&self) -> Option<&Venue> {
470 match self {
471 Self::Venue { venue, .. } => Some(venue),
472 _ => None,
473 }
474 }
475
476 pub fn location(&self) -> Option<&Location> {
477 match self {
478 Self::Venue { location, .. } | Self::Location { location } => Some(location),
479 _ => None,
480 }
481 }
482
483 pub fn new_chat_members(&self) -> Option<&[User]> {
484 match self {
485 Self::NewChatMembers { new_chat_members } => Some(new_chat_members.as_ref()),
486 _ => None,
487 }
488 }
489
490 pub fn left_chat_member(&self) -> Option<&User> {
491 match self {
492 Self::LeftChatMember { left_chat_member } => Some(left_chat_member),
493 _ => None,
494 }
495 }
496
497 pub fn new_chat_title(&self) -> Option<&str> {
498 match self {
499 Self::NewChatTitle { new_chat_title } => Some(new_chat_title),
500 _ => None,
501 }
502 }
503
504 pub fn message_auto_delete_timer_changed(&self) -> Option<&MessageAutoDeleteTimerChanged> {
505 match self {
506 Self::MessageAutoDeleteTimerChanged {
507 message_auto_delete_timer_changed,
508 } => Some(message_auto_delete_timer_changed),
509 _ => None,
510 }
511 }
512
513 pub fn migrate_to_chat_id(&self) -> Option<i64> {
514 match self {
515 Self::GroupMigrated {
516 migrate_to_chat_id, ..
517 } => Some(*migrate_to_chat_id),
518 _ => None,
519 }
520 }
521
522 pub fn migrate_from_chat_id(&self) -> Option<i64> {
523 match self {
524 Self::GroupMigrated {
525 migrate_from_chat_id,
526 ..
527 } => Some(*migrate_from_chat_id),
528 _ => None,
529 }
530 }
531
532 pub fn pinned_message(&self) -> Option<&Message> {
533 match self {
534 Self::MessagePinned { pinned_message } => Some(pinned_message.as_ref()),
535 _ => None,
536 }
537 }
538
539 pub fn invoice(&self) -> Option<&Invoice> {
540 match self {
541 Self::Invoice { invoice } => Some(invoice),
542 _ => None,
543 }
544 }
545
546 pub fn successful_payment(&self) -> Option<&SuccessfulPayment> {
547 match self {
548 Self::SuccessfulPayment { successful_payment } => Some(successful_payment),
549 _ => None,
550 }
551 }
552
553 pub fn connected_website(&self) -> Option<&str> {
554 match self {
555 Self::Login {
556 connected_website, ..
557 } => Some(connected_website),
558 _ => None,
559 }
560 }
561
562 pub fn passport_data(&self) -> Option<&PassportData> {
563 match self {
564 Self::Login { passport_data, .. } => Some(passport_data),
565 _ => None,
566 }
567 }
568
569 pub fn proximity_alert_triggered(&self) -> Option<&ProximityAlertTriggered> {
570 match self {
571 Self::ProximityAlertTriggered {
572 proximity_alert_triggered,
573 } => Some(proximity_alert_triggered),
574 _ => None,
575 }
576 }
577
578 pub fn voice_chat_scheduled(&self) -> Option<&VoiceChatScheduled> {
579 match self {
580 Self::VoiceChatScheduled {
581 voice_chat_scheduled,
582 } => Some(voice_chat_scheduled),
583 _ => None,
584 }
585 }
586
587 pub fn voice_chat_started(&self) -> Option<&VoiceChatStarted> {
588 match self {
589 Self::VoiceChatStarted { voice_chat_started } => Some(voice_chat_started),
590 _ => None,
591 }
592 }
593
594 pub fn voice_chat_ended(&self) -> Option<&VoiceChatEnded> {
595 match self {
596 Self::VoiceChatEnded { voice_chat_ended } => Some(voice_chat_ended),
597 _ => None,
598 }
599 }
600
601 pub fn voice_chat_participants_invited(&self) -> Option<&VoiceChatParticipantsInvited> {
602 match self {
603 Self::VoiceChatParticipantsInvited {
604 voice_chat_participants_invited,
605 } => Some(voice_chat_participants_invited),
606 _ => None,
607 }
608 }
609
610 pub fn is_text(&self) -> bool {
611 matches!(self, Self::Text { .. })
612 }
613
614 pub fn is_animation(&self) -> bool {
615 matches!(self, Self::Animation { .. })
616 }
617
618 pub fn is_audio(&self) -> bool {
619 matches!(self, Self::Audio { .. })
620 }
621
622 pub fn is_document(&self) -> bool {
623 matches!(self, Self::Document { .. })
624 }
625
626 pub fn is_photo(&self) -> bool {
627 matches!(self, Self::Photo { .. })
628 }
629
630 pub fn is_sticker(&self) -> bool {
631 matches!(self, Self::Sticker { .. })
632 }
633
634 pub fn is_video(&self) -> bool {
635 matches!(self, Self::Video { .. })
636 }
637
638 pub fn is_video_note(&self) -> bool {
639 matches!(self, Self::VideoNote { .. })
640 }
641
642 pub fn is_voice(&self) -> bool {
643 matches!(self, Self::Voice { .. })
644 }
645
646 pub fn is_contact(&self) -> bool {
647 matches!(self, Self::Contact { .. })
648 }
649
650 pub fn is_dice(&self) -> bool {
651 matches!(self, Self::Dice { .. })
652 }
653
654 pub fn is_game(&self) -> bool {
655 matches!(self, Self::Game { .. })
656 }
657
658 pub fn is_poll(&self) -> bool {
659 matches!(self, Self::Poll { .. })
660 }
661
662 pub fn is_venue(&self) -> bool {
663 matches!(self, Self::Venue { .. })
664 }
665
666 pub fn is_location(&self) -> bool {
667 matches!(self, Self::Location { .. })
668 }
669
670 pub fn is_new_chat_members(&self) -> bool {
671 matches!(self, Self::NewChatMembers { .. })
672 }
673
674 pub fn is_left_chat_member(&self) -> bool {
675 matches!(self, Self::LeftChatMember { .. })
676 }
677
678 pub fn is_new_chat_title(&self) -> bool {
679 matches!(self, Self::NewChatTitle { .. })
680 }
681
682 pub fn is_delete_chat_photo(&self) -> bool {
683 matches!(self, Self::DeleteChatPhoto { .. })
684 }
685
686 pub fn is_group_chat_created(&self) -> bool {
687 matches!(self, Self::GroupChatCreated { .. })
688 }
689
690 pub fn is_supergroup_chat_created(&self) -> bool {
691 matches!(self, Self::SupergroupChatCreated { .. })
692 }
693
694 pub fn is_channel_chat_created(&self) -> bool {
695 matches!(self, Self::ChannelChatCreated { .. })
696 }
697
698 pub fn is_group_migrated(&self) -> bool {
699 matches!(self, Self::GroupMigrated { .. })
700 }
701
702 pub fn is_message_pinned(&self) -> bool {
703 matches!(self, Self::MessagePinned { .. })
704 }
705
706 pub fn is_invoice(&self) -> bool {
707 matches!(self, Self::Invoice { .. })
708 }
709
710 pub fn is_login(&self) -> bool {
711 matches!(self, Self::Login { .. })
712 }
713
714 pub fn is_proximity_alert_triggered(&self) -> bool {
715 matches!(self, Self::ProximityAlertTriggered { .. })
716 }
717
718 pub fn is_voice_chat_scheduled(&self) -> bool {
719 matches!(self, Self::VoiceChatScheduled { .. })
720 }
721
722 pub fn is_voice_chat_started(&self) -> bool {
723 matches!(self, Self::VoiceChatStarted { .. })
724 }
725
726 pub fn is_voice_chat_ended(&self) -> bool {
727 matches!(self, Self::VoiceChatEnded { .. })
728 }
729
730 pub fn is_voice_chat_participants_invited(&self) -> bool {
731 matches!(self, Self::VoiceChatParticipantsInvited { .. })
732 }
733}
734
735#[derive(Debug, Deserialize)]
737pub struct MessageId {
738 pub message_id: i64,
740}
741
742#[derive(Debug, Deserialize)]
744pub struct Location {
745 pub longitude: f32,
747 pub latitude: f32,
749 pub horizontal_accuracy: Option<f32>,
751 pub live_period: Option<i32>,
754 pub heading: Option<i32>,
757 pub proximity_alert_radius: Option<i32>,
760}
761
762#[derive(Debug, Deserialize)]
764pub struct Contact {
765 pub phone_number: String,
767 pub first_name: String,
769 pub last_name: Option<String>,
771 pub user_id: Option<i64>,
773 pub vcard: Option<String>,
775}
776
777#[derive(Debug, Deserialize)]
779pub struct Dice {
780 pub emoji: String,
782 pub value: i32,
784}
785
786#[derive(Debug, Deserialize)]
787pub struct Game {}
788
789#[derive(Debug, Deserialize)]
791pub struct PollOption {
792 pub text: String,
794 pub voter_count: u32,
796}
797
798#[derive(Debug, Deserialize)]
800pub struct PollAnswer {
801 pub poll_id: String,
803 pub user: User,
805 pub option_ids: Vec<u32>,
808}
809
810#[derive(Debug, Deserialize)]
812pub struct Poll {
813 pub id: String,
815 pub question: String,
817 pub options: Vec<PollOption>,
819 pub total_voter_count: u32,
821 pub is_closed: bool,
823 pub is_anonymous: bool,
825 #[serde(flatten)]
827 pub kind: PollKind,
828 pub allows_multiple_answers: bool,
830 pub open_period: Option<u32>,
832 pub close_date: Option<u64>,
834}
835
836#[derive(Debug, Deserialize)]
838#[serde(rename_all = "snake_case", tag = "type")]
839pub enum PollKind {
840 Regular,
841 Quiz {
842 correct_option_id: Option<usize>,
846 explanation: Option<String>,
849 explanation_entities: Option<Vec<MessageEntity>>,
851 },
852}
853
854impl PollKind {
855 pub fn correct_option_id(&self) -> Option<usize> {
856 match self {
857 Self::Quiz {
858 correct_option_id, ..
859 } => *correct_option_id,
860 _ => None,
861 }
862 }
863
864 pub fn explanation(&self) -> Option<&str> {
865 match self {
866 Self::Quiz { explanation, .. } => explanation.as_deref(),
867 _ => None,
868 }
869 }
870
871 pub fn explanation_entities(&self) -> Option<&[MessageEntity]> {
872 match self {
873 Self::Quiz {
874 explanation_entities,
875 ..
876 } => explanation_entities.as_deref(),
877 _ => None,
878 }
879 }
880
881 pub fn is_regular(&self) -> bool {
882 matches!(self, Self::Regular)
883 }
884
885 pub fn is_quiz(&self) -> bool {
886 matches!(self, Self::Quiz { .. })
887 }
888}
889
890#[derive(Debug, Deserialize)]
892pub struct Venue {
893 pub location: Location,
895 pub title: String,
897 pub address: String,
899 pub foursquare_id: Option<String>,
901 pub foursquare_type: Option<String>,
905 pub google_place_id: Option<String>,
907 pub google_place_type: String,
909}
910
911#[derive(Debug, Deserialize)]
913pub struct MessageAutoDeleteTimerChanged {
914 pub message_auto_delete_time: u32,
916}
917
918#[derive(Debug, Deserialize)]
919pub struct PassportData {}
920
921#[derive(Debug, Deserialize)]
924pub struct ProximityAlertTriggered {
925 pub traveler: User,
927 pub watcher: User,
929 pub distance: u32,
931}
932
933#[derive(Debug, Deserialize)]
935pub struct VoiceChatScheduled {
936 pub start_date: u64,
938}
939
940#[derive(Debug, Deserialize)]
943pub struct VoiceChatStarted;
944
945#[derive(Debug, Deserialize)]
947pub struct VoiceChatEnded {
948 pub duration: u32,
950}
951
952#[derive(Debug, Deserialize)]
954pub struct VoiceChatParticipantsInvited {
955 pub users: Option<Vec<User>>,
957}
958
959#[derive(Clone, Serialize)]
961pub struct SendMessage {
962 pub chat_id: ChatId,
964 pub text: String,
966 #[serde(skip_serializing_if = "Option::is_none")]
969 pub parse_mode: Option<ParseMode>,
970 #[serde(skip_serializing_if = "Option::is_none")]
973 pub entities: Option<Vec<MessageEntity>>,
974 #[serde(skip_serializing_if = "Option::is_none")]
976 pub disable_web_page_preview: Option<bool>,
977 #[serde(skip_serializing_if = "Option::is_none")]
980 pub disable_notification: Option<bool>,
981 #[serde(skip_serializing_if = "Option::is_none")]
983 pub reply_to_message_id: Option<i64>,
984 #[serde(skip_serializing_if = "Option::is_none")]
986 pub allow_sending_without_reply: Option<bool>,
987 #[serde(skip_serializing_if = "Option::is_none")]
992 pub reply_markup: Option<ReplyMarkup>,
993 #[serde(skip_serializing_if = "Option::is_none")]
995 pub protect_content: Option<bool>,
996}
997
998impl SendMessage {
999 pub fn new(chat_id: impl Into<ChatId>, text: impl Into<String>) -> Self {
1001 Self {
1002 chat_id: chat_id.into(),
1003 text: text.into(),
1004 parse_mode: None,
1005 entities: None,
1006 disable_web_page_preview: None,
1007 disable_notification: None,
1008 reply_to_message_id: None,
1009 allow_sending_without_reply: None,
1010 reply_markup: None,
1011 protect_content: None,
1012 }
1013 }
1014 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1016 Self {
1017 parse_mode: Some(parse_mode),
1018 ..self
1019 }
1020 }
1021 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1023 Self {
1024 entities: Some(entities),
1025 ..self
1026 }
1027 }
1028 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1030 let entities = self.entities.get_or_insert_with(Default::default);
1031 entities.push(entity);
1032 self
1033 }
1034 pub fn disable_web_page_preview(self) -> Self {
1036 Self {
1037 disable_web_page_preview: Some(true),
1038 ..self
1039 }
1040 }
1041 pub fn disable_notification(self) -> Self {
1043 Self {
1044 disable_notification: Some(true),
1045 ..self
1046 }
1047 }
1048 pub fn reply_to(self, message_id: i64) -> Self {
1050 Self {
1051 reply_to_message_id: Some(message_id),
1052 ..self
1053 }
1054 }
1055 pub fn allow_sending_without_reply(self) -> Self {
1057 Self {
1058 allow_sending_without_reply: Some(true),
1059 ..self
1060 }
1061 }
1062 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1064 Self {
1065 reply_markup: Some(markup.into()),
1066 ..self
1067 }
1068 }
1069 pub fn protect_content(self) -> Self {
1071 Self {
1072 protect_content: Some(true),
1073 ..self
1074 }
1075 }
1076}
1077
1078impl TelegramMethod for SendMessage {
1079 type Response = Message;
1080
1081 fn name() -> &'static str {
1082 "sendMessage"
1083 }
1084}
1085
1086impl JsonMethod for SendMessage {}
1087
1088#[derive(Clone, Serialize)]
1091pub struct ForwardMessage {
1092 pub chat_id: ChatId,
1094 pub from_chat_id: ChatId,
1096 #[serde(skip_serializing_if = "Option::is_none")]
1099 pub disable_notification: Option<bool>,
1100 pub message_id: i64,
1102 #[serde(skip_serializing_if = "Option::is_none")]
1104 pub protect_content: Option<bool>,
1105}
1106
1107impl ForwardMessage {
1108 pub fn new(to: impl Into<ChatId>, from: impl Into<ChatId>, message: i64) -> Self {
1110 Self {
1111 chat_id: to.into(),
1112 from_chat_id: from.into(),
1113 disable_notification: None,
1114 message_id: message,
1115 protect_content: None,
1116 }
1117 }
1118 pub fn disable_notification(self) -> Self {
1120 Self {
1121 disable_notification: Some(true),
1122 ..self
1123 }
1124 }
1125 pub fn protect_content(self) -> Self {
1127 Self {
1128 protect_content: Some(true),
1129 ..self
1130 }
1131 }
1132}
1133
1134impl TelegramMethod for ForwardMessage {
1135 type Response = Message;
1136
1137 fn name() -> &'static str {
1138 "forwardMessage"
1139 }
1140}
1141
1142impl JsonMethod for ForwardMessage {}
1143
1144#[derive(Clone, Serialize)]
1149pub struct CopyMessage {
1150 pub chat_id: ChatId,
1152 pub from_chat_id: ChatId,
1154 pub message_id: i64,
1156 pub caption: Option<String>,
1159 pub parse_mode: Option<ParseMode>,
1162 pub caption_entities: Option<Vec<MessageEntity>>,
1164 #[serde(skip_serializing_if = "Option::is_none")]
1167 pub disable_notification: Option<bool>,
1168 #[serde(skip_serializing_if = "Option::is_none")]
1170 pub reply_to_message_id: Option<i64>,
1171 #[serde(skip_serializing_if = "Option::is_none")]
1173 pub allow_sending_without_reply: Option<bool>,
1174 #[serde(skip_serializing_if = "Option::is_none")]
1179 pub reply_markup: Option<ReplyMarkup>,
1180 #[serde(skip_serializing_if = "Option::is_none")]
1182 pub protect_content: Option<bool>,
1183}
1184
1185impl CopyMessage {
1186 pub fn new(to: impl Into<ChatId>, from: impl Into<ChatId>, message: i64) -> Self {
1188 Self {
1189 chat_id: to.into(),
1190 from_chat_id: from.into(),
1191 message_id: message,
1192 caption: None,
1193 parse_mode: None,
1194 caption_entities: None,
1195 disable_notification: None,
1196 reply_to_message_id: None,
1197 allow_sending_without_reply: None,
1198 reply_markup: None,
1199 protect_content: None,
1200 }
1201 }
1202 pub fn with_caption(self, caption: impl Into<String>) -> Self {
1204 Self {
1205 caption: Some(caption.into()),
1206 ..self
1207 }
1208 }
1209 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1211 Self {
1212 parse_mode: Some(parse_mode),
1213 ..self
1214 }
1215 }
1216 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1218 Self {
1219 caption_entities: Some(entities),
1220 ..self
1221 }
1222 }
1223 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1225 let entities = self.caption_entities.get_or_insert_with(Default::default);
1226 entities.push(entity);
1227 self
1228 }
1229 pub fn disable_notification(self) -> Self {
1231 Self {
1232 disable_notification: Some(true),
1233 ..self
1234 }
1235 }
1236 pub fn reply_to(self, message_id: i64) -> Self {
1238 Self {
1239 reply_to_message_id: Some(message_id),
1240 ..self
1241 }
1242 }
1243 pub fn allow_sending_without_reply(self) -> Self {
1245 Self {
1246 allow_sending_without_reply: Some(true),
1247 ..self
1248 }
1249 }
1250 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1252 Self {
1253 reply_markup: Some(markup.into()),
1254 ..self
1255 }
1256 }
1257 pub fn protect_content(self) -> Self {
1259 Self {
1260 protect_content: Some(true),
1261 ..self
1262 }
1263 }
1264}
1265
1266impl TelegramMethod for CopyMessage {
1267 type Response = MessageId;
1268
1269 fn name() -> &'static str {
1270 "copyMessage"
1271 }
1272}
1273
1274impl JsonMethod for CopyMessage {}
1275
1276#[derive(Clone, Serialize)]
1279pub struct SendPhoto {
1280 pub chat_id: ChatId,
1282 pub photo: InputFileVariant,
1291 #[serde(skip_serializing_if = "Option::is_none")]
1293 pub caption: Option<String>,
1294 #[serde(skip_serializing_if = "Option::is_none")]
1297 pub parse_mode: Option<ParseMode>,
1298 #[serde(skip_serializing_if = "Option::is_none")]
1300 pub caption_entities: Option<Vec<MessageEntity>>,
1301 #[serde(skip_serializing_if = "Option::is_none")]
1304 pub disable_notification: Option<bool>,
1305 #[serde(skip_serializing_if = "Option::is_none")]
1307 pub reply_to_message_id: Option<i64>,
1308 #[serde(skip_serializing_if = "Option::is_none")]
1310 pub allow_sending_without_reply: Option<bool>,
1311 #[serde(skip_serializing_if = "Option::is_none")]
1316 pub reply_markup: Option<ReplyMarkup>,
1317 #[serde(skip_serializing_if = "Option::is_none")]
1319 pub protect_content: Option<bool>,
1320}
1321
1322impl SendPhoto {
1323 pub fn new(chat_id: impl Into<ChatId>, photo: impl Into<InputFileVariant>) -> Self {
1325 Self {
1326 chat_id: chat_id.into(),
1327 photo: photo.into(),
1328 caption: None,
1329 parse_mode: None,
1330 caption_entities: None,
1331 disable_notification: None,
1332 reply_to_message_id: None,
1333 allow_sending_without_reply: None,
1334 reply_markup: None,
1335 protect_content: None,
1336 }
1337 }
1338 pub fn with_caption(self, caption: impl Into<String>) -> Self {
1340 Self {
1341 caption: Some(caption.into()),
1342 ..self
1343 }
1344 }
1345 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1347 Self {
1348 parse_mode: Some(parse_mode),
1349 ..self
1350 }
1351 }
1352 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1354 Self {
1355 caption_entities: Some(entities),
1356 ..self
1357 }
1358 }
1359 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1361 let entities = self.caption_entities.get_or_insert_with(Default::default);
1362 entities.push(entity);
1363 self
1364 }
1365 pub fn disable_notification(self) -> Self {
1367 Self {
1368 disable_notification: Some(true),
1369 ..self
1370 }
1371 }
1372 pub fn reply_to(self, message_id: i64) -> Self {
1374 Self {
1375 reply_to_message_id: Some(message_id),
1376 ..self
1377 }
1378 }
1379 pub fn allow_sending_without_reply(self) -> Self {
1381 Self {
1382 allow_sending_without_reply: Some(true),
1383 ..self
1384 }
1385 }
1386 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1388 Self {
1389 reply_markup: Some(markup.into()),
1390 ..self
1391 }
1392 }
1393 pub fn protect_content(self) -> Self {
1395 Self {
1396 protect_content: Some(true),
1397 ..self
1398 }
1399 }
1400}
1401
1402impl TelegramMethod for SendPhoto {
1403 type Response = Message;
1404
1405 fn name() -> &'static str {
1406 "sendPhoto"
1407 }
1408}
1409
1410impl FileMethod for SendPhoto {
1411 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
1412 if let InputFileVariant::File(file) = &self.photo {
1413 let mut map = HashMap::new();
1414 map.insert("photo", file);
1415 Some(map)
1416 } else {
1417 None
1418 }
1419 }
1420}
1421
1422#[derive(Clone, Serialize)]
1429pub struct SendAudio {
1430 pub chat_id: ChatId,
1432 pub audio: InputFileVariant,
1438 #[serde(skip_serializing_if = "Option::is_none")]
1440 pub duration: Option<u32>,
1441 #[serde(skip_serializing_if = "Option::is_none")]
1443 pub performer: Option<String>,
1444 #[serde(skip_serializing_if = "Option::is_none")]
1446 pub title: Option<String>,
1447 #[serde(skip_serializing_if = "Option::is_none")]
1453 pub thumb: Option<InputFileVariant>,
1454 #[serde(skip_serializing_if = "Option::is_none")]
1456 pub caption: Option<String>,
1457 #[serde(skip_serializing_if = "Option::is_none")]
1460 pub parse_mode: Option<ParseMode>,
1461 #[serde(skip_serializing_if = "Option::is_none")]
1463 pub caption_entities: Option<Vec<MessageEntity>>,
1464 #[serde(skip_serializing_if = "Option::is_none")]
1467 pub disable_notification: Option<bool>,
1468 #[serde(skip_serializing_if = "Option::is_none")]
1470 pub reply_to_message_id: Option<i64>,
1471 #[serde(skip_serializing_if = "Option::is_none")]
1473 pub allow_sending_without_reply: Option<bool>,
1474 #[serde(skip_serializing_if = "Option::is_none")]
1479 pub reply_markup: Option<ReplyMarkup>,
1480 #[serde(skip_serializing_if = "Option::is_none")]
1482 pub protect_content: Option<bool>,
1483}
1484
1485impl SendAudio {
1486 pub fn new(chat_id: impl Into<ChatId>, audio: impl Into<InputFileVariant>) -> Self {
1488 Self {
1489 chat_id: chat_id.into(),
1490 audio: audio.into(),
1491 duration: None,
1492 performer: None,
1493 title: None,
1494 thumb: None,
1495 caption: None,
1496 parse_mode: None,
1497 caption_entities: None,
1498 disable_notification: None,
1499 reply_to_message_id: None,
1500 allow_sending_without_reply: None,
1501 reply_markup: None,
1502 protect_content: None,
1503 }
1504 }
1505 pub fn with_duration(self, duration: u32) -> Self {
1507 Self {
1508 duration: Some(duration),
1509 ..self
1510 }
1511 }
1512 pub fn with_performer(self, performer: impl Into<String>) -> Self {
1514 Self {
1515 performer: Some(performer.into()),
1516 ..self
1517 }
1518 }
1519 pub fn with_title(self, title: impl Into<String>) -> Self {
1521 Self {
1522 title: Some(title.into()),
1523 ..self
1524 }
1525 }
1526 pub fn with_thumbnail(self, thumbnail: impl Into<InputFileVariant>) -> Self {
1528 Self {
1529 thumb: Some(thumbnail.into()),
1530 ..self
1531 }
1532 }
1533 pub fn with_caption(self, caption: impl Into<String>) -> Self {
1535 Self {
1536 caption: Some(caption.into()),
1537 ..self
1538 }
1539 }
1540 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1542 Self {
1543 parse_mode: Some(parse_mode),
1544 ..self
1545 }
1546 }
1547 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1549 Self {
1550 caption_entities: Some(entities),
1551 ..self
1552 }
1553 }
1554 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1556 let entities = self.caption_entities.get_or_insert_with(Default::default);
1557 entities.push(entity);
1558 self
1559 }
1560 pub fn disable_notification(self) -> Self {
1562 Self {
1563 disable_notification: Some(true),
1564 ..self
1565 }
1566 }
1567 pub fn reply_to(self, message_id: i64) -> Self {
1569 Self {
1570 reply_to_message_id: Some(message_id),
1571 ..self
1572 }
1573 }
1574 pub fn allow_sending_without_reply(self) -> Self {
1576 Self {
1577 allow_sending_without_reply: Some(true),
1578 ..self
1579 }
1580 }
1581 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1583 Self {
1584 reply_markup: Some(markup.into()),
1585 ..self
1586 }
1587 }
1588 pub fn protect_content(self) -> Self {
1590 Self {
1591 protect_content: Some(true),
1592 ..self
1593 }
1594 }
1595}
1596
1597impl TelegramMethod for SendAudio {
1598 type Response = Message;
1599
1600 fn name() -> &'static str {
1601 "sendAudio"
1602 }
1603}
1604
1605impl FileMethod for SendAudio {
1606 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
1607 let mut map = HashMap::new();
1608 if let InputFileVariant::File(file) = &self.audio {
1609 map.insert("audio", file);
1610 }
1611 if let Some(InputFileVariant::File(file)) = &self.thumb {
1612 map.insert("thumb", file);
1613 }
1614 if map.is_empty() {
1615 None
1616 } else {
1617 Some(map)
1618 }
1619 }
1620}
1621
1622#[derive(Clone, Serialize)]
1625pub struct SendDocument {
1626 pub chat_id: ChatId,
1628 pub document: InputFileVariant,
1633 #[serde(skip_serializing_if = "Option::is_none")]
1635 pub disable_content_type_detection: Option<bool>,
1636 #[serde(skip_serializing_if = "Option::is_none")]
1642 pub thumb: Option<InputFileVariant>,
1643 #[serde(skip_serializing_if = "Option::is_none")]
1645 pub caption: Option<String>,
1646 #[serde(skip_serializing_if = "Option::is_none")]
1649 pub parse_mode: Option<ParseMode>,
1650 #[serde(skip_serializing_if = "Option::is_none")]
1652 pub caption_entities: Option<Vec<MessageEntity>>,
1653 #[serde(skip_serializing_if = "Option::is_none")]
1656 pub disable_notification: Option<bool>,
1657 #[serde(skip_serializing_if = "Option::is_none")]
1659 pub reply_to_message_id: Option<i64>,
1660 #[serde(skip_serializing_if = "Option::is_none")]
1662 pub allow_sending_without_reply: Option<bool>,
1663 #[serde(skip_serializing_if = "Option::is_none")]
1668 pub reply_markup: Option<ReplyMarkup>,
1669 #[serde(skip_serializing_if = "Option::is_none")]
1671 pub protect_content: Option<bool>,
1672}
1673
1674impl SendDocument {
1675 pub fn new(chat_id: impl Into<ChatId>, document: impl Into<InputFileVariant>) -> Self {
1677 Self {
1678 chat_id: chat_id.into(),
1679 document: document.into(),
1680 disable_content_type_detection: None,
1681 thumb: None,
1682 caption: None,
1683 parse_mode: None,
1684 caption_entities: None,
1685 disable_notification: None,
1686 reply_to_message_id: None,
1687 allow_sending_without_reply: None,
1688 reply_markup: None,
1689 protect_content: None,
1690 }
1691 }
1692 pub fn with_thumbnail(self, thumbnail: impl Into<InputFileVariant>) -> Self {
1694 Self {
1695 thumb: Some(thumbnail.into()),
1696 ..self
1697 }
1698 }
1699 pub fn disable_content_type_detection(self) -> Self {
1701 Self {
1702 disable_content_type_detection: Some(true),
1703 ..self
1704 }
1705 }
1706 pub fn with_caption(self, caption: impl Into<String>) -> Self {
1708 Self {
1709 caption: Some(caption.into()),
1710 ..self
1711 }
1712 }
1713 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1715 Self {
1716 parse_mode: Some(parse_mode),
1717 ..self
1718 }
1719 }
1720 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1722 Self {
1723 caption_entities: Some(entities),
1724 ..self
1725 }
1726 }
1727 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1729 let entities = self.caption_entities.get_or_insert_with(Default::default);
1730 entities.push(entity);
1731 self
1732 }
1733 pub fn disable_notification(self) -> Self {
1735 Self {
1736 disable_notification: Some(true),
1737 ..self
1738 }
1739 }
1740 pub fn reply_to(self, message_id: i64) -> Self {
1742 Self {
1743 reply_to_message_id: Some(message_id),
1744 ..self
1745 }
1746 }
1747 pub fn allow_sending_without_reply(self) -> Self {
1749 Self {
1750 allow_sending_without_reply: Some(true),
1751 ..self
1752 }
1753 }
1754 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1756 Self {
1757 reply_markup: Some(markup.into()),
1758 ..self
1759 }
1760 }
1761 pub fn protect_content(self) -> Self {
1763 Self {
1764 protect_content: Some(true),
1765 ..self
1766 }
1767 }
1768}
1769
1770impl TelegramMethod for SendDocument {
1771 type Response = Message;
1772
1773 fn name() -> &'static str {
1774 "sendDocument"
1775 }
1776}
1777
1778impl FileMethod for SendDocument {
1779 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
1780 let mut map = HashMap::new();
1781 if let InputFileVariant::File(file) = &self.document {
1782 map.insert("document", file);
1783 }
1784 if let Some(InputFileVariant::File(file)) = &self.thumb {
1785 map.insert("thumb", file);
1786 }
1787 if map.is_empty() {
1788 None
1789 } else {
1790 Some(map)
1791 }
1792 }
1793}
1794
1795#[derive(Clone, Serialize)]
1799pub struct SendVideo {
1800 pub chat_id: ChatId,
1802 pub video: InputFileVariant,
1807 #[serde(skip_serializing_if = "Option::is_none")]
1809 pub duration: Option<u32>,
1810 #[serde(skip_serializing_if = "Option::is_none")]
1812 pub width: Option<u32>,
1813 #[serde(skip_serializing_if = "Option::is_none")]
1815 pub height: Option<u32>,
1816 #[serde(skip_serializing_if = "Option::is_none")]
1818 pub supports_streaming: Option<bool>,
1819 #[serde(skip_serializing_if = "Option::is_none")]
1825 pub thumb: Option<InputFileVariant>,
1826 #[serde(skip_serializing_if = "Option::is_none")]
1828 pub caption: Option<String>,
1829 #[serde(skip_serializing_if = "Option::is_none")]
1832 pub parse_mode: Option<ParseMode>,
1833 #[serde(skip_serializing_if = "Option::is_none")]
1835 pub caption_entities: Option<Vec<MessageEntity>>,
1836 #[serde(skip_serializing_if = "Option::is_none")]
1839 pub disable_notification: Option<bool>,
1840 #[serde(skip_serializing_if = "Option::is_none")]
1842 pub reply_to_message_id: Option<i64>,
1843 #[serde(skip_serializing_if = "Option::is_none")]
1845 pub allow_sending_without_reply: Option<bool>,
1846 #[serde(skip_serializing_if = "Option::is_none")]
1851 pub reply_markup: Option<ReplyMarkup>,
1852 #[serde(skip_serializing_if = "Option::is_none")]
1854 pub protect_content: Option<bool>,
1855}
1856
1857impl SendVideo {
1858 pub fn new(chat_id: impl Into<ChatId>, video: impl Into<InputFileVariant>) -> Self {
1860 Self {
1861 chat_id: chat_id.into(),
1862 video: video.into(),
1863 duration: None,
1864 width: None,
1865 height: None,
1866 supports_streaming: None,
1867 thumb: None,
1868 caption: None,
1869 parse_mode: None,
1870 caption_entities: None,
1871 disable_notification: None,
1872 reply_to_message_id: None,
1873 allow_sending_without_reply: None,
1874 reply_markup: None,
1875 protect_content: None,
1876 }
1877 }
1878 pub fn with_duration(self, duration: u32) -> Self {
1880 Self {
1881 duration: Some(duration),
1882 ..self
1883 }
1884 }
1885 pub fn with_width(self, width: u32) -> Self {
1887 Self {
1888 width: Some(width),
1889 ..self
1890 }
1891 }
1892 pub fn with_height(self, height: u32) -> Self {
1894 Self {
1895 height: Some(height),
1896 ..self
1897 }
1898 }
1899 pub fn set_streaming(self) -> Self {
1901 Self {
1902 supports_streaming: Some(true),
1903 ..self
1904 }
1905 }
1906 pub fn with_thumbnail(self, thumbnail: impl Into<InputFileVariant>) -> Self {
1908 Self {
1909 thumb: Some(thumbnail.into()),
1910 ..self
1911 }
1912 }
1913 pub fn with_caption(self, caption: impl Into<String>) -> Self {
1915 Self {
1916 caption: Some(caption.into()),
1917 ..self
1918 }
1919 }
1920 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
1922 Self {
1923 parse_mode: Some(parse_mode),
1924 ..self
1925 }
1926 }
1927 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
1929 Self {
1930 caption_entities: Some(entities),
1931 ..self
1932 }
1933 }
1934 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
1936 let entities = self.caption_entities.get_or_insert_with(Default::default);
1937 entities.push(entity);
1938 self
1939 }
1940 pub fn disable_notification(self) -> Self {
1942 Self {
1943 disable_notification: Some(true),
1944 ..self
1945 }
1946 }
1947 pub fn reply_to(self, message_id: i64) -> Self {
1949 Self {
1950 reply_to_message_id: Some(message_id),
1951 ..self
1952 }
1953 }
1954 pub fn allow_sending_without_reply(self) -> Self {
1956 Self {
1957 allow_sending_without_reply: Some(true),
1958 ..self
1959 }
1960 }
1961 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
1963 Self {
1964 reply_markup: Some(markup.into()),
1965 ..self
1966 }
1967 }
1968 pub fn protect_content(self) -> Self {
1970 Self {
1971 protect_content: Some(true),
1972 ..self
1973 }
1974 }
1975}
1976
1977impl TelegramMethod for SendVideo {
1978 type Response = Message;
1979
1980 fn name() -> &'static str {
1981 "sendVideo"
1982 }
1983}
1984
1985impl FileMethod for SendVideo {
1986 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
1987 let mut map = HashMap::new();
1988 if let InputFileVariant::File(file) = &self.video {
1989 map.insert("video", file);
1990 }
1991 if let Some(InputFileVariant::File(file)) = &self.thumb {
1992 map.insert("thumb", file);
1993 }
1994 if map.is_empty() {
1995 None
1996 } else {
1997 Some(map)
1998 }
1999 }
2000}
2001
2002#[derive(Clone, Serialize)]
2006pub struct SendAnimation {
2007 pub chat_id: ChatId,
2009 pub animation: InputFileVariant,
2014 #[serde(skip_serializing_if = "Option::is_none")]
2016 pub duration: Option<u32>,
2017 #[serde(skip_serializing_if = "Option::is_none")]
2019 pub width: Option<u32>,
2020 #[serde(skip_serializing_if = "Option::is_none")]
2022 pub height: Option<u32>,
2023 #[serde(skip_serializing_if = "Option::is_none")]
2029 pub thumb: Option<InputFileVariant>,
2030 #[serde(skip_serializing_if = "Option::is_none")]
2032 pub caption: Option<String>,
2033 #[serde(skip_serializing_if = "Option::is_none")]
2036 pub parse_mode: Option<ParseMode>,
2037 #[serde(skip_serializing_if = "Option::is_none")]
2039 pub caption_entities: Option<Vec<MessageEntity>>,
2040 #[serde(skip_serializing_if = "Option::is_none")]
2043 pub disable_notification: Option<bool>,
2044 #[serde(skip_serializing_if = "Option::is_none")]
2046 pub reply_to_message_id: Option<i64>,
2047 #[serde(skip_serializing_if = "Option::is_none")]
2049 pub allow_sending_without_reply: Option<bool>,
2050 #[serde(skip_serializing_if = "Option::is_none")]
2055 pub reply_markup: Option<ReplyMarkup>,
2056 #[serde(skip_serializing_if = "Option::is_none")]
2058 pub protect_content: Option<bool>,
2059}
2060
2061impl SendAnimation {
2062 pub fn new(chat_id: impl Into<ChatId>, animation: impl Into<InputFileVariant>) -> Self {
2064 Self {
2065 chat_id: chat_id.into(),
2066 animation: animation.into(),
2067 duration: None,
2068 width: None,
2069 height: None,
2070 thumb: None,
2071 caption: None,
2072 parse_mode: None,
2073 caption_entities: None,
2074 disable_notification: None,
2075 reply_to_message_id: None,
2076 allow_sending_without_reply: None,
2077 reply_markup: None,
2078 protect_content: None,
2079 }
2080 }
2081 pub fn with_duration(self, duration: u32) -> Self {
2083 Self {
2084 duration: Some(duration),
2085 ..self
2086 }
2087 }
2088 pub fn with_width(self, width: u32) -> Self {
2090 Self {
2091 width: Some(width),
2092 ..self
2093 }
2094 }
2095 pub fn with_height(self, height: u32) -> Self {
2097 Self {
2098 height: Some(height),
2099 ..self
2100 }
2101 }
2102 pub fn with_thumbnail(self, thumbnail: impl Into<InputFileVariant>) -> Self {
2104 Self {
2105 thumb: Some(thumbnail.into()),
2106 ..self
2107 }
2108 }
2109 pub fn with_caption(self, caption: impl Into<String>) -> Self {
2111 Self {
2112 caption: Some(caption.into()),
2113 ..self
2114 }
2115 }
2116 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
2118 Self {
2119 parse_mode: Some(parse_mode),
2120 ..self
2121 }
2122 }
2123 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
2125 Self {
2126 caption_entities: Some(entities),
2127 ..self
2128 }
2129 }
2130 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
2132 let entities = self.caption_entities.get_or_insert_with(Default::default);
2133 entities.push(entity);
2134 self
2135 }
2136 pub fn disable_notification(self) -> Self {
2138 Self {
2139 disable_notification: Some(true),
2140 ..self
2141 }
2142 }
2143 pub fn reply_to(self, message_id: i64) -> Self {
2145 Self {
2146 reply_to_message_id: Some(message_id),
2147 ..self
2148 }
2149 }
2150 pub fn allow_sending_without_reply(self) -> Self {
2152 Self {
2153 allow_sending_without_reply: Some(true),
2154 ..self
2155 }
2156 }
2157 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
2159 Self {
2160 reply_markup: Some(markup.into()),
2161 ..self
2162 }
2163 }
2164 pub fn protect_content(self) -> Self {
2166 Self {
2167 protect_content: Some(true),
2168 ..self
2169 }
2170 }
2171}
2172
2173impl TelegramMethod for SendAnimation {
2174 type Response = Message;
2175
2176 fn name() -> &'static str {
2177 "sendAnimation"
2178 }
2179}
2180
2181impl FileMethod for SendAnimation {
2182 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
2183 let mut map = HashMap::new();
2184 if let InputFileVariant::File(file) = &self.animation {
2185 map.insert("animation", file);
2186 }
2187 if let Some(InputFileVariant::File(file)) = &self.thumb {
2188 map.insert("thumb", file);
2189 }
2190 if map.is_empty() {
2191 None
2192 } else {
2193 Some(map)
2194 }
2195 }
2196}
2197
2198#[derive(Clone, Serialize)]
2204pub struct SendVoice {
2205 pub chat_id: ChatId,
2207 pub voice: InputFileVariant,
2212 #[serde(skip_serializing_if = "Option::is_none")]
2214 pub duration: Option<u32>,
2215 #[serde(skip_serializing_if = "Option::is_none")]
2217 pub caption: Option<String>,
2218 #[serde(skip_serializing_if = "Option::is_none")]
2221 pub parse_mode: Option<ParseMode>,
2222 #[serde(skip_serializing_if = "Option::is_none")]
2224 pub caption_entities: Option<Vec<MessageEntity>>,
2225 #[serde(skip_serializing_if = "Option::is_none")]
2228 pub disable_notification: Option<bool>,
2229 #[serde(skip_serializing_if = "Option::is_none")]
2231 pub reply_to_message_id: Option<i64>,
2232 #[serde(skip_serializing_if = "Option::is_none")]
2234 pub allow_sending_without_reply: Option<bool>,
2235 #[serde(skip_serializing_if = "Option::is_none")]
2240 pub reply_markup: Option<ReplyMarkup>,
2241 #[serde(skip_serializing_if = "Option::is_none")]
2243 pub protect_content: Option<bool>,
2244}
2245
2246impl SendVoice {
2247 pub fn new(chat_id: impl Into<ChatId>, voice: impl Into<InputFileVariant>) -> Self {
2249 Self {
2250 chat_id: chat_id.into(),
2251 voice: voice.into(),
2252 duration: None,
2253 caption: None,
2254 parse_mode: None,
2255 caption_entities: None,
2256 disable_notification: None,
2257 reply_to_message_id: None,
2258 allow_sending_without_reply: None,
2259 reply_markup: None,
2260 protect_content: None,
2261 }
2262 }
2263 pub fn with_duration(self, duration: u32) -> Self {
2265 Self {
2266 duration: Some(duration),
2267 ..self
2268 }
2269 }
2270 pub fn with_caption(self, caption: impl Into<String>) -> Self {
2272 Self {
2273 caption: Some(caption.into()),
2274 ..self
2275 }
2276 }
2277 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
2279 Self {
2280 parse_mode: Some(parse_mode),
2281 ..self
2282 }
2283 }
2284 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
2286 Self {
2287 caption_entities: Some(entities),
2288 ..self
2289 }
2290 }
2291 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
2293 let entities = self.caption_entities.get_or_insert_with(Default::default);
2294 entities.push(entity);
2295 self
2296 }
2297 pub fn disable_notification(self) -> Self {
2299 Self {
2300 disable_notification: Some(true),
2301 ..self
2302 }
2303 }
2304 pub fn reply_to(self, message_id: i64) -> Self {
2306 Self {
2307 reply_to_message_id: Some(message_id),
2308 ..self
2309 }
2310 }
2311 pub fn allow_sending_without_reply(self) -> Self {
2313 Self {
2314 allow_sending_without_reply: Some(true),
2315 ..self
2316 }
2317 }
2318 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
2320 Self {
2321 reply_markup: Some(markup.into()),
2322 ..self
2323 }
2324 }
2325 pub fn protect_content(self) -> Self {
2327 Self {
2328 protect_content: Some(true),
2329 ..self
2330 }
2331 }
2332}
2333
2334impl TelegramMethod for SendVoice {
2335 type Response = Message;
2336
2337 fn name() -> &'static str {
2338 "sendVoice"
2339 }
2340}
2341
2342impl FileMethod for SendVoice {
2343 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
2344 if let InputFileVariant::File(file) = &self.voice {
2345 let mut map = HashMap::new();
2346 map.insert("voice", file);
2347 Some(map)
2348 } else {
2349 None
2350 }
2351 }
2352}
2353
2354#[derive(Clone, Serialize)]
2358pub struct SendVideoNote {
2359 pub chat_id: ChatId,
2361 pub video_note: InputFileVariant,
2366 #[serde(skip_serializing_if = "Option::is_none")]
2368 pub duration: Option<u32>,
2369 #[serde(skip_serializing_if = "Option::is_none")]
2371 pub length: Option<u32>,
2372 #[serde(skip_serializing_if = "Option::is_none")]
2378 pub thumb: Option<InputFileVariant>,
2379 #[serde(skip_serializing_if = "Option::is_none")]
2382 pub disable_notification: Option<bool>,
2383 #[serde(skip_serializing_if = "Option::is_none")]
2385 pub reply_to_message_id: Option<i64>,
2386 #[serde(skip_serializing_if = "Option::is_none")]
2388 pub allow_sending_without_reply: Option<bool>,
2389 #[serde(skip_serializing_if = "Option::is_none")]
2394 pub reply_markup: Option<ReplyMarkup>,
2395 #[serde(skip_serializing_if = "Option::is_none")]
2397 pub protect_content: Option<bool>,
2398}
2399
2400impl SendVideoNote {
2401 pub fn new(chat_id: impl Into<ChatId>, video_note: impl Into<InputFileVariant>) -> Self {
2403 Self {
2404 chat_id: chat_id.into(),
2405 video_note: video_note.into(),
2406 duration: None,
2407 length: None,
2408 thumb: None,
2409 disable_notification: None,
2410 reply_to_message_id: None,
2411 allow_sending_without_reply: None,
2412 reply_markup: None,
2413 protect_content: None,
2414 }
2415 }
2416 pub fn with_duration(self, duration: u32) -> Self {
2418 Self {
2419 duration: Some(duration),
2420 ..self
2421 }
2422 }
2423 pub fn with_length(self, length: u32) -> Self {
2425 Self {
2426 length: Some(length),
2427 ..self
2428 }
2429 }
2430 pub fn with_thumbnail(self, thumbnail: impl Into<InputFileVariant>) -> Self {
2432 Self {
2433 thumb: Some(thumbnail.into()),
2434 ..self
2435 }
2436 }
2437 pub fn disable_notification(self) -> Self {
2439 Self {
2440 disable_notification: Some(true),
2441 ..self
2442 }
2443 }
2444 pub fn reply_to(self, message_id: i64) -> Self {
2446 Self {
2447 reply_to_message_id: Some(message_id),
2448 ..self
2449 }
2450 }
2451 pub fn allow_sending_without_reply(self) -> Self {
2453 Self {
2454 allow_sending_without_reply: Some(true),
2455 ..self
2456 }
2457 }
2458 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
2460 Self {
2461 reply_markup: Some(markup.into()),
2462 ..self
2463 }
2464 }
2465 pub fn protect_content(self) -> Self {
2467 Self {
2468 protect_content: Some(true),
2469 ..self
2470 }
2471 }
2472}
2473
2474impl TelegramMethod for SendVideoNote {
2475 type Response = Message;
2476
2477 fn name() -> &'static str {
2478 "sendVideoNote"
2479 }
2480}
2481
2482impl FileMethod for SendVideoNote {
2483 fn files(&self) -> Option<HashMap<&str, &InputFile>> {
2484 let mut map = HashMap::new();
2485 if let InputFileVariant::File(file) = &self.video_note {
2486 map.insert("video_note", file);
2487 }
2488 if let Some(InputFileVariant::File(file)) = &self.thumb {
2489 map.insert("thumb", file);
2490 }
2491 if map.is_empty() {
2492 None
2493 } else {
2494 Some(map)
2495 }
2496 }
2497}
2498
2499#[derive(Clone, Serialize)]
2502pub struct SendMediaGroup {
2503 pub chat_id: ChatId,
2505 pub media: Vec<InputMedia>,
2507 #[serde(skip_serializing_if = "Option::is_none")]
2510 pub disable_notification: Option<bool>,
2511 #[serde(skip_serializing_if = "Option::is_none")]
2513 pub reply_to_message_id: Option<i64>,
2514 #[serde(skip_serializing_if = "Option::is_none")]
2516 pub allow_sending_without_reply: Option<bool>,
2517 #[serde(skip_serializing_if = "Option::is_none")]
2519 pub protect_content: Option<bool>,
2520}
2521
2522impl SendMediaGroup {
2523 pub fn new(chat_id: impl Into<ChatId>) -> Self {
2525 Self {
2526 chat_id: chat_id.into(),
2527 media: vec![],
2528 disable_notification: None,
2529 reply_to_message_id: None,
2530 allow_sending_without_reply: None,
2531 protect_content: None,
2532 }
2533 }
2534 pub fn with_media_group(self, media_group: Vec<InputMedia>) -> Self {
2536 Self {
2537 media: media_group,
2538 ..self
2539 }
2540 }
2541 pub fn with_media(mut self, media: impl Into<InputMedia>) -> Self {
2543 self.media.push(media.into());
2544 self
2545 }
2546 pub fn disable_notification(self) -> Self {
2548 Self {
2549 disable_notification: Some(true),
2550 ..self
2551 }
2552 }
2553 pub fn reply_to(self, message_id: i64) -> Self {
2555 Self {
2556 reply_to_message_id: Some(message_id),
2557 ..self
2558 }
2559 }
2560 pub fn allow_sending_without_reply(self) -> Self {
2562 Self {
2563 allow_sending_without_reply: Some(true),
2564 ..self
2565 }
2566 }
2567 pub fn protect_content(self) -> Self {
2569 Self {
2570 protect_content: Some(true),
2571 ..self
2572 }
2573 }
2574}
2575
2576impl TelegramMethod for SendMediaGroup {
2577 type Response = Vec<Message>;
2578
2579 fn name() -> &'static str {
2580 "sendMediaGroup"
2581 }
2582}
2583
2584#[derive(Clone, Serialize)]
2587pub struct SendLocation {
2588 pub chat_id: ChatId,
2590 pub latitude: f32,
2592 pub longitude: f32,
2594 pub horizontal_accuracy: f32,
2596 #[serde(skip_serializing_if = "Option::is_none")]
2599 pub live_period: Option<u32>,
2600 #[serde(skip_serializing_if = "Option::is_none")]
2603 pub heading: Option<u32>,
2604 #[serde(skip_serializing_if = "Option::is_none")]
2607 pub proximity_alert_radius: Option<u32>,
2608 #[serde(skip_serializing_if = "Option::is_none")]
2611 pub disable_notification: Option<bool>,
2612 #[serde(skip_serializing_if = "Option::is_none")]
2614 pub reply_to_message_id: Option<i64>,
2615 #[serde(skip_serializing_if = "Option::is_none")]
2617 pub allow_sending_without_reply: Option<bool>,
2618 #[serde(skip_serializing_if = "Option::is_none")]
2623 pub reply_markup: Option<ReplyMarkup>,
2624 #[serde(skip_serializing_if = "Option::is_none")]
2626 pub protect_content: Option<bool>,
2627}
2628
2629impl SendLocation {
2630 pub fn new(
2632 chat_id: impl Into<ChatId>,
2633 latitude: f32,
2634 longitude: f32,
2635 horizontal_accuracy: f32,
2636 ) -> Self {
2637 Self {
2638 chat_id: chat_id.into(),
2639 latitude,
2640 longitude,
2641 horizontal_accuracy,
2642 live_period: None,
2643 heading: None,
2644 proximity_alert_radius: None,
2645 disable_notification: None,
2646 reply_to_message_id: None,
2647 allow_sending_without_reply: None,
2648 reply_markup: None,
2649 protect_content: None,
2650 }
2651 }
2652 pub fn with_live_period(self, live_period: u32) -> Self {
2654 Self {
2655 live_period: Some(live_period),
2656 ..self
2657 }
2658 }
2659 pub fn with_heading(self, direction: u32) -> Self {
2661 Self {
2662 heading: Some(direction),
2663 ..self
2664 }
2665 }
2666 pub fn proximity_alert_within(self, radius: u32) -> Self {
2668 Self {
2669 proximity_alert_radius: Some(radius),
2670 ..self
2671 }
2672 }
2673 pub fn disable_notification(self) -> Self {
2675 Self {
2676 disable_notification: Some(true),
2677 ..self
2678 }
2679 }
2680 pub fn reply_to(self, message_id: i64) -> Self {
2682 Self {
2683 reply_to_message_id: Some(message_id),
2684 ..self
2685 }
2686 }
2687 pub fn allow_sending_without_reply(self) -> Self {
2689 Self {
2690 allow_sending_without_reply: Some(true),
2691 ..self
2692 }
2693 }
2694 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
2696 Self {
2697 reply_markup: Some(markup.into()),
2698 ..self
2699 }
2700 }
2701 pub fn protect_content(self) -> Self {
2703 Self {
2704 protect_content: Some(true),
2705 ..self
2706 }
2707 }
2708}
2709
2710impl TelegramMethod for SendLocation {
2711 type Response = Message;
2712
2713 fn name() -> &'static str {
2714 "sendLocation"
2715 }
2716}
2717
2718impl JsonMethod for SendLocation {}
2719
2720#[derive(Clone, Serialize)]
2725pub struct EditMessageLiveLocation {
2726 pub chat_id: ChatId,
2728 pub message_id: i64,
2730 pub latitude: f32,
2732 pub longitude: f32,
2734 pub horizontal_accuracy: Option<f32>,
2736 #[serde(skip_serializing_if = "Option::is_none")]
2739 pub heading: Option<u32>,
2740 #[serde(skip_serializing_if = "Option::is_none")]
2743 pub proximity_alert_radius: Option<u32>,
2744 #[serde(skip_serializing_if = "Option::is_none")]
2746 pub reply_markup: Option<InlineKeyboardMarkup>,
2747}
2748
2749impl EditMessageLiveLocation {
2750 pub fn new(chat_id: impl Into<ChatId>, message_id: i64, latitude: f32, longitude: f32) -> Self {
2752 Self {
2753 chat_id: chat_id.into(),
2754 message_id,
2755 latitude,
2756 longitude,
2757 horizontal_accuracy: None,
2758 heading: None,
2759 proximity_alert_radius: None,
2760 reply_markup: None,
2761 }
2762 }
2763 pub fn with_horizontal_accuracy(self, accuracy: f32) -> Self {
2765 Self {
2766 horizontal_accuracy: Some(accuracy),
2767 ..self
2768 }
2769 }
2770 pub fn with_heading(self, direction: u32) -> Self {
2772 Self {
2773 heading: Some(direction),
2774 ..self
2775 }
2776 }
2777 pub fn proximity_alert_within(self, radius: u32) -> Self {
2779 Self {
2780 proximity_alert_radius: Some(radius),
2781 ..self
2782 }
2783 }
2784 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
2786 Self {
2787 reply_markup: Some(markup.into()),
2788 ..self
2789 }
2790 }
2791}
2792
2793impl TelegramMethod for EditMessageLiveLocation {
2794 type Response = Message;
2795
2796 fn name() -> &'static str {
2797 "editMessageLiveLocation"
2798 }
2799}
2800
2801impl JsonMethod for EditMessageLiveLocation {}
2802
2803#[derive(Clone, Serialize)]
2808pub struct EditInlineMessageLiveLocation {
2809 pub inline_message_id: String,
2811 pub latitude: f32,
2813 pub longitude: f32,
2815 pub horizontal_accuracy: Option<f32>,
2817 #[serde(skip_serializing_if = "Option::is_none")]
2820 pub heading: Option<u32>,
2821 #[serde(skip_serializing_if = "Option::is_none")]
2824 pub proximity_alert_radius: Option<u32>,
2825 #[serde(skip_serializing_if = "Option::is_none")]
2827 pub reply_markup: Option<InlineKeyboardMarkup>,
2828}
2829
2830impl EditInlineMessageLiveLocation {
2831 pub fn new(inline_message_id: impl Into<String>, latitude: f32, longitude: f32) -> Self {
2833 Self {
2834 inline_message_id: inline_message_id.into(),
2835 latitude,
2836 longitude,
2837 horizontal_accuracy: None,
2838 heading: None,
2839 proximity_alert_radius: None,
2840 reply_markup: None,
2841 }
2842 }
2843 pub fn with_horizontal_accuracy(self, accuracy: f32) -> Self {
2845 Self {
2846 horizontal_accuracy: Some(accuracy),
2847 ..self
2848 }
2849 }
2850 pub fn with_heading(self, direction: u32) -> Self {
2852 Self {
2853 heading: Some(direction),
2854 ..self
2855 }
2856 }
2857 pub fn proximity_alert_within(self, radius: u32) -> Self {
2859 Self {
2860 proximity_alert_radius: Some(radius),
2861 ..self
2862 }
2863 }
2864 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
2866 Self {
2867 reply_markup: Some(markup.into()),
2868 ..self
2869 }
2870 }
2871}
2872
2873impl TelegramMethod for EditInlineMessageLiveLocation {
2874 type Response = bool;
2875
2876 fn name() -> &'static str {
2877 "editMessageLiveLocation"
2878 }
2879}
2880
2881impl JsonMethod for EditInlineMessageLiveLocation {}
2882
2883#[derive(Clone, Serialize)]
2886pub struct StopMessageLiveLocation {
2887 pub chat_id: ChatId,
2889 pub message_id: i64,
2891 #[serde(skip_serializing_if = "Option::is_none")]
2893 pub reply_markup: Option<InlineKeyboardMarkup>,
2894}
2895
2896impl StopMessageLiveLocation {
2897 pub fn from_chat(chat_id: impl Into<ChatId>, message_id: i64) -> Self {
2899 Self {
2900 chat_id: chat_id.into(),
2901 message_id,
2902 reply_markup: None,
2903 }
2904 }
2905 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
2907 Self {
2908 reply_markup: Some(markup.into()),
2909 ..self
2910 }
2911 }
2912}
2913
2914impl TelegramMethod for StopMessageLiveLocation {
2915 type Response = Message;
2916
2917 fn name() -> &'static str {
2918 "stopMessageLiveLocation"
2919 }
2920}
2921
2922impl JsonMethod for StopMessageLiveLocation {}
2923
2924#[derive(Clone, Serialize)]
2927pub struct StopInlineMessageLiveLocation {
2928 pub inline_message_id: String,
2930 #[serde(skip_serializing_if = "Option::is_none")]
2932 pub reply_markup: Option<InlineKeyboardMarkup>,
2933}
2934
2935impl StopInlineMessageLiveLocation {
2936 pub fn new(inline_message_id: impl Into<String>) -> Self {
2938 Self {
2939 inline_message_id: inline_message_id.into(),
2940 reply_markup: None,
2941 }
2942 }
2943 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
2945 Self {
2946 reply_markup: Some(markup.into()),
2947 ..self
2948 }
2949 }
2950}
2951
2952impl TelegramMethod for StopInlineMessageLiveLocation {
2953 type Response = bool;
2954
2955 fn name() -> &'static str {
2956 "stopMessageLiveLocation"
2957 }
2958}
2959
2960impl JsonMethod for StopInlineMessageLiveLocation {}
2961
2962#[derive(Clone, Serialize)]
2965pub struct SendVenue {
2966 pub chat_id: ChatId,
2968 pub latitude: f32,
2970 pub longitude: f32,
2972 pub title: String,
2974 pub address: String,
2976 #[serde(skip_serializing_if = "Option::is_none")]
2978 pub foursquare_id: Option<String>,
2979 #[serde(skip_serializing_if = "Option::is_none")]
2982 pub foursquare_type: Option<String>,
2983 #[serde(skip_serializing_if = "Option::is_none")]
2985 pub google_place_id: Option<String>,
2986 #[serde(skip_serializing_if = "Option::is_none")]
2988 pub google_place_type: Option<String>,
2989 #[serde(skip_serializing_if = "Option::is_none")]
2992 pub disable_notification: Option<bool>,
2993 #[serde(skip_serializing_if = "Option::is_none")]
2995 pub reply_to_message_id: Option<i64>,
2996 #[serde(skip_serializing_if = "Option::is_none")]
2998 pub allow_sending_without_reply: Option<bool>,
2999 #[serde(skip_serializing_if = "Option::is_none")]
3004 pub reply_markup: Option<ReplyMarkup>,
3005 #[serde(skip_serializing_if = "Option::is_none")]
3007 pub protect_content: Option<bool>,
3008}
3009
3010impl SendVenue {
3011 pub fn new(
3013 chat_id: impl Into<ChatId>,
3014 latitude: f32,
3015 longitude: f32,
3016 title: impl Into<String>,
3017 address: impl Into<String>,
3018 ) -> Self {
3019 Self {
3020 chat_id: chat_id.into(),
3021 latitude,
3022 longitude,
3023 title: title.into(),
3024 address: address.into(),
3025 foursquare_id: None,
3026 foursquare_type: None,
3027 google_place_id: None,
3028 google_place_type: None,
3029 disable_notification: None,
3030 reply_to_message_id: None,
3031 allow_sending_without_reply: None,
3032 reply_markup: None,
3033 protect_content: None,
3034 }
3035 }
3036 pub fn with_foursqaure(self, id: impl Into<String>, kind: Option<String>) -> Self {
3038 Self {
3039 foursquare_id: Some(id.into()),
3040 foursquare_type: kind,
3041 ..self
3042 }
3043 }
3044 pub fn with_google_place(self, id: impl Into<String>, kind: Option<String>) -> Self {
3046 Self {
3047 google_place_id: Some(id.into()),
3048 google_place_type: kind,
3049 ..self
3050 }
3051 }
3052 pub fn disable_notification(self) -> Self {
3054 Self {
3055 disable_notification: Some(true),
3056 ..self
3057 }
3058 }
3059 pub fn reply_to(self, message_id: i64) -> Self {
3061 Self {
3062 reply_to_message_id: Some(message_id),
3063 ..self
3064 }
3065 }
3066 pub fn allow_sending_without_reply(self) -> Self {
3068 Self {
3069 allow_sending_without_reply: Some(true),
3070 ..self
3071 }
3072 }
3073 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
3075 Self {
3076 reply_markup: Some(markup.into()),
3077 ..self
3078 }
3079 }
3080 pub fn protect_content(self) -> Self {
3082 Self {
3083 protect_content: Some(true),
3084 ..self
3085 }
3086 }
3087}
3088
3089impl TelegramMethod for SendVenue {
3090 type Response = Message;
3091
3092 fn name() -> &'static str {
3093 "sendVenue"
3094 }
3095}
3096
3097impl JsonMethod for SendVenue {}
3098
3099#[derive(Clone, Serialize)]
3101pub struct SendContact {
3102 pub chat_id: ChatId,
3104 pub phone_number: String,
3106 pub first_name: String,
3108 #[serde(skip_serializing_if = "Option::is_none")]
3110 pub last_name: Option<String>,
3111 #[serde(skip_serializing_if = "Option::is_none")]
3113 pub vcard: Option<String>,
3114 #[serde(skip_serializing_if = "Option::is_none")]
3117 pub disable_notification: Option<bool>,
3118 #[serde(skip_serializing_if = "Option::is_none")]
3120 pub reply_to_message_id: Option<i64>,
3121 #[serde(skip_serializing_if = "Option::is_none")]
3123 pub allow_sending_without_reply: Option<bool>,
3124 #[serde(skip_serializing_if = "Option::is_none")]
3129 pub reply_markup: Option<ReplyMarkup>,
3130 #[serde(skip_serializing_if = "Option::is_none")]
3132 pub protect_content: Option<bool>,
3133}
3134
3135impl SendContact {
3136 pub fn new(
3138 chat_id: impl Into<ChatId>,
3139 phone_number: impl Into<String>,
3140 first_name: impl Into<String>,
3141 ) -> Self {
3142 Self {
3143 chat_id: chat_id.into(),
3144 phone_number: phone_number.into(),
3145 first_name: first_name.into(),
3146 last_name: None,
3147 vcard: None,
3148 disable_notification: None,
3149 reply_to_message_id: None,
3150 allow_sending_without_reply: None,
3151 reply_markup: None,
3152 protect_content: None,
3153 }
3154 }
3155 pub fn with_last_name(self, last_name: impl Into<String>) -> Self {
3157 Self {
3158 last_name: Some(last_name.into()),
3159 ..self
3160 }
3161 }
3162 pub fn with_vcard(self, vcard: impl Into<String>) -> Self {
3164 Self {
3165 vcard: Some(vcard.into()),
3166 ..self
3167 }
3168 }
3169 pub fn disable_notification(self) -> Self {
3171 Self {
3172 disable_notification: Some(true),
3173 ..self
3174 }
3175 }
3176 pub fn reply_to(self, message_id: i64) -> Self {
3178 Self {
3179 reply_to_message_id: Some(message_id),
3180 ..self
3181 }
3182 }
3183 pub fn allow_sending_without_reply(self) -> Self {
3185 Self {
3186 allow_sending_without_reply: Some(true),
3187 ..self
3188 }
3189 }
3190 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
3192 Self {
3193 reply_markup: Some(markup.into()),
3194 ..self
3195 }
3196 }
3197 pub fn protect_content(self) -> Self {
3199 Self {
3200 protect_content: Some(true),
3201 ..self
3202 }
3203 }
3204}
3205
3206impl TelegramMethod for SendContact {
3207 type Response = Message;
3208
3209 fn name() -> &'static str {
3210 "sendContact"
3211 }
3212}
3213
3214impl JsonMethod for SendContact {}
3215
3216#[derive(Clone, Serialize)]
3218pub struct SendPoll {
3219 pub chat_id: ChatId,
3221 pub question: String,
3223 pub options: Vec<String>,
3225 #[serde(skip_serializing_if = "Option::is_none")]
3227 pub is_anonymous: Option<bool>,
3228 #[serde(skip_serializing_if = "Option::is_none")]
3230 #[serde(rename = "type")]
3231 pub kind: Option<String>,
3232 #[serde(skip_serializing_if = "Option::is_none")]
3234 pub allows_multiple_answers: Option<bool>,
3235 #[serde(skip_serializing_if = "Option::is_none")]
3237 pub correct_option_id: Option<u32>,
3238 #[serde(skip_serializing_if = "Option::is_none")]
3241 pub explanation: Option<String>,
3242 #[serde(skip_serializing_if = "Option::is_none")]
3245 pub explanation_parse_mode: Option<ParseMode>,
3246 #[serde(skip_serializing_if = "Option::is_none")]
3248 pub explanation_entities: Option<Vec<MessageEntity>>,
3249 #[serde(skip_serializing_if = "Option::is_none")]
3251 pub open_period: Option<u32>,
3252 #[serde(skip_serializing_if = "Option::is_none")]
3256 pub close_date: Option<u64>,
3257 #[serde(skip_serializing_if = "Option::is_none")]
3260 pub is_closed: Option<bool>,
3261 #[serde(skip_serializing_if = "Option::is_none")]
3264 pub disable_notification: Option<bool>,
3265 #[serde(skip_serializing_if = "Option::is_none")]
3267 pub reply_to_message_id: Option<i64>,
3268 #[serde(skip_serializing_if = "Option::is_none")]
3270 pub allow_sending_without_reply: Option<bool>,
3271 #[serde(skip_serializing_if = "Option::is_none")]
3276 pub reply_markup: Option<ReplyMarkup>,
3277 #[serde(skip_serializing_if = "Option::is_none")]
3279 pub protect_content: Option<bool>,
3280}
3281
3282impl SendPoll {
3283 pub fn new_regular(
3285 chat_id: impl Into<ChatId>,
3286 question: impl Into<String>,
3287 options: Vec<String>,
3288 ) -> Self {
3289 Self {
3290 chat_id: chat_id.into(),
3291 question: question.into(),
3292 options,
3293 is_anonymous: None,
3294 kind: Some("quiz".into()),
3295 allows_multiple_answers: None,
3296 correct_option_id: None,
3297 explanation: None,
3298 explanation_parse_mode: None,
3299 explanation_entities: None,
3300 open_period: None,
3301 close_date: None,
3302 is_closed: None,
3303 disable_notification: None,
3304 reply_to_message_id: None,
3305 allow_sending_without_reply: None,
3306 reply_markup: None,
3307 protect_content: None,
3308 }
3309 }
3310 pub fn new_quiz(
3312 chat_id: impl Into<ChatId>,
3313 question: impl Into<String>,
3314 options: Vec<String>,
3315 correct_option_id: u32,
3316 ) -> Self {
3317 Self {
3318 chat_id: chat_id.into(),
3319 question: question.into(),
3320 options,
3321 is_anonymous: None,
3322 kind: Some("quiz".into()),
3323 allows_multiple_answers: None,
3324 correct_option_id: Some(correct_option_id),
3325 explanation: None,
3326 explanation_parse_mode: None,
3327 explanation_entities: None,
3328 open_period: None,
3329 close_date: None,
3330 is_closed: None,
3331 disable_notification: None,
3332 reply_to_message_id: None,
3333 allow_sending_without_reply: None,
3334 reply_markup: None,
3335 protect_content: None,
3336 }
3337 }
3338 pub fn anonymous(self) -> Self {
3340 Self {
3341 is_anonymous: Some(true),
3342 ..self
3343 }
3344 }
3345 pub fn allow_multiple_answers(self) -> Self {
3347 Self {
3348 allows_multiple_answers: Some(true),
3349 ..self
3350 }
3351 }
3352 pub fn with_explanation(self, explanation: impl Into<String>) -> Self {
3354 Self {
3355 explanation: Some(explanation.into()),
3356 ..self
3357 }
3358 }
3359 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
3361 Self {
3362 explanation_parse_mode: Some(parse_mode),
3363 ..self
3364 }
3365 }
3366 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
3368 Self {
3369 explanation_entities: Some(entities),
3370 ..self
3371 }
3372 }
3373 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
3375 let entities = self
3376 .explanation_entities
3377 .get_or_insert_with(Default::default);
3378 entities.push(entity);
3379 self
3380 }
3381 pub fn with_open_period(self, period: u32) -> Self {
3383 Self {
3384 open_period: Some(period),
3385 close_date: None,
3386 ..self
3387 }
3388 }
3389 pub fn with_close_date(self, close_date: u64) -> Self {
3391 Self {
3392 close_date: Some(close_date),
3393 open_period: None,
3394 ..self
3395 }
3396 }
3397 pub fn closed(self) -> Self {
3399 Self {
3400 is_closed: Some(true),
3401 ..self
3402 }
3403 }
3404 pub fn disable_notification(self) -> Self {
3406 Self {
3407 disable_notification: Some(true),
3408 ..self
3409 }
3410 }
3411 pub fn reply_to(self, message_id: i64) -> Self {
3413 Self {
3414 reply_to_message_id: Some(message_id),
3415 ..self
3416 }
3417 }
3418 pub fn allow_sending_without_reply(self) -> Self {
3420 Self {
3421 allow_sending_without_reply: Some(true),
3422 ..self
3423 }
3424 }
3425 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
3427 Self {
3428 reply_markup: Some(markup.into()),
3429 ..self
3430 }
3431 }
3432 pub fn protect_content(self) -> Self {
3434 Self {
3435 protect_content: Some(true),
3436 ..self
3437 }
3438 }
3439}
3440
3441impl TelegramMethod for SendPoll {
3442 type Response = Message;
3443
3444 fn name() -> &'static str {
3445 "sendPoll"
3446 }
3447}
3448
3449impl JsonMethod for SendPoll {}
3450
3451#[derive(Clone, Serialize)]
3454pub struct SendDice {
3455 pub chat_id: ChatId,
3457 #[serde(skip_serializing_if = "Option::is_none")]
3461 pub emoji: Option<String>,
3462 #[serde(skip_serializing_if = "Option::is_none")]
3465 pub disable_notification: Option<bool>,
3466 #[serde(skip_serializing_if = "Option::is_none")]
3468 pub reply_to_message_id: Option<i64>,
3469 #[serde(skip_serializing_if = "Option::is_none")]
3471 pub allow_sending_without_reply: Option<bool>,
3472 #[serde(skip_serializing_if = "Option::is_none")]
3477 pub reply_markup: Option<ReplyMarkup>,
3478 #[serde(skip_serializing_if = "Option::is_none")]
3480 pub protect_content: Option<bool>,
3481}
3482
3483impl SendDice {
3484 pub fn new(chat_id: impl Into<ChatId>) -> Self {
3486 Self {
3487 chat_id: chat_id.into(),
3488 emoji: None,
3489 disable_notification: None,
3490 reply_to_message_id: None,
3491 allow_sending_without_reply: None,
3492 reply_markup: None,
3493 protect_content: None,
3494 }
3495 }
3496 pub fn with_emoji(self, emoji: impl Into<String>) -> Self {
3498 Self {
3499 emoji: Some(emoji.into()),
3500 ..self
3501 }
3502 }
3503 pub fn disable_notification(self) -> Self {
3505 Self {
3506 disable_notification: Some(true),
3507 ..self
3508 }
3509 }
3510 pub fn reply_to(self, message_id: i64) -> Self {
3512 Self {
3513 reply_to_message_id: Some(message_id),
3514 ..self
3515 }
3516 }
3517 pub fn allow_sending_without_reply(self) -> Self {
3519 Self {
3520 allow_sending_without_reply: Some(true),
3521 ..self
3522 }
3523 }
3524 pub fn with_reply_markup(self, markup: impl Into<ReplyMarkup>) -> Self {
3526 Self {
3527 reply_markup: Some(markup.into()),
3528 ..self
3529 }
3530 }
3531 pub fn protect_content(self) -> Self {
3533 Self {
3534 protect_content: Some(true),
3535 ..self
3536 }
3537 }
3538}
3539
3540impl TelegramMethod for SendDice {
3541 type Response = Message;
3542
3543 fn name() -> &'static str {
3544 "sendDice"
3545 }
3546}
3547
3548impl JsonMethod for SendDice {}
3549
3550#[derive(Clone, Serialize)]
3552#[serde(rename_all = "snake_case")]
3553pub enum ChatActionKind {
3554 Typing,
3555 UploadPhoto,
3556 RecordVideo,
3557 UploadVideo,
3558 RecordVoice,
3559 UploadVoice,
3560 UplaodDocument,
3561 FindLocation,
3562 RecordVideoNote,
3563 UploadVideoNote,
3564}
3565
3566#[derive(Clone, Serialize)]
3576pub struct SendChatAction {
3577 pub chat_id: ChatId,
3579 pub action: ChatActionKind,
3581}
3582
3583impl SendChatAction {
3584 pub fn new(chat_id: impl Into<ChatId>, action: ChatActionKind) -> Self {
3586 Self {
3587 chat_id: chat_id.into(),
3588 action,
3589 }
3590 }
3591}
3592
3593impl TelegramMethod for SendChatAction {
3594 type Response = Message;
3595
3596 fn name() -> &'static str {
3597 "sendChatAction"
3598 }
3599}
3600
3601impl JsonMethod for SendChatAction {}
3602
3603#[derive(Clone, Serialize)]
3607pub struct EditMessageText {
3608 pub chat_id: ChatId,
3610 pub message_id: i64,
3612 pub text: String,
3614 #[serde(skip_serializing_if = "Option::is_none")]
3617 pub parse_mode: Option<ParseMode>,
3618 #[serde(skip_serializing_if = "Option::is_none")]
3621 pub entities: Option<Vec<MessageEntity>>,
3622 #[serde(skip_serializing_if = "Option::is_none")]
3624 pub disable_web_page_preview: Option<bool>,
3625 #[serde(skip_serializing_if = "Option::is_none")]
3627 pub reply_markup: Option<InlineKeyboardMarkup>,
3628}
3629
3630impl EditMessageText {
3631 pub fn new(chat_id: impl Into<ChatId>, message_id: i64, text: impl Into<String>) -> Self {
3633 Self {
3634 chat_id: chat_id.into(),
3635 message_id,
3636 text: text.into(),
3637 parse_mode: None,
3638 entities: None,
3639 disable_web_page_preview: None,
3640 reply_markup: None,
3641 }
3642 }
3643 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
3645 Self {
3646 parse_mode: Some(parse_mode),
3647 ..self
3648 }
3649 }
3650 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
3652 Self {
3653 entities: Some(entities),
3654 ..self
3655 }
3656 }
3657 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
3659 let entities = self.entities.get_or_insert_with(Default::default);
3660 entities.push(entity);
3661 self
3662 }
3663 pub fn disable_web_page_preview(self) -> Self {
3665 Self {
3666 disable_web_page_preview: Some(true),
3667 ..self
3668 }
3669 }
3670 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
3672 Self {
3673 reply_markup: Some(markup.into()),
3674 ..self
3675 }
3676 }
3677}
3678
3679impl TelegramMethod for EditMessageText {
3680 type Response = Message;
3681
3682 fn name() -> &'static str {
3683 "editMessageText"
3684 }
3685}
3686
3687impl JsonMethod for EditMessageText {}
3688
3689#[derive(Clone, Serialize)]
3692pub struct EditInlineMessageText {
3693 pub inline_message_id: String,
3695 pub text: String,
3697 #[serde(skip_serializing_if = "Option::is_none")]
3700 pub parse_mode: Option<ParseMode>,
3701 #[serde(skip_serializing_if = "Option::is_none")]
3704 pub entities: Option<Vec<MessageEntity>>,
3705 #[serde(skip_serializing_if = "Option::is_none")]
3707 pub disable_web_page_preview: Option<bool>,
3708 #[serde(skip_serializing_if = "Option::is_none")]
3710 pub reply_markup: Option<InlineKeyboardMarkup>,
3711}
3712
3713impl EditInlineMessageText {
3714 pub fn new(inline_message_id: impl Into<String>, text: impl Into<String>) -> Self {
3716 Self {
3717 inline_message_id: inline_message_id.into(),
3718 text: text.into(),
3719 parse_mode: None,
3720 entities: None,
3721 disable_web_page_preview: None,
3722 reply_markup: None,
3723 }
3724 }
3725 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
3727 Self {
3728 parse_mode: Some(parse_mode),
3729 ..self
3730 }
3731 }
3732 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
3734 Self {
3735 entities: Some(entities),
3736 ..self
3737 }
3738 }
3739 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
3741 let entities = self.entities.get_or_insert_with(Default::default);
3742 entities.push(entity);
3743 self
3744 }
3745 pub fn disable_web_page_preview(self) -> Self {
3747 Self {
3748 disable_web_page_preview: Some(true),
3749 ..self
3750 }
3751 }
3752 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
3754 Self {
3755 reply_markup: Some(markup.into()),
3756 ..self
3757 }
3758 }
3759}
3760
3761impl TelegramMethod for EditInlineMessageText {
3762 type Response = bool;
3763
3764 fn name() -> &'static str {
3765 "editMessageText"
3766 }
3767}
3768
3769impl JsonMethod for EditInlineMessageText {}
3770
3771#[derive(Clone, Serialize)]
3773pub struct EditMessageCaption {
3774 pub chat_id: ChatId,
3776 pub message_id: i64,
3778 pub caption: Option<String>,
3780 #[serde(skip_serializing_if = "Option::is_none")]
3782 pub caption_entities: Option<Vec<MessageEntity>>,
3783 #[serde(skip_serializing_if = "Option::is_none")]
3786 pub parse_mode: Option<ParseMode>,
3787 #[serde(skip_serializing_if = "Option::is_none")]
3789 pub disable_web_page_preview: Option<bool>,
3790 #[serde(skip_serializing_if = "Option::is_none")]
3792 pub reply_markup: Option<InlineKeyboardMarkup>,
3793}
3794
3795impl EditMessageCaption {
3796 pub fn new_empty(chat_id: impl Into<ChatId>, message_id: i64) -> Self {
3798 Self {
3799 chat_id: chat_id.into(),
3800 message_id,
3801 caption: None,
3802 parse_mode: None,
3803 caption_entities: None,
3804 disable_web_page_preview: None,
3805 reply_markup: None,
3806 }
3807 }
3808 pub fn new(chat_id: impl Into<ChatId>, message_id: i64, caption: impl Into<String>) -> Self {
3810 Self {
3811 chat_id: chat_id.into(),
3812 message_id,
3813 caption: Some(caption.into()),
3814 parse_mode: None,
3815 caption_entities: None,
3816 disable_web_page_preview: None,
3817 reply_markup: None,
3818 }
3819 }
3820 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
3822 Self {
3823 parse_mode: Some(parse_mode),
3824 ..self
3825 }
3826 }
3827 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
3829 Self {
3830 caption_entities: Some(entities),
3831 ..self
3832 }
3833 }
3834 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
3836 let entities = self.caption_entities.get_or_insert_with(Default::default);
3837 entities.push(entity);
3838 self
3839 }
3840 pub fn disable_web_page_preview(self) -> Self {
3842 Self {
3843 disable_web_page_preview: Some(true),
3844 ..self
3845 }
3846 }
3847 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
3849 Self {
3850 reply_markup: Some(markup.into()),
3851 ..self
3852 }
3853 }
3854}
3855
3856impl TelegramMethod for EditMessageCaption {
3857 type Response = Message;
3858
3859 fn name() -> &'static str {
3860 "editMessageCaption"
3861 }
3862}
3863
3864impl JsonMethod for EditMessageCaption {}
3865
3866#[derive(Clone, Serialize)]
3868pub struct EditInlineMessageCaption {
3869 pub inline_message_id: String,
3871 #[serde(skip_serializing_if = "Option::is_none")]
3873 pub caption: Option<String>,
3874 #[serde(skip_serializing_if = "Option::is_none")]
3876 pub caption_entities: Option<Vec<MessageEntity>>,
3877 #[serde(skip_serializing_if = "Option::is_none")]
3880 pub parse_mode: Option<ParseMode>,
3881 #[serde(skip_serializing_if = "Option::is_none")]
3883 pub disable_web_page_preview: Option<bool>,
3884 #[serde(skip_serializing_if = "Option::is_none")]
3886 pub reply_markup: Option<InlineKeyboardMarkup>,
3887}
3888
3889impl EditInlineMessageCaption {
3890 pub fn new_empty(inline_message_id: impl Into<String>) -> Self {
3892 Self {
3893 inline_message_id: inline_message_id.into(),
3894 caption: None,
3895 parse_mode: None,
3896 caption_entities: None,
3897 disable_web_page_preview: None,
3898 reply_markup: None,
3899 }
3900 }
3901 pub fn new(inline_message_id: impl Into<String>, caption: impl Into<String>) -> Self {
3903 Self {
3904 inline_message_id: inline_message_id.into(),
3905 caption: Some(caption.into()),
3906 parse_mode: None,
3907 caption_entities: None,
3908 disable_web_page_preview: None,
3909 reply_markup: None,
3910 }
3911 }
3912 pub fn with_parse_mode(self, parse_mode: ParseMode) -> Self {
3914 Self {
3915 parse_mode: Some(parse_mode),
3916 ..self
3917 }
3918 }
3919 pub fn with_entities(self, entities: Vec<MessageEntity>) -> Self {
3921 Self {
3922 caption_entities: Some(entities),
3923 ..self
3924 }
3925 }
3926 pub fn with_entity(mut self, entity: MessageEntity) -> Self {
3928 let entities = self.caption_entities.get_or_insert_with(Default::default);
3929 entities.push(entity);
3930 self
3931 }
3932 pub fn disable_web_page_preview(self) -> Self {
3934 Self {
3935 disable_web_page_preview: Some(true),
3936 ..self
3937 }
3938 }
3939 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
3941 Self {
3942 reply_markup: Some(markup.into()),
3943 ..self
3944 }
3945 }
3946}
3947
3948impl TelegramMethod for EditInlineMessageCaption {
3949 type Response = bool;
3950
3951 fn name() -> &'static str {
3952 "editMessageCaption"
3953 }
3954}
3955
3956impl JsonMethod for EditInlineMessageCaption {}
3957
3958#[derive(Clone, Serialize)]
3965pub struct EditMessageMedia {
3966 pub chat_id: ChatId,
3968 pub message_id: i64,
3970 pub media: InputMedia,
3972 #[serde(skip_serializing_if = "Option::is_none")]
3974 pub reply_markup: Option<InlineKeyboardMarkup>,
3975}
3976
3977impl EditMessageMedia {
3978 pub fn new(chat_id: impl Into<ChatId>, message_id: i64, media: impl Into<InputMedia>) -> Self {
3980 Self {
3981 chat_id: chat_id.into(),
3982 message_id,
3983 media: media.into(),
3984 reply_markup: None,
3985 }
3986 }
3987 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
3989 Self {
3990 reply_markup: Some(markup.into()),
3991 ..self
3992 }
3993 }
3994}
3995
3996impl TelegramMethod for EditMessageMedia {
3997 type Response = Message;
3998
3999 fn name() -> &'static str {
4000 "editMessageMedia"
4001 }
4002}
4003
4004impl JsonMethod for EditMessageMedia {}
4005
4006#[derive(Clone, Serialize)]
4013pub struct EditInlineMessageMedia {
4014 pub inline_message_id: String,
4016 pub media: InputMedia,
4018 #[serde(skip_serializing_if = "Option::is_none")]
4020 pub reply_markup: Option<InlineKeyboardMarkup>,
4021}
4022
4023impl EditInlineMessageMedia {
4024 pub fn new(inline_message_id: impl Into<String>, media: impl Into<InputMedia>) -> Self {
4026 Self {
4027 inline_message_id: inline_message_id.into(),
4028 media: media.into(),
4029 reply_markup: None,
4030 }
4031 }
4032 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
4034 Self {
4035 reply_markup: Some(markup.into()),
4036 ..self
4037 }
4038 }
4039}
4040
4041impl TelegramMethod for EditInlineMessageMedia {
4042 type Response = bool;
4043
4044 fn name() -> &'static str {
4045 "editMessageMedia"
4046 }
4047}
4048
4049impl JsonMethod for EditInlineMessageMedia {}
4050
4051#[derive(Clone, Serialize)]
4053pub struct EditMessageReplyMarkup {
4054 pub chat_id: ChatId,
4056 pub message_id: i64,
4058 #[serde(skip_serializing_if = "Option::is_none")]
4060 pub reply_markup: Option<InlineKeyboardMarkup>,
4061}
4062
4063impl EditMessageReplyMarkup {
4064 pub fn new_empty(chat_id: impl Into<ChatId>, message_id: i64) -> Self {
4066 Self {
4067 chat_id: chat_id.into(),
4068 message_id,
4069 reply_markup: None,
4070 }
4071 }
4072 pub fn new(
4074 chat_id: impl Into<ChatId>,
4075 message_id: i64,
4076 reply_markup: impl Into<InlineKeyboardMarkup>,
4077 ) -> Self {
4078 Self {
4079 chat_id: chat_id.into(),
4080 message_id,
4081 reply_markup: Some(reply_markup.into()),
4082 }
4083 }
4084}
4085
4086impl TelegramMethod for EditMessageReplyMarkup {
4087 type Response = Message;
4088
4089 fn name() -> &'static str {
4090 "editMessageReplyMarkup"
4091 }
4092}
4093
4094impl JsonMethod for EditMessageReplyMarkup {}
4095
4096#[derive(Clone, Serialize)]
4098pub struct EditInlineMessageReplyMarkup {
4099 pub inline_message_id: String,
4101 #[serde(skip_serializing_if = "Option::is_none")]
4103 pub reply_markup: Option<InlineKeyboardMarkup>,
4104}
4105
4106impl EditInlineMessageReplyMarkup {
4107 pub fn new_empty(inline_message_id: impl Into<String>) -> Self {
4109 Self {
4110 inline_message_id: inline_message_id.into(),
4111 reply_markup: None,
4112 }
4113 }
4114 pub fn new(
4116 inline_message_id: impl Into<String>,
4117 reply_markup: impl Into<InlineKeyboardMarkup>,
4118 ) -> Self {
4119 Self {
4120 inline_message_id: inline_message_id.into(),
4121 reply_markup: Some(reply_markup.into()),
4122 }
4123 }
4124}
4125
4126impl TelegramMethod for EditInlineMessageReplyMarkup {
4127 type Response = bool;
4128
4129 fn name() -> &'static str {
4130 "editMessageReplyMarkup"
4131 }
4132}
4133
4134impl JsonMethod for EditInlineMessageReplyMarkup {}
4135
4136#[derive(Clone, Serialize)]
4139pub struct StopPoll {
4140 pub chat_id: ChatId,
4142 pub message_id: i64,
4144 #[serde(skip_serializing_if = "Option::is_none")]
4146 pub reply_markup: Option<InlineKeyboardMarkup>,
4147}
4148
4149impl StopPoll {
4150 pub fn new(chat_id: impl Into<ChatId>, message_id: i64) -> Self {
4152 Self {
4153 chat_id: chat_id.into(),
4154 message_id,
4155 reply_markup: None,
4156 }
4157 }
4158 pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
4160 Self {
4161 reply_markup: Some(markup.into()),
4162 ..self
4163 }
4164 }
4165}
4166
4167impl TelegramMethod for StopPoll {
4168 type Response = Poll;
4169
4170 fn name() -> &'static str {
4171 "stopPoll"
4172 }
4173}
4174
4175impl JsonMethod for StopPoll {}
4176
4177#[derive(Clone, Serialize)]
4187pub struct DeleteMessage {
4188 pub chat_id: ChatId,
4190 pub message_id: i64,
4192}
4193
4194impl DeleteMessage {
4195 pub fn new(chat_id: impl Into<ChatId>, message_id: i64) -> Self {
4197 Self {
4198 chat_id: chat_id.into(),
4199 message_id,
4200 }
4201 }
4202}
4203
4204impl TelegramMethod for DeleteMessage {
4205 type Response = bool;
4206
4207 fn name() -> &'static str {
4208 "deleteMessage"
4209 }
4210}
4211
4212impl JsonMethod for DeleteMessage {}