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