Skip to main content

ronami_core/requests/
requester.rs

1// We can't change Telegram API
2#![allow(clippy::too_many_arguments)]
3
4use url::Url;
5
6use crate::{errors::AsResponseParameters, payloads::*, requests::Request, types::*};
7
8/// Telegram Bot API client.
9///
10/// This trait is implemented by all bots & bot adaptors.
11///
12/// ## Calling Telegram Bot API methods
13///
14/// To call Telegram's methods you first need to get a [`Bot`] instance or any
15/// other type which implement this trait.
16///
17/// Then you can simply call the method you want and pass required parameters to
18/// it. Optional parameters can be supplied by calling setters (like
19/// `parse_mode` in the example below). Lastly, you need to `.await` the request
20/// created in previous steps, to actually send it to telegram and wait for the
21/// response.
22///
23/// ```
24/// # async {
25/// # let chat_id = ChatId(-1);
26/// use ronami_core::{
27///     prelude::*,
28///     types::{ChatId, ParseMode},
29/// };
30///
31/// // Bot implements `Requester`
32/// let bot = Bot::new("TOKEN");
33///
34/// // Required parameters are supplied to the `Requester` methods:
35/// bot.send_message(chat_id, "<b>Text</b>")
36///     // Optional parameters can be supplied by calling setters
37///     .parse_mode(ParseMode::Html)
38///     // To send request to telegram you need to `.await` the request
39///     .await?;
40/// # Ok::<_, ronami_core::RequestError>(())
41/// # };
42/// ```
43///
44/// ## Adaptors
45///
46/// Similarly to how [`Iterator`] has iterator adaptors ([`FlatMap`],
47/// [`Filter`], etc) that wrap an [`Iterator`] and alter its behaviour, Ronami
48/// has a similar story with `Requester`.
49///
50/// [`adaptors`] module provides a handful of `Requester` adaptors that can be
51/// created via [`RequesterExt`] methods. For example using [`.parse_mode(...)`]
52/// on a bot will wrap it in [`DefaultParseMode`] adaptor which sets the parse
53/// mode to a default value:
54///
55/// ```rust
56/// # async {
57/// # let chat_id = ChatId(-1);
58/// use ronami_core::{
59///     prelude::*,
60///     types::{ChatId, ParseMode},
61/// };
62///
63/// let bot = Bot::new("TOKEN")
64///     // Wrap the bot in an adaptor
65///     .parse_mode(ParseMode::Html);
66///
67/// // This will use `ParseMode::Html`
68/// bot.send_message(chat_id, "<b>Text</b>").await?;
69///
70/// // This will use `ParseMode::MarkdownV2`
71/// bot.send_message(chat_id, "**Text**").parse_mode(ParseMode::MarkdownV2).await?;
72/// # Ok::<_, ronami_core::RequestError>(())
73/// # };
74/// ```
75///
76/// Note that just as with iterators, adaptors change type:
77///
78/// ```compile_fail
79/// # use ronami_core::{prelude::*, types::{ChatId, ParseMode}};
80/// let bot: Bot = Bot::new("TOKEN").parse_mode(ParseMode::Html);
81/// ```
82/// ```rust
83/// # use ronami_core::{prelude::*, types::{ChatId, ParseMode}, adaptors::DefaultParseMode};
84/// let bot: DefaultParseMode<Bot> = Bot::new("TOKEN").parse_mode(ParseMode::Html);
85/// ```
86///
87/// Because of this it's oftentimes more convinient to have a type alias:
88///
89/// ```rust,no_run
90/// # #[cfg(feature = "throttle")] {
91/// # use ronami_core::{adaptors::{DefaultParseMode, Throttle}, requests::RequesterExt, types::ParseMode};
92/// type Bot = DefaultParseMode<Throttle<ronami_core::Bot>>;
93///
94/// let bot: Bot = ronami_core::Bot::new("TOKEN")
95///     .throttle(<_>::default())
96///     .parse_mode(ParseMode::Html);
97/// # let _ = bot;
98/// # };
99/// ```
100///
101/// Also note that most adaptors require specific cargo features to be enabled.
102/// For example, to use [`Throttle`] you need to enable `throttle` feature in
103/// your `Cargo.toml`:
104///
105/// ```toml
106/// ronami_core = { version = "...", features = ["throttle"] }
107/// ```
108///
109/// Refer to adaptor's documentation for information about what features it
110/// requires.
111///
112/// ## Using `Requester` in a generic context
113///
114/// When writing helper function you may be indifferent to which exact type is
115/// being used as a bot and instead only care that it implements `Requester`
116/// trait. In this case you can use generic bounds to express this exact thing:
117///
118/// ```
119/// use ronami_core::{
120///     prelude::*,
121///     types::{ChatId, Message},
122/// };
123///
124/// async fn send_hi<R>(bot: R, chat: ChatId) -> Message
125/// where
126///     R: Requester,
127/// {
128///     bot.send_message(chat, "hi").await.expect("error")
129/// }
130///
131/// // `send_hi` can be called with `Bot`, `DefaultParseMode<Bot>` and so on, and so forth
132/// ```
133///
134/// [`Bot`]: crate::Bot
135/// [`FlatMap`]: std::iter::FlatMap
136/// [`Filter`]: std::iter::Filter
137/// [`adaptors`]: crate::adaptors
138/// [`DefaultParseMode`]: crate::adaptors::DefaultParseMode
139/// [`Throttle`]: crate::adaptors::Throttle
140/// [`RequesterExt`]: crate::requests::RequesterExt
141/// [`.parse_mode(...)`]: crate::requests::RequesterExt::parse_mode
142#[cfg_attr(all(any(docsrs, dep_docsrs), feature = "nightly"), doc(notable_trait))]
143pub trait Requester {
144    /// Error type returned by all requests.
145    type Err: std::error::Error + Send + AsResponseParameters;
146
147    // START BLOCK requester_methods
148    // Generated by `codegen_requester_methods`, do not edit by hand.
149
150    type GetUpdates: Request<Payload = GetUpdates, Err = Self::Err>;
151
152    /// For Telegram documentation see [`GetUpdates`].
153    fn get_updates(&self) -> Self::GetUpdates;
154
155    type SetWebhook: Request<Payload = SetWebhook, Err = Self::Err>;
156
157    /// For Telegram documentation see [`SetWebhook`].
158    fn set_webhook(&self, url: Url) -> Self::SetWebhook;
159
160    type DeleteWebhook: Request<Payload = DeleteWebhook, Err = Self::Err>;
161
162    /// For Telegram documentation see [`DeleteWebhook`].
163    fn delete_webhook(&self) -> Self::DeleteWebhook;
164
165    type GetWebhookInfo: Request<Payload = GetWebhookInfo, Err = Self::Err>;
166
167    /// For Telegram documentation see [`GetWebhookInfo`].
168    fn get_webhook_info(&self) -> Self::GetWebhookInfo;
169
170    type GetMe: Request<Payload = GetMe, Err = Self::Err>;
171
172    /// For Telegram documentation see [`GetMe`].
173    fn get_me(&self) -> Self::GetMe;
174
175    type LogOut: Request<Payload = LogOut, Err = Self::Err>;
176
177    /// For Telegram documentation see [`LogOut`].
178    fn log_out(&self) -> Self::LogOut;
179
180    type Close: Request<Payload = Close, Err = Self::Err>;
181
182    /// For Telegram documentation see [`Close`].
183    fn close(&self) -> Self::Close;
184
185    type SendMessage: Request<Payload = SendMessage, Err = Self::Err>;
186
187    /// For Telegram documentation see [`SendMessage`].
188    fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage
189    where
190        C: Into<Recipient>,
191        T: Into<String>;
192
193    type SendMessageDraft: Request<Payload = SendMessageDraft, Err = Self::Err>;
194
195    /// For Telegram documentation see [`SendMessageDraft`].
196    fn send_message_draft<C, T>(
197        &self,
198        chat_id: C,
199        draft_id: DraftId,
200        text: T,
201    ) -> Self::SendMessageDraft
202    where
203        C: Into<Recipient>,
204        T: Into<String>;
205
206    type ForwardMessage: Request<Payload = ForwardMessage, Err = Self::Err>;
207
208    /// For Telegram documentation see [`ForwardMessage`].
209    fn forward_message<C, F>(
210        &self,
211        chat_id: C,
212        from_chat_id: F,
213        message_id: MessageId,
214    ) -> Self::ForwardMessage
215    where
216        C: Into<Recipient>,
217        F: Into<Recipient>;
218
219    type ForwardMessages: Request<Payload = ForwardMessages, Err = Self::Err>;
220
221    /// For Telegram documentation see [`ForwardMessages`].
222    fn forward_messages<C, F, M>(
223        &self,
224        chat_id: C,
225        from_chat_id: F,
226        message_ids: M,
227    ) -> Self::ForwardMessages
228    where
229        C: Into<Recipient>,
230        F: Into<Recipient>,
231        M: IntoIterator<Item = MessageId>;
232
233    type CopyMessage: Request<Payload = CopyMessage, Err = Self::Err>;
234
235    /// For Telegram documentation see [`CopyMessage`].
236    fn copy_message<C, F>(
237        &self,
238        chat_id: C,
239        from_chat_id: F,
240        message_id: MessageId,
241    ) -> Self::CopyMessage
242    where
243        C: Into<Recipient>,
244        F: Into<Recipient>;
245
246    type CopyMessages: Request<Payload = CopyMessages, Err = Self::Err>;
247
248    /// For Telegram documentation see [`CopyMessages`].
249    fn copy_messages<C, F, M>(
250        &self,
251        chat_id: C,
252        from_chat_id: F,
253        message_ids: M,
254    ) -> Self::CopyMessages
255    where
256        C: Into<Recipient>,
257        F: Into<Recipient>,
258        M: IntoIterator<Item = MessageId>;
259
260    type SendPhoto: Request<Payload = SendPhoto, Err = Self::Err>;
261
262    /// For Telegram documentation see [`SendPhoto`].
263    fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto
264    where
265        C: Into<Recipient>;
266
267    type SendAudio: Request<Payload = SendAudio, Err = Self::Err>;
268
269    /// For Telegram documentation see [`SendAudio`].
270    fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio
271    where
272        C: Into<Recipient>;
273
274    type SendDocument: Request<Payload = SendDocument, Err = Self::Err>;
275
276    /// For Telegram documentation see [`SendDocument`].
277    fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument
278    where
279        C: Into<Recipient>;
280
281    type SendVideo: Request<Payload = SendVideo, Err = Self::Err>;
282
283    /// For Telegram documentation see [`SendVideo`].
284    fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo
285    where
286        C: Into<Recipient>;
287
288    type SendLivePhoto: Request<Payload = SendLivePhoto, Err = Self::Err>;
289
290    /// For Telegram documentation see [`SendLivePhoto`].
291    fn send_live_photo<C>(
292        &self,
293        chat_id: C,
294        live_photo: InputFile,
295        photo: InputFile,
296    ) -> Self::SendLivePhoto
297    where
298        C: Into<Recipient>;
299
300    type SendAnimation: Request<Payload = SendAnimation, Err = Self::Err>;
301
302    /// For Telegram documentation see [`SendAnimation`].
303    fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation
304    where
305        C: Into<Recipient>;
306
307    type SendVoice: Request<Payload = SendVoice, Err = Self::Err>;
308
309    /// For Telegram documentation see [`SendVoice`].
310    fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice
311    where
312        C: Into<Recipient>;
313
314    type SendVideoNote: Request<Payload = SendVideoNote, Err = Self::Err>;
315
316    /// For Telegram documentation see [`SendVideoNote`].
317    fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote
318    where
319        C: Into<Recipient>;
320
321    type SendPaidMedia: Request<Payload = SendPaidMedia, Err = Self::Err>;
322
323    /// For Telegram documentation see [`SendPaidMedia`].
324    fn send_paid_media<C, M>(&self, chat_id: C, star_count: u32, media: M) -> Self::SendPaidMedia
325    where
326        C: Into<Recipient>,
327        M: IntoIterator<Item = InputPaidMedia>;
328
329    type SendMediaGroup: Request<Payload = SendMediaGroup, Err = Self::Err>;
330
331    /// For Telegram documentation see [`SendMediaGroup`].
332    fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
333    where
334        C: Into<Recipient>,
335        M: IntoIterator<Item = InputMedia>;
336
337    type SendLocation: Request<Payload = SendLocation, Err = Self::Err>;
338
339    /// For Telegram documentation see [`SendLocation`].
340    fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation
341    where
342        C: Into<Recipient>;
343
344    type EditMessageLiveLocation: Request<Payload = EditMessageLiveLocation, Err = Self::Err>;
345
346    /// For Telegram documentation see [`EditMessageLiveLocation`].
347    fn edit_message_live_location<C>(
348        &self,
349        chat_id: C,
350        message_id: MessageId,
351        latitude: f64,
352        longitude: f64,
353    ) -> Self::EditMessageLiveLocation
354    where
355        C: Into<Recipient>;
356
357    type EditMessageLiveLocationInline: Request<
358        Payload = EditMessageLiveLocationInline,
359        Err = Self::Err,
360    >;
361
362    /// For Telegram documentation see [`EditMessageLiveLocationInline`].
363    fn edit_message_live_location_inline<I>(
364        &self,
365        inline_message_id: I,
366        latitude: f64,
367        longitude: f64,
368    ) -> Self::EditMessageLiveLocationInline
369    where
370        I: Into<String>;
371
372    type StopMessageLiveLocation: Request<Payload = StopMessageLiveLocation, Err = Self::Err>;
373
374    /// For Telegram documentation see [`StopMessageLiveLocation`].
375    fn stop_message_live_location<C>(
376        &self,
377        chat_id: C,
378        message_id: MessageId,
379    ) -> Self::StopMessageLiveLocation
380    where
381        C: Into<Recipient>;
382
383    type StopMessageLiveLocationInline: Request<
384        Payload = StopMessageLiveLocationInline,
385        Err = Self::Err,
386    >;
387
388    /// For Telegram documentation see [`StopMessageLiveLocationInline`].
389    fn stop_message_live_location_inline<I>(
390        &self,
391        inline_message_id: I,
392    ) -> Self::StopMessageLiveLocationInline
393    where
394        I: Into<String>;
395
396    type EditMessageChecklist: Request<Payload = EditMessageChecklist, Err = Self::Err>;
397
398    /// For Telegram documentation see [`EditMessageChecklist`].
399    fn edit_message_checklist<C>(
400        &self,
401        business_connection_id: BusinessConnectionId,
402        chat_id: C,
403        message_id: MessageId,
404        checklist: InputChecklist,
405    ) -> Self::EditMessageChecklist
406    where
407        C: Into<ChatId>;
408
409    type SendVenue: Request<Payload = SendVenue, Err = Self::Err>;
410
411    /// For Telegram documentation see [`SendVenue`].
412    fn send_venue<C, T, A>(
413        &self,
414        chat_id: C,
415        latitude: f64,
416        longitude: f64,
417        title: T,
418        address: A,
419    ) -> Self::SendVenue
420    where
421        C: Into<Recipient>,
422        T: Into<String>,
423        A: Into<String>;
424
425    type SendContact: Request<Payload = SendContact, Err = Self::Err>;
426
427    /// For Telegram documentation see [`SendContact`].
428    fn send_contact<C, P, F>(
429        &self,
430        chat_id: C,
431        phone_number: P,
432        first_name: F,
433    ) -> Self::SendContact
434    where
435        C: Into<Recipient>,
436        P: Into<String>,
437        F: Into<String>;
438
439    type SendPoll: Request<Payload = SendPoll, Err = Self::Err>;
440
441    /// For Telegram documentation see [`SendPoll`].
442    fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
443    where
444        C: Into<Recipient>,
445        Q: Into<String>,
446        O: IntoIterator<Item = InputPollOption>;
447
448    type SendChecklist: Request<Payload = SendChecklist, Err = Self::Err>;
449
450    /// For Telegram documentation see [`SendChecklist`].
451    fn send_checklist<C>(
452        &self,
453        business_connection_id: BusinessConnectionId,
454        chat_id: C,
455        checklist: InputChecklist,
456    ) -> Self::SendChecklist
457    where
458        C: Into<ChatId>;
459
460    type SendDice: Request<Payload = SendDice, Err = Self::Err>;
461
462    /// For Telegram documentation see [`SendDice`].
463    fn send_dice<C>(&self, chat_id: C) -> Self::SendDice
464    where
465        C: Into<Recipient>;
466
467    type SendChatAction: Request<Payload = SendChatAction, Err = Self::Err>;
468
469    /// For Telegram documentation see [`SendChatAction`].
470    fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction
471    where
472        C: Into<Recipient>;
473
474    type SetMessageReaction: Request<Payload = SetMessageReaction, Err = Self::Err>;
475
476    /// For Telegram documentation see [`SetMessageReaction`].
477    fn set_message_reaction<C>(
478        &self,
479        chat_id: C,
480        message_id: MessageId,
481    ) -> Self::SetMessageReaction
482    where
483        C: Into<Recipient>;
484
485    type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;
486
487    /// For Telegram documentation see [`GetUserProfilePhotos`].
488    fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos;
489
490    type GetUserProfileAudios: Request<Payload = GetUserProfileAudios, Err = Self::Err>;
491
492    /// For Telegram documentation see [`GetUserProfileAudios`].
493    fn get_user_profile_audios(&self, user_id: UserId) -> Self::GetUserProfileAudios;
494
495    type SetUserEmojiStatus: Request<Payload = SetUserEmojiStatus, Err = Self::Err>;
496
497    /// For Telegram documentation see [`SetUserEmojiStatus`].
498    fn set_user_emoji_status(&self, user_id: UserId) -> Self::SetUserEmojiStatus;
499
500    type GetFile: Request<Payload = GetFile, Err = Self::Err>;
501
502    /// For Telegram documentation see [`GetFile`].
503    fn get_file(&self, file_id: FileId) -> Self::GetFile;
504
505    type BanChatMember: Request<Payload = BanChatMember, Err = Self::Err>;
506
507    /// For Telegram documentation see [`BanChatMember`].
508    fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember
509    where
510        C: Into<Recipient>;
511
512    type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;
513
514    /// For Telegram documentation see [`KickChatMember`].
515    fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember
516    where
517        C: Into<Recipient>;
518
519    type UnbanChatMember: Request<Payload = UnbanChatMember, Err = Self::Err>;
520
521    /// For Telegram documentation see [`UnbanChatMember`].
522    fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember
523    where
524        C: Into<Recipient>;
525
526    type RestrictChatMember: Request<Payload = RestrictChatMember, Err = Self::Err>;
527
528    /// For Telegram documentation see [`RestrictChatMember`].
529    fn restrict_chat_member<C>(
530        &self,
531        chat_id: C,
532        user_id: UserId,
533        permissions: ChatPermissions,
534    ) -> Self::RestrictChatMember
535    where
536        C: Into<Recipient>;
537
538    type PromoteChatMember: Request<Payload = PromoteChatMember, Err = Self::Err>;
539
540    /// For Telegram documentation see [`PromoteChatMember`].
541    fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember
542    where
543        C: Into<Recipient>;
544
545    type SetChatAdministratorCustomTitle: Request<
546        Payload = SetChatAdministratorCustomTitle,
547        Err = Self::Err,
548    >;
549
550    /// For Telegram documentation see [`SetChatAdministratorCustomTitle`].
551    fn set_chat_administrator_custom_title<Ch, C>(
552        &self,
553        chat_id: Ch,
554        user_id: UserId,
555        custom_title: C,
556    ) -> Self::SetChatAdministratorCustomTitle
557    where
558        Ch: Into<Recipient>,
559        C: Into<String>;
560
561    type SetChatMemberTag: Request<Payload = SetChatMemberTag, Err = Self::Err>;
562
563    /// For Telegram documentation see [`SetChatMemberTag`].
564    fn set_chat_member_tag<C>(&self, chat_id: C, user_id: UserId) -> Self::SetChatMemberTag
565    where
566        C: Into<Recipient>;
567
568    type BanChatSenderChat: Request<Payload = BanChatSenderChat, Err = Self::Err>;
569
570    /// For Telegram documentation see [`BanChatSenderChat`].
571    fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat
572    where
573        C: Into<Recipient>,
574        S: Into<ChatId>;
575
576    type UnbanChatSenderChat: Request<Payload = UnbanChatSenderChat, Err = Self::Err>;
577
578    /// For Telegram documentation see [`UnbanChatSenderChat`].
579    fn unban_chat_sender_chat<C, S>(
580        &self,
581        chat_id: C,
582        sender_chat_id: S,
583    ) -> Self::UnbanChatSenderChat
584    where
585        C: Into<Recipient>,
586        S: Into<ChatId>;
587
588    type SetChatPermissions: Request<Payload = SetChatPermissions, Err = Self::Err>;
589
590    /// For Telegram documentation see [`SetChatPermissions`].
591    fn set_chat_permissions<C>(
592        &self,
593        chat_id: C,
594        permissions: ChatPermissions,
595    ) -> Self::SetChatPermissions
596    where
597        C: Into<Recipient>;
598
599    type ExportChatInviteLink: Request<Payload = ExportChatInviteLink, Err = Self::Err>;
600
601    /// For Telegram documentation see [`ExportChatInviteLink`].
602    fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
603    where
604        C: Into<Recipient>;
605
606    type CreateChatInviteLink: Request<Payload = CreateChatInviteLink, Err = Self::Err>;
607
608    /// For Telegram documentation see [`CreateChatInviteLink`].
609    fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
610    where
611        C: Into<Recipient>;
612
613    type EditChatInviteLink: Request<Payload = EditChatInviteLink, Err = Self::Err>;
614
615    /// For Telegram documentation see [`EditChatInviteLink`].
616    fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
617    where
618        C: Into<Recipient>,
619        I: Into<String>;
620
621    type CreateChatSubscriptionInviteLink: Request<
622        Payload = CreateChatSubscriptionInviteLink,
623        Err = Self::Err,
624    >;
625
626    /// For Telegram documentation see [`CreateChatSubscriptionInviteLink`].
627    fn create_chat_subscription_invite_link<C>(
628        &self,
629        chat_id: C,
630        subscription_period: Seconds,
631        subscription_price: u32,
632    ) -> Self::CreateChatSubscriptionInviteLink
633    where
634        C: Into<Recipient>;
635
636    type EditChatSubscriptionInviteLink: Request<
637        Payload = EditChatSubscriptionInviteLink,
638        Err = Self::Err,
639    >;
640
641    /// For Telegram documentation see [`EditChatSubscriptionInviteLink`].
642    fn edit_chat_subscription_invite_link<C, I>(
643        &self,
644        chat_id: C,
645        invite_link: I,
646    ) -> Self::EditChatSubscriptionInviteLink
647    where
648        C: Into<Recipient>,
649        I: Into<String>;
650
651    type RevokeChatInviteLink: Request<Payload = RevokeChatInviteLink, Err = Self::Err>;
652
653    /// For Telegram documentation see [`RevokeChatInviteLink`].
654    fn revoke_chat_invite_link<C, I>(
655        &self,
656        chat_id: C,
657        invite_link: I,
658    ) -> Self::RevokeChatInviteLink
659    where
660        C: Into<Recipient>,
661        I: Into<String>;
662
663    type ApproveChatJoinRequest: Request<Payload = ApproveChatJoinRequest, Err = Self::Err>;
664
665    /// For Telegram documentation see [`ApproveChatJoinRequest`].
666    fn approve_chat_join_request<C>(
667        &self,
668        chat_id: C,
669        user_id: UserId,
670    ) -> Self::ApproveChatJoinRequest
671    where
672        C: Into<Recipient>;
673
674    type DeclineChatJoinRequest: Request<Payload = DeclineChatJoinRequest, Err = Self::Err>;
675
676    /// For Telegram documentation see [`DeclineChatJoinRequest`].
677    fn decline_chat_join_request<C>(
678        &self,
679        chat_id: C,
680        user_id: UserId,
681    ) -> Self::DeclineChatJoinRequest
682    where
683        C: Into<Recipient>;
684
685    type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;
686
687    /// For Telegram documentation see [`SetChatPhoto`].
688    fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
689    where
690        C: Into<Recipient>;
691
692    type DeleteChatPhoto: Request<Payload = DeleteChatPhoto, Err = Self::Err>;
693
694    /// For Telegram documentation see [`DeleteChatPhoto`].
695    fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
696    where
697        C: Into<Recipient>;
698
699    type SetChatTitle: Request<Payload = SetChatTitle, Err = Self::Err>;
700
701    /// For Telegram documentation see [`SetChatTitle`].
702    fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
703    where
704        C: Into<Recipient>,
705        T: Into<String>;
706
707    type SetChatDescription: Request<Payload = SetChatDescription, Err = Self::Err>;
708
709    /// For Telegram documentation see [`SetChatDescription`].
710    fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
711    where
712        C: Into<Recipient>;
713
714    type PinChatMessage: Request<Payload = PinChatMessage, Err = Self::Err>;
715
716    /// For Telegram documentation see [`PinChatMessage`].
717    fn pin_chat_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::PinChatMessage
718    where
719        C: Into<Recipient>;
720
721    type UnpinChatMessage: Request<Payload = UnpinChatMessage, Err = Self::Err>;
722
723    /// For Telegram documentation see [`UnpinChatMessage`].
724    fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
725    where
726        C: Into<Recipient>;
727
728    type UnpinAllChatMessages: Request<Payload = UnpinAllChatMessages, Err = Self::Err>;
729
730    /// For Telegram documentation see [`UnpinAllChatMessages`].
731    fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
732    where
733        C: Into<Recipient>;
734
735    type LeaveChat: Request<Payload = LeaveChat, Err = Self::Err>;
736
737    /// For Telegram documentation see [`LeaveChat`].
738    fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
739    where
740        C: Into<Recipient>;
741
742    type GetChat: Request<Payload = GetChat, Err = Self::Err>;
743
744    /// For Telegram documentation see [`GetChat`].
745    fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
746    where
747        C: Into<Recipient>;
748
749    type GetChatAdministrators: Request<Payload = GetChatAdministrators, Err = Self::Err>;
750
751    /// For Telegram documentation see [`GetChatAdministrators`].
752    fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
753    where
754        C: Into<Recipient>;
755
756    type GetChatMemberCount: Request<Payload = GetChatMemberCount, Err = Self::Err>;
757
758    /// For Telegram documentation see [`GetChatMemberCount`].
759    fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
760    where
761        C: Into<Recipient>;
762
763    type GetChatMembersCount: Request<Payload = GetChatMembersCount, Err = Self::Err>;
764
765    /// For Telegram documentation see [`GetChatMembersCount`].
766    fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
767    where
768        C: Into<Recipient>;
769
770    type GetChatMember: Request<Payload = GetChatMember, Err = Self::Err>;
771
772    /// For Telegram documentation see [`GetChatMember`].
773    fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember
774    where
775        C: Into<Recipient>;
776
777    type GetUserPersonalChatMessages: Request<
778        Payload = GetUserPersonalChatMessages,
779        Err = Self::Err,
780    >;
781
782    /// For Telegram documentation see [`GetUserPersonalChatMessages`].
783    fn get_user_personal_chat_messages(
784        &self,
785        user_id: UserId,
786        limit: u8,
787    ) -> Self::GetUserPersonalChatMessages;
788
789    type SetChatStickerSet: Request<Payload = SetChatStickerSet, Err = Self::Err>;
790
791    /// For Telegram documentation see [`SetChatStickerSet`].
792    fn set_chat_sticker_set<C, S>(
793        &self,
794        chat_id: C,
795        sticker_set_name: S,
796    ) -> Self::SetChatStickerSet
797    where
798        C: Into<Recipient>,
799        S: Into<String>;
800
801    type DeleteChatStickerSet: Request<Payload = DeleteChatStickerSet, Err = Self::Err>;
802
803    /// For Telegram documentation see [`DeleteChatStickerSet`].
804    fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
805    where
806        C: Into<Recipient>;
807
808    type GetForumTopicIconStickers: Request<Payload = GetForumTopicIconStickers, Err = Self::Err>;
809
810    /// For Telegram documentation see [`GetForumTopicIconStickers`].
811    fn get_forum_topic_icon_stickers(&self) -> Self::GetForumTopicIconStickers;
812
813    type CreateForumTopic: Request<Payload = CreateForumTopic, Err = Self::Err>;
814
815    /// For Telegram documentation see [`CreateForumTopic`].
816    fn create_forum_topic<C, N>(&self, chat_id: C, name: N) -> Self::CreateForumTopic
817    where
818        C: Into<Recipient>,
819        N: Into<String>;
820
821    type EditForumTopic: Request<Payload = EditForumTopic, Err = Self::Err>;
822
823    /// For Telegram documentation see [`EditForumTopic`].
824    fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic
825    where
826        C: Into<Recipient>;
827
828    type CloseForumTopic: Request<Payload = CloseForumTopic, Err = Self::Err>;
829
830    /// For Telegram documentation see [`CloseForumTopic`].
831    fn close_forum_topic<C>(
832        &self,
833        chat_id: C,
834        message_thread_id: ThreadId,
835    ) -> Self::CloseForumTopic
836    where
837        C: Into<Recipient>;
838
839    type ReopenForumTopic: Request<Payload = ReopenForumTopic, Err = Self::Err>;
840
841    /// For Telegram documentation see [`ReopenForumTopic`].
842    fn reopen_forum_topic<C>(
843        &self,
844        chat_id: C,
845        message_thread_id: ThreadId,
846    ) -> Self::ReopenForumTopic
847    where
848        C: Into<Recipient>;
849
850    type DeleteForumTopic: Request<Payload = DeleteForumTopic, Err = Self::Err>;
851
852    /// For Telegram documentation see [`DeleteForumTopic`].
853    fn delete_forum_topic<C>(
854        &self,
855        chat_id: C,
856        message_thread_id: ThreadId,
857    ) -> Self::DeleteForumTopic
858    where
859        C: Into<Recipient>;
860
861    type UnpinAllForumTopicMessages: Request<Payload = UnpinAllForumTopicMessages, Err = Self::Err>;
862
863    /// For Telegram documentation see [`UnpinAllForumTopicMessages`].
864    fn unpin_all_forum_topic_messages<C>(
865        &self,
866        chat_id: C,
867        message_thread_id: ThreadId,
868    ) -> Self::UnpinAllForumTopicMessages
869    where
870        C: Into<Recipient>;
871
872    type EditGeneralForumTopic: Request<Payload = EditGeneralForumTopic, Err = Self::Err>;
873
874    /// For Telegram documentation see [`EditGeneralForumTopic`].
875    fn edit_general_forum_topic<C, N>(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic
876    where
877        C: Into<Recipient>,
878        N: Into<String>;
879
880    type CloseGeneralForumTopic: Request<Payload = CloseGeneralForumTopic, Err = Self::Err>;
881
882    /// For Telegram documentation see [`CloseGeneralForumTopic`].
883    fn close_general_forum_topic<C>(&self, chat_id: C) -> Self::CloseGeneralForumTopic
884    where
885        C: Into<Recipient>;
886
887    type ReopenGeneralForumTopic: Request<Payload = ReopenGeneralForumTopic, Err = Self::Err>;
888
889    /// For Telegram documentation see [`ReopenGeneralForumTopic`].
890    fn reopen_general_forum_topic<C>(&self, chat_id: C) -> Self::ReopenGeneralForumTopic
891    where
892        C: Into<Recipient>;
893
894    type HideGeneralForumTopic: Request<Payload = HideGeneralForumTopic, Err = Self::Err>;
895
896    /// For Telegram documentation see [`HideGeneralForumTopic`].
897    fn hide_general_forum_topic<C>(&self, chat_id: C) -> Self::HideGeneralForumTopic
898    where
899        C: Into<Recipient>;
900
901    type UnhideGeneralForumTopic: Request<Payload = UnhideGeneralForumTopic, Err = Self::Err>;
902
903    /// For Telegram documentation see [`UnhideGeneralForumTopic`].
904    fn unhide_general_forum_topic<C>(&self, chat_id: C) -> Self::UnhideGeneralForumTopic
905    where
906        C: Into<Recipient>;
907
908    type UnpinAllGeneralForumTopicMessages: Request<
909        Payload = UnpinAllGeneralForumTopicMessages,
910        Err = Self::Err,
911    >;
912
913    /// For Telegram documentation see [`UnpinAllGeneralForumTopicMessages`].
914    fn unpin_all_general_forum_topic_messages<C>(
915        &self,
916        chat_id: C,
917    ) -> Self::UnpinAllGeneralForumTopicMessages
918    where
919        C: Into<Recipient>;
920
921    type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>;
922
923    /// For Telegram documentation see [`AnswerCallbackQuery`].
924    fn answer_callback_query(
925        &self,
926        callback_query_id: CallbackQueryId,
927    ) -> Self::AnswerCallbackQuery;
928
929    type AnswerGuestQuery: Request<Payload = AnswerGuestQuery, Err = Self::Err>;
930
931    /// For Telegram documentation see [`AnswerGuestQuery`].
932    fn answer_guest_query(
933        &self,
934        guest_query_id: GuestQueryId,
935        result: InlineQueryResult,
936    ) -> Self::AnswerGuestQuery;
937
938    type GetUserChatBoosts: Request<Payload = GetUserChatBoosts, Err = Self::Err>;
939
940    /// For Telegram documentation see [`GetUserChatBoosts`].
941    fn get_user_chat_boosts<C>(&self, chat_id: C, user_id: UserId) -> Self::GetUserChatBoosts
942    where
943        C: Into<Recipient>;
944
945    type SetMyCommands: Request<Payload = SetMyCommands, Err = Self::Err>;
946
947    /// For Telegram documentation see [`SetMyCommands`].
948    fn set_my_commands<C>(&self, commands: C) -> Self::SetMyCommands
949    where
950        C: IntoIterator<Item = BotCommand>;
951
952    type GetBusinessConnection: Request<Payload = GetBusinessConnection, Err = Self::Err>;
953
954    /// For Telegram documentation see [`GetBusinessConnection`].
955    fn get_business_connection(
956        &self,
957        business_connection_id: BusinessConnectionId,
958    ) -> Self::GetBusinessConnection;
959
960    type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;
961
962    /// For Telegram documentation see [`GetMyCommands`].
963    fn get_my_commands(&self) -> Self::GetMyCommands;
964
965    type SetMyName: Request<Payload = SetMyName, Err = Self::Err>;
966
967    /// For Telegram documentation see [`SetMyName`].
968    fn set_my_name(&self) -> Self::SetMyName;
969
970    type GetMyName: Request<Payload = GetMyName, Err = Self::Err>;
971
972    /// For Telegram documentation see [`GetMyName`].
973    fn get_my_name(&self) -> Self::GetMyName;
974
975    type SetMyDescription: Request<Payload = SetMyDescription, Err = Self::Err>;
976
977    /// For Telegram documentation see [`SetMyDescription`].
978    fn set_my_description(&self) -> Self::SetMyDescription;
979
980    type GetMyDescription: Request<Payload = GetMyDescription, Err = Self::Err>;
981
982    /// For Telegram documentation see [`GetMyDescription`].
983    fn get_my_description(&self) -> Self::GetMyDescription;
984
985    type SetMyShortDescription: Request<Payload = SetMyShortDescription, Err = Self::Err>;
986
987    /// For Telegram documentation see [`SetMyShortDescription`].
988    fn set_my_short_description(&self) -> Self::SetMyShortDescription;
989
990    type GetMyShortDescription: Request<Payload = GetMyShortDescription, Err = Self::Err>;
991
992    /// For Telegram documentation see [`GetMyShortDescription`].
993    fn get_my_short_description(&self) -> Self::GetMyShortDescription;
994
995    type SetMyProfilePhoto: Request<Payload = SetMyProfilePhoto, Err = Self::Err>;
996
997    /// For Telegram documentation see [`SetMyProfilePhoto`].
998    fn set_my_profile_photo(&self, photo: InputProfilePhoto) -> Self::SetMyProfilePhoto;
999
1000    type RemoveMyProfilePhoto: Request<Payload = RemoveMyProfilePhoto, Err = Self::Err>;
1001
1002    /// For Telegram documentation see [`RemoveMyProfilePhoto`].
1003    fn remove_my_profile_photo(&self) -> Self::RemoveMyProfilePhoto;
1004
1005    type GetManagedBotToken: Request<Payload = GetManagedBotToken, Err = Self::Err>;
1006
1007    /// For Telegram documentation see [`GetManagedBotToken`].
1008    fn get_managed_bot_token(&self, user_id: UserId) -> Self::GetManagedBotToken;
1009
1010    type ReplaceManagedBotToken: Request<Payload = ReplaceManagedBotToken, Err = Self::Err>;
1011
1012    /// For Telegram documentation see [`ReplaceManagedBotToken`].
1013    fn replace_managed_bot_token(&self, user_id: UserId) -> Self::ReplaceManagedBotToken;
1014
1015    type SavePreparedKeyboardButton: Request<Payload = SavePreparedKeyboardButton, Err = Self::Err>;
1016
1017    /// For Telegram documentation see [`SavePreparedKeyboardButton`].
1018    fn save_prepared_keyboard_button(
1019        &self,
1020        user_id: UserId,
1021        button: KeyboardButton,
1022    ) -> Self::SavePreparedKeyboardButton;
1023
1024    type GetManagedBotAccessSettings: Request<
1025        Payload = GetManagedBotAccessSettings,
1026        Err = Self::Err,
1027    >;
1028
1029    /// For Telegram documentation see [`GetManagedBotAccessSettings`].
1030    fn get_managed_bot_access_settings(&self, user_id: UserId)
1031        -> Self::GetManagedBotAccessSettings;
1032
1033    type SetManagedBotAccessSettings: Request<
1034        Payload = SetManagedBotAccessSettings,
1035        Err = Self::Err,
1036    >;
1037
1038    /// For Telegram documentation see [`SetManagedBotAccessSettings`].
1039    fn set_managed_bot_access_settings(
1040        &self,
1041        user_id: UserId,
1042        is_access_restricted: bool,
1043    ) -> Self::SetManagedBotAccessSettings;
1044
1045    type SetChatMenuButton: Request<Payload = SetChatMenuButton, Err = Self::Err>;
1046
1047    /// For Telegram documentation see [`SetChatMenuButton`].
1048    fn set_chat_menu_button(&self) -> Self::SetChatMenuButton;
1049
1050    type GetChatMenuButton: Request<Payload = GetChatMenuButton, Err = Self::Err>;
1051
1052    /// For Telegram documentation see [`GetChatMenuButton`].
1053    fn get_chat_menu_button(&self) -> Self::GetChatMenuButton;
1054
1055    type SetMyDefaultAdministratorRights: Request<
1056        Payload = SetMyDefaultAdministratorRights,
1057        Err = Self::Err,
1058    >;
1059
1060    /// For Telegram documentation see [`SetMyDefaultAdministratorRights`].
1061    fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights;
1062
1063    type GetMyDefaultAdministratorRights: Request<
1064        Payload = GetMyDefaultAdministratorRights,
1065        Err = Self::Err,
1066    >;
1067
1068    /// For Telegram documentation see [`GetMyDefaultAdministratorRights`].
1069    fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights;
1070
1071    type DeleteMyCommands: Request<Payload = DeleteMyCommands, Err = Self::Err>;
1072
1073    /// For Telegram documentation see [`DeleteMyCommands`].
1074    fn delete_my_commands(&self) -> Self::DeleteMyCommands;
1075
1076    type AnswerInlineQuery: Request<Payload = AnswerInlineQuery, Err = Self::Err>;
1077
1078    /// For Telegram documentation see [`AnswerInlineQuery`].
1079    fn answer_inline_query<R>(
1080        &self,
1081        inline_query_id: InlineQueryId,
1082        results: R,
1083    ) -> Self::AnswerInlineQuery
1084    where
1085        R: IntoIterator<Item = InlineQueryResult>;
1086
1087    type AnswerWebAppQuery: Request<Payload = AnswerWebAppQuery, Err = Self::Err>;
1088
1089    /// For Telegram documentation see [`AnswerWebAppQuery`].
1090    fn answer_web_app_query<W>(
1091        &self,
1092        web_app_query_id: W,
1093        result: InlineQueryResult,
1094    ) -> Self::AnswerWebAppQuery
1095    where
1096        W: Into<String>;
1097
1098    type SavePreparedInlineMessage: Request<Payload = SavePreparedInlineMessage, Err = Self::Err>;
1099
1100    /// For Telegram documentation see [`SavePreparedInlineMessage`].
1101    fn save_prepared_inline_message(
1102        &self,
1103        user_id: UserId,
1104        result: InlineQueryResult,
1105    ) -> Self::SavePreparedInlineMessage;
1106
1107    type EditMessageText: Request<Payload = EditMessageText, Err = Self::Err>;
1108
1109    /// For Telegram documentation see [`EditMessageText`].
1110    fn edit_message_text<C, T>(
1111        &self,
1112        chat_id: C,
1113        message_id: MessageId,
1114        text: T,
1115    ) -> Self::EditMessageText
1116    where
1117        C: Into<Recipient>,
1118        T: Into<String>;
1119
1120    type EditMessageTextInline: Request<Payload = EditMessageTextInline, Err = Self::Err>;
1121
1122    /// For Telegram documentation see [`EditMessageTextInline`].
1123    fn edit_message_text_inline<I, T>(
1124        &self,
1125        inline_message_id: I,
1126        text: T,
1127    ) -> Self::EditMessageTextInline
1128    where
1129        I: Into<String>,
1130        T: Into<String>;
1131
1132    type EditMessageCaption: Request<Payload = EditMessageCaption, Err = Self::Err>;
1133
1134    /// For Telegram documentation see [`EditMessageCaption`].
1135    fn edit_message_caption<C>(
1136        &self,
1137        chat_id: C,
1138        message_id: MessageId,
1139    ) -> Self::EditMessageCaption
1140    where
1141        C: Into<Recipient>;
1142
1143    type EditMessageCaptionInline: Request<Payload = EditMessageCaptionInline, Err = Self::Err>;
1144
1145    /// For Telegram documentation see [`EditMessageCaptionInline`].
1146    fn edit_message_caption_inline<I>(
1147        &self,
1148        inline_message_id: I,
1149    ) -> Self::EditMessageCaptionInline
1150    where
1151        I: Into<String>;
1152
1153    type EditMessageMedia: Request<Payload = EditMessageMedia, Err = Self::Err>;
1154
1155    /// For Telegram documentation see [`EditMessageMedia`].
1156    fn edit_message_media<C>(
1157        &self,
1158        chat_id: C,
1159        message_id: MessageId,
1160        media: InputMedia,
1161    ) -> Self::EditMessageMedia
1162    where
1163        C: Into<Recipient>;
1164
1165    type EditMessageMediaInline: Request<Payload = EditMessageMediaInline, Err = Self::Err>;
1166
1167    /// For Telegram documentation see [`EditMessageMediaInline`].
1168    fn edit_message_media_inline<I>(
1169        &self,
1170        inline_message_id: I,
1171        media: InputMedia,
1172    ) -> Self::EditMessageMediaInline
1173    where
1174        I: Into<String>;
1175
1176    type EditMessageReplyMarkup: Request<Payload = EditMessageReplyMarkup, Err = Self::Err>;
1177
1178    /// For Telegram documentation see [`EditMessageReplyMarkup`].
1179    fn edit_message_reply_markup<C>(
1180        &self,
1181        chat_id: C,
1182        message_id: MessageId,
1183    ) -> Self::EditMessageReplyMarkup
1184    where
1185        C: Into<Recipient>;
1186
1187    type EditMessageReplyMarkupInline: Request<
1188        Payload = EditMessageReplyMarkupInline,
1189        Err = Self::Err,
1190    >;
1191
1192    /// For Telegram documentation see [`EditMessageReplyMarkupInline`].
1193    fn edit_message_reply_markup_inline<I>(
1194        &self,
1195        inline_message_id: I,
1196    ) -> Self::EditMessageReplyMarkupInline
1197    where
1198        I: Into<String>;
1199
1200    type StopPoll: Request<Payload = StopPoll, Err = Self::Err>;
1201
1202    /// For Telegram documentation see [`StopPoll`].
1203    fn stop_poll<C>(&self, chat_id: C, message_id: MessageId) -> Self::StopPoll
1204    where
1205        C: Into<Recipient>;
1206
1207    type ApproveSuggestedPost: Request<Payload = ApproveSuggestedPost, Err = Self::Err>;
1208
1209    /// For Telegram documentation see [`ApproveSuggestedPost`].
1210    fn approve_suggested_post<C>(
1211        &self,
1212        chat_id: C,
1213        message_id: MessageId,
1214    ) -> Self::ApproveSuggestedPost
1215    where
1216        C: Into<ChatId>;
1217
1218    type DeclineSuggestedPost: Request<Payload = DeclineSuggestedPost, Err = Self::Err>;
1219
1220    /// For Telegram documentation see [`DeclineSuggestedPost`].
1221    fn decline_suggested_post<C>(
1222        &self,
1223        chat_id: C,
1224        message_id: MessageId,
1225    ) -> Self::DeclineSuggestedPost
1226    where
1227        C: Into<ChatId>;
1228
1229    type DeleteMessage: Request<Payload = DeleteMessage, Err = Self::Err>;
1230
1231    /// For Telegram documentation see [`DeleteMessage`].
1232    fn delete_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::DeleteMessage
1233    where
1234        C: Into<Recipient>;
1235
1236    type DeleteMessages: Request<Payload = DeleteMessages, Err = Self::Err>;
1237
1238    /// For Telegram documentation see [`DeleteMessages`].
1239    fn delete_messages<C, M>(&self, chat_id: C, message_ids: M) -> Self::DeleteMessages
1240    where
1241        C: Into<Recipient>,
1242        M: IntoIterator<Item = MessageId>;
1243
1244    type DeleteMessageReaction: Request<Payload = DeleteMessageReaction, Err = Self::Err>;
1245
1246    /// For Telegram documentation see [`DeleteMessageReaction`].
1247    fn delete_message_reaction<C>(
1248        &self,
1249        chat_id: C,
1250        message_id: i32,
1251    ) -> Self::DeleteMessageReaction
1252    where
1253        C: Into<Recipient>;
1254
1255    type DeleteAllMessageReactions: Request<Payload = DeleteAllMessageReactions, Err = Self::Err>;
1256
1257    /// For Telegram documentation see [`DeleteAllMessageReactions`].
1258    fn delete_all_message_reactions<C>(&self, chat_id: C) -> Self::DeleteAllMessageReactions
1259    where
1260        C: Into<Recipient>;
1261
1262    type SendSticker: Request<Payload = SendSticker, Err = Self::Err>;
1263
1264    /// For Telegram documentation see [`SendSticker`].
1265    fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker
1266    where
1267        C: Into<Recipient>;
1268
1269    type GetStickerSet: Request<Payload = GetStickerSet, Err = Self::Err>;
1270
1271    /// For Telegram documentation see [`GetStickerSet`].
1272    fn get_sticker_set<N>(&self, name: N) -> Self::GetStickerSet
1273    where
1274        N: Into<String>;
1275
1276    type GetCustomEmojiStickers: Request<Payload = GetCustomEmojiStickers, Err = Self::Err>;
1277
1278    /// For Telegram documentation see [`GetCustomEmojiStickers`].
1279    fn get_custom_emoji_stickers<C>(&self, custom_emoji_ids: C) -> Self::GetCustomEmojiStickers
1280    where
1281        C: IntoIterator<Item = CustomEmojiId>;
1282
1283    type UploadStickerFile: Request<Payload = UploadStickerFile, Err = Self::Err>;
1284
1285    /// For Telegram documentation see [`UploadStickerFile`].
1286    fn upload_sticker_file(
1287        &self,
1288        user_id: UserId,
1289        sticker: InputFile,
1290        sticker_format: StickerFormat,
1291    ) -> Self::UploadStickerFile;
1292
1293    type CreateNewStickerSet: Request<Payload = CreateNewStickerSet, Err = Self::Err>;
1294
1295    /// For Telegram documentation see [`CreateNewStickerSet`].
1296    fn create_new_sticker_set<N, T, S>(
1297        &self,
1298        user_id: UserId,
1299        name: N,
1300        title: T,
1301        stickers: S,
1302    ) -> Self::CreateNewStickerSet
1303    where
1304        N: Into<String>,
1305        T: Into<String>,
1306        S: IntoIterator<Item = InputSticker>;
1307
1308    type AddStickerToSet: Request<Payload = AddStickerToSet, Err = Self::Err>;
1309
1310    /// For Telegram documentation see [`AddStickerToSet`].
1311    fn add_sticker_to_set<N>(
1312        &self,
1313        user_id: UserId,
1314        name: N,
1315        sticker: InputSticker,
1316    ) -> Self::AddStickerToSet
1317    where
1318        N: Into<String>;
1319
1320    type SetStickerPositionInSet: Request<Payload = SetStickerPositionInSet, Err = Self::Err>;
1321
1322    /// For Telegram documentation see [`SetStickerPositionInSet`].
1323    fn set_sticker_position_in_set<S>(
1324        &self,
1325        sticker: S,
1326        position: u32,
1327    ) -> Self::SetStickerPositionInSet
1328    where
1329        S: Into<String>;
1330
1331    type DeleteStickerFromSet: Request<Payload = DeleteStickerFromSet, Err = Self::Err>;
1332
1333    /// For Telegram documentation see [`DeleteStickerFromSet`].
1334    fn delete_sticker_from_set<S>(&self, sticker: S) -> Self::DeleteStickerFromSet
1335    where
1336        S: Into<String>;
1337
1338    type ReplaceStickerInSet: Request<Payload = ReplaceStickerInSet, Err = Self::Err>;
1339
1340    /// For Telegram documentation see [`ReplaceStickerInSet`].
1341    fn replace_sticker_in_set<N, O>(
1342        &self,
1343        user_id: UserId,
1344        name: N,
1345        old_sticker: O,
1346        sticker: InputSticker,
1347    ) -> Self::ReplaceStickerInSet
1348    where
1349        N: Into<String>,
1350        O: Into<String>;
1351
1352    type SetStickerSetThumbnail: Request<Payload = SetStickerSetThumbnail, Err = Self::Err>;
1353
1354    /// For Telegram documentation see [`SetStickerSetThumbnail`].
1355    fn set_sticker_set_thumbnail<N>(
1356        &self,
1357        name: N,
1358        user_id: UserId,
1359        format: StickerFormat,
1360    ) -> Self::SetStickerSetThumbnail
1361    where
1362        N: Into<String>;
1363
1364    type SetCustomEmojiStickerSetThumbnail: Request<
1365        Payload = SetCustomEmojiStickerSetThumbnail,
1366        Err = Self::Err,
1367    >;
1368
1369    /// For Telegram documentation see [`SetCustomEmojiStickerSetThumbnail`].
1370    fn set_custom_emoji_sticker_set_thumbnail<N>(
1371        &self,
1372        name: N,
1373    ) -> Self::SetCustomEmojiStickerSetThumbnail
1374    where
1375        N: Into<String>;
1376
1377    type SetStickerSetTitle: Request<Payload = SetStickerSetTitle, Err = Self::Err>;
1378
1379    /// For Telegram documentation see [`SetStickerSetTitle`].
1380    fn set_sticker_set_title<N, T>(&self, name: N, title: T) -> Self::SetStickerSetTitle
1381    where
1382        N: Into<String>,
1383        T: Into<String>;
1384
1385    type DeleteStickerSet: Request<Payload = DeleteStickerSet, Err = Self::Err>;
1386
1387    /// For Telegram documentation see [`DeleteStickerSet`].
1388    fn delete_sticker_set<N>(&self, name: N) -> Self::DeleteStickerSet
1389    where
1390        N: Into<String>;
1391
1392    type SetStickerEmojiList: Request<Payload = SetStickerEmojiList, Err = Self::Err>;
1393
1394    /// For Telegram documentation see [`SetStickerEmojiList`].
1395    fn set_sticker_emoji_list<S, E>(&self, sticker: S, emoji_list: E) -> Self::SetStickerEmojiList
1396    where
1397        S: Into<String>,
1398        E: IntoIterator<Item = String>;
1399
1400    type SetStickerKeywords: Request<Payload = SetStickerKeywords, Err = Self::Err>;
1401
1402    /// For Telegram documentation see [`SetStickerKeywords`].
1403    fn set_sticker_keywords<S>(&self, sticker: S) -> Self::SetStickerKeywords
1404    where
1405        S: Into<String>;
1406
1407    type SetStickerMaskPosition: Request<Payload = SetStickerMaskPosition, Err = Self::Err>;
1408
1409    /// For Telegram documentation see [`SetStickerMaskPosition`].
1410    fn set_sticker_mask_position<S>(&self, sticker: S) -> Self::SetStickerMaskPosition
1411    where
1412        S: Into<String>;
1413
1414    type GetAvailableGifts: Request<Payload = GetAvailableGifts, Err = Self::Err>;
1415
1416    /// For Telegram documentation see [`GetAvailableGifts`].
1417    fn get_available_gifts(&self) -> Self::GetAvailableGifts;
1418
1419    type SendGift: Request<Payload = SendGift, Err = Self::Err>;
1420
1421    /// For Telegram documentation see [`SendGift`].
1422    fn send_gift(&self, user_id: UserId, gift_id: GiftId) -> Self::SendGift;
1423
1424    type SendGiftChat: Request<Payload = SendGiftChat, Err = Self::Err>;
1425
1426    /// For Telegram documentation see [`SendGiftChat`].
1427    fn send_gift_chat<C>(&self, chat_id: C, gift_id: GiftId) -> Self::SendGiftChat
1428    where
1429        C: Into<Recipient>;
1430
1431    type GiftPremiumSubscription: Request<Payload = GiftPremiumSubscription, Err = Self::Err>;
1432
1433    /// For Telegram documentation see [`GiftPremiumSubscription`].
1434    fn gift_premium_subscription(
1435        &self,
1436        user_id: UserId,
1437        month_count: u8,
1438        star_count: u32,
1439    ) -> Self::GiftPremiumSubscription;
1440
1441    type VerifyUser: Request<Payload = VerifyUser, Err = Self::Err>;
1442
1443    /// For Telegram documentation see [`VerifyUser`].
1444    fn verify_user(&self, user_id: UserId) -> Self::VerifyUser;
1445
1446    type VerifyChat: Request<Payload = VerifyChat, Err = Self::Err>;
1447
1448    /// For Telegram documentation see [`VerifyChat`].
1449    fn verify_chat<C>(&self, chat_id: C) -> Self::VerifyChat
1450    where
1451        C: Into<Recipient>;
1452
1453    type RemoveUserVerification: Request<Payload = RemoveUserVerification, Err = Self::Err>;
1454
1455    /// For Telegram documentation see [`RemoveUserVerification`].
1456    fn remove_user_verification(&self, user_id: UserId) -> Self::RemoveUserVerification;
1457
1458    type RemoveChatVerification: Request<Payload = RemoveChatVerification, Err = Self::Err>;
1459
1460    /// For Telegram documentation see [`RemoveChatVerification`].
1461    fn remove_chat_verification<C>(&self, chat_id: C) -> Self::RemoveChatVerification
1462    where
1463        C: Into<Recipient>;
1464
1465    type ReadBusinessMessage: Request<Payload = ReadBusinessMessage, Err = Self::Err>;
1466
1467    /// For Telegram documentation see [`ReadBusinessMessage`].
1468    fn read_business_message<C>(
1469        &self,
1470        business_connection_id: BusinessConnectionId,
1471        chat_id: C,
1472        message_id: MessageId,
1473    ) -> Self::ReadBusinessMessage
1474    where
1475        C: Into<ChatId>;
1476
1477    type DeleteBusinessMessages: Request<Payload = DeleteBusinessMessages, Err = Self::Err>;
1478
1479    /// For Telegram documentation see [`DeleteBusinessMessages`].
1480    fn delete_business_messages<M>(
1481        &self,
1482        business_connection_id: BusinessConnectionId,
1483        message_ids: M,
1484    ) -> Self::DeleteBusinessMessages
1485    where
1486        M: IntoIterator<Item = MessageId>;
1487
1488    type SetBusinessAccountName: Request<Payload = SetBusinessAccountName, Err = Self::Err>;
1489
1490    /// For Telegram documentation see [`SetBusinessAccountName`].
1491    fn set_business_account_name<F>(
1492        &self,
1493        business_connection_id: BusinessConnectionId,
1494        first_name: F,
1495    ) -> Self::SetBusinessAccountName
1496    where
1497        F: Into<String>;
1498
1499    type SetBusinessAccountUsername: Request<Payload = SetBusinessAccountUsername, Err = Self::Err>;
1500
1501    /// For Telegram documentation see [`SetBusinessAccountUsername`].
1502    fn set_business_account_username(
1503        &self,
1504        business_connection_id: BusinessConnectionId,
1505    ) -> Self::SetBusinessAccountUsername;
1506
1507    type SetBusinessAccountBio: Request<Payload = SetBusinessAccountBio, Err = Self::Err>;
1508
1509    /// For Telegram documentation see [`SetBusinessAccountBio`].
1510    fn set_business_account_bio(
1511        &self,
1512        business_connection_id: BusinessConnectionId,
1513    ) -> Self::SetBusinessAccountBio;
1514
1515    type SetBusinessAccountProfilePhoto: Request<
1516        Payload = SetBusinessAccountProfilePhoto,
1517        Err = Self::Err,
1518    >;
1519
1520    /// For Telegram documentation see [`SetBusinessAccountProfilePhoto`].
1521    fn set_business_account_profile_photo(
1522        &self,
1523        business_connection_id: BusinessConnectionId,
1524        photo: InputProfilePhoto,
1525    ) -> Self::SetBusinessAccountProfilePhoto;
1526
1527    type RemoveBusinessAccountProfilePhoto: Request<
1528        Payload = RemoveBusinessAccountProfilePhoto,
1529        Err = Self::Err,
1530    >;
1531
1532    /// For Telegram documentation see [`RemoveBusinessAccountProfilePhoto`].
1533    fn remove_business_account_profile_photo(
1534        &self,
1535        business_connection_id: BusinessConnectionId,
1536    ) -> Self::RemoveBusinessAccountProfilePhoto;
1537
1538    type SetBusinessAccountGiftSettings: Request<
1539        Payload = SetBusinessAccountGiftSettings,
1540        Err = Self::Err,
1541    >;
1542
1543    /// For Telegram documentation see [`SetBusinessAccountGiftSettings`].
1544    fn set_business_account_gift_settings(
1545        &self,
1546        business_connection_id: BusinessConnectionId,
1547        show_gift_button: bool,
1548        accepted_gift_types: AcceptedGiftTypes,
1549    ) -> Self::SetBusinessAccountGiftSettings;
1550
1551    type GetBusinessAccountStarBalance: Request<
1552        Payload = GetBusinessAccountStarBalance,
1553        Err = Self::Err,
1554    >;
1555
1556    /// For Telegram documentation see [`GetBusinessAccountStarBalance`].
1557    fn get_business_account_star_balance(
1558        &self,
1559        business_connection_id: BusinessConnectionId,
1560    ) -> Self::GetBusinessAccountStarBalance;
1561
1562    type TransferBusinessAccountStars: Request<
1563        Payload = TransferBusinessAccountStars,
1564        Err = Self::Err,
1565    >;
1566
1567    /// For Telegram documentation see [`TransferBusinessAccountStars`].
1568    fn transfer_business_account_stars(
1569        &self,
1570        business_connection_id: BusinessConnectionId,
1571        star_count: u32,
1572    ) -> Self::TransferBusinessAccountStars;
1573
1574    type GetBusinessAccountGifts: Request<Payload = GetBusinessAccountGifts, Err = Self::Err>;
1575
1576    /// For Telegram documentation see [`GetBusinessAccountGifts`].
1577    fn get_business_account_gifts(
1578        &self,
1579        business_connection_id: BusinessConnectionId,
1580    ) -> Self::GetBusinessAccountGifts;
1581
1582    type ConvertGiftToStars: Request<Payload = ConvertGiftToStars, Err = Self::Err>;
1583
1584    /// For Telegram documentation see [`ConvertGiftToStars`].
1585    fn convert_gift_to_stars(
1586        &self,
1587        business_connection_id: BusinessConnectionId,
1588        owned_gift_id: OwnedGiftId,
1589    ) -> Self::ConvertGiftToStars;
1590
1591    type UpgradeGift: Request<Payload = UpgradeGift, Err = Self::Err>;
1592
1593    /// For Telegram documentation see [`UpgradeGift`].
1594    fn upgrade_gift(
1595        &self,
1596        business_connection_id: BusinessConnectionId,
1597        owned_gift_id: OwnedGiftId,
1598    ) -> Self::UpgradeGift;
1599
1600    type TransferGift: Request<Payload = TransferGift, Err = Self::Err>;
1601
1602    /// For Telegram documentation see [`TransferGift`].
1603    fn transfer_gift<N>(
1604        &self,
1605        business_connection_id: BusinessConnectionId,
1606        owned_gift_id: OwnedGiftId,
1607        new_owner_chat_id: N,
1608    ) -> Self::TransferGift
1609    where
1610        N: Into<ChatId>;
1611
1612    type GetUserGifts: Request<Payload = GetUserGifts, Err = Self::Err>;
1613
1614    /// For Telegram documentation see [`GetUserGifts`].
1615    fn get_user_gifts(&self, user_id: UserId) -> Self::GetUserGifts;
1616
1617    type GetChatGifts: Request<Payload = GetChatGifts, Err = Self::Err>;
1618
1619    /// For Telegram documentation see [`GetChatGifts`].
1620    fn get_chat_gifts<C>(&self, chat_id: C) -> Self::GetChatGifts
1621    where
1622        C: Into<Recipient>;
1623
1624    type RepostStory: Request<Payload = RepostStory, Err = Self::Err>;
1625
1626    /// For Telegram documentation see [`RepostStory`].
1627    fn repost_story<F>(
1628        &self,
1629        business_connection_id: BusinessConnectionId,
1630        from_chat_id: F,
1631        from_story_id: StoryId,
1632        active_period: Seconds,
1633    ) -> Self::RepostStory
1634    where
1635        F: Into<ChatId>;
1636
1637    type PostStory: Request<Payload = PostStory, Err = Self::Err>;
1638
1639    /// For Telegram documentation see [`PostStory`].
1640    fn post_story(
1641        &self,
1642        business_connection_id: BusinessConnectionId,
1643        content: InputStoryContent,
1644        active_period: Seconds,
1645    ) -> Self::PostStory;
1646
1647    type EditStory: Request<Payload = EditStory, Err = Self::Err>;
1648
1649    /// For Telegram documentation see [`EditStory`].
1650    fn edit_story(
1651        &self,
1652        business_connection_id: BusinessConnectionId,
1653        story_id: StoryId,
1654        content: InputStoryContent,
1655    ) -> Self::EditStory;
1656
1657    type DeleteStory: Request<Payload = DeleteStory, Err = Self::Err>;
1658
1659    /// For Telegram documentation see [`DeleteStory`].
1660    fn delete_story(
1661        &self,
1662        business_connection_id: BusinessConnectionId,
1663        story_id: StoryId,
1664    ) -> Self::DeleteStory;
1665
1666    type SendInvoice: Request<Payload = SendInvoice, Err = Self::Err>;
1667
1668    /// For Telegram documentation see [`SendInvoice`].
1669    fn send_invoice<Ch, T, D, Pa, C, P>(
1670        &self,
1671        chat_id: Ch,
1672        title: T,
1673        description: D,
1674        payload: Pa,
1675        currency: C,
1676        prices: P,
1677    ) -> Self::SendInvoice
1678    where
1679        Ch: Into<Recipient>,
1680        T: Into<String>,
1681        D: Into<String>,
1682        Pa: Into<String>,
1683        C: Into<String>,
1684        P: IntoIterator<Item = LabeledPrice>;
1685
1686    type CreateInvoiceLink: Request<Payload = CreateInvoiceLink, Err = Self::Err>;
1687
1688    /// For Telegram documentation see [`CreateInvoiceLink`].
1689    fn create_invoice_link<T, D, Pa, C, P>(
1690        &self,
1691        title: T,
1692        description: D,
1693        payload: Pa,
1694        currency: C,
1695        prices: P,
1696    ) -> Self::CreateInvoiceLink
1697    where
1698        T: Into<String>,
1699        D: Into<String>,
1700        Pa: Into<String>,
1701        C: Into<String>,
1702        P: IntoIterator<Item = LabeledPrice>;
1703
1704    type AnswerShippingQuery: Request<Payload = AnswerShippingQuery, Err = Self::Err>;
1705
1706    /// For Telegram documentation see [`AnswerShippingQuery`].
1707    fn answer_shipping_query(
1708        &self,
1709        shipping_query_id: ShippingQueryId,
1710        ok: bool,
1711    ) -> Self::AnswerShippingQuery;
1712
1713    type AnswerPreCheckoutQuery: Request<Payload = AnswerPreCheckoutQuery, Err = Self::Err>;
1714
1715    /// For Telegram documentation see [`AnswerPreCheckoutQuery`].
1716    fn answer_pre_checkout_query(
1717        &self,
1718        pre_checkout_query_id: PreCheckoutQueryId,
1719        ok: bool,
1720    ) -> Self::AnswerPreCheckoutQuery;
1721
1722    type GetMyStarBalance: Request<Payload = GetMyStarBalance, Err = Self::Err>;
1723
1724    /// For Telegram documentation see [`GetMyStarBalance`].
1725    fn get_my_star_balance(&self) -> Self::GetMyStarBalance;
1726
1727    type GetStarTransactions: Request<Payload = GetStarTransactions, Err = Self::Err>;
1728
1729    /// For Telegram documentation see [`GetStarTransactions`].
1730    fn get_star_transactions(&self) -> Self::GetStarTransactions;
1731
1732    type RefundStarPayment: Request<Payload = RefundStarPayment, Err = Self::Err>;
1733
1734    /// For Telegram documentation see [`RefundStarPayment`].
1735    fn refund_star_payment(
1736        &self,
1737        user_id: UserId,
1738        telegram_payment_charge_id: TelegramTransactionId,
1739    ) -> Self::RefundStarPayment;
1740
1741    type EditUserStarSubscription: Request<Payload = EditUserStarSubscription, Err = Self::Err>;
1742
1743    /// For Telegram documentation see [`EditUserStarSubscription`].
1744    fn edit_user_star_subscription(
1745        &self,
1746        user_id: UserId,
1747        telegram_payment_charge_id: TelegramTransactionId,
1748        is_canceled: bool,
1749    ) -> Self::EditUserStarSubscription;
1750
1751    type SetPassportDataErrors: Request<Payload = SetPassportDataErrors, Err = Self::Err>;
1752
1753    /// For Telegram documentation see [`SetPassportDataErrors`].
1754    fn set_passport_data_errors<E>(
1755        &self,
1756        user_id: UserId,
1757        errors: E,
1758    ) -> Self::SetPassportDataErrors
1759    where
1760        E: IntoIterator<Item = PassportElementError>;
1761
1762    type SendGame: Request<Payload = SendGame, Err = Self::Err>;
1763
1764    /// For Telegram documentation see [`SendGame`].
1765    fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
1766    where
1767        C: Into<ChatId>,
1768        G: Into<String>;
1769
1770    type SetGameScore: Request<Payload = SetGameScore, Err = Self::Err>;
1771
1772    /// For Telegram documentation see [`SetGameScore`].
1773    fn set_game_score(
1774        &self,
1775        user_id: UserId,
1776        score: u64,
1777        chat_id: u32,
1778        message_id: MessageId,
1779    ) -> Self::SetGameScore;
1780
1781    type SetGameScoreInline: Request<Payload = SetGameScoreInline, Err = Self::Err>;
1782
1783    /// For Telegram documentation see [`SetGameScoreInline`].
1784    fn set_game_score_inline<I>(
1785        &self,
1786        user_id: UserId,
1787        score: u64,
1788        inline_message_id: I,
1789    ) -> Self::SetGameScoreInline
1790    where
1791        I: Into<String>;
1792
1793    type GetGameHighScores: Request<Payload = GetGameHighScores, Err = Self::Err>;
1794
1795    /// For Telegram documentation see [`GetGameHighScores`].
1796    fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
1797    where
1798        T: Into<TargetMessage>;
1799    // END BLOCK requester_methods
1800}
1801
1802macro_rules! fty {
1803    ($T:ident) => {
1804        B::$T
1805    };
1806}
1807
1808macro_rules! fwd_deref {
1809    ($m:ident $this:ident ($($arg:ident : $T:ty),*)) => {
1810        core::ops::Deref::deref($this).$m($($arg),*)
1811    };
1812}
1813
1814macro_rules! forward_all {
1815    ($body:ident, $ty:ident) => {
1816        requester_forward! {
1817            get_me,
1818            log_out,
1819            close,
1820            get_updates,
1821            set_webhook,
1822            delete_webhook,
1823            get_webhook_info,
1824            forward_message,
1825            forward_messages,
1826            copy_message,
1827            copy_messages,
1828            send_message,
1829            send_message_draft,
1830            send_photo,
1831            send_audio,
1832            send_document,
1833            send_video,
1834            send_animation,
1835            send_voice,
1836            send_video_note,
1837            send_paid_media,
1838            send_media_group,
1839            send_location,
1840            edit_message_live_location,
1841            edit_message_live_location_inline,
1842            stop_message_live_location,
1843            stop_message_live_location_inline,
1844            edit_message_checklist,
1845            send_venue,
1846            send_contact,
1847            send_poll,
1848            send_checklist,
1849            send_dice,
1850            send_chat_action,
1851            set_message_reaction,
1852            get_user_profile_photos,
1853            get_user_profile_audios,
1854            set_user_emoji_status,
1855            get_file,
1856            kick_chat_member,
1857            ban_chat_member,
1858            unban_chat_member,
1859            restrict_chat_member,
1860            promote_chat_member,
1861            set_chat_administrator_custom_title,
1862            set_chat_member_tag,
1863            ban_chat_sender_chat,
1864            unban_chat_sender_chat,
1865            set_chat_permissions,
1866            export_chat_invite_link,
1867            create_chat_invite_link,
1868            edit_chat_invite_link,
1869            create_chat_subscription_invite_link,
1870            edit_chat_subscription_invite_link,
1871            revoke_chat_invite_link,
1872            set_chat_photo,
1873            delete_chat_photo,
1874            set_chat_title,
1875            set_chat_description,
1876            pin_chat_message,
1877            unpin_chat_message,
1878            unpin_all_chat_messages,
1879            leave_chat,
1880            get_chat,
1881            get_chat_administrators,
1882            get_chat_members_count,
1883            get_chat_member_count,
1884            get_chat_member,
1885            set_chat_sticker_set,
1886            delete_chat_sticker_set,
1887            get_forum_topic_icon_stickers,
1888            create_forum_topic,
1889            edit_forum_topic,
1890            close_forum_topic,
1891            reopen_forum_topic,
1892            delete_forum_topic,
1893            unpin_all_forum_topic_messages,
1894            edit_general_forum_topic,
1895            close_general_forum_topic,
1896            reopen_general_forum_topic,
1897            hide_general_forum_topic,
1898            unhide_general_forum_topic,
1899            unpin_all_general_forum_topic_messages,
1900            answer_callback_query,
1901            get_user_chat_boosts,
1902            set_my_commands,
1903            get_business_connection,
1904            get_my_commands,
1905            set_my_name,
1906            get_my_name,
1907            set_my_description,
1908            get_my_description,
1909            set_my_short_description,
1910            get_my_short_description,
1911            set_my_profile_photo,
1912            remove_my_profile_photo,
1913        send_live_photo,
1914        get_user_personal_chat_messages,
1915        answer_guest_query,
1916        get_managed_bot_access_settings,
1917        set_managed_bot_access_settings,
1918        delete_message_reaction,
1919        delete_all_message_reactions,
1920            get_managed_bot_token,
1921            replace_managed_bot_token,
1922            save_prepared_keyboard_button,
1923            set_chat_menu_button,
1924            get_chat_menu_button,
1925            set_my_default_administrator_rights,
1926            get_my_default_administrator_rights,
1927            delete_my_commands,
1928            answer_inline_query,
1929            answer_web_app_query,
1930            save_prepared_inline_message,
1931            edit_message_text,
1932            edit_message_text_inline,
1933            edit_message_caption,
1934            edit_message_caption_inline,
1935            edit_message_media,
1936            edit_message_media_inline,
1937            edit_message_reply_markup,
1938            edit_message_reply_markup_inline,
1939            stop_poll,
1940            approve_suggested_post,
1941            decline_suggested_post,
1942            delete_message,
1943            delete_messages,
1944            send_sticker,
1945            get_sticker_set,
1946            get_custom_emoji_stickers,
1947            upload_sticker_file,
1948            create_new_sticker_set,
1949            add_sticker_to_set,
1950            set_sticker_position_in_set,
1951            delete_sticker_from_set,
1952            replace_sticker_in_set,
1953            set_sticker_set_thumbnail,
1954            set_custom_emoji_sticker_set_thumbnail,
1955            set_sticker_set_title,
1956            delete_sticker_set,
1957            set_sticker_emoji_list,
1958            set_sticker_keywords,
1959            set_sticker_mask_position,
1960            get_available_gifts,
1961            send_gift,
1962            send_gift_chat,
1963            gift_premium_subscription,
1964            verify_user,
1965            verify_chat,
1966            remove_user_verification,
1967            remove_chat_verification,
1968            read_business_message,
1969            delete_business_messages,
1970            set_business_account_name,
1971            set_business_account_username,
1972            set_business_account_bio,
1973            set_business_account_profile_photo,
1974            remove_business_account_profile_photo,
1975            set_business_account_gift_settings,
1976            get_business_account_star_balance,
1977            transfer_business_account_stars,
1978            get_business_account_gifts,
1979            get_user_gifts,
1980            get_chat_gifts,
1981            convert_gift_to_stars,
1982            upgrade_gift,
1983            transfer_gift,
1984            post_story,
1985            repost_story,
1986            edit_story,
1987            delete_story,
1988            send_invoice,
1989            create_invoice_link,
1990            answer_shipping_query,
1991            answer_pre_checkout_query,
1992            get_my_star_balance,
1993            get_star_transactions,
1994            refund_star_payment,
1995            edit_user_star_subscription,
1996            set_passport_data_errors,
1997            send_game,
1998            set_game_score,
1999            set_game_score_inline,
2000            get_game_high_scores,
2001            approve_chat_join_request,
2002            decline_chat_join_request
2003            => $body, $ty
2004        }
2005    };
2006    () => {
2007        forward_all! { fwd_deref, fty }
2008    };
2009}
2010
2011impl<B> Requester for &B
2012where
2013    B: Requester,
2014{
2015    type Err = B::Err;
2016
2017    forward_all! {}
2018}
2019
2020impl<B> Requester for &mut B
2021where
2022    B: Requester,
2023{
2024    type Err = B::Err;
2025
2026    forward_all! {}
2027}
2028
2029impl<B> Requester for Box<B>
2030where
2031    B: Requester,
2032{
2033    type Err = B::Err;
2034
2035    forward_all! {}
2036}
2037
2038impl<B> Requester for std::sync::Arc<B>
2039where
2040    B: Requester,
2041{
2042    type Err = B::Err;
2043
2044    forward_all! {}
2045}
2046
2047impl<B> Requester for std::rc::Rc<B>
2048where
2049    B: Requester,
2050{
2051    type Err = B::Err;
2052
2053    forward_all! {}
2054}
2055
2056// macro_rules! fty_either {
2057//     ($T:ident) => {
2058//         either::Either<LR::$T, RR::$T>
2059//     };
2060// }
2061
2062// macro_rules! fwd_either {
2063//     ($m:ident $this:ident ($($arg:ident : $T:ty),*)) => {
2064//         match ($this) {
2065//             either::Either::Left(l) => either::Either::Left(l.$m($($arg),*)),
2066//             either::Either::Right(r) =>
2067// either::Either::Right(r.$m($($arg),*)),         }
2068//     };
2069// }
2070
2071// impl<LR, RR> Requester for either::Either<LR, RR>
2072// where
2073//     LR: Requester,
2074//     RR: Requester<Err = LR::Err>,
2075// {
2076//     type Err = LR::Err;
2077
2078//     forward_all! { fwd_either, fty_either }
2079// }
2080
2081#[test]
2082// waffle: efficiency is not important here, and I don't want to rewrite this
2083#[allow(clippy::format_collect)]
2084fn codegen_requester_methods() {
2085    use crate::codegen::{
2086        add_hidden_preamble,
2087        convert::{convert_for, Convert},
2088        ensure_file_contents, min_prefix, project_root, reformat, replace_block,
2089        schema::{self, Type},
2090        to_uppercase,
2091    };
2092    use indexmap::IndexMap;
2093    use itertools::Itertools;
2094
2095    let schema = schema::get();
2096
2097    let methods = schema
2098        .methods
2099        .iter()
2100        .map(|m| {
2101            let mut convert_params = m
2102                .params
2103                .iter()
2104                .filter(|p| !matches!(p.ty, Type::Option(_)))
2105                .map(|p| (&p.name, convert_for(&p.ty)))
2106                .filter(|(_, c)| !matches!(c, Convert::Id(_)))
2107                .map(|(name, _)| &**name)
2108                .collect::<Vec<_>>();
2109
2110            convert_params.sort_unstable();
2111
2112            let prefixes: IndexMap<_, _> = convert_params
2113                .iter()
2114                .copied()
2115                // Workaround to output the last type as the first letter
2116                .chain(["\0"])
2117                .tuple_windows()
2118                .map(|(l, r)| (l, min_prefix(l, r)))
2119                .collect();
2120
2121            let args = m
2122                .params
2123                .iter()
2124                .filter(|p| !matches!(p.ty, schema::Type::Option(_)))
2125                .map(|p| match prefixes.get(&*p.name) {
2126                    Some(prefix) => format!("{}: {}", p.name, to_uppercase(prefix)),
2127                    None => format!("{}: {}", p.name, p.ty),
2128                })
2129                .join(", ");
2130
2131            let generics = m
2132                .params
2133                .iter()
2134                .flat_map(|p| prefixes.get(&*p.name))
2135                .copied()
2136                .map(to_uppercase)
2137                .join(", ");
2138            let where_clause = m
2139                .params
2140                .iter()
2141                .filter(|p| !matches!(p.ty, Type::Option(_)))
2142                .flat_map(|p| match convert_for(&p.ty) {
2143                    Convert::Id(_) => None,
2144                    Convert::Into(ty) => {
2145                        Some(format!("{}: Into<{}>", &to_uppercase(prefixes[&*p.name]), ty))
2146                    }
2147                    Convert::Collect(ty) => Some(format!(
2148                        "{}: IntoIterator<Item = {}>",
2149                        &to_uppercase(prefixes[&*p.name]),
2150                        ty
2151                    )),
2152                })
2153                .join(",\n        ");
2154
2155            let generics =
2156                if generics.is_empty() { String::from("") } else { format!("<{generics}>") };
2157
2158            let where_clause = if where_clause.is_empty() {
2159                String::from("")
2160            } else {
2161                format!(" where {where_clause}")
2162            };
2163
2164            format!(
2165                "
2166type {Method}: Request<Payload = {Method}, Err = Self::Err>;
2167
2168/// For Telegram documentation see [`{Method}`].
2169fn {method} {generics} (&self, {args}) -> Self::{Method}{where_clause};
2170            ",
2171                Method = m.names.1,
2172                method = m.names.2,
2173            )
2174        })
2175        .collect::<String>();
2176
2177    let path = project_root().join("src/requests/requester.rs");
2178
2179    ensure_file_contents(
2180        &path,
2181        &reformat(replace_block(
2182            &path,
2183            "requester_methods",
2184            &add_hidden_preamble("codegen_requester_methods", methods),
2185        )),
2186    );
2187}