Skip to main content

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