1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use crate::client::Bot;
use serde::Serialize;
/// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, `true` is returned.
/// # Documentation
/// <https://core.telegram.org/bots/api#answercallbackquery>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct AnswerCallbackQuery {
/// Unique identifier for the query to be answered
pub callback_query_id: Box<str>,
/// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<Box<str>>,
/// If `true`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
#[serde(skip_serializing_if = "Option::is_none")]
pub show_alert: Option<bool>,
/// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @`BotFather`, specify the URL that opens your game - note that this will only work if the query comes from a `callback_game` button. Otherwise, you may use links like <https://t.me/your_bot?start=XXXX> that open your bot with a parameter.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<Box<str>>,
/// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_time: Option<i64>,
}
impl AnswerCallbackQuery {
/// Creates a new `AnswerCallbackQuery`.
///
/// # Arguments
/// * `callback_query_id` - Unique identifier for the query to be answered
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<Box<str>>>(callback_query_id: T0) -> Self {
Self {
callback_query_id: callback_query_id.into(),
text: None,
show_alert: None,
url: None,
cache_time: None,
}
}
/// Unique identifier for the query to be answered
#[must_use]
pub fn callback_query_id<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.callback_query_id = val.into();
this
}
/// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
#[must_use]
pub fn text<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.text = Some(val.into());
this
}
/// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
#[must_use]
pub fn text_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.text = val.map(Into::into);
this
}
/// If `true`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
#[must_use]
pub fn show_alert<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.show_alert = Some(val.into());
this
}
/// If `true`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
#[must_use]
pub fn show_alert_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.show_alert = val.map(Into::into);
this
}
/// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @`BotFather`, specify the URL that opens your game - note that this will only work if the query comes from a `callback_game` button. Otherwise, you may use links like <https://t.me/your_bot?start=XXXX> that open your bot with a parameter.
#[must_use]
pub fn url<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.url = Some(val.into());
this
}
/// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @`BotFather`, specify the URL that opens your game - note that this will only work if the query comes from a `callback_game` button. Otherwise, you may use links like <https://t.me/your_bot?start=XXXX> that open your bot with a parameter.
#[must_use]
pub fn url_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.url = val.map(Into::into);
this
}
/// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
#[must_use]
pub fn cache_time<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.cache_time = Some(val.into());
this
}
/// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
#[must_use]
pub fn cache_time_option<T: Into<i64>>(self, val: Option<T>) -> Self {
let mut this = self;
this.cache_time = val.map(Into::into);
this
}
}
impl super::TelegramMethod for AnswerCallbackQuery {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("answerCallbackQuery", self, None)
}
}