telbot_types/
query.rs

1use serde::{Deserialize, Serialize};
2
3use crate::markup::{InlineKeyboardMarkup, MessageEntity, ParseMode};
4use crate::message::{Location, Message};
5use crate::payment::LabeledPrice;
6use crate::user::User;
7use crate::{JsonMethod, TelegramMethod};
8
9/// This object represents an incoming inline query.
10/// When the user sends an empty query, your bot could return some default or trending results.
11#[derive(Debug, Deserialize)]
12pub struct InlineQuery {
13    /// Unique identifier for this query
14    pub id: String,
15    /// Sender
16    pub from: User,
17    /// Text of the query (up to 256 characters)
18    pub query: String,
19    /// Offset of the results to be returned, can be controlled by the bot
20    pub offset: String,
21    /// Type of the chat, from which the inline query was sent.
22    ///
23    /// The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat
24    pub chat_type: Option<String>,
25    /// Sender location, only for bots that request user location
26    pub location: Option<Location>,
27}
28
29#[derive(Debug, Deserialize)]
30pub struct ChosenInlineResult {}
31
32/// This object represents an incoming callback query from a callback button in an
33/// [inline keyboard](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).
34///
35/// If the button that originated the query was attached to a message sent by the bot, the field *message* will be present.
36/// If the button was attached to a message sent via the bot
37/// (in [inline mode](https://core.telegram.org/bots/api#inline-mode)), the field *inline_message_id* will be present.
38/// Exactly one of the fields *data* or *game_short_name* will be present.
39///
40/// > **NOTE:** After the user presses a callback button,
41/// > Telegram clients will display a progress bar until you call [answerCallbackQuery](https://core.telegram.org/bots/api#answercallbackquery).
42/// > It is, therefore, necessary to react by calling [answerCallbackQuery](https://core.telegram.org/bots/api#answercallbackquery)
43/// > even if no notification to the user is needed (e.g., without specifying any of the optional parameters).
44#[derive(Debug, Deserialize)]
45pub struct CallbackQuery {
46    /// Unique identifier for this query
47    pub id: String,
48    /// Sender
49    pub from: User,
50    /// Message with the callback button that originated the query.
51    /// Note that message content and message date will not be available if the message is too old
52    pub message: Option<Message>,
53    /// Identifier of the message sent via the bot in inline mode, that originated the query.
54    pub inline_message_id: Option<String>,
55    /// Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent.
56    /// Useful for high scores in [games](https://core.telegram.org/bots/api#games).
57    pub chat_instance: String,
58    /// Data associated with the callback button.
59    /// Be aware that a bad client can send arbitrary data in this field.
60    pub data: Option<String>,
61    /// Short name of a [Game](https://core.telegram.org/bots/api#games) to be returned,
62    /// serves as the unique identifier for the game
63    pub game_short_name: Option<String>,
64}
65
66/// This object represents one result of an inline query.
67///
68/// Telegram clients currently support results of the following 20 types:
69///
70/// - [InlineQueryResultCachedAudio](https://core.telegram.org/bots/api#inlinequeryresultcachedaudio)
71/// - [InlineQueryResultCachedDocument](https://core.telegram.org/bots/api#inlinequeryresultcacheddocument)
72/// - [InlineQueryResultCachedGif](https://core.telegram.org/bots/api#inlinequeryresultcachedgif)
73/// - [InlineQueryResultCachedMpeg4Gif](https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif)
74/// - [InlineQueryResultCachedPhoto](https://core.telegram.org/bots/api#inlinequeryresultcachedphoto)
75/// - [InlineQueryResultCachedSticker](https://core.telegram.org/bots/api#inlinequeryresultcachedsticker)
76/// - [InlineQueryResultCachedVideo](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo)
77/// - [InlineQueryResultCachedVoice](https://core.telegram.org/bots/api#inlinequeryresultcachedvoice)
78/// - [InlineQueryResultArticle](https://core.telegram.org/bots/api#inlinequeryresultarticle)
79/// - [InlineQueryResultAudio](https://core.telegram.org/bots/api#inlinequeryresultaudio)
80/// - [InlineQueryResultContact](https://core.telegram.org/bots/api#inlinequeryresultcontact)
81/// - [InlineQueryResultGame](https://core.telegram.org/bots/api#inlinequeryresultgame)
82/// - [InlineQueryResultDocument](https://core.telegram.org/bots/api#inlinequeryresultdocument)
83/// - [InlineQueryResultGif](https://core.telegram.org/bots/api#inlinequeryresultgif)
84/// - [InlineQueryResultLocation](https://core.telegram.org/bots/api#inlinequeryresultlocation)
85/// - [InlineQueryResultMpeg4Gif](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif)
86/// - [InlineQueryResultPhoto](https://core.telegram.org/bots/api#inlinequeryresultphoto)
87/// - [InlineQueryResultVenue](https://core.telegram.org/bots/api#inlinequeryresultvenue)
88/// - [InlineQueryResultVideo](https://core.telegram.org/bots/api#inlinequeryresultvideo)
89/// - [InlineQueryResultVoice](https://core.telegram.org/bots/api#inlinequeryresultvoice)
90///
91/// **Note:** All URLs passed in inline query results will be available to end users
92/// and therefore must be assumed to be **public**.
93#[derive(Clone, Serialize)]
94pub struct InlineQueryResult {
95    /// Unique identifier for this result, 1-64 bytes
96    pub id: String,
97    /// Result type, should be handled manually
98    r#type: &'static str,
99    /// Result type
100    #[serde(flatten)]
101    pub kind: InlineQueryResultKind,
102    /// [Inline keyboard](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating) attached to the message
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub reply_markup: Option<InlineKeyboardMarkup>,
105}
106
107impl InlineQueryResult {
108    /// Set reply markup
109    pub fn with_reply_markup(self, markup: impl Into<InlineKeyboardMarkup>) -> Self {
110        Self {
111            reply_markup: Some(markup.into()),
112            ..self
113        }
114    }
115}
116
117/// Inline query result type
118#[derive(Clone, Serialize)]
119#[serde(untagged)]
120pub enum InlineQueryResultKind {
121    /// Represents a link to an article or web page.
122    Article {
123        /// Title of the result
124        title: String,
125        /// Content of the message to be sent
126        input_message_content: InputMessageContent,
127        /// URL of the result
128        #[serde(skip_serializing_if = "Option::is_none")]
129        url: Option<String>,
130        /// Pass *True*, if you don't want the URL to be shown in the message
131        #[serde(skip_serializing_if = "Option::is_none")]
132        hide_url: Option<bool>,
133        /// Short description of the result
134        #[serde(skip_serializing_if = "Option::is_none")]
135        description: Option<String>,
136        /// Url of the thumbnail for the result
137        #[serde(skip_serializing_if = "Option::is_none")]
138        thumb_url: Option<String>,
139        /// Thumbnail width
140        #[serde(skip_serializing_if = "Option::is_none")]
141        thumb_width: Option<u32>,
142        /// Thumbnail height
143        #[serde(skip_serializing_if = "Option::is_none")]
144        thumb_height: Option<u32>,
145    },
146    /// Represents a link to a photo.
147    ///
148    /// By default, this photo will be sent by the user with optional caption.
149    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the photo.
150    Photo {
151        /// A valid URL of the photo. Photo must be in **jpeg** format.
152        ///
153        /// Photo size must not exceed 5MB
154        photo_url: String,
155        /// URL of the thumbnail for the photo
156        thumb_url: String,
157        /// Width of the photo
158        #[serde(skip_serializing_if = "Option::is_none")]
159        photo_width: Option<u32>,
160        /// Height of the photo
161        #[serde(skip_serializing_if = "Option::is_none")]
162        photo_height: Option<u32>,
163        /// Title for the result
164        #[serde(skip_serializing_if = "Option::is_none")]
165        title: Option<String>,
166        /// Short description of the result
167        #[serde(skip_serializing_if = "Option::is_none")]
168        description: Option<String>,
169        /// Caption of the photo to be sent, 0-1024 characters after entities parsing
170        #[serde(skip_serializing_if = "Option::is_none")]
171        caption: Option<String>,
172        /// Mode for parsing entities in the photo caption.
173        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
174        #[serde(skip_serializing_if = "Option::is_none")]
175        parse_mode: Option<ParseMode>,
176        /// List of special entities that appear in the caption,
177        /// which can be specified instead of parse_mode
178        #[serde(skip_serializing_if = "Option::is_none")]
179        caption_entities: Option<Vec<MessageEntity>>,
180        /// Content of the message to be sent instead of the photo
181        #[serde(skip_serializing_if = "Option::is_none")]
182        input_message_content: Option<InputMessageContent>,
183    },
184    /// Represents a link to an animated GIF file.
185    ///
186    /// By default, this animated GIF file will be sent by the user with optional caption.
187    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the animation.
188    Gif {
189        /// A valid URL for the GIF file. File size must not exceed 1MB
190        gif_url: String,
191        /// Width of the GIF
192        #[serde(skip_serializing_if = "Option::is_none")]
193        gif_width: Option<u32>,
194        /// Height of the GIF
195        #[serde(skip_serializing_if = "Option::is_none")]
196        gif_height: Option<u32>,
197        /// Duration of the GIF
198        #[serde(skip_serializing_if = "Option::is_none")]
199        gif_duration: Option<u32>,
200        /// URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
201        thumb_url: String,
202        /// MIME type of the thumbnail,
203        /// must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
204        #[serde(skip_serializing_if = "Option::is_none")]
205        thumb_mime_type: Option<String>,
206        /// Title for the result
207        #[serde(skip_serializing_if = "Option::is_none")]
208        title: Option<String>,
209        /// Caption of the GIF file to be sent, 0-1024 characters after entities parsing
210        #[serde(skip_serializing_if = "Option::is_none")]
211        caption: Option<String>,
212        /// Mode for parsing entities in the caption.
213        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
214        #[serde(skip_serializing_if = "Option::is_none")]
215        parse_mode: Option<ParseMode>,
216        /// List of special entities that appear in the caption,
217        /// which can be specified instead of parse_mode
218        #[serde(skip_serializing_if = "Option::is_none")]
219        caption_entities: Option<Vec<MessageEntity>>,
220        /// Content of the message to be sent instead of the GIF animation
221        #[serde(skip_serializing_if = "Option::is_none")]
222        input_message_content: Option<InputMessageContent>,
223    },
224    /// Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
225    ///
226    /// By default, this animated MPEG-4 file will be sent by the user with optional caption.
227    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the animation.
228    Mpeg4Gif {
229        /// A valid URL for the MP4 file. File size must not exceed 1MB
230        mpeg4_url: String,
231        /// Video width
232        #[serde(skip_serializing_if = "Option::is_none")]
233        mpeg4_width: Option<u32>,
234        /// Video height
235        #[serde(skip_serializing_if = "Option::is_none")]
236        mpeg4_height: Option<u32>,
237        /// Video duration
238        #[serde(skip_serializing_if = "Option::is_none")]
239        mpeg4_duration: Option<u32>,
240        /// URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
241        thumb_url: String,
242        /// MIME type of the thumbnail,
243        /// must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
244        #[serde(skip_serializing_if = "Option::is_none")]
245        thumb_mime_type: Option<String>,
246        /// Title for the result
247        #[serde(skip_serializing_if = "Option::is_none")]
248        title: Option<String>,
249        /// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing
250        #[serde(skip_serializing_if = "Option::is_none")]
251        caption: Option<String>,
252        /// Mode for parsing entities in the caption.
253        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
254        #[serde(skip_serializing_if = "Option::is_none")]
255        parse_mode: Option<ParseMode>,
256        /// List of special entities that appear in the caption,
257        /// which can be specified instead of parse_mode
258        #[serde(skip_serializing_if = "Option::is_none")]
259        caption_entities: Option<Vec<MessageEntity>>,
260        /// Content of the message to be sent instead of the video animation
261        #[serde(skip_serializing_if = "Option::is_none")]
262        input_message_content: Option<InputMessageContent>,
263    },
264    /// Represents a link to a page containing an embedded video player or a video file.
265    ///
266    /// By default, this video file will be sent by the user with an optional caption.
267    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the video.
268    /// > If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube),
269    /// > you **must** replace its content using *input_message_content*.
270    Video {
271        /// A valid URL for the embedded video player or video file
272        video_url: String,
273        /// Mime type of the content of video url, “text/html” or “video/mp4”
274        mime_type: String,
275        /// URL of the thumbnail (jpeg only) for the video
276        thumb_url: String,
277        /// Title for the result
278        title: String,
279        /// Video width
280        #[serde(skip_serializing_if = "Option::is_none")]
281        video_width: Option<u32>,
282        /// Video height
283        #[serde(skip_serializing_if = "Option::is_none")]
284        video_height: Option<u32>,
285        /// Video duration in seconds
286        #[serde(skip_serializing_if = "Option::is_none")]
287        video_duration: Option<u32>,
288        /// Short description of the result
289        #[serde(skip_serializing_if = "Option::is_none")]
290        description: Option<String>,
291        /// Caption of the video to be sent, 0-1024 characters after entities parsing
292        #[serde(skip_serializing_if = "Option::is_none")]
293        caption: Option<String>,
294        /// Mode for parsing entities in the caption.
295        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
296        #[serde(skip_serializing_if = "Option::is_none")]
297        parse_mode: Option<ParseMode>,
298        /// List of special entities that appear in the caption,
299        /// which can be specified instead of parse_mode
300        #[serde(skip_serializing_if = "Option::is_none")]
301        caption_entities: Option<Vec<MessageEntity>>,
302        /// Content of the message to be sent instead of the video.
303        /// This field is **required** if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
304        #[serde(skip_serializing_if = "Option::is_none")]
305        input_message_content: Option<InputMessageContent>,
306    },
307    /// Represents a link to an MP3 audio file.
308    ///
309    /// By default, this audio file will be sent by the user.
310    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the audio.
311    Audio {
312        /// A valid URL for the audio file
313        audio_url: String,
314        /// Title
315        title: String,
316        /// Performer
317        performer: Option<String>,
318        /// Audio duration in seconds
319        #[serde(skip_serializing_if = "Option::is_none")]
320        audio_duration: Option<u32>,
321        /// Caption, 0-1024 characters after entities parsing
322        #[serde(skip_serializing_if = "Option::is_none")]
323        caption: Option<String>,
324        /// Mode for parsing entities in the caption.
325        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
326        #[serde(skip_serializing_if = "Option::is_none")]
327        parse_mode: Option<ParseMode>,
328        /// List of special entities that appear in the caption,
329        /// which can be specified instead of parse_mode
330        #[serde(skip_serializing_if = "Option::is_none")]
331        caption_entities: Option<Vec<MessageEntity>>,
332        /// Content of the message to be sent instead of the audio
333        #[serde(skip_serializing_if = "Option::is_none")]
334        input_message_content: Option<InputMessageContent>,
335    },
336    /// Represents a link to a voice recording in an .OGG container encoded with OPUS.
337    ///
338    /// By default, this voice recording will be sent by the user.
339    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the the voice message.
340    Voice {
341        /// A valid URL for the voice recording
342        voice_url: String,
343        /// Recording title
344        title: String,
345        /// Recording duration in seconds
346        #[serde(skip_serializing_if = "Option::is_none")]
347        voice_duration: Option<u32>,
348        /// Caption, 0-1024 characters after entities parsing
349        caption: Option<String>,
350        /// Mode for parsing entities in the caption.
351        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
352        #[serde(skip_serializing_if = "Option::is_none")]
353        parse_mode: Option<ParseMode>,
354        /// List of special entities that appear in the caption,
355        /// which can be specified instead of parse_mode
356        #[serde(skip_serializing_if = "Option::is_none")]
357        caption_entities: Option<Vec<MessageEntity>>,
358        /// Content of the message to be sent instead of the voice recording
359        #[serde(skip_serializing_if = "Option::is_none")]
360        input_message_content: Option<InputMessageContent>,
361    },
362    /// Represents a link to a file.
363    ///
364    /// By default, this file will be sent by the user with an optional caption.
365    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the file.
366    /// Currently, only **.PDF** and **.ZIP** files can be sent using this method.
367    ///
368    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
369    Document {
370        /// A valid URL for the file
371        document_url: String,
372        /// Mime type of the content of the file, either “application/pdf” or “application/zip”
373        mime_type: String,
374        /// Short description of the result
375        description: String,
376        /// URL of the thumbnail (jpeg only) for the file
377        thumb_url: Option<String>,
378        /// Thumbnail width
379        #[serde(skip_serializing_if = "Option::is_none")]
380        thumb_width: Option<u32>,
381        /// Thumbnail height
382        #[serde(skip_serializing_if = "Option::is_none")]
383        thumb_height: Option<u32>,
384        /// Caption of the document to be sent, 0-1024 characters after entities parsing
385        caption: Option<String>,
386        /// Mode for parsing entities in the caption.
387        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
388        #[serde(skip_serializing_if = "Option::is_none")]
389        parse_mode: Option<ParseMode>,
390        /// List of special entities that appear in the caption,
391        /// which can be specified instead of parse_mode
392        #[serde(skip_serializing_if = "Option::is_none")]
393        caption_entities: Option<Vec<MessageEntity>>,
394        /// Content of the message to be sent instead of the file
395        #[serde(skip_serializing_if = "Option::is_none")]
396        input_message_content: Option<InputMessageContent>,
397    },
398    /// Represents a location on a map.
399    ///
400    /// By default, the location will be sent by the user.
401    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the location.
402    ///
403    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
404    Location {
405        /// Location latitude in degrees
406        latitude: f32,
407        /// Location longitude in degrees
408        longitude: f32,
409        /// Location title
410        title: String,
411        /// The radius of uncertainty for the location, measured in meters; 0-1500
412        horizontal_accuracy: f32,
413        /// Period in seconds for which the location can be updated, should be between 60 and 86400.
414        #[serde(skip_serializing_if = "Option::is_none")]
415        live_period: Option<u32>,
416        /// For live locations, a direction in which the user is moving, in degrees.
417        /// Must be between 1 and 360 if specified.
418        #[serde(skip_serializing_if = "Option::is_none")]
419        heading: Option<u32>,
420        /// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
421        /// Must be between 1 and 100000 if specified.
422        #[serde(skip_serializing_if = "Option::is_none")]
423        proximity_alert_radius: Option<u32>,
424        /// Url of the thumbnail for the result
425        thumb_url: Option<String>,
426        /// Thumbnail width
427        #[serde(skip_serializing_if = "Option::is_none")]
428        thumb_width: Option<u32>,
429        /// Thumbnail height
430        #[serde(skip_serializing_if = "Option::is_none")]
431        thumb_height: Option<u32>,
432        /// Content of the message to be sent instead of the location
433        #[serde(skip_serializing_if = "Option::is_none")]
434        input_message_content: Option<InputMessageContent>,
435    },
436    /// Represents a venue.
437    ///
438    /// By default, the venue will be sent by the user.
439    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the venue.
440    ///
441    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
442    Venue {
443        /// Location latitude in degrees
444        latitude: f32,
445        /// Location longitude in degrees
446        longitude: f32,
447        /// Location title
448        title: String,
449        /// Address of the venue
450        address: String,
451        /// Foursquare identifier of the venue if known
452        #[serde(skip_serializing_if = "Option::is_none")]
453        foursquare_id: Option<String>,
454        /// Foursquare type of the venue, if known.
455        /// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
456        #[serde(skip_serializing_if = "Option::is_none")]
457        foursquare_type: Option<String>,
458        /// Google Places identifier of the venue
459        #[serde(skip_serializing_if = "Option::is_none")]
460        google_place_id: Option<String>,
461        /// Google Places type of the venue. (See [supported types.](https://developers.google.com/places/web-service/supported_types))
462        #[serde(skip_serializing_if = "Option::is_none")]
463        google_place_type: Option<String>,
464        /// Url of the thumbnail for the result
465        thumb_url: Option<String>,
466        /// Thumbnail width
467        #[serde(skip_serializing_if = "Option::is_none")]
468        thumb_width: Option<u32>,
469        /// Thumbnail height
470        #[serde(skip_serializing_if = "Option::is_none")]
471        thumb_height: Option<u32>,
472        /// Content of the message to be sent instead of the venue
473        #[serde(skip_serializing_if = "Option::is_none")]
474        input_message_content: Option<InputMessageContent>,
475    },
476    /// Represents a contact with a phone number.
477    ///
478    /// By default, this contact will be sent by the user.
479    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the contact.
480    ///
481    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
482    Contact {
483        /// Contact's phone number
484        phone_number: String,
485        /// Contact's first name
486        first_name: String,
487        /// Contact's last name
488        #[serde(skip_serializing_if = "Option::is_none")]
489        last_name: Option<String>,
490        /// Additional data about the contact in the form of a [vCard](https://en.wikipedia.org/wiki/VCard), 0-2048 bytes
491        #[serde(skip_serializing_if = "Option::is_none")]
492        vcard: Option<String>,
493        /// Url of the thumbnail for the result
494        #[serde(skip_serializing_if = "Option::is_none")]
495        thumb_url: Option<String>,
496        /// Thumbnail width
497        #[serde(skip_serializing_if = "Option::is_none")]
498        thumb_width: Option<u32>,
499        /// Thumbnail height
500        #[serde(skip_serializing_if = "Option::is_none")]
501        thumb_height: Option<u32>,
502        /// Content of the message to be sent instead of the contact
503        #[serde(skip_serializing_if = "Option::is_none")]
504        input_message_content: Option<InputMessageContent>,
505    },
506    /// Represents a [Game](https://core.telegram.org/bots/api#games).
507    Game {
508        /// Short name of the game
509        game_short_name: String,
510    },
511    /// Represents a link to a photo stored on the Telegram servers.
512    ///
513    /// By default, this photo will be sent by the user with an optional caption.
514    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the photo.
515    ///
516    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
517    CachedPhoto {
518        /// A valid file identifier of the photo
519        photo_file_id: String,
520        /// Title for the result
521        title: String,
522        /// Short description of the result
523        #[serde(skip_serializing_if = "Option::is_none")]
524        description: Option<String>,
525        /// Caption of the photo to be sent, 0-1024 characters after entities parsing
526        #[serde(skip_serializing_if = "Option::is_none")]
527        caption: Option<String>,
528        /// Mode for parsing entities in the photo caption.
529        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
530        #[serde(skip_serializing_if = "Option::is_none")]
531        parse_mode: Option<ParseMode>,
532        /// List of special entities that appear in the caption,
533        /// which can be specified instead of parse_mode
534        #[serde(skip_serializing_if = "Option::is_none")]
535        caption_entities: Option<Vec<MessageEntity>>,
536        /// Content of the message to be sent instead of the photo
537        #[serde(skip_serializing_if = "Option::is_none")]
538        input_message_content: Option<InputMessageContent>,
539    },
540    /// Represents a link to an animated GIF file stored on the Telegram servers.
541    ///
542    /// By default, this animated GIF file will be sent by the user with optional caption.
543    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the animation.
544    ///
545    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
546    CachedGif {
547        /// A valid file identifier for the GIF file
548        gif_file_id: String,
549        /// Title for the result
550        title: String,
551        /// Caption of the GIF file to be sent, 0-1024 characters after entities parsing
552        #[serde(skip_serializing_if = "Option::is_none")]
553        caption: Option<String>,
554        /// Mode for parsing entities in the caption.
555        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
556        #[serde(skip_serializing_if = "Option::is_none")]
557        parse_mode: Option<ParseMode>,
558        /// List of special entities that appear in the caption,
559        /// which can be specified instead of parse_mode
560        #[serde(skip_serializing_if = "Option::is_none")]
561        caption_entities: Option<Vec<MessageEntity>>,
562        /// Content of the message to be sent instead of the GIF animation
563        #[serde(skip_serializing_if = "Option::is_none")]
564        input_message_content: Option<InputMessageContent>,
565    },
566    /// Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers.
567    ///
568    /// By default, this animated MPEG-4 file will be sent by the user with optional caption.
569    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the animation.
570    ///
571    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
572    CachedMpeg4Gif {
573        /// A valid file identifier for the MP4 file
574        mpeg4_file_id: String,
575        /// Title for the result
576        title: String,
577        /// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing
578        #[serde(skip_serializing_if = "Option::is_none")]
579        caption: Option<String>,
580        /// Mode for parsing entities in the caption.
581        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
582        #[serde(skip_serializing_if = "Option::is_none")]
583        parse_mode: Option<ParseMode>,
584        /// List of special entities that appear in the caption,
585        /// which can be specified instead of parse_mode
586        #[serde(skip_serializing_if = "Option::is_none")]
587        caption_entities: Option<Vec<MessageEntity>>,
588        /// Content of the message to be sent instead of the video animation
589        #[serde(skip_serializing_if = "Option::is_none")]
590        input_message_content: Option<InputMessageContent>,
591    },
592    /// Represents a link to a video file stored on the Telegram servers.
593    ///
594    /// By default, this video file will be sent by the user with an optional caption.
595    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the video.
596    /// > If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube),
597    /// > you **must** replace its content using *input_message_content*.
598    ///
599    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
600    CachedVideo {
601        /// A valid file identifier for the video file
602        video_file_id: String,
603        /// Title for the result
604        title: String,
605        /// Short description of the result
606        #[serde(skip_serializing_if = "Option::is_none")]
607        description: Option<String>,
608        /// Caption of the video to be sent, 0-1024 characters after entities parsing
609        #[serde(skip_serializing_if = "Option::is_none")]
610        caption: Option<String>,
611        /// Mode for parsing entities in the caption.
612        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
613        #[serde(skip_serializing_if = "Option::is_none")]
614        parse_mode: Option<ParseMode>,
615        /// List of special entities that appear in the caption,
616        /// which can be specified instead of parse_mode
617        #[serde(skip_serializing_if = "Option::is_none")]
618        caption_entities: Option<Vec<MessageEntity>>,
619        /// Content of the message to be sent instead of the video.
620        /// This field is **required** if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
621        #[serde(skip_serializing_if = "Option::is_none")]
622        input_message_content: Option<InputMessageContent>,
623    },
624    /// Represents a link to an MP3 audio file stored on the Telegram servers.
625    ///
626    /// By default, this audio file will be sent by the user.
627    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the audio.
628    ///
629    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
630    CachedAudio {
631        /// A valid file identifier for the audio file
632        audio_file_id: String,
633        /// Caption, 0-1024 characters after entities parsing
634        #[serde(skip_serializing_if = "Option::is_none")]
635        caption: Option<String>,
636        /// Mode for parsing entities in the caption.
637        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
638        #[serde(skip_serializing_if = "Option::is_none")]
639        parse_mode: Option<ParseMode>,
640        /// List of special entities that appear in the caption,
641        /// which can be specified instead of parse_mode
642        #[serde(skip_serializing_if = "Option::is_none")]
643        caption_entities: Option<Vec<MessageEntity>>,
644        /// Content of the message to be sent instead of the audio
645        #[serde(skip_serializing_if = "Option::is_none")]
646        input_message_content: Option<InputMessageContent>,
647    },
648    /// Represents a link to a voice message stored on the Telegram servers.
649    ///
650    /// By default, this voice recording will be sent by the user.
651    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the the voice message.
652    ///
653    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
654    CachedVoice {
655        /// A valid file identifier for the voice message
656        voice_file_id: String,
657        /// Recording title
658        title: String,
659        /// Caption, 0-1024 characters after entities parsing
660        #[serde(skip_serializing_if = "Option::is_none")]
661        caption: Option<String>,
662        /// Mode for parsing entities in the caption.
663        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
664        #[serde(skip_serializing_if = "Option::is_none")]
665        parse_mode: Option<ParseMode>,
666        /// List of special entities that appear in the caption,
667        /// which can be specified instead of parse_mode
668        #[serde(skip_serializing_if = "Option::is_none")]
669        caption_entities: Option<Vec<MessageEntity>>,
670        /// Content of the message to be sent instead of the voice recording
671        #[serde(skip_serializing_if = "Option::is_none")]
672        input_message_content: Option<InputMessageContent>,
673    },
674    /// Represents a link to a file stored on the Telegram servers.
675    ///
676    /// By default, this file will be sent by the user with an optional caption.
677    /// Alternatively, you can use *input_message_content* to send a message with the specified content instead of the file.
678    /// Currently, only **.PDF** and **.ZIP** files can be sent using this method.
679    ///
680    /// **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
681    CachedDocument {
682        /// A valid file identifier for the file
683        document_file_id: String,
684        /// Title for the result
685        title: String,
686        /// Short description of the result
687        description: String,
688        /// Caption of the document to be sent, 0-1024 characters after entities parsing
689        #[serde(skip_serializing_if = "Option::is_none")]
690        caption: Option<String>,
691        /// Mode for parsing entities in the caption.
692        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
693        #[serde(skip_serializing_if = "Option::is_none")]
694        parse_mode: Option<ParseMode>,
695        /// List of special entities that appear in the caption,
696        /// which can be specified instead of parse_mode
697        #[serde(skip_serializing_if = "Option::is_none")]
698        caption_entities: Option<Vec<MessageEntity>>,
699        /// Content of the message to be sent instead of the file
700        #[serde(skip_serializing_if = "Option::is_none")]
701        input_message_content: Option<InputMessageContent>,
702    },
703}
704
705impl InlineQueryResultKind {
706    pub fn with_id(self, id: impl Into<String>) -> InlineQueryResult {
707        use InlineQueryResultKind::*;
708        let r#type = match self {
709            Article { .. } => "article",
710            Photo { .. } | CachedPhoto { .. } => "photo",
711            Gif { .. } | CachedGif { .. } => "gif",
712            Mpeg4Gif { .. } | CachedMpeg4Gif { .. } => "mpeg4_gif",
713            Video { .. } | CachedVideo { .. } => "video",
714            Audio { .. } | CachedAudio { .. } => "audio",
715            Voice { .. } | CachedVoice { .. } => "voice",
716            Document { .. } | CachedDocument { .. } => "document",
717            Location { .. } => "location",
718            Venue { .. } => "venue",
719            Contact { .. } => "contact",
720            Game { .. } => "game",
721        };
722        InlineQueryResult {
723            id: id.into(),
724            r#type,
725            kind: self,
726            reply_markup: None,
727        }
728    }
729}
730
731/// This object represents the content of a message to be sent as a result of an inline query.
732///
733/// Telegram clients currently support the following 5 types:
734/// - [InputTextMessageContent](https://core.telegram.org/bots/api#inputtextmessagecontent)
735/// - [InputLocationMessageContent](https://core.telegram.org/bots/api#inputlocationmessagecontent)
736/// - [InputVenueMessageContent](https://core.telegram.org/bots/api#inputvenuemessagecontent)
737/// - [InputContactMessageContent](https://core.telegram.org/bots/api#inputcontactmessagecontent)
738/// - [InputInvoiceMessageContent](https://core.telegram.org/bots/api#inputinvoicemessagecontent)
739
740#[derive(Clone, Serialize)]
741#[serde(untagged)]
742pub enum InputMessageContent {
743    /// Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent)
744    /// of a text message to be sent as the result of an inline query.
745    Text {
746        /// Text of the message to be sent, 1-4096 characters
747        message_text: String,
748        /// Mode for parsing entities in the message text.
749        /// See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.
750        #[serde(skip_serializing_if = "Option::is_none")]
751        parse_mode: Option<ParseMode>,
752        /// List of special entities that appear in message text, which can be specified instead of *parse_mode*
753        #[serde(skip_serializing_if = "Option::is_none")]
754        entities: Option<Vec<MessageEntity>>,
755        /// Disables link previews for links in the sent message
756        #[serde(skip_serializing_if = "Option::is_none")]
757        disable_web_page_preview: Option<bool>,
758    },
759    /// Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent)
760    /// of a location message to be sent as the result of an inline query.
761    Location {
762        /// Latitude of the location in degrees
763        latitude: f32,
764        /// Longitude of the location in degrees
765        longitude: f32,
766        /// The radius of uncertainty for the location, measured in meters; 0-1500
767        horizontal_accuracy: f32,
768        /// Period in seconds for which the location can be updated, should be between 60 and 86400.
769        #[serde(skip_serializing_if = "Option::is_none")]
770        live_period: Option<u32>,
771        /// For live locations, a direction in which the user is moving, in degrees.
772        /// Must be between 1 and 360 if specified.
773        #[serde(skip_serializing_if = "Option::is_none")]
774        heading: Option<u32>,
775        /// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
776        /// Must be between 1 and 100000 if specified.
777        #[serde(skip_serializing_if = "Option::is_none")]
778        proximity_alert_radius: Option<u32>,
779    },
780    /// Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent)
781    /// of a venue message to be sent as the result of an inline query.
782    Venue {
783        /// Latitude of the venue in degrees
784        latitude: f32,
785        /// Longitude of the venue in degrees
786        longitude: f32,
787        /// Name of the venue
788        title: String,
789        /// Address of the venue
790        address: String,
791        /// Foursquare identifier of the venue, if known
792        #[serde(skip_serializing_if = "Option::is_none")]
793        foursquare_id: Option<String>,
794        /// Foursquare type of the venue, if known.
795        /// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
796        #[serde(skip_serializing_if = "Option::is_none")]
797        foursquare_type: Option<String>,
798        /// Google Places identifier of the venue
799        #[serde(skip_serializing_if = "Option::is_none")]
800        google_place_id: Option<String>,
801        /// Google Places type of the venue. (See [supported types.](https://developers.google.com/places/web-service/supported_types))
802        #[serde(skip_serializing_if = "Option::is_none")]
803        google_place_type: Option<String>,
804    },
805    /// Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent)
806    /// of a contact message to be sent as the result of an inline query.
807    Contact {
808        /// Contact's phone number
809        phone_number: String,
810        /// Contact's first name
811        first_name: String,
812        /// Contact's last name
813        #[serde(skip_serializing_if = "Option::is_none")]
814        last_name: Option<String>,
815        /// Additional data about the contact in the form of a [vCard](https://en.wikipedia.org/wiki/VCard), 0-2048 bytes
816        #[serde(skip_serializing_if = "Option::is_none")]
817        vcard: Option<String>,
818    },
819    /// Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent)
820    /// of an invoice message to be sent as the result of an inline query.
821    Invoice {
822        /// Product name, 1-32 characters
823        title: String,
824        /// Product description, 1-255 characters
825        description: String,
826        /// Bot-defined invoice payload, 1-128 bytes.
827        /// This will not be displayed to the user, use for your internal processes.
828        payload: String,
829        /// Payment provider token, obtained via [Botfather](https://t.me/botfather)
830        provider_token: String,
831        /// Three-letter ISO 4217 currency code, see [more on currencies](https://core.telegram.org/bots/payments#supported-currencies)
832        currency: String,
833        /// Price breakdown, a JSON-serialized list of components
834        /// (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
835        prices: Vec<LabeledPrice>,
836        /// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double).
837        /// For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`.
838        /// See the exp parameter in [currencies.json](https://core.telegram.org/bots/payments/currencies.json),
839        /// it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
840        #[serde(skip_serializing_if = "Option::is_none")]
841        max_tip_amount: Option<i32>,
842        /// A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, **not** float/double).
843        /// At most 4 suggested tip amounts can be specified.
844        /// The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed *max_tip_amount*.
845        #[serde(skip_serializing_if = "Option::is_none")]
846        suggested_tip_amounts: Option<Vec<i32>>,
847        /// Unique deep-linking parameter.
848        /// If left empty, **forwarded copies** of the sent message will have a *Pay* button, allowing multiple users to pay directly from the forwarded message, using the same invoice.
849        /// If non-empty, forwarded copies of the sent message will have a *URL* button with a deep link to the bot (instead of a *Pay* button), with the value used as the start parameter
850        #[serde(skip_serializing_if = "Option::is_none")]
851        start_parameter: Option<String>,
852        /// A JSON-serialized data about the invoice, which will be shared with the payment provider.
853        /// A detailed description of required fields should be provided by the payment provider.
854        #[serde(skip_serializing_if = "Option::is_none")]
855        provider_data: Option<String>,
856        /// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
857        /// People like it better when they see what they are paying for.
858        #[serde(skip_serializing_if = "Option::is_none")]
859        photo_url: Option<String>,
860        /// Photo size
861        #[serde(skip_serializing_if = "Option::is_none")]
862        photo_size: Option<u32>,
863        /// Photo width
864        #[serde(skip_serializing_if = "Option::is_none")]
865        photo_width: Option<u32>,
866        /// Photo height
867        #[serde(skip_serializing_if = "Option::is_none")]
868        photo_height: Option<u32>,
869        /// Pass *True*, if you require the user's full name to complete the order
870        #[serde(skip_serializing_if = "Option::is_none")]
871        need_name: Option<bool>,
872        /// Pass *True*, if you require the user's phone number to complete the order
873        #[serde(skip_serializing_if = "Option::is_none")]
874        need_phone_number: Option<bool>,
875        /// Pass *True*, if you require the user's email address to complete the order
876        #[serde(skip_serializing_if = "Option::is_none")]
877        need_email: Option<bool>,
878        /// Pass *True*, if you require the user's shipping address to complete the order
879        #[serde(skip_serializing_if = "Option::is_none")]
880        need_shipping_address: Option<bool>,
881        /// Pass *True*, if user's phone number should be sent to provider
882        #[serde(skip_serializing_if = "Option::is_none")]
883        send_phone_number_to_provider: Option<bool>,
884        /// Pass *True*, if user's email address should be sent to provider
885        #[serde(skip_serializing_if = "Option::is_none")]
886        send_email_to_provider: Option<bool>,
887        /// Pass *True*, if the final price depends on the shipping method
888        #[serde(skip_serializing_if = "Option::is_none")]
889        is_flexible: Option<bool>,
890        /// Sends the message [silently](https://telegram.org/blog/channels-2-0#silent-messages).
891        /// Users will receive a notification with no sound.
892        #[serde(skip_serializing_if = "Option::is_none")]
893        disable_notification: Option<bool>,
894        /// If the message is a reply, ID of the original message
895        #[serde(skip_serializing_if = "Option::is_none")]
896        reply_to_message_id: Option<i64>,
897        /// Pass *True*, if the message should be sent even if the specified replied-to message is not found
898        #[serde(skip_serializing_if = "Option::is_none")]
899        allow_sending_without_reply: Option<bool>,
900        /// A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).
901        /// If empty, one 'Pay `total price`' button will be shown.
902        /// If not empty, the first button must be a Pay button.
903        #[serde(skip_serializing_if = "Option::is_none")]
904        reply_markup: Option<InlineKeyboardMarkup>,
905    },
906}
907
908/// Use this method to send answers to callback queries sent from inline keyboards.
909/// The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
910/// On success, *True* is returned.
911///
912/// > Alternatively, the user can be redirected to the specified Game URL.
913/// > For this option to work, you must first create a game for your bot via [@Botfather](https://t.me/botfather) and accept the terms.
914///
915/// Otherwise, you may use links like `t.me/your_bot?start=XXXX` that open your bot with a parameter.
916#[derive(Clone, Serialize)]
917pub struct AnswerCallbackQuery {
918    /// Unique identifier for the query to be answered
919    pub callback_query_id: String,
920    /// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
921    #[serde(skip_serializing_if = "Option::is_none")]
922    pub text: Option<String>,
923    /// If *true*, an alert will be shown by the client instead of a notification at the top of the chat screen.
924    /// Defaults to false.
925    #[serde(skip_serializing_if = "Option::is_none")]
926    pub show_alert: Option<bool>,
927    /// URL that will be opened by the user's client.
928    // If you have created a [Game](https://core.telegram.org/bots/api#game) and accepted the conditions via [@Botfather](https://t.me/botfather),
929    // specify the URL that opens your game
930    /// — note that this will only work if the query comes from a [*callback_game*](https://core.telegram.org/bots/api#inlinekeyboardbutton) button.
931    ///
932    /// Otherwise, you may use links like `t.me/your_bot?start=XXXX` that open your bot with a parameter.
933    #[serde(skip_serializing_if = "Option::is_none")]
934    pub url: Option<String>,
935    /// The maximum amount of time in seconds that the result of the callback query may be cached client-side.
936    /// Telegram apps will support caching starting in version 3.14. Defaults to 0.
937    #[serde(skip_serializing_if = "Option::is_none")]
938    pub cache_time: Option<u32>,
939}
940
941impl AnswerCallbackQuery {
942    /// Create a new answerCallbackQuery request
943    pub fn new(query_id: impl Into<String>) -> Self {
944        Self {
945            callback_query_id: query_id.into(),
946            text: None,
947            show_alert: None,
948            url: None,
949            cache_time: None,
950        }
951    }
952    /// Set text
953    pub fn with_text(self, text: impl Into<String>) -> Self {
954        Self {
955            text: Some(text.into()),
956            ..self
957        }
958    }
959    /// Show alert
960    pub fn show_alert(self) -> Self {
961        Self {
962            show_alert: Some(true),
963            ..self
964        }
965    }
966    /// Set url
967    pub fn with_url(self, url: impl Into<String>) -> Self {
968        Self {
969            url: Some(url.into()),
970            ..self
971        }
972    }
973    /// Set cache time
974    pub fn with_cache_time(self, cache_time: u32) -> Self {
975        Self {
976            cache_time: Some(cache_time),
977            ..self
978        }
979    }
980}
981
982impl TelegramMethod for AnswerCallbackQuery {
983    type Response = bool;
984
985    fn name() -> &'static str {
986        "answerCallbackQuery"
987    }
988}
989
990impl JsonMethod for AnswerCallbackQuery {}
991
992/// Use this method to send answers to an inline query. On success, True is returned.
993/// No more than 50 results per query are allowed.
994#[derive(Clone, Serialize)]
995pub struct AnswerInlineQuery {
996    /// Unique identifier for the answered query
997    pub inline_query_id: String,
998    /// A JSON-serialized array of results for the inline query
999    pub results: Vec<InlineQueryResult>,
1000    /// The maximum amount of time in seconds that the result of the inline query may be cached on the server.
1001    /// Defaults to 300.
1002    #[serde(skip_serializing_if = "Option::is_none")]
1003    pub cache_time: Option<u32>,
1004    /// Pass *True*, if results may be cached on the server side only for the user that sent the query.
1005    /// By default, results may be returned to any user who sends the same query
1006    #[serde(skip_serializing_if = "Option::is_none")]
1007    pub is_personal: Option<bool>,
1008    /// Pass the offset that a client should send in the next query with the same text to receive more results.
1009    /// Pass an empty string if there are no more results or if you don't support pagination.
1010    /// Offset length can't exceed 64 bytes.
1011    #[serde(skip_serializing_if = "Option::is_none")]
1012    pub next_offset: Option<String>,
1013    /// If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
1014    #[serde(skip_serializing_if = "Option::is_none")]
1015    pub switch_pm_text: Option<String>,
1016    /// [Deep-linking](https://core.telegram.org/bots#deep-linking) parameter for the /start message sent to the bot when user presses the switch button.
1017    /// 1-64 characters, only `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed.
1018    ///
1019    /// *Example:* An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly.
1020    /// To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any.
1021    /// The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link.
1022    /// Once done, the bot can offer a [*switch_inline*](https://core.telegram.org/bots/api#inlinekeyboardmarkup) button
1023    /// so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
1024    #[serde(skip_serializing_if = "Option::is_none")]
1025    pub switch_pm_parameter: Option<String>,
1026}
1027
1028impl AnswerInlineQuery {
1029    /// Create a new answerInlineQuery request
1030    pub fn new(query_id: impl Into<String>, results: Vec<InlineQueryResult>) -> Self {
1031        Self {
1032            inline_query_id: query_id.into(),
1033            results,
1034            cache_time: None,
1035            is_personal: None,
1036            next_offset: None,
1037            switch_pm_text: None,
1038            switch_pm_parameter: None,
1039        }
1040    }
1041    /// Set cache time
1042    pub fn with_cache_time(self, cache_time: u32) -> Self {
1043        Self {
1044            cache_time: Some(cache_time),
1045            ..self
1046        }
1047    }
1048    /// Set the results to be cached on the server side
1049    pub fn personal(self) -> Self {
1050        Self {
1051            is_personal: Some(true),
1052            ..self
1053        }
1054    }
1055    /// Set next offset string
1056    pub fn with_next_offset(self, offset: impl Into<String>) -> Self {
1057        Self {
1058            next_offset: Some(offset.into()),
1059            ..self
1060        }
1061    }
1062    /// Set switch pm text
1063    pub fn with_switch_pm_text(self, text: impl Into<String>) -> Self {
1064        Self {
1065            switch_pm_text: Some(text.into()),
1066            ..self
1067        }
1068    }
1069    // Set switch pm parameter
1070    pub fn with_switch_pm_parameter(self, param: impl Into<String>) -> Self {
1071        Self {
1072            switch_pm_parameter: Some(param.into()),
1073            ..self
1074        }
1075    }
1076}
1077
1078impl TelegramMethod for AnswerInlineQuery {
1079    type Response = bool;
1080
1081    fn name() -> &'static str {
1082        "answerInlineQuery"
1083    }
1084}
1085
1086impl JsonMethod for AnswerInlineQuery {}