1#![allow(clippy::wildcard_imports)]
3use crate::{
4 contexts::fields::Message,
5 methods::*,
6 types::{
7 chat,
8 input_file::{
9 Animation, Audio, ChatPhoto, Document, EditableMedia, GroupMedia,
10 Photo, Sticker, Video, VideoNote, Voice,
11 },
12 keyboard::inline,
13 message,
14 parameters::{Any, ImplicitChatId, Text},
15 user, LabeledPrice,
16 },
17};
18
19pub trait ChatMethods: Message {
21 fn delete_chat_photo(&self) -> DeleteChatPhoto<'_> {
23 self.bot().delete_chat_photo(self.chat().id)
24 }
25
26 fn delete_chat_sticker_set(&self) -> DeleteChatStickerSet<'_> {
28 self.bot().delete_chat_sticker_set(self.chat().id)
29 }
30
31 fn delete_message(&self, message_id: message::Id) -> DeleteMessage<'_> {
33 self.bot().delete_message(self.chat().id, message_id)
34 }
35
36 fn delete_this_message(&self) -> DeleteMessage<'_> {
38 self.delete_message(self.message_id())
39 }
40
41 fn edit_message_caption<'a>(
43 &'a self,
44 message_id: message::Id,
45 caption: impl Into<Text<'a>>,
46 ) -> EditMessageCaption<'a> {
47 self.bot()
48 .edit_message_caption(self.chat().id, message_id, caption)
49 }
50
51 fn edit_message_location(
53 &self,
54 message_id: message::Id,
55 location: (f64, f64),
56 ) -> EditMessageLocation<'_> {
57 self.bot()
58 .edit_message_location(self.chat().id, message_id, location)
59 }
60
61 fn edit_message_media<'a>(
63 &'a self,
64 message_id: message::Id,
65 media: impl Into<EditableMedia<'a>>,
66 ) -> EditMessageMedia<'a> {
67 self.bot()
68 .edit_message_media(self.chat().id, message_id, media)
69 }
70
71 fn edit_message_reply_markup<'a>(
73 &'a self,
74 message_id: message::Id,
75 reply_markup: inline::Keyboard<'a>,
76 ) -> EditMessageReplyMarkup<'a> {
77 self.bot().edit_message_reply_markup(
78 self.chat().id,
79 message_id,
80 reply_markup,
81 )
82 }
83
84 fn edit_message_text<'a>(
86 &'a self,
87 message_id: message::Id,
88 text: impl Into<Text<'a>>,
89 ) -> EditMessageText<'a> {
90 self.bot()
91 .edit_message_text(self.chat().id, message_id, text)
92 }
93
94 fn export_chat_invite_link(&self) -> ExportChatInviteLink<'_> {
96 self.bot().export_chat_invite_link(self.chat().id)
97 }
98
99 fn forward_here<'a>(
101 &'a self,
102 from_chat_id: impl ImplicitChatId<'a>,
103 message_id: message::Id,
104 ) -> ForwardMessage<'a> {
105 self.bot()
106 .forward_message(self.chat().id, from_chat_id, message_id)
107 }
108
109 fn get_chat(&self) -> GetChat<'_> {
111 self.bot().get_chat(self.chat().id)
112 }
113
114 fn get_chat_administrators(&self) -> GetChatAdministrators<'_> {
116 self.bot().get_chat_administrators(self.chat().id)
117 }
118
119 fn get_chat_member(&self, user_id: user::Id) -> GetChatMember<'_> {
121 self.bot().get_chat_member(self.chat().id, user_id)
122 }
123
124 fn get_chat_members_count(&self) -> GetChatMembersCount<'_> {
126 self.bot().get_chat_members_count(self.chat().id)
127 }
128
129 fn get_message_game_high_scores(
131 &self,
132 message_id: message::Id,
133 user_id: user::Id,
134 ) -> GetMessageGameHighScores<'_> {
135 self.bot().get_message_game_high_scores(
136 self.chat().id,
137 message_id,
138 user_id,
139 )
140 }
141
142 fn kick_chat_member(&self, user_id: user::Id) -> KickChatMember<'_> {
144 self.bot().kick_chat_member(self.chat().id, user_id)
145 }
146
147 fn leave_chat(&self) -> LeaveChat<'_> {
149 self.bot().leave_chat(self.chat().id)
150 }
151
152 fn pin_chat_message(&self, message_id: message::Id) -> PinChatMessage<'_> {
154 self.bot().pin_chat_message(self.chat().id, message_id)
155 }
156
157 fn promote_chat_member(&self, user_id: user::Id) -> PromoteChatMember<'_> {
159 self.bot().promote_chat_member(self.chat().id, user_id)
160 }
161
162 fn restrict_chat_member(
164 &self,
165 user_id: user::Id,
166 permissions: chat::Permissions,
167 ) -> RestrictChatMember<'_> {
168 self.bot()
169 .restrict_chat_member(self.chat().id, user_id, permissions)
170 }
171
172 fn send_animation<'a>(
174 &'a self,
175 animation: Animation<'a>,
176 ) -> SendAnimation<'a> {
177 self.bot().send_animation(self.chat().id, animation)
178 }
179
180 fn send_animation_in_reply<'a>(
182 &'a self,
183 animation: Animation<'a>,
184 ) -> SendAnimation<'a> {
185 self.send_animation(animation)
186 .in_reply_to(self.message_id())
187 }
188
189 fn send_audio<'a>(&'a self, audio: Audio<'a>) -> SendAudio<'a> {
191 self.bot().send_audio(self.chat().id, audio)
192 }
193
194 fn send_audio_in_reply<'a>(&'a self, audio: Audio<'a>) -> SendAudio<'a> {
196 self.send_audio(audio).in_reply_to(self.message_id())
197 }
198
199 fn send_chat_action(&self, action: chat::Action) -> SendChatAction {
201 self.bot().send_chat_action(self.chat().id, action)
202 }
203
204 fn send_contact<'a>(
206 &'a self,
207 phone_number: &'a str,
208 first_name: &'a str,
209 ) -> SendContact<'a> {
210 self.bot()
211 .send_contact(self.chat().id, phone_number, first_name)
212 }
213
214 fn send_contact_in_reply<'a>(
216 &'a self,
217 phone_number: &'a str,
218 first_name: &'a str,
219 ) -> SendContact<'a> {
220 self.send_contact(phone_number, first_name)
221 .in_reply_to(self.message_id())
222 }
223
224 fn send_game<'a>(&'a self, game_short_name: &'a str) -> SendGame<'a> {
226 self.bot().send_game(self.chat().id, game_short_name)
227 }
228
229 fn send_game_in_reply<'a>(
231 &'a self,
232 game_short_name: &'a str,
233 ) -> SendGame<'a> {
234 self.send_game(game_short_name)
235 .in_reply_to(self.message_id())
236 }
237
238 fn send_dice(&self) -> SendDice<'_> {
240 self.bot().send_dice(self.chat().id)
241 }
242
243 fn send_dice_in_reply(&self) -> SendDice<'_> {
245 self.send_dice().in_reply_to(self.message_id())
246 }
247
248 fn send_document<'a>(&'a self, document: Document<'a>) -> SendDocument<'a> {
250 self.bot().send_document(self.chat().id, document)
251 }
252
253 fn send_document_in_reply<'a>(
255 &'a self,
256 document: Document<'a>,
257 ) -> SendDocument<'a> {
258 self.send_document(document).in_reply_to(self.message_id())
259 }
260
261 #[allow(clippy::too_many_arguments)]
263 fn send_invoice<'a>(
264 &'a self,
265 title: &'a str,
266 description: &'a str,
267 payload: &'a str,
268 provider_token: &'a str,
269 start_parameter: &'a str,
270 currency: &'a str,
271 prices: &'a [LabeledPrice<'a>],
272 ) -> SendInvoice<'a> {
273 self.bot().send_invoice(
274 self.chat().id,
275 title,
276 description,
277 payload,
278 provider_token,
279 start_parameter,
280 currency,
281 prices,
282 )
283 }
284
285 #[allow(clippy::too_many_arguments)]
287 fn send_invoice_in_reply<'a>(
288 &'a self,
289 title: &'a str,
290 description: &'a str,
291 payload: &'a str,
292 provider_token: &'a str,
293 start_parameter: &'a str,
294 currency: &'a str,
295 prices: &'a [LabeledPrice<'a>],
296 ) -> SendInvoice<'a> {
297 self.send_invoice(
298 title,
299 description,
300 payload,
301 provider_token,
302 start_parameter,
303 currency,
304 prices,
305 )
306 .in_reply_to(self.message_id())
307 }
308
309 fn send_location(&self, location: (f64, f64)) -> SendLocation {
311 self.bot().send_location(self.chat().id, location)
312 }
313
314 fn send_location_in_reply(&self, location: (f64, f64)) -> SendLocation {
316 self.send_location(location).in_reply_to(self.message_id())
317 }
318
319 fn send_media_group<'a>(
321 &'a self,
322 media: &'a [GroupMedia<'a>],
323 ) -> SendMediaGroup<'a> {
324 self.bot().send_media_group(self.chat().id, media)
325 }
326
327 fn send_media_group_in_reply<'a>(
329 &'a self,
330 media: &'a [GroupMedia<'a>],
331 ) -> SendMediaGroup<'a> {
332 self.send_media_group(media).in_reply_to(self.message_id())
333 }
334
335 fn send_message<'a>(
337 &'a self,
338 text: impl Into<Text<'a>>,
339 ) -> SendMessage<'a> {
340 self.bot().send_message(self.chat().id, text)
341 }
342
343 fn send_message_in_reply<'a>(
345 &'a self,
346 text: impl Into<Text<'a>>,
347 ) -> SendMessage<'a> {
348 self.send_message(text).in_reply_to(self.message_id())
349 }
350
351 fn send_photo<'a>(&'a self, photo: Photo<'a>) -> SendPhoto<'a> {
353 self.bot().send_photo(self.chat().id, photo)
354 }
355
356 fn send_photo_in_reply<'a>(&'a self, photo: Photo<'a>) -> SendPhoto<'a> {
358 self.send_photo(photo).in_reply_to(self.message_id())
359 }
360
361 fn send_poll<'a>(&'a self, poll: &'a Any<'a>) -> SendPoll<'a> {
363 self.bot().send_poll(self.chat().id, poll)
364 }
365
366 fn send_poll_in_reply<'a>(&'a self, poll: &'a Any<'a>) -> SendPoll<'a> {
368 self.send_poll(poll).in_reply_to(self.message_id())
369 }
370
371 fn send_sticker<'a>(&'a self, sticker: Sticker<'a>) -> SendSticker<'a> {
373 self.bot().send_sticker(self.chat().id, sticker)
374 }
375
376 fn send_sticker_in_reply<'a>(
378 &'a self,
379 sticker: Sticker<'a>,
380 ) -> SendSticker<'a> {
381 self.send_sticker(sticker).in_reply_to(self.message_id())
382 }
383
384 fn send_venue<'a>(
386 &'a self,
387 location: (f64, f64),
388 title: &'a str,
389 address: &'a str,
390 ) -> SendVenue<'a> {
391 self.bot()
392 .send_venue(self.chat().id, location, title, address)
393 }
394
395 fn send_venue_in_reply<'a>(
397 &'a self,
398 location: (f64, f64),
399 title: &'a str,
400 address: &'a str,
401 ) -> SendVenue<'a> {
402 self.send_venue(location, title, address)
403 .in_reply_to(self.message_id())
404 }
405
406 fn send_video<'a>(&'a self, video: Video<'a>) -> SendVideo<'a> {
408 self.bot().send_video(self.chat().id, video)
409 }
410
411 fn send_video_in_reply<'a>(&'a self, video: Video<'a>) -> SendVideo<'a> {
413 self.send_video(video).in_reply_to(self.message_id())
414 }
415
416 fn send_video_note<'a>(
418 &'a self,
419 video_note: VideoNote<'a>,
420 ) -> SendVideoNote<'a> {
421 self.bot().send_video_note(self.chat().id, video_note)
422 }
423
424 fn send_video_note_in_reply<'a>(
426 &'a self,
427 video_note: VideoNote<'a>,
428 ) -> SendVideoNote<'a> {
429 self.send_video_note(video_note)
430 .in_reply_to(self.message_id())
431 }
432
433 fn send_voice<'a>(&'a self, voice: Voice<'a>) -> SendVoice<'a> {
435 self.bot().send_voice(self.chat().id, voice)
436 }
437
438 fn send_voice_in_reply<'a>(&'a self, voice: Voice<'a>) -> SendVoice<'a> {
440 self.send_voice(voice).in_reply_to(self.message_id())
441 }
442
443 fn set_chat_administrator_custom_title<'a>(
445 &'a self,
446 user_id: user::Id,
447 custom_title: &'a str,
448 ) -> SetChatAdministratorCustomTitle<'a> {
449 self.bot().set_chat_administrator_custom_title(
450 self.chat().id,
451 user_id,
452 custom_title,
453 )
454 }
455
456 fn set_chat_description<'a>(
458 &'a self,
459 description: &'a str,
460 ) -> SetChatDescription<'a> {
461 self.bot().set_chat_description(self.chat().id, description)
462 }
463
464 fn set_chat_permissions(
466 &self,
467 permissions: chat::Permissions,
468 ) -> SetChatPermissions<'_> {
469 self.bot().set_chat_permissions(self.chat().id, permissions)
470 }
471
472 fn set_chat_photo<'a>(&'a self, photo: ChatPhoto<'a>) -> SetChatPhoto<'a> {
474 self.bot().set_chat_photo(self.chat().id, photo)
475 }
476
477 fn set_chat_sticker_set<'a>(
479 &'a self,
480 sticker_set_name: &'a str,
481 ) -> SetChatStickerSet<'a> {
482 self.bot()
483 .set_chat_sticker_set(self.chat().id, sticker_set_name)
484 }
485
486 fn set_chat_title<'a>(&'a self, title: &'a str) -> SetChatTitle<'a> {
488 self.bot().set_chat_title(self.chat().id, title)
489 }
490
491 fn set_message_game_score(
493 &self,
494 message_id: message::Id,
495 user_id: user::Id,
496 score: u32,
497 ) -> SetMessageGameScore<'_> {
498 self.bot().set_message_game_score(
499 self.chat().id,
500 message_id,
501 user_id,
502 score,
503 )
504 }
505
506 fn unban_chat_member(&self, user_id: user::Id) -> UnbanChatMember<'_> {
508 self.bot().unban_chat_member(self.chat().id, user_id)
509 }
510
511 fn unpin_chat_message(&self) -> UnpinChatMessage<'_> {
513 self.bot().unpin_chat_message(self.chat().id)
514 }
515}
516
517impl<T: Message> ChatMethods for T {}