Skip to main content

teloxide_core/bot/
api.rs

1use url::Url;
2
3use crate::{
4    payloads,
5    prelude::Requester,
6    requests::{JsonRequest, MultipartRequest},
7    types::{
8        AcceptedGiftTypes, BotCommand, BusinessConnectionId, CallbackQueryId, ChatId,
9        ChatJoinRequestQueryResult, ChatPermissions, CustomEmojiId, FileId, GiftId, InlineQueryId,
10        InlineQueryResult, InputChecklist, InputFile, InputGroupMedia, InputMedia, InputPaidMedia,
11        InputPollOption, InputProfilePhoto, InputRichMessage, InputSticker, InputStoryContent,
12        KeyboardButton, LabeledPrice, MessageId, OwnedGiftId, PreCheckoutQueryId, Recipient,
13        Seconds, ShippingQueryId, StickerFormat, StoryId, TelegramTransactionId, ThreadId, UserId,
14        WidgetId, WidgetQueryId,
15    },
16    Bot,
17};
18
19impl Requester for Bot {
20    type Err = crate::errors::RequestError;
21
22    type GetUpdates = JsonRequest<payloads::GetUpdates>;
23
24    fn get_updates(&self) -> Self::GetUpdates {
25        Self::GetUpdates::new(self.clone(), payloads::GetUpdates::new())
26    }
27
28    type SetWebhook = MultipartRequest<payloads::SetWebhook>;
29
30    fn set_webhook(&self, url: Url) -> Self::SetWebhook {
31        Self::SetWebhook::new(self.clone(), payloads::SetWebhook::new(url))
32    }
33
34    type DeleteWebhook = JsonRequest<payloads::DeleteWebhook>;
35
36    fn delete_webhook(&self) -> Self::DeleteWebhook {
37        Self::DeleteWebhook::new(self.clone(), payloads::DeleteWebhook::new())
38    }
39
40    type GetWebhookInfo = JsonRequest<payloads::GetWebhookInfo>;
41
42    fn get_webhook_info(&self) -> Self::GetWebhookInfo {
43        Self::GetWebhookInfo::new(self.clone(), payloads::GetWebhookInfo::new())
44    }
45
46    type SendWidget = JsonRequest<payloads::SendWidget>;
47
48    fn send_widget<C, H>(&self, chat_id: C, html: H) -> Self::SendWidget
49    where
50        C: Into<Recipient>,
51        H: Into<String>,
52    {
53        Self::SendWidget::new(self.clone(), payloads::SendWidget::new(chat_id, html))
54    }
55
56    type SendSharedWidget = JsonRequest<payloads::SendSharedWidget>;
57
58    fn send_shared_widget<C>(&self, chat_id: C, widget_id: WidgetId) -> Self::SendSharedWidget
59    where
60        C: Into<Recipient>,
61    {
62        Self::SendSharedWidget::new(
63            self.clone(),
64            payloads::SendSharedWidget::new(chat_id, widget_id),
65        )
66    }
67
68    type GetChatShareThemeBackdrops = JsonRequest<payloads::GetChatShareThemeBackdrops>;
69
70    fn get_chat_share_theme_backdrops(&self) -> Self::GetChatShareThemeBackdrops {
71        Self::GetChatShareThemeBackdrops::new(
72            self.clone(),
73            payloads::GetChatShareThemeBackdrops::new(),
74        )
75    }
76
77    type AnswerWidgetQuery = JsonRequest<payloads::AnswerWidgetQuery>;
78
79    fn answer_widget_query(&self, widget_query_id: WidgetQueryId) -> Self::AnswerWidgetQuery {
80        Self::AnswerWidgetQuery::new(
81            self.clone(),
82            payloads::AnswerWidgetQuery::new(widget_query_id),
83        )
84    }
85
86    type GetUniqueGift = JsonRequest<payloads::GetUniqueGift>;
87
88    fn get_unique_gift<N>(&self, name: N) -> Self::GetUniqueGift
89    where
90        N: Into<String>,
91    {
92        Self::GetUniqueGift::new(self.clone(), payloads::GetUniqueGift::new(name))
93    }
94
95    type DeleteBusinessAccountGift = JsonRequest<payloads::DeleteBusinessAccountGift>;
96
97    fn delete_business_account_gift(
98        &self,
99        business_connection_id: BusinessConnectionId,
100        owned_gift_id: OwnedGiftId,
101    ) -> Self::DeleteBusinessAccountGift {
102        Self::DeleteBusinessAccountGift::new(
103            self.clone(),
104            payloads::DeleteBusinessAccountGift::new(business_connection_id, owned_gift_id),
105        )
106    }
107
108    type EditMessageWidgetData = JsonRequest<payloads::EditMessageWidgetData>;
109
110    fn edit_message_widget_data<C>(
111        &self,
112        chat_id: C,
113        message_id: MessageId,
114    ) -> Self::EditMessageWidgetData
115    where
116        C: Into<Recipient>,
117    {
118        Self::EditMessageWidgetData::new(
119            self.clone(),
120            payloads::EditMessageWidgetData::new(chat_id, message_id),
121        )
122    }
123
124    type EditMessageWidgetDataInline = JsonRequest<payloads::EditMessageWidgetDataInline>;
125
126    fn edit_message_widget_data_inline<I>(
127        &self,
128        inline_message_id: I,
129    ) -> Self::EditMessageWidgetDataInline
130    where
131        I: Into<String>,
132    {
133        Self::EditMessageWidgetDataInline::new(
134            self.clone(),
135            payloads::EditMessageWidgetDataInline::new(inline_message_id),
136        )
137    }
138
139    type EditSharedWidgetData = JsonRequest<payloads::EditSharedWidgetData>;
140
141    fn edit_shared_widget_data<P>(
142        &self,
143        widget_id: WidgetId,
144        public_data: P,
145    ) -> Self::EditSharedWidgetData
146    where
147        P: Into<String>,
148    {
149        Self::EditSharedWidgetData::new(
150            self.clone(),
151            payloads::EditSharedWidgetData::new(widget_id, public_data),
152        )
153    }
154
155    type GetMe = JsonRequest<payloads::GetMe>;
156
157    fn get_me(&self) -> Self::GetMe {
158        Self::GetMe::new(self.clone(), payloads::GetMe::new())
159    }
160
161    type SendMessage = JsonRequest<payloads::SendMessage>;
162
163    fn send_message<T>(&self, text: T) -> Self::SendMessage
164    where
165        T: Into<String>,
166    {
167        Self::SendMessage::new(self.clone(), payloads::SendMessage::new(text))
168    }
169
170    type SendMessageDraft = JsonRequest<payloads::SendMessageDraft>;
171
172    fn send_message_draft<C>(&self, chat_id: C, draft_id: i64) -> Self::SendMessageDraft
173    where
174        C: Into<ChatId>,
175    {
176        Self::SendMessageDraft::new(
177            self.clone(),
178            payloads::SendMessageDraft::new(chat_id, draft_id),
179        )
180    }
181
182    type SendRichMessage = MultipartRequest<payloads::SendRichMessage>;
183
184    fn send_rich_message(&self, rich_message: InputRichMessage) -> Self::SendRichMessage {
185        Self::SendRichMessage::new(self.clone(), payloads::SendRichMessage::new(rich_message))
186    }
187
188    type SendRichMessageDraft = MultipartRequest<payloads::SendRichMessageDraft>;
189
190    fn send_rich_message_draft<C>(
191        &self,
192        chat_id: C,
193        draft_id: i64,
194        rich_message: InputRichMessage,
195    ) -> Self::SendRichMessageDraft
196    where
197        C: Into<ChatId>,
198    {
199        Self::SendRichMessageDraft::new(
200            self.clone(),
201            payloads::SendRichMessageDraft::new(chat_id, draft_id, rich_message),
202        )
203    }
204
205    type ForwardMessage = JsonRequest<payloads::ForwardMessage>;
206
207    fn forward_message<C, F>(
208        &self,
209        chat_id: C,
210        from_chat_id: F,
211        message_id: MessageId,
212    ) -> Self::ForwardMessage
213    where
214        C: Into<Recipient>,
215        F: Into<Recipient>,
216    {
217        Self::ForwardMessage::new(
218            self.clone(),
219            payloads::ForwardMessage::new(chat_id, from_chat_id, message_id),
220        )
221    }
222
223    type ForwardMessages = JsonRequest<payloads::ForwardMessages>;
224    fn forward_messages<C, F, M>(
225        &self,
226        chat_id: C,
227        from_chat_id: F,
228        message_ids: M,
229    ) -> Self::ForwardMessages
230    where
231        C: Into<Recipient>,
232        F: Into<Recipient>,
233        M: IntoIterator<Item = MessageId>,
234    {
235        Self::ForwardMessages::new(
236            self.clone(),
237            payloads::ForwardMessages::new(chat_id, from_chat_id, message_ids),
238        )
239    }
240
241    type SendPhoto = MultipartRequest<payloads::SendPhoto>;
242
243    fn send_photo(&self, photo: InputFile) -> Self::SendPhoto {
244        Self::SendPhoto::new(self.clone(), payloads::SendPhoto::new(photo))
245    }
246
247    type SendLivePhoto = MultipartRequest<payloads::SendLivePhoto>;
248
249    fn send_live_photo(&self, live_photo: InputFile, photo: InputFile) -> Self::SendLivePhoto {
250        Self::SendLivePhoto::new(self.clone(), payloads::SendLivePhoto::new(live_photo, photo))
251    }
252
253    type SendAudio = MultipartRequest<payloads::SendAudio>;
254
255    fn send_audio(&self, audio: InputFile) -> Self::SendAudio {
256        Self::SendAudio::new(self.clone(), payloads::SendAudio::new(audio))
257    }
258
259    type SendDocument = MultipartRequest<payloads::SendDocument>;
260
261    fn send_document(&self, document: InputFile) -> Self::SendDocument {
262        Self::SendDocument::new(self.clone(), payloads::SendDocument::new(document))
263    }
264
265    type SendVideo = MultipartRequest<payloads::SendVideo>;
266
267    fn send_video(&self, video: InputFile) -> Self::SendVideo {
268        Self::SendVideo::new(self.clone(), payloads::SendVideo::new(video))
269    }
270
271    type SendAnimation = MultipartRequest<payloads::SendAnimation>;
272
273    fn send_animation(&self, animation: InputFile) -> Self::SendAnimation {
274        Self::SendAnimation::new(self.clone(), payloads::SendAnimation::new(animation))
275    }
276
277    type SendVoice = MultipartRequest<payloads::SendVoice>;
278
279    fn send_voice(&self, voice: InputFile) -> Self::SendVoice {
280        Self::SendVoice::new(self.clone(), payloads::SendVoice::new(voice))
281    }
282
283    type SendVideoNote = MultipartRequest<payloads::SendVideoNote>;
284
285    fn send_video_note(&self, video_note: InputFile) -> Self::SendVideoNote {
286        Self::SendVideoNote::new(self.clone(), payloads::SendVideoNote::new(video_note))
287    }
288
289    type SendPaidMedia = MultipartRequest<payloads::SendPaidMedia>;
290
291    fn send_paid_media<C, M>(&self, chat_id: C, star_count: u32, media: M) -> Self::SendPaidMedia
292    where
293        C: Into<Recipient>,
294        M: IntoIterator<Item = InputPaidMedia>,
295    {
296        Self::SendPaidMedia::new(
297            self.clone(),
298            payloads::SendPaidMedia::new(chat_id, star_count, media),
299        )
300    }
301
302    type SendMediaGroup = MultipartRequest<payloads::SendMediaGroup>;
303
304    fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
305    where
306        C: Into<Recipient>,
307        M: IntoIterator<Item = InputGroupMedia>,
308    {
309        Self::SendMediaGroup::new(self.clone(), payloads::SendMediaGroup::new(chat_id, media))
310    }
311
312    type SendLocation = JsonRequest<payloads::SendLocation>;
313
314    fn send_location(&self, latitude: f64, longitude: f64) -> Self::SendLocation {
315        Self::SendLocation::new(self.clone(), payloads::SendLocation::new(latitude, longitude))
316    }
317
318    type EditMessageLiveLocation = JsonRequest<payloads::EditMessageLiveLocation>;
319
320    fn edit_message_live_location<C>(
321        &self,
322        chat_id: C,
323        message_id: MessageId,
324        latitude: f64,
325        longitude: f64,
326    ) -> Self::EditMessageLiveLocation
327    where
328        C: Into<Recipient>,
329    {
330        Self::EditMessageLiveLocation::new(
331            self.clone(),
332            payloads::EditMessageLiveLocation::new(chat_id, message_id, latitude, longitude),
333        )
334    }
335
336    type EditMessageLiveLocationInline = JsonRequest<payloads::EditMessageLiveLocationInline>;
337
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        Self::EditMessageLiveLocationInline::new(
348            self.clone(),
349            payloads::EditMessageLiveLocationInline::new(inline_message_id, latitude, longitude),
350        )
351    }
352
353    type StopMessageLiveLocation = JsonRequest<payloads::StopMessageLiveLocation>;
354
355    fn stop_message_live_location<C>(
356        &self,
357        chat_id: C,
358        message_id: MessageId,
359    ) -> Self::StopMessageLiveLocation
360    where
361        C: Into<Recipient>,
362    {
363        Self::StopMessageLiveLocation::new(
364            self.clone(),
365            payloads::StopMessageLiveLocation::new(chat_id, message_id),
366        )
367    }
368
369    type StopMessageLiveLocationInline = JsonRequest<payloads::StopMessageLiveLocationInline>;
370
371    fn stop_message_live_location_inline<I>(
372        &self,
373        inline_message_id: I,
374    ) -> Self::StopMessageLiveLocationInline
375    where
376        I: Into<String>,
377    {
378        Self::StopMessageLiveLocationInline::new(
379            self.clone(),
380            payloads::StopMessageLiveLocationInline::new(inline_message_id),
381        )
382    }
383
384    type EditMessageChecklist = JsonRequest<payloads::EditMessageChecklist>;
385
386    fn edit_message_checklist<C>(
387        &self,
388        business_connection_id: BusinessConnectionId,
389        chat_id: C,
390        message_id: MessageId,
391        checklist: InputChecklist,
392    ) -> Self::EditMessageChecklist
393    where
394        C: Into<ChatId>,
395    {
396        Self::EditMessageChecklist::new(
397            self.clone(),
398            payloads::EditMessageChecklist::new(
399                business_connection_id,
400                chat_id,
401                message_id,
402                checklist,
403            ),
404        )
405    }
406
407    type SendVenue = JsonRequest<payloads::SendVenue>;
408
409    fn send_venue<T, A>(
410        &self,
411        latitude: f64,
412        longitude: f64,
413        title: T,
414        address: A,
415    ) -> Self::SendVenue
416    where
417        T: Into<String>,
418        A: Into<String>,
419    {
420        Self::SendVenue::new(
421            self.clone(),
422            payloads::SendVenue::new(latitude, longitude, title, address),
423        )
424    }
425
426    type SendContact = JsonRequest<payloads::SendContact>;
427
428    fn send_contact<P, F>(&self, phone_number: P, first_name: F) -> Self::SendContact
429    where
430        P: Into<String>,
431        F: Into<String>,
432    {
433        Self::SendContact::new(self.clone(), payloads::SendContact::new(phone_number, first_name))
434    }
435
436    type SendPoll = MultipartRequest<payloads::SendPoll>;
437
438    fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
439    where
440        C: Into<Recipient>,
441        Q: Into<String>,
442        O: IntoIterator<Item = InputPollOption>,
443    {
444        Self::SendPoll::new(self.clone(), payloads::SendPoll::new(chat_id, question, options))
445    }
446
447    type SendChecklist = JsonRequest<payloads::SendChecklist>;
448
449    fn send_checklist<C>(
450        &self,
451        business_connection_id: BusinessConnectionId,
452        chat_id: C,
453        checklist: InputChecklist,
454    ) -> Self::SendChecklist
455    where
456        C: Into<ChatId>,
457    {
458        Self::SendChecklist::new(
459            self.clone(),
460            payloads::SendChecklist::new(business_connection_id, chat_id, checklist),
461        )
462    }
463
464    type SendDice = JsonRequest<payloads::SendDice>;
465
466    fn send_dice<C>(&self, chat_id: C) -> Self::SendDice
467    where
468        C: Into<Recipient>,
469    {
470        Self::SendDice::new(self.clone(), payloads::SendDice::new(chat_id))
471    }
472
473    type SendChatAction = JsonRequest<payloads::SendChatAction>;
474
475    fn send_chat_action<C>(
476        &self,
477        chat_id: C,
478        action: crate::types::ChatAction,
479    ) -> Self::SendChatAction
480    where
481        C: Into<Recipient>,
482    {
483        Self::SendChatAction::new(self.clone(), payloads::SendChatAction::new(chat_id, action))
484    }
485
486    type SetMessageReaction = JsonRequest<payloads::SetMessageReaction>;
487
488    fn set_message_reaction<C>(&self, chat_id: C, message_id: MessageId) -> Self::SetMessageReaction
489    where
490        C: Into<Recipient>,
491    {
492        Self::SetMessageReaction::new(
493            self.clone(),
494            payloads::SetMessageReaction::new(chat_id, message_id),
495        )
496    }
497
498    type GetUserProfilePhotos = JsonRequest<payloads::GetUserProfilePhotos>;
499
500    fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos {
501        Self::GetUserProfilePhotos::new(self.clone(), payloads::GetUserProfilePhotos::new(user_id))
502    }
503
504    type SetUserEmojiStatus = JsonRequest<payloads::SetUserEmojiStatus>;
505
506    fn set_user_emoji_status(&self, user_id: UserId) -> Self::SetUserEmojiStatus {
507        Self::SetUserEmojiStatus::new(self.clone(), payloads::SetUserEmojiStatus::new(user_id))
508    }
509
510    type GetFile = JsonRequest<payloads::GetFile>;
511
512    fn get_file(&self, file_id: FileId) -> Self::GetFile {
513        Self::GetFile::new(self.clone(), payloads::GetFile::new(file_id))
514    }
515
516    type KickChatMember = JsonRequest<payloads::KickChatMember>;
517
518    fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember
519    where
520        C: Into<Recipient>,
521    {
522        Self::KickChatMember::new(self.clone(), payloads::KickChatMember::new(chat_id, user_id))
523    }
524
525    type BanChatMember = JsonRequest<payloads::BanChatMember>;
526
527    fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember
528    where
529        C: Into<Recipient>,
530    {
531        Self::BanChatMember::new(self.clone(), payloads::BanChatMember::new(chat_id, user_id))
532    }
533
534    type UnbanChatMember = JsonRequest<payloads::UnbanChatMember>;
535
536    fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember
537    where
538        C: Into<Recipient>,
539    {
540        Self::UnbanChatMember::new(self.clone(), payloads::UnbanChatMember::new(chat_id, user_id))
541    }
542
543    type RestrictChatMember = JsonRequest<payloads::RestrictChatMember>;
544
545    fn restrict_chat_member<C>(
546        &self,
547        chat_id: C,
548        user_id: UserId,
549        permissions: ChatPermissions,
550    ) -> Self::RestrictChatMember
551    where
552        C: Into<Recipient>,
553    {
554        Self::RestrictChatMember::new(
555            self.clone(),
556            payloads::RestrictChatMember::new(chat_id, user_id, permissions),
557        )
558    }
559
560    type PromoteChatMember = JsonRequest<payloads::PromoteChatMember>;
561
562    fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember
563    where
564        C: Into<Recipient>,
565    {
566        Self::PromoteChatMember::new(
567            self.clone(),
568            payloads::PromoteChatMember::new(chat_id, user_id),
569        )
570    }
571
572    type SetChatAdministratorCustomTitle = JsonRequest<payloads::SetChatAdministratorCustomTitle>;
573
574    fn set_chat_administrator_custom_title<Ch, Cu>(
575        &self,
576        chat_id: Ch,
577        user_id: UserId,
578        custom_title: Cu,
579    ) -> Self::SetChatAdministratorCustomTitle
580    where
581        Ch: Into<Recipient>,
582        Cu: Into<String>,
583    {
584        Self::SetChatAdministratorCustomTitle::new(
585            self.clone(),
586            payloads::SetChatAdministratorCustomTitle::new(chat_id, user_id, custom_title),
587        )
588    }
589
590    type SetChatMemberTag = JsonRequest<payloads::SetChatMemberTag>;
591
592    fn set_chat_member_tag<C>(&self, chat_id: C, user_id: UserId) -> Self::SetChatMemberTag
593    where
594        C: Into<Recipient>,
595    {
596        Self::SetChatMemberTag::new(self.clone(), payloads::SetChatMemberTag::new(chat_id, user_id))
597    }
598
599    type BanChatSenderChat = JsonRequest<payloads::BanChatSenderChat>;
600
601    fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat
602    where
603        C: Into<Recipient>,
604        S: Into<ChatId>,
605    {
606        Self::BanChatSenderChat::new(
607            self.clone(),
608            payloads::BanChatSenderChat::new(chat_id, sender_chat_id),
609        )
610    }
611
612    type UnbanChatSenderChat = JsonRequest<payloads::UnbanChatSenderChat>;
613
614    fn unban_chat_sender_chat<C, S>(
615        &self,
616        chat_id: C,
617        sender_chat_id: S,
618    ) -> Self::UnbanChatSenderChat
619    where
620        C: Into<Recipient>,
621        S: Into<ChatId>,
622    {
623        Self::UnbanChatSenderChat::new(
624            self.clone(),
625            payloads::UnbanChatSenderChat::new(chat_id, sender_chat_id),
626        )
627    }
628
629    type SetChatPermissions = JsonRequest<payloads::SetChatPermissions>;
630
631    fn set_chat_permissions<C>(
632        &self,
633        chat_id: C,
634        permissions: ChatPermissions,
635    ) -> Self::SetChatPermissions
636    where
637        C: Into<Recipient>,
638    {
639        Self::SetChatPermissions::new(
640            self.clone(),
641            payloads::SetChatPermissions::new(chat_id, permissions),
642        )
643    }
644
645    type ExportChatInviteLink = JsonRequest<payloads::ExportChatInviteLink>;
646
647    fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
648    where
649        C: Into<Recipient>,
650    {
651        Self::ExportChatInviteLink::new(self.clone(), payloads::ExportChatInviteLink::new(chat_id))
652    }
653
654    type CreateChatInviteLink = JsonRequest<payloads::CreateChatInviteLink>;
655
656    fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
657    where
658        C: Into<Recipient>,
659    {
660        Self::CreateChatInviteLink::new(self.clone(), payloads::CreateChatInviteLink::new(chat_id))
661    }
662
663    type EditChatInviteLink = JsonRequest<payloads::EditChatInviteLink>;
664
665    fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
666    where
667        C: Into<Recipient>,
668        I: Into<String>,
669    {
670        Self::EditChatInviteLink::new(
671            self.clone(),
672            payloads::EditChatInviteLink::new(chat_id, invite_link),
673        )
674    }
675
676    type CreateChatSubscriptionInviteLink = JsonRequest<payloads::CreateChatSubscriptionInviteLink>;
677
678    fn create_chat_subscription_invite_link<C>(
679        &self,
680        chat_id: C,
681        subscription_period: Seconds,
682        subscription_price: u32,
683    ) -> Self::CreateChatSubscriptionInviteLink
684    where
685        C: Into<Recipient>,
686    {
687        Self::CreateChatSubscriptionInviteLink::new(
688            self.clone(),
689            payloads::CreateChatSubscriptionInviteLink::new(
690                chat_id,
691                subscription_period,
692                subscription_price,
693            ),
694        )
695    }
696
697    type EditChatSubscriptionInviteLink = JsonRequest<payloads::EditChatSubscriptionInviteLink>;
698
699    fn edit_chat_subscription_invite_link<C, I>(
700        &self,
701        chat_id: C,
702        invite_link: I,
703    ) -> Self::EditChatSubscriptionInviteLink
704    where
705        C: Into<Recipient>,
706        I: Into<String>,
707    {
708        Self::EditChatSubscriptionInviteLink::new(
709            self.clone(),
710            payloads::EditChatSubscriptionInviteLink::new(chat_id, invite_link),
711        )
712    }
713
714    type RevokeChatInviteLink = JsonRequest<payloads::RevokeChatInviteLink>;
715
716    fn revoke_chat_invite_link<C, I>(
717        &self,
718        chat_id: C,
719        invite_link: I,
720    ) -> Self::RevokeChatInviteLink
721    where
722        C: Into<Recipient>,
723        I: Into<String>,
724    {
725        Self::RevokeChatInviteLink::new(
726            self.clone(),
727            payloads::RevokeChatInviteLink::new(chat_id, invite_link),
728        )
729    }
730
731    type ApproveChatJoinRequest = JsonRequest<payloads::ApproveChatJoinRequest>;
732
733    fn approve_chat_join_request<C>(
734        &self,
735        chat_id: C,
736        user_id: UserId,
737    ) -> Self::ApproveChatJoinRequest
738    where
739        C: Into<Recipient>,
740    {
741        Self::ApproveChatJoinRequest::new(
742            self.clone(),
743            payloads::ApproveChatJoinRequest::new(chat_id, user_id),
744        )
745    }
746
747    type DeclineChatJoinRequest = JsonRequest<payloads::DeclineChatJoinRequest>;
748
749    fn decline_chat_join_request<C>(
750        &self,
751        chat_id: C,
752        user_id: UserId,
753    ) -> Self::DeclineChatJoinRequest
754    where
755        C: Into<Recipient>,
756    {
757        Self::DeclineChatJoinRequest::new(
758            self.clone(),
759            payloads::DeclineChatJoinRequest::new(chat_id, user_id),
760        )
761    }
762
763    type AnswerChatJoinRequestQuery = JsonRequest<payloads::AnswerChatJoinRequestQuery>;
764
765    fn answer_chat_join_request_query<C>(
766        &self,
767        chat_join_request_query_id: C,
768        result: ChatJoinRequestQueryResult,
769    ) -> Self::AnswerChatJoinRequestQuery
770    where
771        C: Into<String>,
772    {
773        Self::AnswerChatJoinRequestQuery::new(
774            self.clone(),
775            payloads::AnswerChatJoinRequestQuery::new(chat_join_request_query_id, result),
776        )
777    }
778
779    type SendChatJoinRequestWebApp = JsonRequest<payloads::SendChatJoinRequestWebApp>;
780
781    fn send_chat_join_request_web_app<C, W>(
782        &self,
783        chat_join_request_query_id: C,
784        web_app_url: W,
785    ) -> Self::SendChatJoinRequestWebApp
786    where
787        C: Into<String>,
788        W: Into<String>,
789    {
790        Self::SendChatJoinRequestWebApp::new(
791            self.clone(),
792            payloads::SendChatJoinRequestWebApp::new(chat_join_request_query_id, web_app_url),
793        )
794    }
795
796    type SetChatPhoto = MultipartRequest<payloads::SetChatPhoto>;
797
798    fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
799    where
800        C: Into<Recipient>,
801    {
802        Self::SetChatPhoto::new(self.clone(), payloads::SetChatPhoto::new(chat_id, photo))
803    }
804
805    type DeleteChatPhoto = JsonRequest<payloads::DeleteChatPhoto>;
806
807    fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
808    where
809        C: Into<Recipient>,
810    {
811        Self::DeleteChatPhoto::new(self.clone(), payloads::DeleteChatPhoto::new(chat_id))
812    }
813
814    type SetChatTitle = JsonRequest<payloads::SetChatTitle>;
815
816    fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
817    where
818        C: Into<Recipient>,
819        T: Into<String>,
820    {
821        Self::SetChatTitle::new(self.clone(), payloads::SetChatTitle::new(chat_id, title))
822    }
823
824    type SetChatDescription = JsonRequest<payloads::SetChatDescription>;
825
826    fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
827    where
828        C: Into<Recipient>,
829    {
830        Self::SetChatDescription::new(self.clone(), payloads::SetChatDescription::new(chat_id))
831    }
832
833    type PinChatMessage = JsonRequest<payloads::PinChatMessage>;
834
835    fn pin_chat_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::PinChatMessage
836    where
837        C: Into<Recipient>,
838    {
839        Self::PinChatMessage::new(self.clone(), payloads::PinChatMessage::new(chat_id, message_id))
840    }
841
842    type UnpinChatMessage = JsonRequest<payloads::UnpinChatMessage>;
843
844    fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
845    where
846        C: Into<Recipient>,
847    {
848        Self::UnpinChatMessage::new(self.clone(), payloads::UnpinChatMessage::new(chat_id))
849    }
850
851    type LeaveChat = JsonRequest<payloads::LeaveChat>;
852
853    fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
854    where
855        C: Into<Recipient>,
856    {
857        Self::LeaveChat::new(self.clone(), payloads::LeaveChat::new(chat_id))
858    }
859
860    type GetChat = JsonRequest<payloads::GetChat>;
861
862    fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
863    where
864        C: Into<Recipient>,
865    {
866        Self::GetChat::new(self.clone(), payloads::GetChat::new(chat_id))
867    }
868
869    type GetChatAdministrators = JsonRequest<payloads::GetChatAdministrators>;
870
871    fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
872    where
873        C: Into<Recipient>,
874    {
875        Self::GetChatAdministrators::new(
876            self.clone(),
877            payloads::GetChatAdministrators::new(chat_id),
878        )
879    }
880
881    type GetChatMembersCount = JsonRequest<payloads::GetChatMembersCount>;
882
883    fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
884    where
885        C: Into<Recipient>,
886    {
887        Self::GetChatMembersCount::new(self.clone(), payloads::GetChatMembersCount::new(chat_id))
888    }
889
890    type GetChatMemberCount = JsonRequest<payloads::GetChatMemberCount>;
891
892    fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
893    where
894        C: Into<Recipient>,
895    {
896        Self::GetChatMemberCount::new(self.clone(), payloads::GetChatMemberCount::new(chat_id))
897    }
898
899    type GetChatMember = JsonRequest<payloads::GetChatMember>;
900
901    fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember
902    where
903        C: Into<Recipient>,
904    {
905        Self::GetChatMember::new(self.clone(), payloads::GetChatMember::new(chat_id, user_id))
906    }
907
908    type GetUserPersonalChatMessages = JsonRequest<payloads::GetUserPersonalChatMessages>;
909
910    fn get_user_personal_chat_messages(
911        &self,
912        user_id: UserId,
913        limit: u8,
914    ) -> Self::GetUserPersonalChatMessages {
915        Self::GetUserPersonalChatMessages::new(
916            self.clone(),
917            payloads::GetUserPersonalChatMessages::new(user_id, limit),
918        )
919    }
920
921    type SetChatStickerSet = JsonRequest<payloads::SetChatStickerSet>;
922
923    fn set_chat_sticker_set<C, S>(&self, chat_id: C, sticker_set_name: S) -> Self::SetChatStickerSet
924    where
925        C: Into<Recipient>,
926        S: Into<String>,
927    {
928        Self::SetChatStickerSet::new(
929            self.clone(),
930            payloads::SetChatStickerSet::new(chat_id, sticker_set_name),
931        )
932    }
933
934    type DeleteChatStickerSet = JsonRequest<payloads::DeleteChatStickerSet>;
935
936    fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
937    where
938        C: Into<Recipient>,
939    {
940        Self::DeleteChatStickerSet::new(self.clone(), payloads::DeleteChatStickerSet::new(chat_id))
941    }
942
943    type GetForumTopicIconStickers = JsonRequest<payloads::GetForumTopicIconStickers>;
944
945    fn get_forum_topic_icon_stickers(&self) -> Self::GetForumTopicIconStickers {
946        Self::GetForumTopicIconStickers::new(
947            self.clone(),
948            payloads::GetForumTopicIconStickers::new(),
949        )
950    }
951
952    type CreateForumTopic = JsonRequest<payloads::CreateForumTopic>;
953
954    fn create_forum_topic<C, N>(&self, chat_id: C, name: N) -> Self::CreateForumTopic
955    where
956        C: Into<Recipient>,
957        N: Into<String>,
958    {
959        Self::CreateForumTopic::new(self.clone(), payloads::CreateForumTopic::new(chat_id, name))
960    }
961
962    type EditForumTopic = JsonRequest<payloads::EditForumTopic>;
963
964    fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic
965    where
966        C: Into<Recipient>,
967    {
968        Self::EditForumTopic::new(
969            self.clone(),
970            payloads::EditForumTopic::new(chat_id, message_thread_id),
971        )
972    }
973
974    type CloseForumTopic = JsonRequest<payloads::CloseForumTopic>;
975
976    fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::CloseForumTopic
977    where
978        C: Into<Recipient>,
979    {
980        Self::CloseForumTopic::new(
981            self.clone(),
982            payloads::CloseForumTopic::new(chat_id, message_thread_id),
983        )
984    }
985
986    type ReopenForumTopic = JsonRequest<payloads::ReopenForumTopic>;
987
988    fn reopen_forum_topic<C>(
989        &self,
990        chat_id: C,
991        message_thread_id: ThreadId,
992    ) -> Self::ReopenForumTopic
993    where
994        C: Into<Recipient>,
995    {
996        Self::ReopenForumTopic::new(
997            self.clone(),
998            payloads::ReopenForumTopic::new(chat_id, message_thread_id),
999        )
1000    }
1001
1002    type DeleteForumTopic = JsonRequest<payloads::DeleteForumTopic>;
1003
1004    fn delete_forum_topic<C>(
1005        &self,
1006        chat_id: C,
1007        message_thread_id: ThreadId,
1008    ) -> Self::DeleteForumTopic
1009    where
1010        C: Into<Recipient>,
1011    {
1012        Self::DeleteForumTopic::new(
1013            self.clone(),
1014            payloads::DeleteForumTopic::new(chat_id, message_thread_id),
1015        )
1016    }
1017
1018    type UnpinAllForumTopicMessages = JsonRequest<payloads::UnpinAllForumTopicMessages>;
1019
1020    fn unpin_all_forum_topic_messages<C>(
1021        &self,
1022        chat_id: C,
1023        message_thread_id: ThreadId,
1024    ) -> Self::UnpinAllForumTopicMessages
1025    where
1026        C: Into<Recipient>,
1027    {
1028        Self::UnpinAllForumTopicMessages::new(
1029            self.clone(),
1030            payloads::UnpinAllForumTopicMessages::new(chat_id, message_thread_id),
1031        )
1032    }
1033
1034    type EditGeneralForumTopic = JsonRequest<payloads::EditGeneralForumTopic>;
1035
1036    fn edit_general_forum_topic<C, N>(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic
1037    where
1038        C: Into<Recipient>,
1039        N: Into<String>,
1040    {
1041        Self::EditGeneralForumTopic::new(
1042            self.clone(),
1043            payloads::EditGeneralForumTopic::new(chat_id, name),
1044        )
1045    }
1046
1047    type CloseGeneralForumTopic = JsonRequest<payloads::CloseGeneralForumTopic>;
1048
1049    fn close_general_forum_topic<C>(&self, chat_id: C) -> Self::CloseGeneralForumTopic
1050    where
1051        C: Into<Recipient>,
1052    {
1053        Self::CloseGeneralForumTopic::new(
1054            self.clone(),
1055            payloads::CloseGeneralForumTopic::new(chat_id),
1056        )
1057    }
1058
1059    type ReopenGeneralForumTopic = JsonRequest<payloads::ReopenGeneralForumTopic>;
1060
1061    fn reopen_general_forum_topic<C>(&self, chat_id: C) -> Self::ReopenGeneralForumTopic
1062    where
1063        C: Into<Recipient>,
1064    {
1065        Self::ReopenGeneralForumTopic::new(
1066            self.clone(),
1067            payloads::ReopenGeneralForumTopic::new(chat_id),
1068        )
1069    }
1070
1071    type HideGeneralForumTopic = JsonRequest<payloads::HideGeneralForumTopic>;
1072
1073    fn hide_general_forum_topic<C>(&self, chat_id: C) -> Self::HideGeneralForumTopic
1074    where
1075        C: Into<Recipient>,
1076    {
1077        Self::HideGeneralForumTopic::new(
1078            self.clone(),
1079            payloads::HideGeneralForumTopic::new(chat_id),
1080        )
1081    }
1082
1083    type UnhideGeneralForumTopic = JsonRequest<payloads::UnhideGeneralForumTopic>;
1084
1085    fn unhide_general_forum_topic<C>(&self, chat_id: C) -> Self::UnhideGeneralForumTopic
1086    where
1087        C: Into<Recipient>,
1088    {
1089        Self::UnhideGeneralForumTopic::new(
1090            self.clone(),
1091            payloads::UnhideGeneralForumTopic::new(chat_id),
1092        )
1093    }
1094
1095    type UnpinAllGeneralForumTopicMessages =
1096        JsonRequest<payloads::UnpinAllGeneralForumTopicMessages>;
1097
1098    fn unpin_all_general_forum_topic_messages<C>(
1099        &self,
1100        chat_id: C,
1101    ) -> Self::UnpinAllGeneralForumTopicMessages
1102    where
1103        C: Into<Recipient>,
1104    {
1105        Self::UnpinAllGeneralForumTopicMessages::new(
1106            self.clone(),
1107            payloads::UnpinAllGeneralForumTopicMessages::new(chat_id),
1108        )
1109    }
1110
1111    type AnswerCallbackQuery = JsonRequest<payloads::AnswerCallbackQuery>;
1112
1113    fn answer_callback_query(
1114        &self,
1115        callback_query_id: CallbackQueryId,
1116    ) -> Self::AnswerCallbackQuery {
1117        Self::AnswerCallbackQuery::new(
1118            self.clone(),
1119            payloads::AnswerCallbackQuery::new(callback_query_id),
1120        )
1121    }
1122
1123    type GetUserChatBoosts = JsonRequest<payloads::GetUserChatBoosts>;
1124
1125    fn get_user_chat_boosts<C>(&self, chat_id: C, user_id: UserId) -> Self::GetUserChatBoosts
1126    where
1127        C: Into<Recipient>,
1128    {
1129        Self::GetUserChatBoosts::new(
1130            self.clone(),
1131            payloads::GetUserChatBoosts::new(chat_id, user_id),
1132        )
1133    }
1134
1135    type SetMyCommands = JsonRequest<payloads::SetMyCommands>;
1136
1137    fn set_my_commands<C>(&self, commands: C) -> Self::SetMyCommands
1138    where
1139        C: IntoIterator<Item = BotCommand>,
1140    {
1141        Self::SetMyCommands::new(self.clone(), payloads::SetMyCommands::new(commands))
1142    }
1143
1144    type GetBusinessConnection = JsonRequest<payloads::GetBusinessConnection>;
1145
1146    fn get_business_connection(
1147        &self,
1148        business_connection_id: BusinessConnectionId,
1149    ) -> Self::GetBusinessConnection {
1150        Self::GetBusinessConnection::new(
1151            self.clone(),
1152            payloads::GetBusinessConnection::new(business_connection_id),
1153        )
1154    }
1155
1156    type GetMyCommands = JsonRequest<payloads::GetMyCommands>;
1157
1158    fn get_my_commands(&self) -> Self::GetMyCommands {
1159        Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new())
1160    }
1161
1162    type SetMySettings = JsonRequest<payloads::SetMySettings>;
1163
1164    fn set_my_settings(&self) -> Self::SetMySettings {
1165        Self::SetMySettings::new(self.clone(), payloads::SetMySettings::new())
1166    }
1167
1168    type SetMyName = JsonRequest<payloads::SetMyName>;
1169
1170    fn set_my_name(&self) -> Self::SetMyName {
1171        Self::SetMyName::new(self.clone(), payloads::SetMyName::new())
1172    }
1173
1174    type GetMyName = JsonRequest<payloads::GetMyName>;
1175
1176    fn get_my_name(&self) -> Self::GetMyName {
1177        Self::GetMyName::new(self.clone(), payloads::GetMyName::new())
1178    }
1179
1180    type SetMyDescription = JsonRequest<payloads::SetMyDescription>;
1181
1182    fn set_my_description(&self) -> Self::SetMyDescription {
1183        Self::SetMyDescription::new(self.clone(), payloads::SetMyDescription::new())
1184    }
1185
1186    type GetMyDescription = JsonRequest<payloads::GetMyDescription>;
1187
1188    fn get_my_description(&self) -> Self::GetMyDescription {
1189        Self::GetMyDescription::new(self.clone(), payloads::GetMyDescription::new())
1190    }
1191
1192    type SetMyShortDescription = JsonRequest<payloads::SetMyShortDescription>;
1193
1194    fn set_my_short_description(&self) -> Self::SetMyShortDescription {
1195        Self::SetMyShortDescription::new(self.clone(), payloads::SetMyShortDescription::new())
1196    }
1197
1198    type GetMyShortDescription = JsonRequest<payloads::GetMyShortDescription>;
1199    fn get_my_short_description(&self) -> Self::GetMyShortDescription {
1200        Self::GetMyShortDescription::new(self.clone(), payloads::GetMyShortDescription::new())
1201    }
1202
1203    type SetChatMenuButton = JsonRequest<payloads::SetChatMenuButton>;
1204
1205    fn set_chat_menu_button(&self) -> Self::SetChatMenuButton {
1206        Self::SetChatMenuButton::new(self.clone(), payloads::SetChatMenuButton::new())
1207    }
1208
1209    type GetChatMenuButton = JsonRequest<payloads::GetChatMenuButton>;
1210
1211    fn get_chat_menu_button(&self) -> Self::GetChatMenuButton {
1212        Self::GetChatMenuButton::new(self.clone(), payloads::GetChatMenuButton::new())
1213    }
1214
1215    type SetMyProfilePhoto = JsonRequest<payloads::SetMyProfilePhoto>;
1216
1217    fn set_my_profile_photo(&self, photo: InputProfilePhoto) -> Self::SetMyProfilePhoto {
1218        Self::SetMyProfilePhoto::new(self.clone(), payloads::SetMyProfilePhoto::new(photo))
1219    }
1220
1221    type RemoveMyProfilePhoto = JsonRequest<payloads::RemoveMyProfilePhoto>;
1222
1223    fn remove_my_profile_photo(&self) -> Self::RemoveMyProfilePhoto {
1224        Self::RemoveMyProfilePhoto::new(self.clone(), payloads::RemoveMyProfilePhoto::new())
1225    }
1226
1227    type SetMyDefaultAdministratorRights = JsonRequest<payloads::SetMyDefaultAdministratorRights>;
1228
1229    fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights {
1230        Self::SetMyDefaultAdministratorRights::new(
1231            self.clone(),
1232            payloads::SetMyDefaultAdministratorRights::new(),
1233        )
1234    }
1235
1236    type GetMyDefaultAdministratorRights = JsonRequest<payloads::GetMyDefaultAdministratorRights>;
1237
1238    fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights {
1239        Self::GetMyDefaultAdministratorRights::new(
1240            self.clone(),
1241            payloads::GetMyDefaultAdministratorRights::new(),
1242        )
1243    }
1244
1245    type DeleteMyCommands = JsonRequest<payloads::DeleteMyCommands>;
1246
1247    fn delete_my_commands(&self) -> Self::DeleteMyCommands {
1248        Self::DeleteMyCommands::new(self.clone(), payloads::DeleteMyCommands::new())
1249    }
1250
1251    type AnswerInlineQuery = JsonRequest<payloads::AnswerInlineQuery>;
1252
1253    fn answer_inline_query<R>(
1254        &self,
1255        inline_query_id: InlineQueryId,
1256        results: R,
1257    ) -> Self::AnswerInlineQuery
1258    where
1259        R: IntoIterator<Item = InlineQueryResult>,
1260    {
1261        Self::AnswerInlineQuery::new(
1262            self.clone(),
1263            payloads::AnswerInlineQuery::new(inline_query_id, results),
1264        )
1265    }
1266
1267    type AnswerGuestQuery = JsonRequest<payloads::AnswerGuestQuery>;
1268
1269    fn answer_guest_query<G>(
1270        &self,
1271        guest_query_id: G,
1272        result: InlineQueryResult,
1273    ) -> Self::AnswerGuestQuery
1274    where
1275        G: Into<String>,
1276    {
1277        Self::AnswerGuestQuery::new(
1278            self.clone(),
1279            payloads::AnswerGuestQuery::new(guest_query_id, result),
1280        )
1281    }
1282
1283    type AnswerWebAppQuery = JsonRequest<payloads::AnswerWebAppQuery>;
1284
1285    fn answer_web_app_query<W>(
1286        &self,
1287        web_app_query_id: W,
1288        result: InlineQueryResult,
1289    ) -> Self::AnswerWebAppQuery
1290    where
1291        W: Into<String>,
1292    {
1293        Self::AnswerWebAppQuery::new(
1294            self.clone(),
1295            payloads::AnswerWebAppQuery::new(web_app_query_id, result),
1296        )
1297    }
1298
1299    type SavePreparedInlineMessage = JsonRequest<payloads::SavePreparedInlineMessage>;
1300
1301    fn save_prepared_inline_message(
1302        &self,
1303        user_id: UserId,
1304        result: InlineQueryResult,
1305    ) -> Self::SavePreparedInlineMessage {
1306        Self::SavePreparedInlineMessage::new(
1307            self.clone(),
1308            payloads::SavePreparedInlineMessage::new(user_id, result),
1309        )
1310    }
1311
1312    type GetManagedBotToken = JsonRequest<payloads::GetManagedBotToken>;
1313
1314    fn get_managed_bot_token(&self, user_id: UserId) -> Self::GetManagedBotToken {
1315        Self::GetManagedBotToken::new(self.clone(), payloads::GetManagedBotToken::new(user_id))
1316    }
1317
1318    type GetManagedBotAccessSettings = JsonRequest<payloads::GetManagedBotAccessSettings>;
1319
1320    fn get_managed_bot_access_settings(
1321        &self,
1322        user_id: UserId,
1323    ) -> Self::GetManagedBotAccessSettings {
1324        Self::GetManagedBotAccessSettings::new(
1325            self.clone(),
1326            payloads::GetManagedBotAccessSettings::new(user_id),
1327        )
1328    }
1329
1330    type SetManagedBotAccessSettings = JsonRequest<payloads::SetManagedBotAccessSettings>;
1331
1332    fn set_managed_bot_access_settings(
1333        &self,
1334        user_id: UserId,
1335        is_access_restricted: bool,
1336    ) -> Self::SetManagedBotAccessSettings {
1337        Self::SetManagedBotAccessSettings::new(
1338            self.clone(),
1339            payloads::SetManagedBotAccessSettings::new(user_id, is_access_restricted),
1340        )
1341    }
1342
1343    type ReplaceManagedBotToken = JsonRequest<payloads::ReplaceManagedBotToken>;
1344
1345    fn replace_managed_bot_token(&self, user_id: UserId) -> Self::ReplaceManagedBotToken {
1346        Self::ReplaceManagedBotToken::new(
1347            self.clone(),
1348            payloads::ReplaceManagedBotToken::new(user_id),
1349        )
1350    }
1351
1352    type SavePreparedKeyboardButton = JsonRequest<payloads::SavePreparedKeyboardButton>;
1353
1354    fn save_prepared_keyboard_button(
1355        &self,
1356        user_id: UserId,
1357        button: KeyboardButton,
1358    ) -> Self::SavePreparedKeyboardButton {
1359        Self::SavePreparedKeyboardButton::new(
1360            self.clone(),
1361            payloads::SavePreparedKeyboardButton::new(user_id, button),
1362        )
1363    }
1364
1365    type EditMessageText = MultipartRequest<payloads::EditMessageText>;
1366
1367    fn edit_message_text<C>(&self, chat_id: C, message_id: MessageId) -> Self::EditMessageText
1368    where
1369        C: Into<Recipient>,
1370    {
1371        Self::EditMessageText::new(
1372            self.clone(),
1373            payloads::EditMessageText::new(chat_id, message_id),
1374        )
1375    }
1376
1377    type EditMessageTextInline = MultipartRequest<payloads::EditMessageTextInline>;
1378
1379    fn edit_message_text_inline<I>(&self, inline_message_id: I) -> Self::EditMessageTextInline
1380    where
1381        I: Into<String>,
1382    {
1383        Self::EditMessageTextInline::new(
1384            self.clone(),
1385            payloads::EditMessageTextInline::new(inline_message_id),
1386        )
1387    }
1388
1389    type EditMessageCaption = JsonRequest<payloads::EditMessageCaption>;
1390
1391    fn edit_message_caption<C>(&self, chat_id: C, message_id: MessageId) -> Self::EditMessageCaption
1392    where
1393        C: Into<Recipient>,
1394    {
1395        Self::EditMessageCaption::new(
1396            self.clone(),
1397            payloads::EditMessageCaption::new(chat_id, message_id),
1398        )
1399    }
1400
1401    type EditMessageCaptionInline = JsonRequest<payloads::EditMessageCaptionInline>;
1402
1403    fn edit_message_caption_inline<I>(&self, inline_message_id: I) -> Self::EditMessageCaptionInline
1404    where
1405        I: Into<String>,
1406    {
1407        Self::EditMessageCaptionInline::new(
1408            self.clone(),
1409            payloads::EditMessageCaptionInline::new(inline_message_id),
1410        )
1411    }
1412
1413    type EditMessageMedia = MultipartRequest<payloads::EditMessageMedia>;
1414
1415    fn edit_message_media<C>(
1416        &self,
1417        chat_id: C,
1418        message_id: MessageId,
1419        media: InputMedia,
1420    ) -> Self::EditMessageMedia
1421    where
1422        C: Into<Recipient>,
1423    {
1424        Self::EditMessageMedia::new(
1425            self.clone(),
1426            payloads::EditMessageMedia::new(chat_id, message_id, media),
1427        )
1428    }
1429
1430    type EditMessageMediaInline = MultipartRequest<payloads::EditMessageMediaInline>;
1431
1432    fn edit_message_media_inline<I>(
1433        &self,
1434        inline_message_id: I,
1435        media: InputMedia,
1436    ) -> Self::EditMessageMediaInline
1437    where
1438        I: Into<String>,
1439    {
1440        Self::EditMessageMediaInline::new(
1441            self.clone(),
1442            payloads::EditMessageMediaInline::new(inline_message_id, media),
1443        )
1444    }
1445
1446    type EditMessageReplyMarkup = JsonRequest<payloads::EditMessageReplyMarkup>;
1447
1448    fn edit_message_reply_markup<C>(
1449        &self,
1450        chat_id: C,
1451        message_id: MessageId,
1452    ) -> Self::EditMessageReplyMarkup
1453    where
1454        C: Into<Recipient>,
1455    {
1456        Self::EditMessageReplyMarkup::new(
1457            self.clone(),
1458            payloads::EditMessageReplyMarkup::new(chat_id, message_id),
1459        )
1460    }
1461
1462    type EditMessageReplyMarkupInline = JsonRequest<payloads::EditMessageReplyMarkupInline>;
1463
1464    fn edit_message_reply_markup_inline<I>(
1465        &self,
1466        inline_message_id: I,
1467    ) -> Self::EditMessageReplyMarkupInline
1468    where
1469        I: Into<String>,
1470    {
1471        Self::EditMessageReplyMarkupInline::new(
1472            self.clone(),
1473            payloads::EditMessageReplyMarkupInline::new(inline_message_id),
1474        )
1475    }
1476
1477    type EditEphemeralMessageText = MultipartRequest<payloads::EditEphemeralMessageText>;
1478
1479    fn edit_ephemeral_message_text<C>(
1480        &self,
1481        chat_id: C,
1482        receiver_user_id: i64,
1483        ephemeral_message_id: MessageId,
1484    ) -> Self::EditEphemeralMessageText
1485    where
1486        C: Into<Recipient>,
1487    {
1488        Self::EditEphemeralMessageText::new(
1489            self.clone(),
1490            payloads::EditEphemeralMessageText::new(
1491                chat_id,
1492                receiver_user_id,
1493                ephemeral_message_id,
1494            ),
1495        )
1496    }
1497
1498    type EditEphemeralMessageCaption = JsonRequest<payloads::EditEphemeralMessageCaption>;
1499
1500    fn edit_ephemeral_message_caption<C>(
1501        &self,
1502        chat_id: C,
1503        receiver_user_id: i64,
1504        ephemeral_message_id: MessageId,
1505    ) -> Self::EditEphemeralMessageCaption
1506    where
1507        C: Into<Recipient>,
1508    {
1509        Self::EditEphemeralMessageCaption::new(
1510            self.clone(),
1511            payloads::EditEphemeralMessageCaption::new(
1512                chat_id,
1513                receiver_user_id,
1514                ephemeral_message_id,
1515            ),
1516        )
1517    }
1518
1519    type EditEphemeralMessageMedia = MultipartRequest<payloads::EditEphemeralMessageMedia>;
1520
1521    fn edit_ephemeral_message_media<C>(
1522        &self,
1523        chat_id: C,
1524        receiver_user_id: i64,
1525        ephemeral_message_id: MessageId,
1526        media: InputMedia,
1527    ) -> Self::EditEphemeralMessageMedia
1528    where
1529        C: Into<Recipient>,
1530    {
1531        Self::EditEphemeralMessageMedia::new(
1532            self.clone(),
1533            payloads::EditEphemeralMessageMedia::new(
1534                chat_id,
1535                receiver_user_id,
1536                ephemeral_message_id,
1537                media,
1538            ),
1539        )
1540    }
1541
1542    type EditEphemeralMessageReplyMarkup = JsonRequest<payloads::EditEphemeralMessageReplyMarkup>;
1543
1544    fn edit_ephemeral_message_reply_markup<C>(
1545        &self,
1546        chat_id: C,
1547        receiver_user_id: i64,
1548        ephemeral_message_id: MessageId,
1549    ) -> Self::EditEphemeralMessageReplyMarkup
1550    where
1551        C: Into<Recipient>,
1552    {
1553        Self::EditEphemeralMessageReplyMarkup::new(
1554            self.clone(),
1555            payloads::EditEphemeralMessageReplyMarkup::new(
1556                chat_id,
1557                receiver_user_id,
1558                ephemeral_message_id,
1559            ),
1560        )
1561    }
1562
1563    type StopPoll = JsonRequest<payloads::StopPoll>;
1564
1565    fn stop_poll<C>(&self, chat_id: C, message_id: MessageId) -> Self::StopPoll
1566    where
1567        C: Into<Recipient>,
1568    {
1569        Self::StopPoll::new(self.clone(), payloads::StopPoll::new(chat_id, message_id))
1570    }
1571
1572    type ApproveSuggestedPost = JsonRequest<payloads::ApproveSuggestedPost>;
1573
1574    fn approve_suggested_post<C>(
1575        &self,
1576        chat_id: C,
1577        message_id: MessageId,
1578    ) -> Self::ApproveSuggestedPost
1579    where
1580        C: Into<ChatId>,
1581    {
1582        Self::ApproveSuggestedPost::new(
1583            self.clone(),
1584            payloads::ApproveSuggestedPost::new(chat_id, message_id),
1585        )
1586    }
1587
1588    type DeclineSuggestedPost = JsonRequest<payloads::DeclineSuggestedPost>;
1589
1590    fn decline_suggested_post<C>(
1591        &self,
1592        chat_id: C,
1593        message_id: MessageId,
1594    ) -> Self::DeclineSuggestedPost
1595    where
1596        C: Into<ChatId>,
1597    {
1598        Self::DeclineSuggestedPost::new(
1599            self.clone(),
1600            payloads::DeclineSuggestedPost::new(chat_id, message_id),
1601        )
1602    }
1603
1604    type DeleteMessage = JsonRequest<payloads::DeleteMessage>;
1605
1606    fn delete_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::DeleteMessage
1607    where
1608        C: Into<Recipient>,
1609    {
1610        Self::DeleteMessage::new(self.clone(), payloads::DeleteMessage::new(chat_id, message_id))
1611    }
1612
1613    type DeleteEphemeralMessage = JsonRequest<payloads::DeleteEphemeralMessage>;
1614
1615    fn delete_ephemeral_message<C>(
1616        &self,
1617        chat_id: C,
1618        receiver_user_id: i64,
1619        ephemeral_message_id: MessageId,
1620    ) -> Self::DeleteEphemeralMessage
1621    where
1622        C: Into<Recipient>,
1623    {
1624        Self::DeleteEphemeralMessage::new(
1625            self.clone(),
1626            payloads::DeleteEphemeralMessage::new(chat_id, receiver_user_id, ephemeral_message_id),
1627        )
1628    }
1629
1630    type DeleteMessages = JsonRequest<payloads::DeleteMessages>;
1631    fn delete_messages<C, M>(&self, chat_id: C, message_ids: M) -> Self::DeleteMessages
1632    where
1633        C: Into<Recipient>,
1634        M: IntoIterator<Item = MessageId>,
1635    {
1636        Self::DeleteMessages::new(self.clone(), payloads::DeleteMessages::new(chat_id, message_ids))
1637    }
1638
1639    type DeleteMessageReaction = JsonRequest<payloads::DeleteMessageReaction>;
1640
1641    fn delete_message_reaction<C>(
1642        &self,
1643        chat_id: C,
1644        message_id: MessageId,
1645    ) -> Self::DeleteMessageReaction
1646    where
1647        C: Into<Recipient>,
1648    {
1649        Self::DeleteMessageReaction::new(
1650            self.clone(),
1651            payloads::DeleteMessageReaction::new(chat_id, message_id),
1652        )
1653    }
1654
1655    type DeleteAllMessageReactions = JsonRequest<payloads::DeleteAllMessageReactions>;
1656
1657    fn delete_all_message_reactions<C>(&self, chat_id: C) -> Self::DeleteAllMessageReactions
1658    where
1659        C: Into<Recipient>,
1660    {
1661        Self::DeleteAllMessageReactions::new(
1662            self.clone(),
1663            payloads::DeleteAllMessageReactions::new(chat_id),
1664        )
1665    }
1666
1667    type SendSticker = MultipartRequest<payloads::SendSticker>;
1668
1669    fn send_sticker(&self, sticker: InputFile) -> Self::SendSticker {
1670        Self::SendSticker::new(self.clone(), payloads::SendSticker::new(sticker))
1671    }
1672
1673    type GetStickerSet = JsonRequest<payloads::GetStickerSet>;
1674
1675    fn get_sticker_set<N>(&self, name: N) -> Self::GetStickerSet
1676    where
1677        N: Into<String>,
1678    {
1679        Self::GetStickerSet::new(self.clone(), payloads::GetStickerSet::new(name))
1680    }
1681
1682    type GetCustomEmojiStickers = JsonRequest<payloads::GetCustomEmojiStickers>;
1683
1684    fn get_custom_emoji_stickers<C>(&self, custom_emoji_ids: C) -> Self::GetCustomEmojiStickers
1685    where
1686        C: IntoIterator<Item = CustomEmojiId>,
1687    {
1688        Self::GetCustomEmojiStickers::new(
1689            self.clone(),
1690            payloads::GetCustomEmojiStickers::new(custom_emoji_ids),
1691        )
1692    }
1693
1694    type UploadStickerFile = MultipartRequest<payloads::UploadStickerFile>;
1695
1696    fn upload_sticker_file(
1697        &self,
1698        user_id: UserId,
1699        sticker: InputFile,
1700        sticker_format: StickerFormat,
1701    ) -> Self::UploadStickerFile {
1702        Self::UploadStickerFile::new(
1703            self.clone(),
1704            payloads::UploadStickerFile::new(user_id, sticker, sticker_format),
1705        )
1706    }
1707
1708    type CreateNewStickerSet = MultipartRequest<payloads::CreateNewStickerSet>;
1709
1710    fn create_new_sticker_set<N, T, S>(
1711        &self,
1712        user_id: UserId,
1713        name: N,
1714        title: T,
1715        stickers: S,
1716    ) -> Self::CreateNewStickerSet
1717    where
1718        N: Into<String>,
1719        T: Into<String>,
1720        S: IntoIterator<Item = InputSticker>,
1721    {
1722        Self::CreateNewStickerSet::new(
1723            self.clone(),
1724            payloads::CreateNewStickerSet::new(user_id, name, title, stickers),
1725        )
1726    }
1727
1728    type AddStickerToSet = MultipartRequest<payloads::AddStickerToSet>;
1729
1730    fn add_sticker_to_set<N>(
1731        &self,
1732        user_id: UserId,
1733        name: N,
1734        sticker: InputSticker,
1735    ) -> Self::AddStickerToSet
1736    where
1737        N: Into<String>,
1738    {
1739        Self::AddStickerToSet::new(
1740            self.clone(),
1741            payloads::AddStickerToSet::new(user_id, name, sticker),
1742        )
1743    }
1744
1745    type SetStickerPositionInSet = JsonRequest<payloads::SetStickerPositionInSet>;
1746
1747    fn set_sticker_position_in_set<S>(
1748        &self,
1749        sticker: S,
1750        position: u32,
1751    ) -> Self::SetStickerPositionInSet
1752    where
1753        S: Into<String>,
1754    {
1755        Self::SetStickerPositionInSet::new(
1756            self.clone(),
1757            payloads::SetStickerPositionInSet::new(sticker, position),
1758        )
1759    }
1760
1761    type DeleteStickerFromSet = JsonRequest<payloads::DeleteStickerFromSet>;
1762
1763    fn delete_sticker_from_set<S>(&self, sticker: S) -> Self::DeleteStickerFromSet
1764    where
1765        S: Into<String>,
1766    {
1767        Self::DeleteStickerFromSet::new(self.clone(), payloads::DeleteStickerFromSet::new(sticker))
1768    }
1769
1770    type ReplaceStickerInSet = MultipartRequest<payloads::ReplaceStickerInSet>;
1771
1772    fn replace_sticker_in_set<N, O>(
1773        &self,
1774        user_id: UserId,
1775        name: N,
1776        old_sticker: O,
1777        sticker: InputSticker,
1778    ) -> Self::ReplaceStickerInSet
1779    where
1780        N: Into<String>,
1781        O: Into<String>,
1782    {
1783        Self::ReplaceStickerInSet::new(
1784            self.clone(),
1785            payloads::ReplaceStickerInSet {
1786                user_id,
1787                name: name.into(),
1788                old_sticker: old_sticker.into(),
1789                sticker,
1790            },
1791        )
1792    }
1793
1794    type SetStickerSetThumbnail = MultipartRequest<payloads::SetStickerSetThumbnail>;
1795
1796    fn set_sticker_set_thumbnail<N>(
1797        &self,
1798        name: N,
1799        user_id: UserId,
1800        format: StickerFormat,
1801    ) -> Self::SetStickerSetThumbnail
1802    where
1803        N: Into<String>,
1804    {
1805        Self::SetStickerSetThumbnail::new(
1806            self.clone(),
1807            payloads::SetStickerSetThumbnail::new(name, user_id, format),
1808        )
1809    }
1810
1811    type SetCustomEmojiStickerSetThumbnail =
1812        JsonRequest<payloads::SetCustomEmojiStickerSetThumbnail>;
1813
1814    fn set_custom_emoji_sticker_set_thumbnail<N>(
1815        &self,
1816        name: N,
1817    ) -> Self::SetCustomEmojiStickerSetThumbnail
1818    where
1819        N: Into<String>,
1820    {
1821        Self::SetCustomEmojiStickerSetThumbnail::new(
1822            self.clone(),
1823            payloads::SetCustomEmojiStickerSetThumbnail::new(name),
1824        )
1825    }
1826
1827    type SetStickerSetTitle = JsonRequest<payloads::SetStickerSetTitle>;
1828
1829    fn set_sticker_set_title<N, T>(&self, name: N, title: T) -> Self::SetStickerSetTitle
1830    where
1831        N: Into<String>,
1832        T: Into<String>,
1833    {
1834        Self::SetStickerSetTitle::new(self.clone(), payloads::SetStickerSetTitle::new(name, title))
1835    }
1836
1837    type DeleteStickerSet = JsonRequest<payloads::DeleteStickerSet>;
1838
1839    fn delete_sticker_set<N>(&self, name: N) -> Self::DeleteStickerSet
1840    where
1841        N: Into<String>,
1842    {
1843        Self::DeleteStickerSet::new(self.clone(), payloads::DeleteStickerSet::new(name))
1844    }
1845
1846    type SetStickerEmojiList = JsonRequest<payloads::SetStickerEmojiList>;
1847
1848    fn set_sticker_emoji_list<S, E>(&self, sticker: S, emoji_list: E) -> Self::SetStickerEmojiList
1849    where
1850        S: Into<String>,
1851        E: IntoIterator<Item = String>,
1852    {
1853        Self::SetStickerEmojiList::new(
1854            self.clone(),
1855            payloads::SetStickerEmojiList::new(sticker, emoji_list),
1856        )
1857    }
1858
1859    type SetStickerKeywords = JsonRequest<payloads::SetStickerKeywords>;
1860
1861    fn set_sticker_keywords<S>(&self, sticker: S) -> Self::SetStickerKeywords
1862    where
1863        S: Into<String>,
1864    {
1865        Self::SetStickerKeywords::new(self.clone(), payloads::SetStickerKeywords::new(sticker))
1866    }
1867
1868    type SetStickerMaskPosition = JsonRequest<payloads::SetStickerMaskPosition>;
1869
1870    fn set_sticker_mask_position<S>(&self, sticker: S) -> Self::SetStickerMaskPosition
1871    where
1872        S: Into<String>,
1873    {
1874        Self::SetStickerMaskPosition::new(
1875            self.clone(),
1876            payloads::SetStickerMaskPosition::new(sticker),
1877        )
1878    }
1879
1880    type GetAvailableGifts = JsonRequest<payloads::GetAvailableGifts>;
1881
1882    fn get_available_gifts(&self) -> Self::GetAvailableGifts {
1883        Self::GetAvailableGifts::new(self.clone(), payloads::GetAvailableGifts::new())
1884    }
1885
1886    type SendGift = JsonRequest<payloads::SendGift>;
1887
1888    fn send_gift(&self, user_id: UserId, gift_id: GiftId) -> Self::SendGift {
1889        Self::SendGift::new(self.clone(), payloads::SendGift::new(user_id, gift_id))
1890    }
1891
1892    type SendGiftChat = JsonRequest<payloads::SendGiftChat>;
1893
1894    fn send_gift_chat<C>(&self, chat_id: C, gift_id: GiftId) -> Self::SendGiftChat
1895    where
1896        C: Into<Recipient>,
1897    {
1898        Self::SendGiftChat::new(self.clone(), payloads::SendGiftChat::new(chat_id, gift_id))
1899    }
1900
1901    type GiftPremiumSubscription = JsonRequest<payloads::GiftPremiumSubscription>;
1902
1903    fn gift_premium_subscription(
1904        &self,
1905        user_id: UserId,
1906        month_count: u8,
1907        star_count: u32,
1908    ) -> Self::GiftPremiumSubscription {
1909        Self::GiftPremiumSubscription::new(
1910            self.clone(),
1911            payloads::GiftPremiumSubscription::new(user_id, month_count, star_count),
1912        )
1913    }
1914
1915    type VerifyUser = JsonRequest<payloads::VerifyUser>;
1916
1917    fn verify_user(&self, user_id: UserId) -> Self::VerifyUser {
1918        Self::VerifyUser::new(self.clone(), payloads::VerifyUser::new(user_id))
1919    }
1920
1921    type VerifyChat = JsonRequest<payloads::VerifyChat>;
1922
1923    fn verify_chat<C>(&self, chat_id: C) -> Self::VerifyChat
1924    where
1925        C: Into<Recipient>,
1926    {
1927        Self::VerifyChat::new(self.clone(), payloads::VerifyChat::new(chat_id))
1928    }
1929
1930    type RemoveUserVerification = JsonRequest<payloads::RemoveUserVerification>;
1931
1932    fn remove_user_verification(&self, user_id: UserId) -> Self::RemoveUserVerification {
1933        Self::RemoveUserVerification::new(
1934            self.clone(),
1935            payloads::RemoveUserVerification::new(user_id),
1936        )
1937    }
1938
1939    type RemoveChatVerification = JsonRequest<payloads::RemoveChatVerification>;
1940
1941    fn remove_chat_verification<C>(&self, chat_id: C) -> Self::RemoveChatVerification
1942    where
1943        C: Into<Recipient>,
1944    {
1945        Self::RemoveChatVerification::new(
1946            self.clone(),
1947            payloads::RemoveChatVerification::new(chat_id),
1948        )
1949    }
1950
1951    type ReadBusinessMessage = JsonRequest<payloads::ReadBusinessMessage>;
1952
1953    fn read_business_message<C>(
1954        &self,
1955        business_connection_id: BusinessConnectionId,
1956        chat_id: C,
1957        message_id: MessageId,
1958    ) -> Self::ReadBusinessMessage
1959    where
1960        C: Into<ChatId>,
1961    {
1962        Self::ReadBusinessMessage::new(
1963            self.clone(),
1964            payloads::ReadBusinessMessage::new(business_connection_id, chat_id, message_id),
1965        )
1966    }
1967
1968    type DeleteBusinessMessages = JsonRequest<payloads::DeleteBusinessMessages>;
1969
1970    fn delete_business_messages<M>(
1971        &self,
1972        business_connection_id: BusinessConnectionId,
1973        message_ids: M,
1974    ) -> Self::DeleteBusinessMessages
1975    where
1976        M: IntoIterator<Item = MessageId>,
1977    {
1978        Self::DeleteBusinessMessages::new(
1979            self.clone(),
1980            payloads::DeleteBusinessMessages::new(business_connection_id, message_ids),
1981        )
1982    }
1983
1984    type SetBusinessAccountName = JsonRequest<payloads::SetBusinessAccountName>;
1985
1986    fn set_business_account_name<F>(
1987        &self,
1988        business_connection_id: BusinessConnectionId,
1989        first_name: F,
1990    ) -> Self::SetBusinessAccountName
1991    where
1992        F: Into<String>,
1993    {
1994        Self::SetBusinessAccountName::new(
1995            self.clone(),
1996            payloads::SetBusinessAccountName::new(business_connection_id, first_name),
1997        )
1998    }
1999
2000    type SetBusinessAccountUsername = JsonRequest<payloads::SetBusinessAccountUsername>;
2001
2002    fn set_business_account_username(
2003        &self,
2004        business_connection_id: BusinessConnectionId,
2005    ) -> Self::SetBusinessAccountUsername {
2006        Self::SetBusinessAccountUsername::new(
2007            self.clone(),
2008            payloads::SetBusinessAccountUsername::new(business_connection_id),
2009        )
2010    }
2011
2012    type SetBusinessAccountBio = JsonRequest<payloads::SetBusinessAccountBio>;
2013
2014    fn set_business_account_bio(
2015        &self,
2016        business_connection_id: BusinessConnectionId,
2017    ) -> Self::SetBusinessAccountBio {
2018        Self::SetBusinessAccountBio::new(
2019            self.clone(),
2020            payloads::SetBusinessAccountBio::new(business_connection_id),
2021        )
2022    }
2023
2024    type SetBusinessAccountProfilePhoto = JsonRequest<payloads::SetBusinessAccountProfilePhoto>;
2025
2026    fn set_business_account_profile_photo(
2027        &self,
2028        business_connection_id: BusinessConnectionId,
2029        photo: InputProfilePhoto,
2030    ) -> Self::SetBusinessAccountProfilePhoto {
2031        Self::SetBusinessAccountProfilePhoto::new(
2032            self.clone(),
2033            payloads::SetBusinessAccountProfilePhoto::new(business_connection_id, photo),
2034        )
2035    }
2036
2037    type RemoveBusinessAccountProfilePhoto =
2038        JsonRequest<payloads::RemoveBusinessAccountProfilePhoto>;
2039
2040    fn remove_business_account_profile_photo(
2041        &self,
2042        business_connection_id: BusinessConnectionId,
2043    ) -> Self::RemoveBusinessAccountProfilePhoto {
2044        Self::RemoveBusinessAccountProfilePhoto::new(
2045            self.clone(),
2046            payloads::RemoveBusinessAccountProfilePhoto::new(business_connection_id),
2047        )
2048    }
2049
2050    type SetBusinessAccountGiftSettings = JsonRequest<payloads::SetBusinessAccountGiftSettings>;
2051
2052    fn set_business_account_gift_settings(
2053        &self,
2054        business_connection_id: BusinessConnectionId,
2055        show_gift_button: bool,
2056        accepted_gift_types: AcceptedGiftTypes,
2057    ) -> Self::SetBusinessAccountGiftSettings {
2058        Self::SetBusinessAccountGiftSettings::new(
2059            self.clone(),
2060            payloads::SetBusinessAccountGiftSettings::new(
2061                business_connection_id,
2062                show_gift_button,
2063                accepted_gift_types,
2064            ),
2065        )
2066    }
2067
2068    type GetBusinessAccountStarBalance = JsonRequest<payloads::GetBusinessAccountStarBalance>;
2069
2070    fn get_business_account_star_balance(
2071        &self,
2072        business_connection_id: BusinessConnectionId,
2073    ) -> Self::GetBusinessAccountStarBalance {
2074        Self::GetBusinessAccountStarBalance::new(
2075            self.clone(),
2076            payloads::GetBusinessAccountStarBalance::new(business_connection_id),
2077        )
2078    }
2079
2080    type TransferBusinessAccountStars = JsonRequest<payloads::TransferBusinessAccountStars>;
2081
2082    fn transfer_business_account_stars(
2083        &self,
2084        business_connection_id: BusinessConnectionId,
2085        star_count: u32,
2086    ) -> Self::TransferBusinessAccountStars {
2087        Self::TransferBusinessAccountStars::new(
2088            self.clone(),
2089            payloads::TransferBusinessAccountStars::new(business_connection_id, star_count),
2090        )
2091    }
2092
2093    type GetBusinessAccountGifts = JsonRequest<payloads::GetBusinessAccountGifts>;
2094
2095    fn get_business_account_gifts(
2096        &self,
2097        business_connection_id: BusinessConnectionId,
2098    ) -> Self::GetBusinessAccountGifts {
2099        Self::GetBusinessAccountGifts::new(
2100            self.clone(),
2101            payloads::GetBusinessAccountGifts::new(business_connection_id),
2102        )
2103    }
2104
2105    type GetUserGifts = JsonRequest<payloads::GetUserGifts>;
2106
2107    fn get_user_gifts(&self, user_id: UserId) -> Self::GetUserGifts {
2108        Self::GetUserGifts::new(self.clone(), payloads::GetUserGifts::new(user_id))
2109    }
2110
2111    type GetUserProfileAudios = JsonRequest<payloads::GetUserProfileAudios>;
2112
2113    fn get_user_profile_audios(&self, user_id: UserId) -> Self::GetUserProfileAudios {
2114        Self::GetUserProfileAudios::new(self.clone(), payloads::GetUserProfileAudios::new(user_id))
2115    }
2116
2117    type GetChatGifts = JsonRequest<payloads::GetChatGifts>;
2118
2119    fn get_chat_gifts<C>(&self, chat_id: C) -> Self::GetChatGifts
2120    where
2121        C: Into<Recipient>,
2122    {
2123        Self::GetChatGifts::new(self.clone(), payloads::GetChatGifts::new(chat_id))
2124    }
2125
2126    type ConvertGiftToStars = JsonRequest<payloads::ConvertGiftToStars>;
2127
2128    fn convert_gift_to_stars(
2129        &self,
2130        business_connection_id: BusinessConnectionId,
2131        owned_gift_id: OwnedGiftId,
2132    ) -> Self::ConvertGiftToStars {
2133        Self::ConvertGiftToStars::new(
2134            self.clone(),
2135            payloads::ConvertGiftToStars::new(business_connection_id, owned_gift_id),
2136        )
2137    }
2138
2139    type UpgradeGift = JsonRequest<payloads::UpgradeGift>;
2140
2141    fn upgrade_gift(
2142        &self,
2143        business_connection_id: BusinessConnectionId,
2144        owned_gift_id: OwnedGiftId,
2145    ) -> Self::UpgradeGift {
2146        Self::UpgradeGift::new(
2147            self.clone(),
2148            payloads::UpgradeGift::new(business_connection_id, owned_gift_id),
2149        )
2150    }
2151
2152    type TransferGift = JsonRequest<payloads::TransferGift>;
2153
2154    fn transfer_gift<C>(
2155        &self,
2156        business_connection_id: BusinessConnectionId,
2157        owned_gift_id: OwnedGiftId,
2158        new_owner_chat_id: C,
2159    ) -> Self::TransferGift
2160    where
2161        C: Into<ChatId>,
2162    {
2163        Self::TransferGift::new(
2164            self.clone(),
2165            payloads::TransferGift::new(business_connection_id, owned_gift_id, new_owner_chat_id),
2166        )
2167    }
2168
2169    type RepostStory = JsonRequest<payloads::RepostStory>;
2170
2171    fn repost_story<F>(
2172        &self,
2173        business_connection_id: BusinessConnectionId,
2174        from_chat_id: F,
2175        from_story_id: StoryId,
2176        active_period: Seconds,
2177    ) -> Self::RepostStory
2178    where
2179        F: Into<Recipient>,
2180    {
2181        Self::RepostStory::new(
2182            self.clone(),
2183            payloads::RepostStory::new(
2184                business_connection_id,
2185                from_chat_id,
2186                from_story_id,
2187                active_period,
2188            ),
2189        )
2190    }
2191
2192    type PostStory = MultipartRequest<payloads::PostStory>;
2193
2194    fn post_story(
2195        &self,
2196        business_connection_id: BusinessConnectionId,
2197        content: InputStoryContent,
2198        active_period: Seconds,
2199    ) -> Self::PostStory {
2200        Self::PostStory::new(
2201            self.clone(),
2202            payloads::PostStory::new(business_connection_id, content, active_period),
2203        )
2204    }
2205
2206    type EditStory = MultipartRequest<payloads::EditStory>;
2207
2208    fn edit_story(
2209        &self,
2210        business_connection_id: BusinessConnectionId,
2211        story_id: StoryId,
2212        content: InputStoryContent,
2213    ) -> Self::EditStory {
2214        Self::EditStory::new(
2215            self.clone(),
2216            payloads::EditStory::new(business_connection_id, story_id, content),
2217        )
2218    }
2219
2220    type DeleteStory = JsonRequest<payloads::DeleteStory>;
2221
2222    fn delete_story(
2223        &self,
2224        business_connection_id: BusinessConnectionId,
2225        story_id: StoryId,
2226    ) -> Self::DeleteStory {
2227        Self::DeleteStory::new(
2228            self.clone(),
2229            payloads::DeleteStory::new(business_connection_id, story_id),
2230        )
2231    }
2232
2233    type SendInvoice = JsonRequest<payloads::SendInvoice>;
2234
2235    fn send_invoice<Ch, T, D, Pa, C, Pri>(
2236        &self,
2237        chat_id: Ch,
2238        title: T,
2239        description: D,
2240        payload: Pa,
2241        currency: C,
2242        prices: Pri,
2243    ) -> Self::SendInvoice
2244    where
2245        Ch: Into<Recipient>,
2246        T: Into<String>,
2247        D: Into<String>,
2248        Pa: Into<String>,
2249        C: Into<String>,
2250        Pri: IntoIterator<Item = LabeledPrice>,
2251    {
2252        Self::SendInvoice::new(
2253            self.clone(),
2254            payloads::SendInvoice::new(chat_id, title, description, payload, currency, prices),
2255        )
2256    }
2257
2258    type CreateInvoiceLink = JsonRequest<payloads::CreateInvoiceLink>;
2259
2260    fn create_invoice_link<T, D, Pa, C, Pri>(
2261        &self,
2262        title: T,
2263        description: D,
2264        payload: Pa,
2265        currency: C,
2266        prices: Pri,
2267    ) -> Self::CreateInvoiceLink
2268    where
2269        T: Into<String>,
2270        D: Into<String>,
2271        Pa: Into<String>,
2272        C: Into<String>,
2273        Pri: IntoIterator<Item = LabeledPrice>,
2274    {
2275        Self::CreateInvoiceLink::new(
2276            self.clone(),
2277            payloads::CreateInvoiceLink::new(title, description, payload, currency, prices),
2278        )
2279    }
2280
2281    type AnswerShippingQuery = JsonRequest<payloads::AnswerShippingQuery>;
2282
2283    fn answer_shipping_query(
2284        &self,
2285        shipping_query_id: ShippingQueryId,
2286        ok: bool,
2287    ) -> Self::AnswerShippingQuery {
2288        Self::AnswerShippingQuery::new(
2289            self.clone(),
2290            payloads::AnswerShippingQuery::new(shipping_query_id, ok),
2291        )
2292    }
2293
2294    type AnswerPreCheckoutQuery = JsonRequest<payloads::AnswerPreCheckoutQuery>;
2295
2296    fn answer_pre_checkout_query(
2297        &self,
2298        pre_checkout_query_id: PreCheckoutQueryId,
2299        ok: bool,
2300    ) -> Self::AnswerPreCheckoutQuery {
2301        Self::AnswerPreCheckoutQuery::new(
2302            self.clone(),
2303            payloads::AnswerPreCheckoutQuery::new(pre_checkout_query_id, ok),
2304        )
2305    }
2306
2307    type GetMyStarBalance = JsonRequest<payloads::GetMyStarBalance>;
2308
2309    fn get_my_star_balance(&self) -> Self::GetMyStarBalance {
2310        Self::GetMyStarBalance::new(self.clone(), payloads::GetMyStarBalance::new())
2311    }
2312
2313    type GetStarTransactions = JsonRequest<payloads::GetStarTransactions>;
2314
2315    fn get_star_transactions(&self) -> Self::GetStarTransactions {
2316        Self::GetStarTransactions::new(self.clone(), payloads::GetStarTransactions::new())
2317    }
2318
2319    type RefundStarPayment = JsonRequest<payloads::RefundStarPayment>;
2320
2321    fn refund_star_payment(
2322        &self,
2323        user_id: UserId,
2324        telegram_payment_charge_id: TelegramTransactionId,
2325    ) -> Self::RefundStarPayment {
2326        Self::RefundStarPayment::new(
2327            self.clone(),
2328            payloads::RefundStarPayment::new(user_id, telegram_payment_charge_id),
2329        )
2330    }
2331
2332    type EditUserStarSubscription = JsonRequest<payloads::EditUserStarSubscription>;
2333
2334    fn edit_user_star_subscription(
2335        &self,
2336        user_id: UserId,
2337        telegram_payment_charge_id: TelegramTransactionId,
2338        is_canceled: bool,
2339    ) -> Self::EditUserStarSubscription {
2340        Self::EditUserStarSubscription::new(
2341            self.clone(),
2342            payloads::EditUserStarSubscription::new(
2343                user_id,
2344                telegram_payment_charge_id,
2345                is_canceled,
2346            ),
2347        )
2348    }
2349
2350    type SetPassportDataErrors = JsonRequest<payloads::SetPassportDataErrors>;
2351
2352    fn set_passport_data_errors<E>(&self, user_id: UserId, errors: E) -> Self::SetPassportDataErrors
2353    where
2354        E: IntoIterator<Item = crate::types::PassportElementError>,
2355    {
2356        Self::SetPassportDataErrors::new(
2357            self.clone(),
2358            payloads::SetPassportDataErrors::new(user_id, errors),
2359        )
2360    }
2361
2362    type SendGame = JsonRequest<payloads::SendGame>;
2363
2364    fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
2365    where
2366        C: Into<ChatId>,
2367        G: Into<String>,
2368    {
2369        Self::SendGame::new(self.clone(), payloads::SendGame::new(chat_id, game_short_name))
2370    }
2371
2372    type SetGameScore = JsonRequest<payloads::SetGameScore>;
2373
2374    fn set_game_score(
2375        &self,
2376        user_id: UserId,
2377        score: u64,
2378        chat_id: u32,
2379        message_id: MessageId,
2380    ) -> Self::SetGameScore {
2381        Self::SetGameScore::new(
2382            self.clone(),
2383            payloads::SetGameScore::new(user_id, score, chat_id, message_id),
2384        )
2385    }
2386
2387    type SetGameScoreInline = JsonRequest<payloads::SetGameScoreInline>;
2388
2389    fn set_game_score_inline<I>(
2390        &self,
2391        user_id: UserId,
2392        score: u64,
2393        inline_message_id: I,
2394    ) -> Self::SetGameScoreInline
2395    where
2396        I: Into<String>,
2397    {
2398        Self::SetGameScoreInline::new(
2399            self.clone(),
2400            payloads::SetGameScoreInline::new(user_id, score, inline_message_id),
2401        )
2402    }
2403
2404    type GetGameHighScores = JsonRequest<payloads::GetGameHighScores>;
2405
2406    fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
2407    where
2408        T: Into<crate::types::TargetMessage>,
2409    {
2410        Self::GetGameHighScores::new(
2411            self.clone(),
2412            payloads::GetGameHighScores::new(user_id, target),
2413        )
2414    }
2415
2416    type LogOut = JsonRequest<payloads::LogOut>;
2417
2418    fn log_out(&self) -> Self::LogOut {
2419        Self::LogOut::new(self.clone(), payloads::LogOut::new())
2420    }
2421
2422    type Close = JsonRequest<payloads::Close>;
2423
2424    fn close(&self) -> Self::Close {
2425        Self::Close::new(self.clone(), payloads::Close::new())
2426    }
2427
2428    type CopyMessage = JsonRequest<payloads::CopyMessage>;
2429
2430    fn copy_message<C, F>(
2431        &self,
2432        chat_id: C,
2433        from_chat_id: F,
2434        message_id: MessageId,
2435    ) -> Self::CopyMessage
2436    where
2437        C: Into<Recipient>,
2438        F: Into<Recipient>,
2439    {
2440        Self::CopyMessage::new(
2441            self.clone(),
2442            payloads::CopyMessage::new(chat_id, from_chat_id, message_id),
2443        )
2444    }
2445
2446    type CopyMessages = JsonRequest<payloads::CopyMessages>;
2447    fn copy_messages<C, F, M>(
2448        &self,
2449        chat_id: C,
2450        from_chat_id: F,
2451        message_ids: M,
2452    ) -> Self::CopyMessages
2453    where
2454        C: Into<Recipient>,
2455        F: Into<Recipient>,
2456        M: IntoIterator<Item = MessageId>,
2457    {
2458        Self::CopyMessages::new(
2459            self.clone(),
2460            payloads::CopyMessages::new(chat_id, from_chat_id, message_ids),
2461        )
2462    }
2463
2464    type UnpinAllChatMessages = JsonRequest<payloads::UnpinAllChatMessages>;
2465
2466    fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
2467    where
2468        C: Into<Recipient>,
2469    {
2470        Self::UnpinAllChatMessages::new(self.clone(), payloads::UnpinAllChatMessages::new(chat_id))
2471    }
2472}
2473
2474#[cfg(test)]
2475mod tests {
2476    use super::*;
2477
2478    #[tokio::test]
2479    async fn story_and_replace_sticker_multipart_uploads_over_transport() {
2480        use crate::{
2481            requests::Request,
2482            types::{
2483                BusinessConnectionId, InputSticker, InputStoryContent, InputStoryContentPhoto,
2484                InputStoryContentVideo, Seconds, StickerFormat, StoryId,
2485            },
2486        };
2487        use std::{
2488            collections::HashMap,
2489            io::{Read, Write},
2490            net::TcpListener,
2491            sync::mpsc,
2492        };
2493
2494        struct TempFileGuard(std::path::PathBuf);
2495        impl Drop for TempFileGuard {
2496            fn drop(&mut self) {
2497                let _ = std::fs::remove_file(&self.0);
2498            }
2499        }
2500
2501        fn parse_multipart_parts(headers: &str, body: &[u8]) -> HashMap<String, Vec<u8>> {
2502            let boundary = headers
2503                .lines()
2504                .find_map(|line| {
2505                    let (k, v) = line.split_once(':')?;
2506                    if !k.eq_ignore_ascii_case("content-type") {
2507                        return None;
2508                    }
2509                    v.split(';')
2510                        .find_map(|part| part.trim().strip_prefix("boundary="))
2511                        .map(str::to_owned)
2512                })
2513                .expect("missing multipart boundary");
2514            let delim = format!("--{boundary}").into_bytes();
2515            let mut parts = HashMap::new();
2516            let mut pos = 0;
2517            while let Some(rel_start) =
2518                body[pos..].windows(delim.len()).position(|w| w == delim.as_slice())
2519            {
2520                let part_start = pos + rel_start + delim.len();
2521                pos = part_start;
2522                if body[part_start..].starts_with(b"--") {
2523                    break;
2524                }
2525                let content_start = if body[part_start..].starts_with(b"\r\n") {
2526                    part_start + 2
2527                } else {
2528                    part_start
2529                };
2530                let Some(hdr_end_rel) =
2531                    body[content_start..].windows(4).position(|w| w == b"\r\n\r\n")
2532                else {
2533                    continue;
2534                };
2535                let part_headers =
2536                    String::from_utf8_lossy(&body[content_start..content_start + hdr_end_rel]);
2537                let data_start = content_start + hdr_end_rel + 4;
2538                let Some(next_delim_rel) =
2539                    body[data_start..].windows(delim.len()).position(|w| w == delim.as_slice())
2540                else {
2541                    continue;
2542                };
2543                let mut data_end = data_start + next_delim_rel;
2544                if body[data_start..data_end].ends_with(b"\r\n") {
2545                    data_end -= 2;
2546                }
2547                if let Some(name_start) = part_headers.find("name=\"") {
2548                    let name_rest = &part_headers[name_start + 6..];
2549                    if let Some(name_end) = name_rest.find('"') {
2550                        parts.insert(
2551                            name_rest[..name_end].to_owned(),
2552                            body[data_start..data_end].to_vec(),
2553                        );
2554                    }
2555                }
2556                pos = data_start + next_delim_rel;
2557            }
2558            parts
2559        }
2560
2561        let story_json = serde_json::json!({
2562            "ok": true,
2563            "result": {
2564                "chat": { "id": 100, "first_name": "Alice", "type": "private" },
2565                "id": 7
2566            }
2567        })
2568        .to_string();
2569        let ok_true = r#"{"ok":true,"result":true}"#.to_owned();
2570
2571        let listener = TcpListener::bind("127.0.0.1:0").unwrap();
2572        let addr = listener.local_addr().unwrap();
2573        let (tx, rx) = mpsc::channel();
2574        let responses = vec![
2575            story_json.clone(),
2576            story_json.clone(),
2577            story_json.clone(),
2578            story_json,
2579            ok_true.clone(),
2580            ok_true,
2581        ];
2582
2583        std::thread::spawn(move || {
2584            for response_body in responses {
2585                let (mut stream, _) = listener.accept().unwrap();
2586                stream.set_read_timeout(Some(std::time::Duration::from_secs(5))).unwrap();
2587                let mut data = Vec::new();
2588                let mut buf = [0u8; 4096];
2589                let header_end = loop {
2590                    let n = stream.read(&mut buf).unwrap();
2591                    assert!(n > 0);
2592                    data.extend_from_slice(&buf[..n]);
2593                    if let Some(pos) = data.windows(4).position(|w| w == b"\r\n\r\n") {
2594                        break pos + 4;
2595                    }
2596                };
2597                let headers = String::from_utf8_lossy(&data[..header_end]).into_owned();
2598                let req_line = headers.lines().next().unwrap().to_owned();
2599                let is_chunked = headers.lines().any(|line| {
2600                    line.split_once(':').is_some_and(|(k, v)| {
2601                        k.eq_ignore_ascii_case("transfer-encoding")
2602                            && v.to_ascii_lowercase().contains("chunked")
2603                    })
2604                });
2605                let raw_body = if is_chunked {
2606                    let mut cursor = header_end;
2607                    let mut decoded = Vec::new();
2608                    loop {
2609                        let line_end = loop {
2610                            if let Some(pos) = data[cursor..].windows(2).position(|w| w == b"\r\n")
2611                            {
2612                                break cursor + pos;
2613                            }
2614                            let n = stream.read(&mut buf).unwrap();
2615                            assert!(n > 0);
2616                            data.extend_from_slice(&buf[..n]);
2617                        };
2618                        let size_str = std::str::from_utf8(&data[cursor..line_end]).unwrap();
2619                        let size_hex = size_str.split(';').next().unwrap().trim();
2620                        let chunk_len = usize::from_str_radix(size_hex, 16).unwrap();
2621                        cursor = line_end + 2;
2622                        if chunk_len == 0 {
2623                            while data.len() < cursor + 2 {
2624                                let n = stream.read(&mut buf).unwrap();
2625                                if n == 0 {
2626                                    break;
2627                                }
2628                                data.extend_from_slice(&buf[..n]);
2629                            }
2630                            break;
2631                        }
2632                        while data.len() < cursor + chunk_len + 2 {
2633                            let n = stream.read(&mut buf).unwrap();
2634                            assert!(n > 0);
2635                            data.extend_from_slice(&buf[..n]);
2636                        }
2637                        decoded.extend_from_slice(&data[cursor..cursor + chunk_len]);
2638                        cursor += chunk_len + 2;
2639                    }
2640                    decoded
2641                } else {
2642                    let content_len: usize = headers
2643                        .lines()
2644                        .find_map(|line| {
2645                            let (k, v) = line.split_once(':')?;
2646                            k.eq_ignore_ascii_case("content-length")
2647                                .then(|| v.trim().parse().ok())?
2648                        })
2649                        .unwrap_or(0);
2650                    while data.len() < header_end + content_len {
2651                        let n = stream.read(&mut buf).unwrap();
2652                        assert!(n > 0);
2653                        data.extend_from_slice(&buf[..n]);
2654                    }
2655                    data[header_end..header_end + content_len].to_vec()
2656                };
2657                tx.send((req_line, headers, raw_body)).unwrap();
2658
2659                let reply = format!(
2660                    "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: \
2661                     {}\r\nConnection: close\r\n\r\n{}",
2662                    response_body.len(),
2663                    response_body
2664                );
2665                stream.write_all(reply.as_bytes()).unwrap();
2666                stream.flush().unwrap();
2667            }
2668        });
2669
2670        let api_url = reqwest::Url::parse(&format!("http://{addr}/")).unwrap();
2671        let client =
2672            reqwest::Client::builder().timeout(std::time::Duration::from_secs(5)).build().unwrap();
2673        let bot = Bot::with_client("test-token", client).set_api_url(api_url);
2674
2675        let unique =
2676            std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
2677        let story_video_bytes = b"\x00\x01DISK_STORY_MP4\xff\xfe".to_vec();
2678        let story_video_path =
2679            std::env::temp_dir().join(format!("teloxide-story-vid-{unique}.mp4"));
2680        std::fs::write(&story_video_path, &story_video_bytes).unwrap();
2681        let _vid_guard = TempFileGuard(story_video_path.clone());
2682
2683        let story_photo_bytes = b"\xff\xd8MEM_STORY_PHOTO\xd9".to_vec();
2684        let sticker_bytes = b"\x89PNG_REPLACE_STICKER\x00".to_vec();
2685
2686        let post_req = bot.post_story(
2687            BusinessConnectionId("bc-1".to_owned()),
2688            InputStoryContent::Photo(InputStoryContentPhoto {
2689                photo: InputFile::memory(story_photo_bytes.clone()).file_name("story.jpg"),
2690            }),
2691            Seconds::from_seconds(21_600),
2692        );
2693        assert_eq!(post_req.send_ref().await.unwrap().id, StoryId(7));
2694        assert_eq!(post_req.send().await.unwrap().id, StoryId(7));
2695
2696        let edit_req = bot.edit_story(
2697            BusinessConnectionId("bc-1".to_owned()),
2698            StoryId(7),
2699            InputStoryContent::Video(InputStoryContentVideo {
2700                video: InputFile::file(&story_video_path),
2701                duration: Some(5.0),
2702                cover_frame_timestamp: None,
2703                is_animation: Some(false),
2704            }),
2705        );
2706        assert_eq!(edit_req.send_ref().await.unwrap().id, StoryId(7));
2707        assert_eq!(edit_req.send().await.unwrap().id, StoryId(7));
2708
2709        let replace_req = bot.replace_sticker_in_set(
2710            UserId(42),
2711            "my_pack",
2712            "old_file_id",
2713            InputSticker {
2714                sticker: InputFile::memory(sticker_bytes.clone()).file_name("new.png"),
2715                format: StickerFormat::Static,
2716                emoji_list: vec!["😀".to_owned()],
2717                mask_position: None,
2718                keywords: Vec::new(),
2719            },
2720        );
2721        assert_eq!(replace_req.send_ref().await.unwrap(), crate::types::True);
2722        assert_eq!(replace_req.send().await.unwrap(), crate::types::True);
2723
2724        for _ in 0..2 {
2725            let (line, headers, body) = rx.recv().unwrap();
2726            assert!(line.starts_with("POST /bottest-token/PostStory "), "{line}");
2727            assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2728            let parts = parse_multipart_parts(&headers, &body);
2729            let content: serde_json::Value =
2730                serde_json::from_slice(parts.get("content").unwrap()).unwrap();
2731            let attach = content["photo"].as_str().unwrap().strip_prefix("attach://").unwrap();
2732            assert_eq!(parts.get(attach), Some(&story_photo_bytes));
2733        }
2734
2735        for _ in 0..2 {
2736            let (line, headers, body) = rx.recv().unwrap();
2737            assert!(line.starts_with("POST /bottest-token/EditStory "), "{line}");
2738            assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2739            let parts = parse_multipart_parts(&headers, &body);
2740            let content: serde_json::Value =
2741                serde_json::from_slice(parts.get("content").unwrap()).unwrap();
2742            let attach = content["video"].as_str().unwrap().strip_prefix("attach://").unwrap();
2743            assert_eq!(parts.get(attach), Some(&story_video_bytes));
2744        }
2745
2746        for _ in 0..2 {
2747            let (line, headers, body) = rx.recv().unwrap();
2748            assert!(line.starts_with("POST /bottest-token/ReplaceStickerInSet "), "{line}");
2749            assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2750            let parts = parse_multipart_parts(&headers, &body);
2751            let sticker: serde_json::Value =
2752                serde_json::from_slice(parts.get("sticker").unwrap()).unwrap();
2753            let attach = sticker["sticker"].as_str().unwrap().strip_prefix("attach://").unwrap();
2754            assert_eq!(parts.get(attach), Some(&sticker_bytes));
2755        }
2756    }
2757}