rust_tdlib/types/
input_message_content.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// The content of a message to send
8pub trait TDInputMessageContent: Debug + RObject {}
9
10/// The content of a message to send
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum InputMessageContent {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// An animation message (GIF-style).
18    #[serde(rename = "inputMessageAnimation")]
19    InputMessageAnimation(InputMessageAnimation),
20    /// An audio message
21    #[serde(rename = "inputMessageAudio")]
22    InputMessageAudio(InputMessageAudio),
23    /// A message containing a user contact
24    #[serde(rename = "inputMessageContact")]
25    InputMessageContact(InputMessageContact),
26    /// A dice message
27    #[serde(rename = "inputMessageDice")]
28    InputMessageDice(InputMessageDice),
29    /// A document message (general file)
30    #[serde(rename = "inputMessageDocument")]
31    InputMessageDocument(InputMessageDocument),
32    /// A forwarded message
33    #[serde(rename = "inputMessageForwarded")]
34    InputMessageForwarded(InputMessageForwarded),
35    /// A message with a game; not supported for channels or secret chats
36    #[serde(rename = "inputMessageGame")]
37    InputMessageGame(InputMessageGame),
38    /// A message with an invoice; can be used only by bots
39    #[serde(rename = "inputMessageInvoice")]
40    InputMessageInvoice(InputMessageInvoice),
41    /// A message with a location
42    #[serde(rename = "inputMessageLocation")]
43    InputMessageLocation(InputMessageLocation),
44    /// A photo message
45    #[serde(rename = "inputMessagePhoto")]
46    InputMessagePhoto(InputMessagePhoto),
47    /// A message with a poll. Polls can't be sent to secret chats. Polls can be sent only to a private chat with a bot
48    #[serde(rename = "inputMessagePoll")]
49    InputMessagePoll(InputMessagePoll),
50    /// A sticker message
51    #[serde(rename = "inputMessageSticker")]
52    InputMessageSticker(InputMessageSticker),
53    /// A text message
54    #[serde(rename = "inputMessageText")]
55    InputMessageText(InputMessageText),
56    /// A message with information about a venue
57    #[serde(rename = "inputMessageVenue")]
58    InputMessageVenue(InputMessageVenue),
59    /// A video message
60    #[serde(rename = "inputMessageVideo")]
61    InputMessageVideo(InputMessageVideo),
62    /// A video note message
63    #[serde(rename = "inputMessageVideoNote")]
64    InputMessageVideoNote(InputMessageVideoNote),
65    /// A voice note message
66    #[serde(rename = "inputMessageVoiceNote")]
67    InputMessageVoiceNote(InputMessageVoiceNote),
68}
69
70impl RObject for InputMessageContent {
71    #[doc(hidden)]
72    fn extra(&self) -> Option<&str> {
73        match self {
74            InputMessageContent::InputMessageAnimation(t) => t.extra(),
75            InputMessageContent::InputMessageAudio(t) => t.extra(),
76            InputMessageContent::InputMessageContact(t) => t.extra(),
77            InputMessageContent::InputMessageDice(t) => t.extra(),
78            InputMessageContent::InputMessageDocument(t) => t.extra(),
79            InputMessageContent::InputMessageForwarded(t) => t.extra(),
80            InputMessageContent::InputMessageGame(t) => t.extra(),
81            InputMessageContent::InputMessageInvoice(t) => t.extra(),
82            InputMessageContent::InputMessageLocation(t) => t.extra(),
83            InputMessageContent::InputMessagePhoto(t) => t.extra(),
84            InputMessageContent::InputMessagePoll(t) => t.extra(),
85            InputMessageContent::InputMessageSticker(t) => t.extra(),
86            InputMessageContent::InputMessageText(t) => t.extra(),
87            InputMessageContent::InputMessageVenue(t) => t.extra(),
88            InputMessageContent::InputMessageVideo(t) => t.extra(),
89            InputMessageContent::InputMessageVideoNote(t) => t.extra(),
90            InputMessageContent::InputMessageVoiceNote(t) => t.extra(),
91
92            _ => None,
93        }
94    }
95    #[doc(hidden)]
96    fn client_id(&self) -> Option<i32> {
97        match self {
98            InputMessageContent::InputMessageAnimation(t) => t.client_id(),
99            InputMessageContent::InputMessageAudio(t) => t.client_id(),
100            InputMessageContent::InputMessageContact(t) => t.client_id(),
101            InputMessageContent::InputMessageDice(t) => t.client_id(),
102            InputMessageContent::InputMessageDocument(t) => t.client_id(),
103            InputMessageContent::InputMessageForwarded(t) => t.client_id(),
104            InputMessageContent::InputMessageGame(t) => t.client_id(),
105            InputMessageContent::InputMessageInvoice(t) => t.client_id(),
106            InputMessageContent::InputMessageLocation(t) => t.client_id(),
107            InputMessageContent::InputMessagePhoto(t) => t.client_id(),
108            InputMessageContent::InputMessagePoll(t) => t.client_id(),
109            InputMessageContent::InputMessageSticker(t) => t.client_id(),
110            InputMessageContent::InputMessageText(t) => t.client_id(),
111            InputMessageContent::InputMessageVenue(t) => t.client_id(),
112            InputMessageContent::InputMessageVideo(t) => t.client_id(),
113            InputMessageContent::InputMessageVideoNote(t) => t.client_id(),
114            InputMessageContent::InputMessageVoiceNote(t) => t.client_id(),
115
116            _ => None,
117        }
118    }
119}
120
121impl InputMessageContent {
122    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
123        Ok(serde_json::from_str(json.as_ref())?)
124    }
125    #[doc(hidden)]
126    pub fn _is_default(&self) -> bool {
127        matches!(self, InputMessageContent::_Default)
128    }
129}
130
131impl AsRef<InputMessageContent> for InputMessageContent {
132    fn as_ref(&self) -> &InputMessageContent {
133        self
134    }
135}
136
137/// An animation message (GIF-style).
138#[derive(Debug, Clone, Default, Serialize, Deserialize)]
139pub struct InputMessageAnimation {
140    #[doc(hidden)]
141    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
142    extra: Option<String>,
143    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
144    client_id: Option<i32>,
145    /// Animation file to be sent
146
147    #[serde(skip_serializing_if = "InputFile::_is_default")]
148    animation: InputFile,
149    /// Animation thumbnail; pass null to skip thumbnail uploading
150    thumbnail: InputThumbnail,
151    /// File identifiers of the stickers added to the animation, if applicable
152
153    #[serde(default)]
154    added_sticker_file_ids: Vec<i32>,
155    /// Duration of the animation, in seconds
156
157    #[serde(default)]
158    duration: i32,
159    /// Width of the animation; may be replaced by the server
160
161    #[serde(default)]
162    width: i32,
163    /// Height of the animation; may be replaced by the server
164
165    #[serde(default)]
166    height: i32,
167    /// Animation caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
168    caption: FormattedText,
169}
170
171impl RObject for InputMessageAnimation {
172    #[doc(hidden)]
173    fn extra(&self) -> Option<&str> {
174        self.extra.as_deref()
175    }
176    #[doc(hidden)]
177    fn client_id(&self) -> Option<i32> {
178        self.client_id
179    }
180}
181
182impl TDInputMessageContent for InputMessageAnimation {}
183
184impl InputMessageAnimation {
185    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
186        Ok(serde_json::from_str(json.as_ref())?)
187    }
188    pub fn builder() -> InputMessageAnimationBuilder {
189        let mut inner = InputMessageAnimation::default();
190        inner.extra = Some(Uuid::new_v4().to_string());
191
192        InputMessageAnimationBuilder { inner }
193    }
194
195    pub fn animation(&self) -> &InputFile {
196        &self.animation
197    }
198
199    pub fn thumbnail(&self) -> &InputThumbnail {
200        &self.thumbnail
201    }
202
203    pub fn added_sticker_file_ids(&self) -> &Vec<i32> {
204        &self.added_sticker_file_ids
205    }
206
207    pub fn duration(&self) -> i32 {
208        self.duration
209    }
210
211    pub fn width(&self) -> i32 {
212        self.width
213    }
214
215    pub fn height(&self) -> i32 {
216        self.height
217    }
218
219    pub fn caption(&self) -> &FormattedText {
220        &self.caption
221    }
222}
223
224#[doc(hidden)]
225pub struct InputMessageAnimationBuilder {
226    inner: InputMessageAnimation,
227}
228
229#[deprecated]
230pub type RTDInputMessageAnimationBuilder = InputMessageAnimationBuilder;
231
232impl InputMessageAnimationBuilder {
233    pub fn build(&self) -> InputMessageAnimation {
234        self.inner.clone()
235    }
236
237    pub fn animation<T: AsRef<InputFile>>(&mut self, animation: T) -> &mut Self {
238        self.inner.animation = animation.as_ref().clone();
239        self
240    }
241
242    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
243        self.inner.thumbnail = thumbnail.as_ref().clone();
244        self
245    }
246
247    pub fn added_sticker_file_ids(&mut self, added_sticker_file_ids: Vec<i32>) -> &mut Self {
248        self.inner.added_sticker_file_ids = added_sticker_file_ids;
249        self
250    }
251
252    pub fn duration(&mut self, duration: i32) -> &mut Self {
253        self.inner.duration = duration;
254        self
255    }
256
257    pub fn width(&mut self, width: i32) -> &mut Self {
258        self.inner.width = width;
259        self
260    }
261
262    pub fn height(&mut self, height: i32) -> &mut Self {
263        self.inner.height = height;
264        self
265    }
266
267    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
268        self.inner.caption = caption.as_ref().clone();
269        self
270    }
271}
272
273impl AsRef<InputMessageAnimation> for InputMessageAnimation {
274    fn as_ref(&self) -> &InputMessageAnimation {
275        self
276    }
277}
278
279impl AsRef<InputMessageAnimation> for InputMessageAnimationBuilder {
280    fn as_ref(&self) -> &InputMessageAnimation {
281        &self.inner
282    }
283}
284
285/// An audio message
286#[derive(Debug, Clone, Default, Serialize, Deserialize)]
287pub struct InputMessageAudio {
288    #[doc(hidden)]
289    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
290    extra: Option<String>,
291    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
292    client_id: Option<i32>,
293    /// Audio file to be sent
294
295    #[serde(skip_serializing_if = "InputFile::_is_default")]
296    audio: InputFile,
297    /// Thumbnail of the cover for the album; pass null to skip thumbnail uploading
298    album_cover_thumbnail: InputThumbnail,
299    /// Duration of the audio, in seconds; may be replaced by the server
300
301    #[serde(default)]
302    duration: i32,
303    /// Title of the audio; 0-64 characters; may be replaced by the server
304
305    #[serde(default)]
306    title: String,
307    /// Performer of the audio; 0-64 characters, may be replaced by the server
308
309    #[serde(default)]
310    performer: String,
311    /// Audio caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
312    caption: FormattedText,
313}
314
315impl RObject for InputMessageAudio {
316    #[doc(hidden)]
317    fn extra(&self) -> Option<&str> {
318        self.extra.as_deref()
319    }
320    #[doc(hidden)]
321    fn client_id(&self) -> Option<i32> {
322        self.client_id
323    }
324}
325
326impl TDInputMessageContent for InputMessageAudio {}
327
328impl InputMessageAudio {
329    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
330        Ok(serde_json::from_str(json.as_ref())?)
331    }
332    pub fn builder() -> InputMessageAudioBuilder {
333        let mut inner = InputMessageAudio::default();
334        inner.extra = Some(Uuid::new_v4().to_string());
335
336        InputMessageAudioBuilder { inner }
337    }
338
339    pub fn audio(&self) -> &InputFile {
340        &self.audio
341    }
342
343    pub fn album_cover_thumbnail(&self) -> &InputThumbnail {
344        &self.album_cover_thumbnail
345    }
346
347    pub fn duration(&self) -> i32 {
348        self.duration
349    }
350
351    pub fn title(&self) -> &String {
352        &self.title
353    }
354
355    pub fn performer(&self) -> &String {
356        &self.performer
357    }
358
359    pub fn caption(&self) -> &FormattedText {
360        &self.caption
361    }
362}
363
364#[doc(hidden)]
365pub struct InputMessageAudioBuilder {
366    inner: InputMessageAudio,
367}
368
369#[deprecated]
370pub type RTDInputMessageAudioBuilder = InputMessageAudioBuilder;
371
372impl InputMessageAudioBuilder {
373    pub fn build(&self) -> InputMessageAudio {
374        self.inner.clone()
375    }
376
377    pub fn audio<T: AsRef<InputFile>>(&mut self, audio: T) -> &mut Self {
378        self.inner.audio = audio.as_ref().clone();
379        self
380    }
381
382    pub fn album_cover_thumbnail<T: AsRef<InputThumbnail>>(
383        &mut self,
384        album_cover_thumbnail: T,
385    ) -> &mut Self {
386        self.inner.album_cover_thumbnail = album_cover_thumbnail.as_ref().clone();
387        self
388    }
389
390    pub fn duration(&mut self, duration: i32) -> &mut Self {
391        self.inner.duration = duration;
392        self
393    }
394
395    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
396        self.inner.title = title.as_ref().to_string();
397        self
398    }
399
400    pub fn performer<T: AsRef<str>>(&mut self, performer: T) -> &mut Self {
401        self.inner.performer = performer.as_ref().to_string();
402        self
403    }
404
405    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
406        self.inner.caption = caption.as_ref().clone();
407        self
408    }
409}
410
411impl AsRef<InputMessageAudio> for InputMessageAudio {
412    fn as_ref(&self) -> &InputMessageAudio {
413        self
414    }
415}
416
417impl AsRef<InputMessageAudio> for InputMessageAudioBuilder {
418    fn as_ref(&self) -> &InputMessageAudio {
419        &self.inner
420    }
421}
422
423/// A message containing a user contact
424#[derive(Debug, Clone, Default, Serialize, Deserialize)]
425pub struct InputMessageContact {
426    #[doc(hidden)]
427    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
428    extra: Option<String>,
429    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
430    client_id: Option<i32>,
431    /// Contact to send
432    contact: Contact,
433}
434
435impl RObject for InputMessageContact {
436    #[doc(hidden)]
437    fn extra(&self) -> Option<&str> {
438        self.extra.as_deref()
439    }
440    #[doc(hidden)]
441    fn client_id(&self) -> Option<i32> {
442        self.client_id
443    }
444}
445
446impl TDInputMessageContent for InputMessageContact {}
447
448impl InputMessageContact {
449    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
450        Ok(serde_json::from_str(json.as_ref())?)
451    }
452    pub fn builder() -> InputMessageContactBuilder {
453        let mut inner = InputMessageContact::default();
454        inner.extra = Some(Uuid::new_v4().to_string());
455
456        InputMessageContactBuilder { inner }
457    }
458
459    pub fn contact(&self) -> &Contact {
460        &self.contact
461    }
462}
463
464#[doc(hidden)]
465pub struct InputMessageContactBuilder {
466    inner: InputMessageContact,
467}
468
469#[deprecated]
470pub type RTDInputMessageContactBuilder = InputMessageContactBuilder;
471
472impl InputMessageContactBuilder {
473    pub fn build(&self) -> InputMessageContact {
474        self.inner.clone()
475    }
476
477    pub fn contact<T: AsRef<Contact>>(&mut self, contact: T) -> &mut Self {
478        self.inner.contact = contact.as_ref().clone();
479        self
480    }
481}
482
483impl AsRef<InputMessageContact> for InputMessageContact {
484    fn as_ref(&self) -> &InputMessageContact {
485        self
486    }
487}
488
489impl AsRef<InputMessageContact> for InputMessageContactBuilder {
490    fn as_ref(&self) -> &InputMessageContact {
491        &self.inner
492    }
493}
494
495/// A dice message
496#[derive(Debug, Clone, Default, Serialize, Deserialize)]
497pub struct InputMessageDice {
498    #[doc(hidden)]
499    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
500    extra: Option<String>,
501    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
502    client_id: Option<i32>,
503    /// Emoji on which the dice throw animation is based
504
505    #[serde(default)]
506    emoji: String,
507    /// True, if the chat message draft must be deleted
508
509    #[serde(default)]
510    clear_draft: bool,
511}
512
513impl RObject for InputMessageDice {
514    #[doc(hidden)]
515    fn extra(&self) -> Option<&str> {
516        self.extra.as_deref()
517    }
518    #[doc(hidden)]
519    fn client_id(&self) -> Option<i32> {
520        self.client_id
521    }
522}
523
524impl TDInputMessageContent for InputMessageDice {}
525
526impl InputMessageDice {
527    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
528        Ok(serde_json::from_str(json.as_ref())?)
529    }
530    pub fn builder() -> InputMessageDiceBuilder {
531        let mut inner = InputMessageDice::default();
532        inner.extra = Some(Uuid::new_v4().to_string());
533
534        InputMessageDiceBuilder { inner }
535    }
536
537    pub fn emoji(&self) -> &String {
538        &self.emoji
539    }
540
541    pub fn clear_draft(&self) -> bool {
542        self.clear_draft
543    }
544}
545
546#[doc(hidden)]
547pub struct InputMessageDiceBuilder {
548    inner: InputMessageDice,
549}
550
551#[deprecated]
552pub type RTDInputMessageDiceBuilder = InputMessageDiceBuilder;
553
554impl InputMessageDiceBuilder {
555    pub fn build(&self) -> InputMessageDice {
556        self.inner.clone()
557    }
558
559    pub fn emoji<T: AsRef<str>>(&mut self, emoji: T) -> &mut Self {
560        self.inner.emoji = emoji.as_ref().to_string();
561        self
562    }
563
564    pub fn clear_draft(&mut self, clear_draft: bool) -> &mut Self {
565        self.inner.clear_draft = clear_draft;
566        self
567    }
568}
569
570impl AsRef<InputMessageDice> for InputMessageDice {
571    fn as_ref(&self) -> &InputMessageDice {
572        self
573    }
574}
575
576impl AsRef<InputMessageDice> for InputMessageDiceBuilder {
577    fn as_ref(&self) -> &InputMessageDice {
578        &self.inner
579    }
580}
581
582/// A document message (general file)
583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
584pub struct InputMessageDocument {
585    #[doc(hidden)]
586    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
587    extra: Option<String>,
588    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
589    client_id: Option<i32>,
590    /// Document to be sent
591
592    #[serde(skip_serializing_if = "InputFile::_is_default")]
593    document: InputFile,
594    /// Document thumbnail; pass null to skip thumbnail uploading
595    thumbnail: InputThumbnail,
596    /// If true, automatic file type detection will be disabled and the document will be always sent as file. Always true for files sent to secret chats
597
598    #[serde(default)]
599    disable_content_type_detection: bool,
600    /// Document caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
601    caption: FormattedText,
602}
603
604impl RObject for InputMessageDocument {
605    #[doc(hidden)]
606    fn extra(&self) -> Option<&str> {
607        self.extra.as_deref()
608    }
609    #[doc(hidden)]
610    fn client_id(&self) -> Option<i32> {
611        self.client_id
612    }
613}
614
615impl TDInputMessageContent for InputMessageDocument {}
616
617impl InputMessageDocument {
618    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
619        Ok(serde_json::from_str(json.as_ref())?)
620    }
621    pub fn builder() -> InputMessageDocumentBuilder {
622        let mut inner = InputMessageDocument::default();
623        inner.extra = Some(Uuid::new_v4().to_string());
624
625        InputMessageDocumentBuilder { inner }
626    }
627
628    pub fn document(&self) -> &InputFile {
629        &self.document
630    }
631
632    pub fn thumbnail(&self) -> &InputThumbnail {
633        &self.thumbnail
634    }
635
636    pub fn disable_content_type_detection(&self) -> bool {
637        self.disable_content_type_detection
638    }
639
640    pub fn caption(&self) -> &FormattedText {
641        &self.caption
642    }
643}
644
645#[doc(hidden)]
646pub struct InputMessageDocumentBuilder {
647    inner: InputMessageDocument,
648}
649
650#[deprecated]
651pub type RTDInputMessageDocumentBuilder = InputMessageDocumentBuilder;
652
653impl InputMessageDocumentBuilder {
654    pub fn build(&self) -> InputMessageDocument {
655        self.inner.clone()
656    }
657
658    pub fn document<T: AsRef<InputFile>>(&mut self, document: T) -> &mut Self {
659        self.inner.document = document.as_ref().clone();
660        self
661    }
662
663    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
664        self.inner.thumbnail = thumbnail.as_ref().clone();
665        self
666    }
667
668    pub fn disable_content_type_detection(
669        &mut self,
670        disable_content_type_detection: bool,
671    ) -> &mut Self {
672        self.inner.disable_content_type_detection = disable_content_type_detection;
673        self
674    }
675
676    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
677        self.inner.caption = caption.as_ref().clone();
678        self
679    }
680}
681
682impl AsRef<InputMessageDocument> for InputMessageDocument {
683    fn as_ref(&self) -> &InputMessageDocument {
684        self
685    }
686}
687
688impl AsRef<InputMessageDocument> for InputMessageDocumentBuilder {
689    fn as_ref(&self) -> &InputMessageDocument {
690        &self.inner
691    }
692}
693
694/// A forwarded message
695#[derive(Debug, Clone, Default, Serialize, Deserialize)]
696pub struct InputMessageForwarded {
697    #[doc(hidden)]
698    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
699    extra: Option<String>,
700    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
701    client_id: Option<i32>,
702    /// Identifier for the chat this forwarded message came from
703
704    #[serde(default)]
705    from_chat_id: i64,
706    /// Identifier of the message to forward
707
708    #[serde(default)]
709    message_id: i64,
710    /// True, if a game message is being shared from a launched game; applies only to game messages
711
712    #[serde(default)]
713    in_game_share: bool,
714    /// Options to be used to copy content of the message without reference to the original sender; pass null to forward the message as usual
715    copy_options: MessageCopyOptions,
716}
717
718impl RObject for InputMessageForwarded {
719    #[doc(hidden)]
720    fn extra(&self) -> Option<&str> {
721        self.extra.as_deref()
722    }
723    #[doc(hidden)]
724    fn client_id(&self) -> Option<i32> {
725        self.client_id
726    }
727}
728
729impl TDInputMessageContent for InputMessageForwarded {}
730
731impl InputMessageForwarded {
732    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
733        Ok(serde_json::from_str(json.as_ref())?)
734    }
735    pub fn builder() -> InputMessageForwardedBuilder {
736        let mut inner = InputMessageForwarded::default();
737        inner.extra = Some(Uuid::new_v4().to_string());
738
739        InputMessageForwardedBuilder { inner }
740    }
741
742    pub fn from_chat_id(&self) -> i64 {
743        self.from_chat_id
744    }
745
746    pub fn message_id(&self) -> i64 {
747        self.message_id
748    }
749
750    pub fn in_game_share(&self) -> bool {
751        self.in_game_share
752    }
753
754    pub fn copy_options(&self) -> &MessageCopyOptions {
755        &self.copy_options
756    }
757}
758
759#[doc(hidden)]
760pub struct InputMessageForwardedBuilder {
761    inner: InputMessageForwarded,
762}
763
764#[deprecated]
765pub type RTDInputMessageForwardedBuilder = InputMessageForwardedBuilder;
766
767impl InputMessageForwardedBuilder {
768    pub fn build(&self) -> InputMessageForwarded {
769        self.inner.clone()
770    }
771
772    pub fn from_chat_id(&mut self, from_chat_id: i64) -> &mut Self {
773        self.inner.from_chat_id = from_chat_id;
774        self
775    }
776
777    pub fn message_id(&mut self, message_id: i64) -> &mut Self {
778        self.inner.message_id = message_id;
779        self
780    }
781
782    pub fn in_game_share(&mut self, in_game_share: bool) -> &mut Self {
783        self.inner.in_game_share = in_game_share;
784        self
785    }
786
787    pub fn copy_options<T: AsRef<MessageCopyOptions>>(&mut self, copy_options: T) -> &mut Self {
788        self.inner.copy_options = copy_options.as_ref().clone();
789        self
790    }
791}
792
793impl AsRef<InputMessageForwarded> for InputMessageForwarded {
794    fn as_ref(&self) -> &InputMessageForwarded {
795        self
796    }
797}
798
799impl AsRef<InputMessageForwarded> for InputMessageForwardedBuilder {
800    fn as_ref(&self) -> &InputMessageForwarded {
801        &self.inner
802    }
803}
804
805/// A message with a game; not supported for channels or secret chats
806#[derive(Debug, Clone, Default, Serialize, Deserialize)]
807pub struct InputMessageGame {
808    #[doc(hidden)]
809    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
810    extra: Option<String>,
811    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
812    client_id: Option<i32>,
813    /// User identifier of the bot that owns the game
814
815    #[serde(default)]
816    bot_user_id: i64,
817    /// Short name of the game
818
819    #[serde(default)]
820    game_short_name: String,
821}
822
823impl RObject for InputMessageGame {
824    #[doc(hidden)]
825    fn extra(&self) -> Option<&str> {
826        self.extra.as_deref()
827    }
828    #[doc(hidden)]
829    fn client_id(&self) -> Option<i32> {
830        self.client_id
831    }
832}
833
834impl TDInputMessageContent for InputMessageGame {}
835
836impl InputMessageGame {
837    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
838        Ok(serde_json::from_str(json.as_ref())?)
839    }
840    pub fn builder() -> InputMessageGameBuilder {
841        let mut inner = InputMessageGame::default();
842        inner.extra = Some(Uuid::new_v4().to_string());
843
844        InputMessageGameBuilder { inner }
845    }
846
847    pub fn bot_user_id(&self) -> i64 {
848        self.bot_user_id
849    }
850
851    pub fn game_short_name(&self) -> &String {
852        &self.game_short_name
853    }
854}
855
856#[doc(hidden)]
857pub struct InputMessageGameBuilder {
858    inner: InputMessageGame,
859}
860
861#[deprecated]
862pub type RTDInputMessageGameBuilder = InputMessageGameBuilder;
863
864impl InputMessageGameBuilder {
865    pub fn build(&self) -> InputMessageGame {
866        self.inner.clone()
867    }
868
869    pub fn bot_user_id(&mut self, bot_user_id: i64) -> &mut Self {
870        self.inner.bot_user_id = bot_user_id;
871        self
872    }
873
874    pub fn game_short_name<T: AsRef<str>>(&mut self, game_short_name: T) -> &mut Self {
875        self.inner.game_short_name = game_short_name.as_ref().to_string();
876        self
877    }
878}
879
880impl AsRef<InputMessageGame> for InputMessageGame {
881    fn as_ref(&self) -> &InputMessageGame {
882        self
883    }
884}
885
886impl AsRef<InputMessageGame> for InputMessageGameBuilder {
887    fn as_ref(&self) -> &InputMessageGame {
888        &self.inner
889    }
890}
891
892/// A message with an invoice; can be used only by bots
893#[derive(Debug, Clone, Default, Serialize, Deserialize)]
894pub struct InputMessageInvoice {
895    #[doc(hidden)]
896    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
897    extra: Option<String>,
898    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
899    client_id: Option<i32>,
900    /// Invoice
901    invoice: Invoice,
902    /// Product title; 1-32 characters
903
904    #[serde(default)]
905    title: String,
906    /// A message with an invoice; can be used only by bots
907
908    #[serde(default)]
909    description: String,
910    /// Product photo URL; optional
911
912    #[serde(default)]
913    photo_url: String,
914    /// Product photo size
915
916    #[serde(default)]
917    photo_size: i32,
918    /// Product photo width
919
920    #[serde(default)]
921    photo_width: i32,
922    /// Product photo height
923
924    #[serde(default)]
925    photo_height: i32,
926    /// The invoice payload
927
928    #[serde(default)]
929    payload: String,
930    /// Payment provider token
931
932    #[serde(default)]
933    provider_token: String,
934    /// JSON-encoded data about the invoice, which will be shared with the payment provider
935
936    #[serde(default)]
937    provider_data: String,
938    /// Unique invoice bot deep link parameter for the generation of this invoice. If empty, it would be possible to pay directly from forwards of the invoice message
939
940    #[serde(default)]
941    start_parameter: String,
942}
943
944impl RObject for InputMessageInvoice {
945    #[doc(hidden)]
946    fn extra(&self) -> Option<&str> {
947        self.extra.as_deref()
948    }
949    #[doc(hidden)]
950    fn client_id(&self) -> Option<i32> {
951        self.client_id
952    }
953}
954
955impl TDInputMessageContent for InputMessageInvoice {}
956
957impl InputMessageInvoice {
958    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
959        Ok(serde_json::from_str(json.as_ref())?)
960    }
961    pub fn builder() -> InputMessageInvoiceBuilder {
962        let mut inner = InputMessageInvoice::default();
963        inner.extra = Some(Uuid::new_v4().to_string());
964
965        InputMessageInvoiceBuilder { inner }
966    }
967
968    pub fn invoice(&self) -> &Invoice {
969        &self.invoice
970    }
971
972    pub fn title(&self) -> &String {
973        &self.title
974    }
975
976    pub fn description(&self) -> &String {
977        &self.description
978    }
979
980    pub fn photo_url(&self) -> &String {
981        &self.photo_url
982    }
983
984    pub fn photo_size(&self) -> i32 {
985        self.photo_size
986    }
987
988    pub fn photo_width(&self) -> i32 {
989        self.photo_width
990    }
991
992    pub fn photo_height(&self) -> i32 {
993        self.photo_height
994    }
995
996    pub fn payload(&self) -> &String {
997        &self.payload
998    }
999
1000    pub fn provider_token(&self) -> &String {
1001        &self.provider_token
1002    }
1003
1004    pub fn provider_data(&self) -> &String {
1005        &self.provider_data
1006    }
1007
1008    pub fn start_parameter(&self) -> &String {
1009        &self.start_parameter
1010    }
1011}
1012
1013#[doc(hidden)]
1014pub struct InputMessageInvoiceBuilder {
1015    inner: InputMessageInvoice,
1016}
1017
1018#[deprecated]
1019pub type RTDInputMessageInvoiceBuilder = InputMessageInvoiceBuilder;
1020
1021impl InputMessageInvoiceBuilder {
1022    pub fn build(&self) -> InputMessageInvoice {
1023        self.inner.clone()
1024    }
1025
1026    pub fn invoice<T: AsRef<Invoice>>(&mut self, invoice: T) -> &mut Self {
1027        self.inner.invoice = invoice.as_ref().clone();
1028        self
1029    }
1030
1031    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
1032        self.inner.title = title.as_ref().to_string();
1033        self
1034    }
1035
1036    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
1037        self.inner.description = description.as_ref().to_string();
1038        self
1039    }
1040
1041    pub fn photo_url<T: AsRef<str>>(&mut self, photo_url: T) -> &mut Self {
1042        self.inner.photo_url = photo_url.as_ref().to_string();
1043        self
1044    }
1045
1046    pub fn photo_size(&mut self, photo_size: i32) -> &mut Self {
1047        self.inner.photo_size = photo_size;
1048        self
1049    }
1050
1051    pub fn photo_width(&mut self, photo_width: i32) -> &mut Self {
1052        self.inner.photo_width = photo_width;
1053        self
1054    }
1055
1056    pub fn photo_height(&mut self, photo_height: i32) -> &mut Self {
1057        self.inner.photo_height = photo_height;
1058        self
1059    }
1060
1061    pub fn payload<T: AsRef<str>>(&mut self, payload: T) -> &mut Self {
1062        self.inner.payload = payload.as_ref().to_string();
1063        self
1064    }
1065
1066    pub fn provider_token<T: AsRef<str>>(&mut self, provider_token: T) -> &mut Self {
1067        self.inner.provider_token = provider_token.as_ref().to_string();
1068        self
1069    }
1070
1071    pub fn provider_data<T: AsRef<str>>(&mut self, provider_data: T) -> &mut Self {
1072        self.inner.provider_data = provider_data.as_ref().to_string();
1073        self
1074    }
1075
1076    pub fn start_parameter<T: AsRef<str>>(&mut self, start_parameter: T) -> &mut Self {
1077        self.inner.start_parameter = start_parameter.as_ref().to_string();
1078        self
1079    }
1080}
1081
1082impl AsRef<InputMessageInvoice> for InputMessageInvoice {
1083    fn as_ref(&self) -> &InputMessageInvoice {
1084        self
1085    }
1086}
1087
1088impl AsRef<InputMessageInvoice> for InputMessageInvoiceBuilder {
1089    fn as_ref(&self) -> &InputMessageInvoice {
1090        &self.inner
1091    }
1092}
1093
1094/// A message with a location
1095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1096pub struct InputMessageLocation {
1097    #[doc(hidden)]
1098    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1099    extra: Option<String>,
1100    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1101    client_id: Option<i32>,
1102    /// Location to be sent
1103    location: Location,
1104    /// Period for which the location can be updated, in seconds; must be between 60 and 86400 for a live location and 0 otherwise
1105
1106    #[serde(default)]
1107    live_period: i32,
1108    /// For live locations, a direction in which the location moves, in degrees; 1-360. Pass 0 if unknown
1109
1110    #[serde(default)]
1111    heading: i32,
1112    /// For live locations, a maximum distance to another chat member for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled. Can't be enabled in channels and Saved Messages
1113
1114    #[serde(default)]
1115    proximity_alert_radius: i32,
1116}
1117
1118impl RObject for InputMessageLocation {
1119    #[doc(hidden)]
1120    fn extra(&self) -> Option<&str> {
1121        self.extra.as_deref()
1122    }
1123    #[doc(hidden)]
1124    fn client_id(&self) -> Option<i32> {
1125        self.client_id
1126    }
1127}
1128
1129impl TDInputMessageContent for InputMessageLocation {}
1130
1131impl InputMessageLocation {
1132    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1133        Ok(serde_json::from_str(json.as_ref())?)
1134    }
1135    pub fn builder() -> InputMessageLocationBuilder {
1136        let mut inner = InputMessageLocation::default();
1137        inner.extra = Some(Uuid::new_v4().to_string());
1138
1139        InputMessageLocationBuilder { inner }
1140    }
1141
1142    pub fn location(&self) -> &Location {
1143        &self.location
1144    }
1145
1146    pub fn live_period(&self) -> i32 {
1147        self.live_period
1148    }
1149
1150    pub fn heading(&self) -> i32 {
1151        self.heading
1152    }
1153
1154    pub fn proximity_alert_radius(&self) -> i32 {
1155        self.proximity_alert_radius
1156    }
1157}
1158
1159#[doc(hidden)]
1160pub struct InputMessageLocationBuilder {
1161    inner: InputMessageLocation,
1162}
1163
1164#[deprecated]
1165pub type RTDInputMessageLocationBuilder = InputMessageLocationBuilder;
1166
1167impl InputMessageLocationBuilder {
1168    pub fn build(&self) -> InputMessageLocation {
1169        self.inner.clone()
1170    }
1171
1172    pub fn location<T: AsRef<Location>>(&mut self, location: T) -> &mut Self {
1173        self.inner.location = location.as_ref().clone();
1174        self
1175    }
1176
1177    pub fn live_period(&mut self, live_period: i32) -> &mut Self {
1178        self.inner.live_period = live_period;
1179        self
1180    }
1181
1182    pub fn heading(&mut self, heading: i32) -> &mut Self {
1183        self.inner.heading = heading;
1184        self
1185    }
1186
1187    pub fn proximity_alert_radius(&mut self, proximity_alert_radius: i32) -> &mut Self {
1188        self.inner.proximity_alert_radius = proximity_alert_radius;
1189        self
1190    }
1191}
1192
1193impl AsRef<InputMessageLocation> for InputMessageLocation {
1194    fn as_ref(&self) -> &InputMessageLocation {
1195        self
1196    }
1197}
1198
1199impl AsRef<InputMessageLocation> for InputMessageLocationBuilder {
1200    fn as_ref(&self) -> &InputMessageLocation {
1201        &self.inner
1202    }
1203}
1204
1205/// A photo message
1206#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1207pub struct InputMessagePhoto {
1208    #[doc(hidden)]
1209    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1210    extra: Option<String>,
1211    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1212    client_id: Option<i32>,
1213    /// Photo to send
1214
1215    #[serde(skip_serializing_if = "InputFile::_is_default")]
1216    photo: InputFile,
1217    /// Photo thumbnail to be sent; pass null to skip thumbnail uploading. The thumbnail is sent to the other party only in secret chats
1218    thumbnail: InputThumbnail,
1219    /// File identifiers of the stickers added to the photo, if applicable
1220
1221    #[serde(default)]
1222    added_sticker_file_ids: Vec<i32>,
1223    /// Photo width
1224
1225    #[serde(default)]
1226    width: i32,
1227    /// Photo height
1228
1229    #[serde(default)]
1230    height: i32,
1231    /// Photo caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
1232    caption: FormattedText,
1233    /// Photo TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
1234
1235    #[serde(default)]
1236    ttl: i32,
1237}
1238
1239impl RObject for InputMessagePhoto {
1240    #[doc(hidden)]
1241    fn extra(&self) -> Option<&str> {
1242        self.extra.as_deref()
1243    }
1244    #[doc(hidden)]
1245    fn client_id(&self) -> Option<i32> {
1246        self.client_id
1247    }
1248}
1249
1250impl TDInputMessageContent for InputMessagePhoto {}
1251
1252impl InputMessagePhoto {
1253    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1254        Ok(serde_json::from_str(json.as_ref())?)
1255    }
1256    pub fn builder() -> InputMessagePhotoBuilder {
1257        let mut inner = InputMessagePhoto::default();
1258        inner.extra = Some(Uuid::new_v4().to_string());
1259
1260        InputMessagePhotoBuilder { inner }
1261    }
1262
1263    pub fn photo(&self) -> &InputFile {
1264        &self.photo
1265    }
1266
1267    pub fn thumbnail(&self) -> &InputThumbnail {
1268        &self.thumbnail
1269    }
1270
1271    pub fn added_sticker_file_ids(&self) -> &Vec<i32> {
1272        &self.added_sticker_file_ids
1273    }
1274
1275    pub fn width(&self) -> i32 {
1276        self.width
1277    }
1278
1279    pub fn height(&self) -> i32 {
1280        self.height
1281    }
1282
1283    pub fn caption(&self) -> &FormattedText {
1284        &self.caption
1285    }
1286
1287    pub fn ttl(&self) -> i32 {
1288        self.ttl
1289    }
1290}
1291
1292#[doc(hidden)]
1293pub struct InputMessagePhotoBuilder {
1294    inner: InputMessagePhoto,
1295}
1296
1297#[deprecated]
1298pub type RTDInputMessagePhotoBuilder = InputMessagePhotoBuilder;
1299
1300impl InputMessagePhotoBuilder {
1301    pub fn build(&self) -> InputMessagePhoto {
1302        self.inner.clone()
1303    }
1304
1305    pub fn photo<T: AsRef<InputFile>>(&mut self, photo: T) -> &mut Self {
1306        self.inner.photo = photo.as_ref().clone();
1307        self
1308    }
1309
1310    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
1311        self.inner.thumbnail = thumbnail.as_ref().clone();
1312        self
1313    }
1314
1315    pub fn added_sticker_file_ids(&mut self, added_sticker_file_ids: Vec<i32>) -> &mut Self {
1316        self.inner.added_sticker_file_ids = added_sticker_file_ids;
1317        self
1318    }
1319
1320    pub fn width(&mut self, width: i32) -> &mut Self {
1321        self.inner.width = width;
1322        self
1323    }
1324
1325    pub fn height(&mut self, height: i32) -> &mut Self {
1326        self.inner.height = height;
1327        self
1328    }
1329
1330    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
1331        self.inner.caption = caption.as_ref().clone();
1332        self
1333    }
1334
1335    pub fn ttl(&mut self, ttl: i32) -> &mut Self {
1336        self.inner.ttl = ttl;
1337        self
1338    }
1339}
1340
1341impl AsRef<InputMessagePhoto> for InputMessagePhoto {
1342    fn as_ref(&self) -> &InputMessagePhoto {
1343        self
1344    }
1345}
1346
1347impl AsRef<InputMessagePhoto> for InputMessagePhotoBuilder {
1348    fn as_ref(&self) -> &InputMessagePhoto {
1349        &self.inner
1350    }
1351}
1352
1353/// A message with a poll. Polls can't be sent to secret chats. Polls can be sent only to a private chat with a bot
1354#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1355pub struct InputMessagePoll {
1356    #[doc(hidden)]
1357    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1358    extra: Option<String>,
1359    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1360    client_id: Option<i32>,
1361    /// Poll question; 1-255 characters (up to 300 characters for bots)
1362
1363    #[serde(default)]
1364    question: String,
1365    /// List of poll answer options, 2-10 strings 1-100 characters each
1366
1367    #[serde(default)]
1368    options: Vec<String>,
1369    /// True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels
1370
1371    #[serde(default)]
1372    is_anonymous: bool,
1373    /// Type of the poll
1374
1375    #[serde(rename(serialize = "type", deserialize = "type"))]
1376    #[serde(skip_serializing_if = "PollType::_is_default")]
1377    type_: PollType,
1378    /// Amount of time the poll will be active after creation, in seconds; for bots only
1379
1380    #[serde(default)]
1381    open_period: i32,
1382    /// Point in time (Unix timestamp) when the poll will automatically be closed; for bots only
1383
1384    #[serde(default)]
1385    close_date: i32,
1386    /// True, if the poll needs to be sent already closed; for bots only
1387
1388    #[serde(default)]
1389    is_closed: bool,
1390}
1391
1392impl RObject for InputMessagePoll {
1393    #[doc(hidden)]
1394    fn extra(&self) -> Option<&str> {
1395        self.extra.as_deref()
1396    }
1397    #[doc(hidden)]
1398    fn client_id(&self) -> Option<i32> {
1399        self.client_id
1400    }
1401}
1402
1403impl TDInputMessageContent for InputMessagePoll {}
1404
1405impl InputMessagePoll {
1406    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1407        Ok(serde_json::from_str(json.as_ref())?)
1408    }
1409    pub fn builder() -> InputMessagePollBuilder {
1410        let mut inner = InputMessagePoll::default();
1411        inner.extra = Some(Uuid::new_v4().to_string());
1412
1413        InputMessagePollBuilder { inner }
1414    }
1415
1416    pub fn question(&self) -> &String {
1417        &self.question
1418    }
1419
1420    pub fn options(&self) -> &Vec<String> {
1421        &self.options
1422    }
1423
1424    pub fn is_anonymous(&self) -> bool {
1425        self.is_anonymous
1426    }
1427
1428    pub fn type_(&self) -> &PollType {
1429        &self.type_
1430    }
1431
1432    pub fn open_period(&self) -> i32 {
1433        self.open_period
1434    }
1435
1436    pub fn close_date(&self) -> i32 {
1437        self.close_date
1438    }
1439
1440    pub fn is_closed(&self) -> bool {
1441        self.is_closed
1442    }
1443}
1444
1445#[doc(hidden)]
1446pub struct InputMessagePollBuilder {
1447    inner: InputMessagePoll,
1448}
1449
1450#[deprecated]
1451pub type RTDInputMessagePollBuilder = InputMessagePollBuilder;
1452
1453impl InputMessagePollBuilder {
1454    pub fn build(&self) -> InputMessagePoll {
1455        self.inner.clone()
1456    }
1457
1458    pub fn question<T: AsRef<str>>(&mut self, question: T) -> &mut Self {
1459        self.inner.question = question.as_ref().to_string();
1460        self
1461    }
1462
1463    pub fn options(&mut self, options: Vec<String>) -> &mut Self {
1464        self.inner.options = options;
1465        self
1466    }
1467
1468    pub fn is_anonymous(&mut self, is_anonymous: bool) -> &mut Self {
1469        self.inner.is_anonymous = is_anonymous;
1470        self
1471    }
1472
1473    pub fn type_<T: AsRef<PollType>>(&mut self, type_: T) -> &mut Self {
1474        self.inner.type_ = type_.as_ref().clone();
1475        self
1476    }
1477
1478    pub fn open_period(&mut self, open_period: i32) -> &mut Self {
1479        self.inner.open_period = open_period;
1480        self
1481    }
1482
1483    pub fn close_date(&mut self, close_date: i32) -> &mut Self {
1484        self.inner.close_date = close_date;
1485        self
1486    }
1487
1488    pub fn is_closed(&mut self, is_closed: bool) -> &mut Self {
1489        self.inner.is_closed = is_closed;
1490        self
1491    }
1492}
1493
1494impl AsRef<InputMessagePoll> for InputMessagePoll {
1495    fn as_ref(&self) -> &InputMessagePoll {
1496        self
1497    }
1498}
1499
1500impl AsRef<InputMessagePoll> for InputMessagePollBuilder {
1501    fn as_ref(&self) -> &InputMessagePoll {
1502        &self.inner
1503    }
1504}
1505
1506/// A sticker message
1507#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1508pub struct InputMessageSticker {
1509    #[doc(hidden)]
1510    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1511    extra: Option<String>,
1512    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1513    client_id: Option<i32>,
1514    /// Sticker to be sent
1515
1516    #[serde(skip_serializing_if = "InputFile::_is_default")]
1517    sticker: InputFile,
1518    /// Sticker thumbnail; pass null to skip thumbnail uploading
1519    thumbnail: InputThumbnail,
1520    /// Sticker width
1521
1522    #[serde(default)]
1523    width: i32,
1524    /// Sticker height
1525
1526    #[serde(default)]
1527    height: i32,
1528    /// Emoji used to choose the sticker
1529
1530    #[serde(default)]
1531    emoji: String,
1532}
1533
1534impl RObject for InputMessageSticker {
1535    #[doc(hidden)]
1536    fn extra(&self) -> Option<&str> {
1537        self.extra.as_deref()
1538    }
1539    #[doc(hidden)]
1540    fn client_id(&self) -> Option<i32> {
1541        self.client_id
1542    }
1543}
1544
1545impl TDInputMessageContent for InputMessageSticker {}
1546
1547impl InputMessageSticker {
1548    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1549        Ok(serde_json::from_str(json.as_ref())?)
1550    }
1551    pub fn builder() -> InputMessageStickerBuilder {
1552        let mut inner = InputMessageSticker::default();
1553        inner.extra = Some(Uuid::new_v4().to_string());
1554
1555        InputMessageStickerBuilder { inner }
1556    }
1557
1558    pub fn sticker(&self) -> &InputFile {
1559        &self.sticker
1560    }
1561
1562    pub fn thumbnail(&self) -> &InputThumbnail {
1563        &self.thumbnail
1564    }
1565
1566    pub fn width(&self) -> i32 {
1567        self.width
1568    }
1569
1570    pub fn height(&self) -> i32 {
1571        self.height
1572    }
1573
1574    pub fn emoji(&self) -> &String {
1575        &self.emoji
1576    }
1577}
1578
1579#[doc(hidden)]
1580pub struct InputMessageStickerBuilder {
1581    inner: InputMessageSticker,
1582}
1583
1584#[deprecated]
1585pub type RTDInputMessageStickerBuilder = InputMessageStickerBuilder;
1586
1587impl InputMessageStickerBuilder {
1588    pub fn build(&self) -> InputMessageSticker {
1589        self.inner.clone()
1590    }
1591
1592    pub fn sticker<T: AsRef<InputFile>>(&mut self, sticker: T) -> &mut Self {
1593        self.inner.sticker = sticker.as_ref().clone();
1594        self
1595    }
1596
1597    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
1598        self.inner.thumbnail = thumbnail.as_ref().clone();
1599        self
1600    }
1601
1602    pub fn width(&mut self, width: i32) -> &mut Self {
1603        self.inner.width = width;
1604        self
1605    }
1606
1607    pub fn height(&mut self, height: i32) -> &mut Self {
1608        self.inner.height = height;
1609        self
1610    }
1611
1612    pub fn emoji<T: AsRef<str>>(&mut self, emoji: T) -> &mut Self {
1613        self.inner.emoji = emoji.as_ref().to_string();
1614        self
1615    }
1616}
1617
1618impl AsRef<InputMessageSticker> for InputMessageSticker {
1619    fn as_ref(&self) -> &InputMessageSticker {
1620        self
1621    }
1622}
1623
1624impl AsRef<InputMessageSticker> for InputMessageStickerBuilder {
1625    fn as_ref(&self) -> &InputMessageSticker {
1626        &self.inner
1627    }
1628}
1629
1630/// A text message
1631#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1632pub struct InputMessageText {
1633    #[doc(hidden)]
1634    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1635    extra: Option<String>,
1636    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1637    client_id: Option<i32>,
1638    /// Formatted text to be sent; 1-GetOption("message_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Code, Pre, PreCode, TextUrl and MentionName entities are allowed to be specified manually
1639    text: FormattedText,
1640    /// True, if rich web page previews for URLs in the message text must be disabled
1641
1642    #[serde(default)]
1643    disable_web_page_preview: bool,
1644    /// True, if a chat message draft must be deleted
1645
1646    #[serde(default)]
1647    clear_draft: bool,
1648}
1649
1650impl RObject for InputMessageText {
1651    #[doc(hidden)]
1652    fn extra(&self) -> Option<&str> {
1653        self.extra.as_deref()
1654    }
1655    #[doc(hidden)]
1656    fn client_id(&self) -> Option<i32> {
1657        self.client_id
1658    }
1659}
1660
1661impl TDInputMessageContent for InputMessageText {}
1662
1663impl InputMessageText {
1664    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1665        Ok(serde_json::from_str(json.as_ref())?)
1666    }
1667    pub fn builder() -> InputMessageTextBuilder {
1668        let mut inner = InputMessageText::default();
1669        inner.extra = Some(Uuid::new_v4().to_string());
1670
1671        InputMessageTextBuilder { inner }
1672    }
1673
1674    pub fn text(&self) -> &FormattedText {
1675        &self.text
1676    }
1677
1678    pub fn disable_web_page_preview(&self) -> bool {
1679        self.disable_web_page_preview
1680    }
1681
1682    pub fn clear_draft(&self) -> bool {
1683        self.clear_draft
1684    }
1685}
1686
1687#[doc(hidden)]
1688pub struct InputMessageTextBuilder {
1689    inner: InputMessageText,
1690}
1691
1692#[deprecated]
1693pub type RTDInputMessageTextBuilder = InputMessageTextBuilder;
1694
1695impl InputMessageTextBuilder {
1696    pub fn build(&self) -> InputMessageText {
1697        self.inner.clone()
1698    }
1699
1700    pub fn text<T: AsRef<FormattedText>>(&mut self, text: T) -> &mut Self {
1701        self.inner.text = text.as_ref().clone();
1702        self
1703    }
1704
1705    pub fn disable_web_page_preview(&mut self, disable_web_page_preview: bool) -> &mut Self {
1706        self.inner.disable_web_page_preview = disable_web_page_preview;
1707        self
1708    }
1709
1710    pub fn clear_draft(&mut self, clear_draft: bool) -> &mut Self {
1711        self.inner.clear_draft = clear_draft;
1712        self
1713    }
1714}
1715
1716impl AsRef<InputMessageText> for InputMessageText {
1717    fn as_ref(&self) -> &InputMessageText {
1718        self
1719    }
1720}
1721
1722impl AsRef<InputMessageText> for InputMessageTextBuilder {
1723    fn as_ref(&self) -> &InputMessageText {
1724        &self.inner
1725    }
1726}
1727
1728/// A message with information about a venue
1729#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1730pub struct InputMessageVenue {
1731    #[doc(hidden)]
1732    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1733    extra: Option<String>,
1734    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1735    client_id: Option<i32>,
1736    /// Venue to send
1737    venue: Venue,
1738}
1739
1740impl RObject for InputMessageVenue {
1741    #[doc(hidden)]
1742    fn extra(&self) -> Option<&str> {
1743        self.extra.as_deref()
1744    }
1745    #[doc(hidden)]
1746    fn client_id(&self) -> Option<i32> {
1747        self.client_id
1748    }
1749}
1750
1751impl TDInputMessageContent for InputMessageVenue {}
1752
1753impl InputMessageVenue {
1754    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1755        Ok(serde_json::from_str(json.as_ref())?)
1756    }
1757    pub fn builder() -> InputMessageVenueBuilder {
1758        let mut inner = InputMessageVenue::default();
1759        inner.extra = Some(Uuid::new_v4().to_string());
1760
1761        InputMessageVenueBuilder { inner }
1762    }
1763
1764    pub fn venue(&self) -> &Venue {
1765        &self.venue
1766    }
1767}
1768
1769#[doc(hidden)]
1770pub struct InputMessageVenueBuilder {
1771    inner: InputMessageVenue,
1772}
1773
1774#[deprecated]
1775pub type RTDInputMessageVenueBuilder = InputMessageVenueBuilder;
1776
1777impl InputMessageVenueBuilder {
1778    pub fn build(&self) -> InputMessageVenue {
1779        self.inner.clone()
1780    }
1781
1782    pub fn venue<T: AsRef<Venue>>(&mut self, venue: T) -> &mut Self {
1783        self.inner.venue = venue.as_ref().clone();
1784        self
1785    }
1786}
1787
1788impl AsRef<InputMessageVenue> for InputMessageVenue {
1789    fn as_ref(&self) -> &InputMessageVenue {
1790        self
1791    }
1792}
1793
1794impl AsRef<InputMessageVenue> for InputMessageVenueBuilder {
1795    fn as_ref(&self) -> &InputMessageVenue {
1796        &self.inner
1797    }
1798}
1799
1800/// A video message
1801#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1802pub struct InputMessageVideo {
1803    #[doc(hidden)]
1804    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1805    extra: Option<String>,
1806    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1807    client_id: Option<i32>,
1808    /// Video to be sent
1809
1810    #[serde(skip_serializing_if = "InputFile::_is_default")]
1811    video: InputFile,
1812    /// Video thumbnail; pass null to skip thumbnail uploading
1813    thumbnail: InputThumbnail,
1814    /// File identifiers of the stickers added to the video, if applicable
1815
1816    #[serde(default)]
1817    added_sticker_file_ids: Vec<i32>,
1818    /// Duration of the video, in seconds
1819
1820    #[serde(default)]
1821    duration: i32,
1822    /// Video width
1823
1824    #[serde(default)]
1825    width: i32,
1826    /// Video height
1827
1828    #[serde(default)]
1829    height: i32,
1830    /// True, if the video is supposed to be streamed
1831
1832    #[serde(default)]
1833    supports_streaming: bool,
1834    /// Video caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
1835    caption: FormattedText,
1836    /// Video TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
1837
1838    #[serde(default)]
1839    ttl: i32,
1840}
1841
1842impl RObject for InputMessageVideo {
1843    #[doc(hidden)]
1844    fn extra(&self) -> Option<&str> {
1845        self.extra.as_deref()
1846    }
1847    #[doc(hidden)]
1848    fn client_id(&self) -> Option<i32> {
1849        self.client_id
1850    }
1851}
1852
1853impl TDInputMessageContent for InputMessageVideo {}
1854
1855impl InputMessageVideo {
1856    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1857        Ok(serde_json::from_str(json.as_ref())?)
1858    }
1859    pub fn builder() -> InputMessageVideoBuilder {
1860        let mut inner = InputMessageVideo::default();
1861        inner.extra = Some(Uuid::new_v4().to_string());
1862
1863        InputMessageVideoBuilder { inner }
1864    }
1865
1866    pub fn video(&self) -> &InputFile {
1867        &self.video
1868    }
1869
1870    pub fn thumbnail(&self) -> &InputThumbnail {
1871        &self.thumbnail
1872    }
1873
1874    pub fn added_sticker_file_ids(&self) -> &Vec<i32> {
1875        &self.added_sticker_file_ids
1876    }
1877
1878    pub fn duration(&self) -> i32 {
1879        self.duration
1880    }
1881
1882    pub fn width(&self) -> i32 {
1883        self.width
1884    }
1885
1886    pub fn height(&self) -> i32 {
1887        self.height
1888    }
1889
1890    pub fn supports_streaming(&self) -> bool {
1891        self.supports_streaming
1892    }
1893
1894    pub fn caption(&self) -> &FormattedText {
1895        &self.caption
1896    }
1897
1898    pub fn ttl(&self) -> i32 {
1899        self.ttl
1900    }
1901}
1902
1903#[doc(hidden)]
1904pub struct InputMessageVideoBuilder {
1905    inner: InputMessageVideo,
1906}
1907
1908#[deprecated]
1909pub type RTDInputMessageVideoBuilder = InputMessageVideoBuilder;
1910
1911impl InputMessageVideoBuilder {
1912    pub fn build(&self) -> InputMessageVideo {
1913        self.inner.clone()
1914    }
1915
1916    pub fn video<T: AsRef<InputFile>>(&mut self, video: T) -> &mut Self {
1917        self.inner.video = video.as_ref().clone();
1918        self
1919    }
1920
1921    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
1922        self.inner.thumbnail = thumbnail.as_ref().clone();
1923        self
1924    }
1925
1926    pub fn added_sticker_file_ids(&mut self, added_sticker_file_ids: Vec<i32>) -> &mut Self {
1927        self.inner.added_sticker_file_ids = added_sticker_file_ids;
1928        self
1929    }
1930
1931    pub fn duration(&mut self, duration: i32) -> &mut Self {
1932        self.inner.duration = duration;
1933        self
1934    }
1935
1936    pub fn width(&mut self, width: i32) -> &mut Self {
1937        self.inner.width = width;
1938        self
1939    }
1940
1941    pub fn height(&mut self, height: i32) -> &mut Self {
1942        self.inner.height = height;
1943        self
1944    }
1945
1946    pub fn supports_streaming(&mut self, supports_streaming: bool) -> &mut Self {
1947        self.inner.supports_streaming = supports_streaming;
1948        self
1949    }
1950
1951    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
1952        self.inner.caption = caption.as_ref().clone();
1953        self
1954    }
1955
1956    pub fn ttl(&mut self, ttl: i32) -> &mut Self {
1957        self.inner.ttl = ttl;
1958        self
1959    }
1960}
1961
1962impl AsRef<InputMessageVideo> for InputMessageVideo {
1963    fn as_ref(&self) -> &InputMessageVideo {
1964        self
1965    }
1966}
1967
1968impl AsRef<InputMessageVideo> for InputMessageVideoBuilder {
1969    fn as_ref(&self) -> &InputMessageVideo {
1970        &self.inner
1971    }
1972}
1973
1974/// A video note message
1975#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1976pub struct InputMessageVideoNote {
1977    #[doc(hidden)]
1978    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1979    extra: Option<String>,
1980    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1981    client_id: Option<i32>,
1982    /// Video note to be sent
1983
1984    #[serde(skip_serializing_if = "InputFile::_is_default")]
1985    video_note: InputFile,
1986    /// Video thumbnail; pass null to skip thumbnail uploading
1987    thumbnail: InputThumbnail,
1988    /// Duration of the video, in seconds
1989
1990    #[serde(default)]
1991    duration: i32,
1992    /// Video width and height; must be positive and not greater than 640
1993
1994    #[serde(default)]
1995    length: i32,
1996}
1997
1998impl RObject for InputMessageVideoNote {
1999    #[doc(hidden)]
2000    fn extra(&self) -> Option<&str> {
2001        self.extra.as_deref()
2002    }
2003    #[doc(hidden)]
2004    fn client_id(&self) -> Option<i32> {
2005        self.client_id
2006    }
2007}
2008
2009impl TDInputMessageContent for InputMessageVideoNote {}
2010
2011impl InputMessageVideoNote {
2012    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
2013        Ok(serde_json::from_str(json.as_ref())?)
2014    }
2015    pub fn builder() -> InputMessageVideoNoteBuilder {
2016        let mut inner = InputMessageVideoNote::default();
2017        inner.extra = Some(Uuid::new_v4().to_string());
2018
2019        InputMessageVideoNoteBuilder { inner }
2020    }
2021
2022    pub fn video_note(&self) -> &InputFile {
2023        &self.video_note
2024    }
2025
2026    pub fn thumbnail(&self) -> &InputThumbnail {
2027        &self.thumbnail
2028    }
2029
2030    pub fn duration(&self) -> i32 {
2031        self.duration
2032    }
2033
2034    pub fn length(&self) -> i32 {
2035        self.length
2036    }
2037}
2038
2039#[doc(hidden)]
2040pub struct InputMessageVideoNoteBuilder {
2041    inner: InputMessageVideoNote,
2042}
2043
2044#[deprecated]
2045pub type RTDInputMessageVideoNoteBuilder = InputMessageVideoNoteBuilder;
2046
2047impl InputMessageVideoNoteBuilder {
2048    pub fn build(&self) -> InputMessageVideoNote {
2049        self.inner.clone()
2050    }
2051
2052    pub fn video_note<T: AsRef<InputFile>>(&mut self, video_note: T) -> &mut Self {
2053        self.inner.video_note = video_note.as_ref().clone();
2054        self
2055    }
2056
2057    pub fn thumbnail<T: AsRef<InputThumbnail>>(&mut self, thumbnail: T) -> &mut Self {
2058        self.inner.thumbnail = thumbnail.as_ref().clone();
2059        self
2060    }
2061
2062    pub fn duration(&mut self, duration: i32) -> &mut Self {
2063        self.inner.duration = duration;
2064        self
2065    }
2066
2067    pub fn length(&mut self, length: i32) -> &mut Self {
2068        self.inner.length = length;
2069        self
2070    }
2071}
2072
2073impl AsRef<InputMessageVideoNote> for InputMessageVideoNote {
2074    fn as_ref(&self) -> &InputMessageVideoNote {
2075        self
2076    }
2077}
2078
2079impl AsRef<InputMessageVideoNote> for InputMessageVideoNoteBuilder {
2080    fn as_ref(&self) -> &InputMessageVideoNote {
2081        &self.inner
2082    }
2083}
2084
2085/// A voice note message
2086#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2087pub struct InputMessageVoiceNote {
2088    #[doc(hidden)]
2089    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
2090    extra: Option<String>,
2091    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
2092    client_id: Option<i32>,
2093    /// Voice note to be sent
2094
2095    #[serde(skip_serializing_if = "InputFile::_is_default")]
2096    voice_note: InputFile,
2097    /// Duration of the voice note, in seconds
2098
2099    #[serde(default)]
2100    duration: i32,
2101    /// Waveform representation of the voice note, in 5-bit format
2102
2103    #[serde(default)]
2104    waveform: String,
2105    /// Voice note caption; pass null to use an empty caption; 0-GetOption("message_caption_length_max") characters
2106    caption: FormattedText,
2107}
2108
2109impl RObject for InputMessageVoiceNote {
2110    #[doc(hidden)]
2111    fn extra(&self) -> Option<&str> {
2112        self.extra.as_deref()
2113    }
2114    #[doc(hidden)]
2115    fn client_id(&self) -> Option<i32> {
2116        self.client_id
2117    }
2118}
2119
2120impl TDInputMessageContent for InputMessageVoiceNote {}
2121
2122impl InputMessageVoiceNote {
2123    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
2124        Ok(serde_json::from_str(json.as_ref())?)
2125    }
2126    pub fn builder() -> InputMessageVoiceNoteBuilder {
2127        let mut inner = InputMessageVoiceNote::default();
2128        inner.extra = Some(Uuid::new_v4().to_string());
2129
2130        InputMessageVoiceNoteBuilder { inner }
2131    }
2132
2133    pub fn voice_note(&self) -> &InputFile {
2134        &self.voice_note
2135    }
2136
2137    pub fn duration(&self) -> i32 {
2138        self.duration
2139    }
2140
2141    pub fn waveform(&self) -> &String {
2142        &self.waveform
2143    }
2144
2145    pub fn caption(&self) -> &FormattedText {
2146        &self.caption
2147    }
2148}
2149
2150#[doc(hidden)]
2151pub struct InputMessageVoiceNoteBuilder {
2152    inner: InputMessageVoiceNote,
2153}
2154
2155#[deprecated]
2156pub type RTDInputMessageVoiceNoteBuilder = InputMessageVoiceNoteBuilder;
2157
2158impl InputMessageVoiceNoteBuilder {
2159    pub fn build(&self) -> InputMessageVoiceNote {
2160        self.inner.clone()
2161    }
2162
2163    pub fn voice_note<T: AsRef<InputFile>>(&mut self, voice_note: T) -> &mut Self {
2164        self.inner.voice_note = voice_note.as_ref().clone();
2165        self
2166    }
2167
2168    pub fn duration(&mut self, duration: i32) -> &mut Self {
2169        self.inner.duration = duration;
2170        self
2171    }
2172
2173    pub fn waveform<T: AsRef<str>>(&mut self, waveform: T) -> &mut Self {
2174        self.inner.waveform = waveform.as_ref().to_string();
2175        self
2176    }
2177
2178    pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
2179        self.inner.caption = caption.as_ref().clone();
2180        self
2181    }
2182}
2183
2184impl AsRef<InputMessageVoiceNote> for InputMessageVoiceNote {
2185    fn as_ref(&self) -> &InputMessageVoiceNote {
2186        self
2187    }
2188}
2189
2190impl AsRef<InputMessageVoiceNote> for InputMessageVoiceNoteBuilder {
2191    fn as_ref(&self) -> &InputMessageVoiceNote {
2192        &self.inner
2193    }
2194}