Skip to main content

ronami_core/requests/
requester.rs

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