1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use serde::{Deserialize, Serialize};
/// This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
/// # Documentation
/// <https://core.telegram.org/bots/api#inlinequery>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct InlineQuery {
/// Unique identifier for this query
pub id: Box<str>,
/// Sender
pub from: Box<crate::types::User>,
/// Text of the query (up to 256 characters)
pub query: Box<str>,
/// Offset of the results to be returned, can be controlled by the bot
pub offset: Box<str>,
/// Type of the chat from which the inline query was sent. Can be either `sender` for a private chat with the inline query sender, `private`, `group`, `supergroup`, or `channel`. 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
#[serde(skip_serializing_if = "Option::is_none")]
pub chat_type: Option<Box<str>>,
/// Sender location, only for bots that request user location
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<crate::types::Location>,
}
impl InlineQuery {
/// Creates a new `InlineQuery`.
///
/// # Arguments
/// * `id` - Unique identifier for this query
/// * `from` - Sender
/// * `query` - Text of the query (up to 256 characters)
/// * `offset` - Offset of the results to be returned, can be controlled by the bot
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<
T0: Into<Box<str>>,
T1: Into<crate::types::User>,
T2: Into<Box<str>>,
T3: Into<Box<str>>,
>(
id: T0,
from: T1,
query: T2,
offset: T3,
) -> Self {
Self {
id: id.into(),
from: Box::new(from.into()),
query: query.into(),
offset: offset.into(),
chat_type: None,
location: None,
}
}
/// Unique identifier for this query
#[must_use]
pub fn id<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.id = val.into();
this
}
/// Sender
#[must_use]
pub fn from<T: Into<crate::types::User>>(self, val: T) -> Self {
let mut this = self;
this.from = Box::new(val.into());
this
}
/// Text of the query (up to 256 characters)
#[must_use]
pub fn query<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.query = val.into();
this
}
/// Offset of the results to be returned, can be controlled by the bot
#[must_use]
pub fn offset<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.offset = val.into();
this
}
/// Type of the chat from which the inline query was sent. Can be either `sender` for a private chat with the inline query sender, `private`, `group`, `supergroup`, or `channel`. 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
#[must_use]
pub fn chat_type<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.chat_type = Some(val.into());
this
}
/// Type of the chat from which the inline query was sent. Can be either `sender` for a private chat with the inline query sender, `private`, `group`, `supergroup`, or `channel`. 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
#[must_use]
pub fn chat_type_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.chat_type = val.map(Into::into);
this
}
/// Sender location, only for bots that request user location
#[must_use]
pub fn location<T: Into<crate::types::Location>>(self, val: T) -> Self {
let mut this = self;
this.location = Some(val.into());
this
}
/// Sender location, only for bots that request user location
#[must_use]
pub fn location_option<T: Into<crate::types::Location>>(self, val: Option<T>) -> Self {
let mut this = self;
this.location = val.map(Into::into);
this
}
}