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