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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
use super::*;
use crate::types::InputMedia;
/// Request-scoped runtime facade for handler code.
///
/// This is the preferred entry point inside handlers. It mirrors the stable runtime surface of
/// [`crate::client::AppApi`], but keeps the call path centered on `context.app()` so handler code
/// reads naturally and stays on the business/runtime plane.
#[derive(Clone)]
pub struct ContextAppApi {
client: Client,
}
impl ContextAppApi {
pub(crate) fn new(client: Client) -> Self {
Self { client }
}
/// Returns the governance-oriented moderation facade for handler-side actions.
pub fn moderation(&self) -> crate::client::ModerationApi {
self.client.app().moderation()
}
/// Returns the membership/capability facade used by install and bind pre-check flows.
pub fn membership(&self) -> crate::client::MembershipApi {
self.client.app().membership()
}
/// Returns the dedicated Web App facade for runtime query handling.
pub fn web_app(&self) -> crate::client::WebAppApi {
self.client.app().web_app()
}
/// Starts a callback-answer builder.
///
/// Prefer this when callback replies need options such as `show_alert`, `url`, or
/// `cache_time`.
pub fn callback_answer(
&self,
callback_query_id: impl Into<String>,
) -> crate::client::CallbackAnswerBuilder {
self.client.app().callback_answer(callback_query_id)
}
/// Starts a callback-answer builder using the callback id extracted from an update.
pub fn callback_answer_from_update(
&self,
update: &Update,
) -> Result<crate::client::CallbackAnswerBuilder> {
self.client.app().callback_answer_from_update(update)
}
/// Starts a text-send builder for a target chat.
pub fn text(
&self,
chat_id: impl Into<ChatId>,
text: impl Into<String>,
) -> Result<crate::client::TextSendBuilder> {
self.client.app().text(chat_id, text)
}
/// Starts a text-send builder using the canonical reply chat derived from an update.
pub fn reply(
&self,
update: &Update,
text: impl Into<String>,
) -> Result<crate::client::TextSendBuilder> {
self.client.app().reply(update, text)
}
/// Starts a photo-send builder for a target chat.
pub fn photo(
&self,
chat_id: impl Into<ChatId>,
photo: impl Into<String>,
) -> crate::client::PhotoSendBuilder {
self.client.app().photo(chat_id, photo)
}
/// Starts a photo-send builder using the canonical reply chat derived from an update.
pub fn reply_photo(
&self,
update: &Update,
photo: impl Into<String>,
) -> Result<crate::client::PhotoSendBuilder> {
self.client.app().reply_photo(update, photo)
}
/// Starts a document-send builder for a target chat.
pub fn document(
&self,
chat_id: impl Into<ChatId>,
document: impl Into<String>,
) -> crate::client::DocumentSendBuilder {
self.client.app().document(chat_id, document)
}
/// Starts a document-send builder using the canonical reply chat derived from an update.
pub fn reply_document(
&self,
update: &Update,
document: impl Into<String>,
) -> Result<crate::client::DocumentSendBuilder> {
self.client.app().reply_document(update, document)
}
/// Starts a video-send builder for a target chat.
pub fn video(
&self,
chat_id: impl Into<ChatId>,
video: impl Into<String>,
) -> crate::client::VideoSendBuilder {
self.client.app().video(chat_id, video)
}
/// Starts a video-send builder using the canonical reply chat derived from an update.
pub fn reply_video(
&self,
update: &Update,
video: impl Into<String>,
) -> Result<crate::client::VideoSendBuilder> {
self.client.app().reply_video(update, video)
}
/// Starts an audio-send builder for a target chat.
pub fn audio(
&self,
chat_id: impl Into<ChatId>,
audio: impl Into<String>,
) -> crate::client::AudioSendBuilder {
self.client.app().audio(chat_id, audio)
}
/// Starts an audio-send builder using the canonical reply chat derived from an update.
pub fn reply_audio(
&self,
update: &Update,
audio: impl Into<String>,
) -> Result<crate::client::AudioSendBuilder> {
self.client.app().reply_audio(update, audio)
}
/// Starts an animation-send builder for a target chat.
pub fn animation(
&self,
chat_id: impl Into<ChatId>,
animation: impl Into<String>,
) -> crate::client::AnimationSendBuilder {
self.client.app().animation(chat_id, animation)
}
/// Starts an animation-send builder using the canonical reply chat derived from an update.
pub fn reply_animation(
&self,
update: &Update,
animation: impl Into<String>,
) -> Result<crate::client::AnimationSendBuilder> {
self.client.app().reply_animation(update, animation)
}
/// Starts a voice-send builder for a target chat.
pub fn voice(
&self,
chat_id: impl Into<ChatId>,
voice: impl Into<String>,
) -> crate::client::VoiceSendBuilder {
self.client.app().voice(chat_id, voice)
}
/// Starts a voice-send builder using the canonical reply chat derived from an update.
pub fn reply_voice(
&self,
update: &Update,
voice: impl Into<String>,
) -> Result<crate::client::VoiceSendBuilder> {
self.client.app().reply_voice(update, voice)
}
/// Starts a sticker-send builder for a target chat.
pub fn sticker(
&self,
chat_id: impl Into<ChatId>,
sticker: impl Into<String>,
) -> crate::client::StickerSendBuilder {
self.client.app().sticker(chat_id, sticker)
}
/// Starts a sticker-send builder using the canonical reply chat derived from an update.
pub fn reply_sticker(
&self,
update: &Update,
sticker: impl Into<String>,
) -> Result<crate::client::StickerSendBuilder> {
self.client.app().reply_sticker(update, sticker)
}
/// Starts a media-group builder for a target chat.
pub fn media_group<I, M>(
&self,
chat_id: impl Into<ChatId>,
media: I,
) -> Result<crate::client::MediaGroupSendBuilder>
where
I: IntoIterator<Item = M>,
M: Into<InputMedia>,
{
self.client.app().media_group(chat_id, media)
}
/// Starts a media-group builder using the canonical reply chat derived from an update.
pub fn reply_media_group<I, M>(
&self,
update: &Update,
media: I,
) -> Result<crate::client::MediaGroupSendBuilder>
where
I: IntoIterator<Item = M>,
M: Into<InputMedia>,
{
self.client.app().reply_media_group(update, media)
}
/// Shortcut for `text(...).send().await`.
pub async fn send_text(
&self,
chat_id: impl Into<ChatId>,
text: impl Into<String>,
) -> Result<Message> {
self.client.app().send_text(chat_id, text).await
}
/// Shortcut for `reply(...).send().await`.
pub async fn reply_text(&self, update: &Update, text: impl Into<String>) -> Result<Message> {
self.client.app().reply_text(update, text).await
}
/// Shortcut for `callback_answer(...).text_optional(...).send().await`.
pub async fn answer_callback(
&self,
callback_query_id: impl Into<String>,
text: Option<String>,
) -> Result<bool> {
self.client
.app()
.answer_callback(callback_query_id, text)
.await
}
/// Shortcut for `callback_answer_from_update(...).text_optional(...).send().await`.
pub async fn answer_callback_from_update(
&self,
update: &Update,
text: Option<String>,
) -> Result<bool> {
self.client
.app()
.answer_callback_from_update(update, text)
.await
}
}