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: u64, 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 = MultipartRequest<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: u64,
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 =
2025 MultipartRequest<payloads::SetBusinessAccountProfilePhoto>;
2026
2027 fn set_business_account_profile_photo(
2028 &self,
2029 business_connection_id: BusinessConnectionId,
2030 photo: InputProfilePhoto,
2031 ) -> Self::SetBusinessAccountProfilePhoto {
2032 Self::SetBusinessAccountProfilePhoto::new(
2033 self.clone(),
2034 payloads::SetBusinessAccountProfilePhoto::new(business_connection_id, photo),
2035 )
2036 }
2037
2038 type RemoveBusinessAccountProfilePhoto =
2039 JsonRequest<payloads::RemoveBusinessAccountProfilePhoto>;
2040
2041 fn remove_business_account_profile_photo(
2042 &self,
2043 business_connection_id: BusinessConnectionId,
2044 ) -> Self::RemoveBusinessAccountProfilePhoto {
2045 Self::RemoveBusinessAccountProfilePhoto::new(
2046 self.clone(),
2047 payloads::RemoveBusinessAccountProfilePhoto::new(business_connection_id),
2048 )
2049 }
2050
2051 type SetBusinessAccountGiftSettings = JsonRequest<payloads::SetBusinessAccountGiftSettings>;
2052
2053 fn set_business_account_gift_settings(
2054 &self,
2055 business_connection_id: BusinessConnectionId,
2056 show_gift_button: bool,
2057 accepted_gift_types: AcceptedGiftTypes,
2058 ) -> Self::SetBusinessAccountGiftSettings {
2059 Self::SetBusinessAccountGiftSettings::new(
2060 self.clone(),
2061 payloads::SetBusinessAccountGiftSettings::new(
2062 business_connection_id,
2063 show_gift_button,
2064 accepted_gift_types,
2065 ),
2066 )
2067 }
2068
2069 type GetBusinessAccountStarBalance = JsonRequest<payloads::GetBusinessAccountStarBalance>;
2070
2071 fn get_business_account_star_balance(
2072 &self,
2073 business_connection_id: BusinessConnectionId,
2074 ) -> Self::GetBusinessAccountStarBalance {
2075 Self::GetBusinessAccountStarBalance::new(
2076 self.clone(),
2077 payloads::GetBusinessAccountStarBalance::new(business_connection_id),
2078 )
2079 }
2080
2081 type TransferBusinessAccountStars = JsonRequest<payloads::TransferBusinessAccountStars>;
2082
2083 fn transfer_business_account_stars(
2084 &self,
2085 business_connection_id: BusinessConnectionId,
2086 star_count: u64,
2087 ) -> Self::TransferBusinessAccountStars {
2088 Self::TransferBusinessAccountStars::new(
2089 self.clone(),
2090 payloads::TransferBusinessAccountStars::new(business_connection_id, star_count),
2091 )
2092 }
2093
2094 type GetBusinessAccountGifts = JsonRequest<payloads::GetBusinessAccountGifts>;
2095
2096 fn get_business_account_gifts(
2097 &self,
2098 business_connection_id: BusinessConnectionId,
2099 ) -> Self::GetBusinessAccountGifts {
2100 Self::GetBusinessAccountGifts::new(
2101 self.clone(),
2102 payloads::GetBusinessAccountGifts::new(business_connection_id),
2103 )
2104 }
2105
2106 type GetUserGifts = JsonRequest<payloads::GetUserGifts>;
2107
2108 fn get_user_gifts(&self, user_id: UserId) -> Self::GetUserGifts {
2109 Self::GetUserGifts::new(self.clone(), payloads::GetUserGifts::new(user_id))
2110 }
2111
2112 type GetUserProfileAudios = JsonRequest<payloads::GetUserProfileAudios>;
2113
2114 fn get_user_profile_audios(&self, user_id: UserId) -> Self::GetUserProfileAudios {
2115 Self::GetUserProfileAudios::new(self.clone(), payloads::GetUserProfileAudios::new(user_id))
2116 }
2117
2118 type GetChatGifts = JsonRequest<payloads::GetChatGifts>;
2119
2120 fn get_chat_gifts<C>(&self, chat_id: C) -> Self::GetChatGifts
2121 where
2122 C: Into<Recipient>,
2123 {
2124 Self::GetChatGifts::new(self.clone(), payloads::GetChatGifts::new(chat_id))
2125 }
2126
2127 type ConvertGiftToStars = JsonRequest<payloads::ConvertGiftToStars>;
2128
2129 fn convert_gift_to_stars(
2130 &self,
2131 business_connection_id: BusinessConnectionId,
2132 owned_gift_id: OwnedGiftId,
2133 ) -> Self::ConvertGiftToStars {
2134 Self::ConvertGiftToStars::new(
2135 self.clone(),
2136 payloads::ConvertGiftToStars::new(business_connection_id, owned_gift_id),
2137 )
2138 }
2139
2140 type UpgradeGift = JsonRequest<payloads::UpgradeGift>;
2141
2142 fn upgrade_gift(
2143 &self,
2144 business_connection_id: BusinessConnectionId,
2145 owned_gift_id: OwnedGiftId,
2146 ) -> Self::UpgradeGift {
2147 Self::UpgradeGift::new(
2148 self.clone(),
2149 payloads::UpgradeGift::new(business_connection_id, owned_gift_id),
2150 )
2151 }
2152
2153 type TransferGift = JsonRequest<payloads::TransferGift>;
2154
2155 fn transfer_gift<C>(
2156 &self,
2157 business_connection_id: BusinessConnectionId,
2158 owned_gift_id: OwnedGiftId,
2159 new_owner_chat_id: C,
2160 ) -> Self::TransferGift
2161 where
2162 C: Into<ChatId>,
2163 {
2164 Self::TransferGift::new(
2165 self.clone(),
2166 payloads::TransferGift::new(business_connection_id, owned_gift_id, new_owner_chat_id),
2167 )
2168 }
2169
2170 type RepostStory = JsonRequest<payloads::RepostStory>;
2171
2172 fn repost_story<F>(
2173 &self,
2174 business_connection_id: BusinessConnectionId,
2175 from_chat_id: F,
2176 from_story_id: StoryId,
2177 active_period: Seconds,
2178 ) -> Self::RepostStory
2179 where
2180 F: Into<Recipient>,
2181 {
2182 Self::RepostStory::new(
2183 self.clone(),
2184 payloads::RepostStory::new(
2185 business_connection_id,
2186 from_chat_id,
2187 from_story_id,
2188 active_period,
2189 ),
2190 )
2191 }
2192
2193 type PostStory = MultipartRequest<payloads::PostStory>;
2194
2195 fn post_story(
2196 &self,
2197 business_connection_id: BusinessConnectionId,
2198 content: InputStoryContent,
2199 active_period: Seconds,
2200 ) -> Self::PostStory {
2201 Self::PostStory::new(
2202 self.clone(),
2203 payloads::PostStory::new(business_connection_id, content, active_period),
2204 )
2205 }
2206
2207 type EditStory = MultipartRequest<payloads::EditStory>;
2208
2209 fn edit_story(
2210 &self,
2211 business_connection_id: BusinessConnectionId,
2212 story_id: StoryId,
2213 content: InputStoryContent,
2214 ) -> Self::EditStory {
2215 Self::EditStory::new(
2216 self.clone(),
2217 payloads::EditStory::new(business_connection_id, story_id, content),
2218 )
2219 }
2220
2221 type DeleteStory = JsonRequest<payloads::DeleteStory>;
2222
2223 fn delete_story(
2224 &self,
2225 business_connection_id: BusinessConnectionId,
2226 story_id: StoryId,
2227 ) -> Self::DeleteStory {
2228 Self::DeleteStory::new(
2229 self.clone(),
2230 payloads::DeleteStory::new(business_connection_id, story_id),
2231 )
2232 }
2233
2234 type SendInvoice = JsonRequest<payloads::SendInvoice>;
2235
2236 fn send_invoice<Ch, T, D, Pa, C, Pri>(
2237 &self,
2238 chat_id: Ch,
2239 title: T,
2240 description: D,
2241 payload: Pa,
2242 currency: C,
2243 prices: Pri,
2244 ) -> Self::SendInvoice
2245 where
2246 Ch: Into<Recipient>,
2247 T: Into<String>,
2248 D: Into<String>,
2249 Pa: Into<String>,
2250 C: Into<String>,
2251 Pri: IntoIterator<Item = LabeledPrice>,
2252 {
2253 Self::SendInvoice::new(
2254 self.clone(),
2255 payloads::SendInvoice::new(chat_id, title, description, payload, currency, prices),
2256 )
2257 }
2258
2259 type CreateInvoiceLink = JsonRequest<payloads::CreateInvoiceLink>;
2260
2261 fn create_invoice_link<T, D, Pa, C, Pri>(
2262 &self,
2263 title: T,
2264 description: D,
2265 payload: Pa,
2266 currency: C,
2267 prices: Pri,
2268 ) -> Self::CreateInvoiceLink
2269 where
2270 T: Into<String>,
2271 D: Into<String>,
2272 Pa: Into<String>,
2273 C: Into<String>,
2274 Pri: IntoIterator<Item = LabeledPrice>,
2275 {
2276 Self::CreateInvoiceLink::new(
2277 self.clone(),
2278 payloads::CreateInvoiceLink::new(title, description, payload, currency, prices),
2279 )
2280 }
2281
2282 type AnswerShippingQuery = JsonRequest<payloads::AnswerShippingQuery>;
2283
2284 fn answer_shipping_query(
2285 &self,
2286 shipping_query_id: ShippingQueryId,
2287 ok: bool,
2288 ) -> Self::AnswerShippingQuery {
2289 Self::AnswerShippingQuery::new(
2290 self.clone(),
2291 payloads::AnswerShippingQuery::new(shipping_query_id, ok),
2292 )
2293 }
2294
2295 type AnswerPreCheckoutQuery = JsonRequest<payloads::AnswerPreCheckoutQuery>;
2296
2297 fn answer_pre_checkout_query(
2298 &self,
2299 pre_checkout_query_id: PreCheckoutQueryId,
2300 ok: bool,
2301 ) -> Self::AnswerPreCheckoutQuery {
2302 Self::AnswerPreCheckoutQuery::new(
2303 self.clone(),
2304 payloads::AnswerPreCheckoutQuery::new(pre_checkout_query_id, ok),
2305 )
2306 }
2307
2308 type GetMyStarBalance = JsonRequest<payloads::GetMyStarBalance>;
2309
2310 fn get_my_star_balance(&self) -> Self::GetMyStarBalance {
2311 Self::GetMyStarBalance::new(self.clone(), payloads::GetMyStarBalance::new())
2312 }
2313
2314 type GetStarTransactions = JsonRequest<payloads::GetStarTransactions>;
2315
2316 fn get_star_transactions(&self) -> Self::GetStarTransactions {
2317 Self::GetStarTransactions::new(self.clone(), payloads::GetStarTransactions::new())
2318 }
2319
2320 type RefundStarPayment = JsonRequest<payloads::RefundStarPayment>;
2321
2322 fn refund_star_payment(
2323 &self,
2324 user_id: UserId,
2325 telegram_payment_charge_id: TelegramTransactionId,
2326 ) -> Self::RefundStarPayment {
2327 Self::RefundStarPayment::new(
2328 self.clone(),
2329 payloads::RefundStarPayment::new(user_id, telegram_payment_charge_id),
2330 )
2331 }
2332
2333 type EditUserStarSubscription = JsonRequest<payloads::EditUserStarSubscription>;
2334
2335 fn edit_user_star_subscription(
2336 &self,
2337 user_id: UserId,
2338 telegram_payment_charge_id: TelegramTransactionId,
2339 is_canceled: bool,
2340 ) -> Self::EditUserStarSubscription {
2341 Self::EditUserStarSubscription::new(
2342 self.clone(),
2343 payloads::EditUserStarSubscription::new(
2344 user_id,
2345 telegram_payment_charge_id,
2346 is_canceled,
2347 ),
2348 )
2349 }
2350
2351 type SetPassportDataErrors = JsonRequest<payloads::SetPassportDataErrors>;
2352
2353 fn set_passport_data_errors<E>(&self, user_id: UserId, errors: E) -> Self::SetPassportDataErrors
2354 where
2355 E: IntoIterator<Item = crate::types::PassportElementError>,
2356 {
2357 Self::SetPassportDataErrors::new(
2358 self.clone(),
2359 payloads::SetPassportDataErrors::new(user_id, errors),
2360 )
2361 }
2362
2363 type SendGame = JsonRequest<payloads::SendGame>;
2364
2365 fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
2366 where
2367 C: Into<ChatId>,
2368 G: Into<String>,
2369 {
2370 Self::SendGame::new(self.clone(), payloads::SendGame::new(chat_id, game_short_name))
2371 }
2372
2373 type SetGameScore = JsonRequest<payloads::SetGameScore>;
2374
2375 fn set_game_score<C>(
2376 &self,
2377 user_id: UserId,
2378 score: u64,
2379 chat_id: C,
2380 message_id: MessageId,
2381 ) -> Self::SetGameScore
2382 where
2383 C: Into<ChatId>,
2384 {
2385 Self::SetGameScore::new(
2386 self.clone(),
2387 payloads::SetGameScore::new(user_id, score, chat_id, message_id),
2388 )
2389 }
2390
2391 type SetGameScoreInline = JsonRequest<payloads::SetGameScoreInline>;
2392
2393 fn set_game_score_inline<I>(
2394 &self,
2395 user_id: UserId,
2396 score: u64,
2397 inline_message_id: I,
2398 ) -> Self::SetGameScoreInline
2399 where
2400 I: Into<String>,
2401 {
2402 Self::SetGameScoreInline::new(
2403 self.clone(),
2404 payloads::SetGameScoreInline::new(user_id, score, inline_message_id),
2405 )
2406 }
2407
2408 type GetGameHighScores = JsonRequest<payloads::GetGameHighScores>;
2409
2410 fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
2411 where
2412 T: Into<crate::types::TargetMessage>,
2413 {
2414 Self::GetGameHighScores::new(
2415 self.clone(),
2416 payloads::GetGameHighScores::new(user_id, target),
2417 )
2418 }
2419
2420 type LogOut = JsonRequest<payloads::LogOut>;
2421
2422 fn log_out(&self) -> Self::LogOut {
2423 Self::LogOut::new(self.clone(), payloads::LogOut::new())
2424 }
2425
2426 type Close = JsonRequest<payloads::Close>;
2427
2428 fn close(&self) -> Self::Close {
2429 Self::Close::new(self.clone(), payloads::Close::new())
2430 }
2431
2432 type CopyMessage = JsonRequest<payloads::CopyMessage>;
2433
2434 fn copy_message<C, F>(
2435 &self,
2436 chat_id: C,
2437 from_chat_id: F,
2438 message_id: MessageId,
2439 ) -> Self::CopyMessage
2440 where
2441 C: Into<Recipient>,
2442 F: Into<Recipient>,
2443 {
2444 Self::CopyMessage::new(
2445 self.clone(),
2446 payloads::CopyMessage::new(chat_id, from_chat_id, message_id),
2447 )
2448 }
2449
2450 type CopyMessages = JsonRequest<payloads::CopyMessages>;
2451 fn copy_messages<C, F, M>(
2452 &self,
2453 chat_id: C,
2454 from_chat_id: F,
2455 message_ids: M,
2456 ) -> Self::CopyMessages
2457 where
2458 C: Into<Recipient>,
2459 F: Into<Recipient>,
2460 M: IntoIterator<Item = MessageId>,
2461 {
2462 Self::CopyMessages::new(
2463 self.clone(),
2464 payloads::CopyMessages::new(chat_id, from_chat_id, message_ids),
2465 )
2466 }
2467
2468 type UnpinAllChatMessages = JsonRequest<payloads::UnpinAllChatMessages>;
2469
2470 fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
2471 where
2472 C: Into<Recipient>,
2473 {
2474 Self::UnpinAllChatMessages::new(self.clone(), payloads::UnpinAllChatMessages::new(chat_id))
2475 }
2476}
2477
2478#[cfg(test)]
2479mod tests {
2480 use super::*;
2481
2482 #[tokio::test]
2483 async fn multipart_uploads_over_transport() {
2484 use crate::{
2485 payloads::SendPhotoSetters,
2486 requests::Request,
2487 types::{
2488 BusinessConnectionId, InputProfilePhotoAnimated, InputProfilePhotoStatic,
2489 InputSticker, InputStoryContent, InputStoryContentPhoto, InputStoryContentVideo,
2490 Seconds, StickerFormat, StoryId, SuggestedPostParameters,
2491 },
2492 };
2493 use std::{
2494 collections::HashMap,
2495 io::{Read, Write},
2496 net::TcpListener,
2497 sync::mpsc,
2498 };
2499
2500 struct TempFileGuard(std::path::PathBuf);
2501 impl Drop for TempFileGuard {
2502 fn drop(&mut self) {
2503 let _ = std::fs::remove_file(&self.0);
2504 }
2505 }
2506
2507 fn parse_multipart_parts(headers: &str, body: &[u8]) -> HashMap<String, Vec<u8>> {
2508 let boundary = headers
2509 .lines()
2510 .find_map(|line| {
2511 let (k, v) = line.split_once(':')?;
2512 if !k.eq_ignore_ascii_case("content-type") {
2513 return None;
2514 }
2515 v.split(';')
2516 .find_map(|part| part.trim().strip_prefix("boundary="))
2517 .map(str::to_owned)
2518 })
2519 .expect("missing multipart boundary");
2520 let delim = format!("--{boundary}").into_bytes();
2521 let mut parts = HashMap::new();
2522 let mut pos = 0;
2523 while let Some(rel_start) =
2524 body[pos..].windows(delim.len()).position(|w| w == delim.as_slice())
2525 {
2526 let part_start = pos + rel_start + delim.len();
2527 pos = part_start;
2528 if body[part_start..].starts_with(b"--") {
2529 break;
2530 }
2531 let content_start = if body[part_start..].starts_with(b"\r\n") {
2532 part_start + 2
2533 } else {
2534 part_start
2535 };
2536 let Some(hdr_end_rel) =
2537 body[content_start..].windows(4).position(|w| w == b"\r\n\r\n")
2538 else {
2539 continue;
2540 };
2541 let part_headers =
2542 String::from_utf8_lossy(&body[content_start..content_start + hdr_end_rel]);
2543 let data_start = content_start + hdr_end_rel + 4;
2544 let Some(next_delim_rel) =
2545 body[data_start..].windows(delim.len()).position(|w| w == delim.as_slice())
2546 else {
2547 continue;
2548 };
2549 let mut data_end = data_start + next_delim_rel;
2550 if body[data_start..data_end].ends_with(b"\r\n") {
2551 data_end -= 2;
2552 }
2553 if let Some(name_start) = part_headers.find("name=\"") {
2554 let name_rest = &part_headers[name_start + 6..];
2555 if let Some(name_end) = name_rest.find('"') {
2556 parts.insert(
2557 name_rest[..name_end].to_owned(),
2558 body[data_start..data_end].to_vec(),
2559 );
2560 }
2561 }
2562 pos = data_start + next_delim_rel;
2563 }
2564 parts
2565 }
2566
2567 let story_json = serde_json::json!({
2568 "ok": true,
2569 "result": {
2570 "chat": { "id": 100, "first_name": "Alice", "type": "private" },
2571 "id": 7
2572 }
2573 })
2574 .to_string();
2575 let ok_true = r#"{"ok":true,"result":true}"#.to_owned();
2576
2577 let listener = TcpListener::bind("127.0.0.1:0").unwrap();
2578 let addr = listener.local_addr().unwrap();
2579 let (tx, rx) = mpsc::channel();
2580 let message_json = serde_json::json!({"ok":true,"result":{"message_id":7,"date":0,"chat":{"id":100,"type":"private","first_name":"Alice"},"text":"test"}}).to_string();
2581 let responses = vec![
2582 story_json.clone(),
2583 story_json.clone(),
2584 story_json.clone(),
2585 story_json,
2586 ok_true.clone(),
2587 ok_true.clone(),
2588 ok_true.clone(),
2589 ok_true,
2590 message_json,
2591 ];
2592
2593 std::thread::spawn(move || {
2594 for response_body in responses {
2595 let (mut stream, _) = listener.accept().unwrap();
2596 stream.set_read_timeout(Some(std::time::Duration::from_secs(5))).unwrap();
2597 let mut data = Vec::new();
2598 let mut buf = [0u8; 4096];
2599 let header_end = loop {
2600 let n = stream.read(&mut buf).unwrap();
2601 assert!(n > 0);
2602 data.extend_from_slice(&buf[..n]);
2603 if let Some(pos) = data.windows(4).position(|w| w == b"\r\n\r\n") {
2604 break pos + 4;
2605 }
2606 };
2607 let headers = String::from_utf8_lossy(&data[..header_end]).into_owned();
2608 let req_line = headers.lines().next().unwrap().to_owned();
2609 let is_chunked = headers.lines().any(|line| {
2610 line.split_once(':').is_some_and(|(k, v)| {
2611 k.eq_ignore_ascii_case("transfer-encoding")
2612 && v.to_ascii_lowercase().contains("chunked")
2613 })
2614 });
2615 let raw_body = if is_chunked {
2616 let mut cursor = header_end;
2617 let mut decoded = Vec::new();
2618 loop {
2619 let line_end = loop {
2620 if let Some(pos) = data[cursor..].windows(2).position(|w| w == b"\r\n")
2621 {
2622 break cursor + pos;
2623 }
2624 let n = stream.read(&mut buf).unwrap();
2625 assert!(n > 0);
2626 data.extend_from_slice(&buf[..n]);
2627 };
2628 let size_str = std::str::from_utf8(&data[cursor..line_end]).unwrap();
2629 let size_hex = size_str.split(';').next().unwrap().trim();
2630 let chunk_len = usize::from_str_radix(size_hex, 16).unwrap();
2631 cursor = line_end + 2;
2632 if chunk_len == 0 {
2633 while data.len() < cursor + 2 {
2634 let n = stream.read(&mut buf).unwrap();
2635 if n == 0 {
2636 break;
2637 }
2638 data.extend_from_slice(&buf[..n]);
2639 }
2640 break;
2641 }
2642 while data.len() < cursor + chunk_len + 2 {
2643 let n = stream.read(&mut buf).unwrap();
2644 assert!(n > 0);
2645 data.extend_from_slice(&buf[..n]);
2646 }
2647 decoded.extend_from_slice(&data[cursor..cursor + chunk_len]);
2648 cursor += chunk_len + 2;
2649 }
2650 decoded
2651 } else {
2652 let content_len: usize = headers
2653 .lines()
2654 .find_map(|line| {
2655 let (k, v) = line.split_once(':')?;
2656 k.eq_ignore_ascii_case("content-length")
2657 .then(|| v.trim().parse().ok())?
2658 })
2659 .unwrap_or(0);
2660 while data.len() < header_end + content_len {
2661 let n = stream.read(&mut buf).unwrap();
2662 assert!(n > 0);
2663 data.extend_from_slice(&buf[..n]);
2664 }
2665 data[header_end..header_end + content_len].to_vec()
2666 };
2667 tx.send((req_line, headers, raw_body)).unwrap();
2668
2669 let reply = format!(
2670 "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: \
2671 {}\r\nConnection: close\r\n\r\n{}",
2672 response_body.len(),
2673 response_body
2674 );
2675 stream.write_all(reply.as_bytes()).unwrap();
2676 stream.flush().unwrap();
2677 }
2678 });
2679
2680 let api_url = reqwest::Url::parse(&format!("http://{addr}/")).unwrap();
2681 let client =
2682 reqwest::Client::builder().timeout(std::time::Duration::from_secs(5)).build().unwrap();
2683 let bot = Bot::with_client("test-token", client).set_api_url(api_url);
2684
2685 let unique =
2686 std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
2687 let story_video_bytes = b"\x00\x01DISK_STORY_MP4\xff\xfe".to_vec();
2688 let story_video_path =
2689 std::env::temp_dir().join(format!("teloxide-story-vid-{unique}.mp4"));
2690 std::fs::write(&story_video_path, &story_video_bytes).unwrap();
2691 let _vid_guard = TempFileGuard(story_video_path.clone());
2692
2693 let story_photo_bytes = b"\xff\xd8MEM_STORY_PHOTO\xd9".to_vec();
2694 let sticker_bytes = b"\x89PNG_REPLACE_STICKER\x00".to_vec();
2695
2696 let post_req = bot.post_story(
2697 BusinessConnectionId("bc-1".to_owned()),
2698 InputStoryContent::Photo(InputStoryContentPhoto {
2699 photo: InputFile::memory(story_photo_bytes.clone()).file_name("story.jpg"),
2700 }),
2701 Seconds::from_seconds(21_600),
2702 );
2703 assert_eq!(post_req.send_ref().await.unwrap().id, StoryId(7));
2704 assert_eq!(post_req.send().await.unwrap().id, StoryId(7));
2705
2706 let edit_req = bot.edit_story(
2707 BusinessConnectionId("bc-1".to_owned()),
2708 StoryId(7),
2709 InputStoryContent::Video(InputStoryContentVideo {
2710 video: InputFile::file(&story_video_path),
2711 duration: Some(5.0),
2712 cover_frame_timestamp: None,
2713 is_animation: Some(false),
2714 }),
2715 );
2716 assert_eq!(edit_req.send_ref().await.unwrap().id, StoryId(7));
2717 assert_eq!(edit_req.send().await.unwrap().id, StoryId(7));
2718
2719 let replace_req = bot.replace_sticker_in_set(
2720 UserId(42),
2721 "my_pack",
2722 "old_file_id",
2723 InputSticker {
2724 sticker: InputFile::memory(sticker_bytes.clone()).file_name("new.png"),
2725 format: StickerFormat::Static,
2726 emoji_list: vec!["😀".to_owned()],
2727 mask_position: None,
2728 keywords: Vec::new(),
2729 },
2730 );
2731 assert_eq!(replace_req.send_ref().await.unwrap(), crate::types::True);
2732 assert_eq!(replace_req.send().await.unwrap(), crate::types::True);
2733
2734 bot.set_my_profile_photo(InputProfilePhoto::Static(InputProfilePhotoStatic {
2735 photo: InputFile::memory(story_photo_bytes.clone()),
2736 }))
2737 .send_ref()
2738 .await
2739 .unwrap();
2740 bot.set_business_account_profile_photo(
2741 BusinessConnectionId("bc-1".to_owned()),
2742 InputProfilePhoto::Animated(InputProfilePhotoAnimated {
2743 animation: InputFile::file(&story_video_path),
2744 main_frame_timestamp: Some(1.5),
2745 }),
2746 )
2747 .await
2748 .unwrap();
2749 bot.send_photo(InputFile::file_id("photo".into()))
2750 .chat_id(ChatId(100))
2751 .suggested_post_parameters(SuggestedPostParameters { price: None, send_date: None })
2752 .await
2753 .unwrap();
2754
2755 for _ in 0..2 {
2756 let (line, headers, body) = rx.recv().unwrap();
2757 assert!(line.starts_with("POST /bottest-token/PostStory "), "{line}");
2758 assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2759 let parts = parse_multipart_parts(&headers, &body);
2760 let content: serde_json::Value =
2761 serde_json::from_slice(parts.get("content").unwrap()).unwrap();
2762 let attach = content["photo"].as_str().unwrap().strip_prefix("attach://").unwrap();
2763 assert_eq!(parts.get(attach), Some(&story_photo_bytes));
2764 }
2765
2766 for _ in 0..2 {
2767 let (line, headers, body) = rx.recv().unwrap();
2768 assert!(line.starts_with("POST /bottest-token/EditStory "), "{line}");
2769 assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2770 let parts = parse_multipart_parts(&headers, &body);
2771 let content: serde_json::Value =
2772 serde_json::from_slice(parts.get("content").unwrap()).unwrap();
2773 let attach = content["video"].as_str().unwrap().strip_prefix("attach://").unwrap();
2774 assert_eq!(parts.get(attach), Some(&story_video_bytes));
2775 }
2776
2777 for _ in 0..2 {
2778 let (line, headers, body) = rx.recv().unwrap();
2779 assert!(line.starts_with("POST /bottest-token/ReplaceStickerInSet "), "{line}");
2780 assert!(headers.to_ascii_lowercase().contains("multipart/form-data"));
2781 let parts = parse_multipart_parts(&headers, &body);
2782 let sticker: serde_json::Value =
2783 serde_json::from_slice(parts.get("sticker").unwrap()).unwrap();
2784 let attach = sticker["sticker"].as_str().unwrap().strip_prefix("attach://").unwrap();
2785 assert_eq!(parts.get(attach), Some(&sticker_bytes));
2786 }
2787
2788 for (method, kind, field, bytes) in [
2789 ("SetMyProfilePhoto", "static", "photo", story_photo_bytes),
2790 ("SetBusinessAccountProfilePhoto", "animated", "animation", story_video_bytes),
2791 ] {
2792 let (line, headers, body) = rx.recv().unwrap();
2793 assert!(line.starts_with(&format!("POST /bottest-token/{method} ")), "{line}");
2794 let parts = parse_multipart_parts(&headers, &body);
2795 let photo: serde_json::Value = serde_json::from_slice(&parts["photo"]).unwrap();
2796 assert_eq!(photo["type"], kind);
2797 let attach = photo[field].as_str().unwrap().strip_prefix("attach://").unwrap();
2798 assert_eq!(parts[attach], bytes);
2799 }
2800 let (_, headers, body) = rx.recv().unwrap();
2801 let parts = parse_multipart_parts(&headers, &body);
2802 assert_eq!(parts["suggested_post_parameters"], b"{}");
2803 }
2804
2805 #[tokio::test]
2806 async fn all_siblings_use_their_telegram_route() {
2807 use std::{
2808 io::{BufRead, BufReader, Write},
2809 net::TcpListener,
2810 time::Duration,
2811 };
2812 let listener = TcpListener::bind("127.0.0.1:0").unwrap();
2813 let bot = Bot::new("route-token").set_api_url(
2814 format!("http://{}/prefix/", listener.local_addr().unwrap()).parse().unwrap(),
2815 );
2816 let server = std::thread::spawn(move || {
2817 for method in [
2818 "EditMessageLiveLocation",
2819 "EditMessageLiveLocation",
2820 "StopMessageLiveLocation",
2821 "StopMessageLiveLocation",
2822 "EditMessageText",
2823 "EditMessageText",
2824 "EditMessageCaption",
2825 "EditMessageCaption",
2826 "EditMessageMedia",
2827 "EditMessageMedia",
2828 "EditMessageWidgetData",
2829 "EditMessageWidgetData",
2830 "EditMessageReplyMarkup",
2831 "EditMessageReplyMarkup",
2832 "SendGift",
2833 "SendGift",
2834 "SetGameScore",
2835 "SetGameScore",
2836 ] {
2837 let (mut stream, _) = listener.accept().unwrap();
2838 stream.set_read_timeout(Some(Duration::from_secs(2))).unwrap();
2839 let mut headers = BufReader::new(&mut stream);
2840 let mut line = String::new();
2841 headers.read_line(&mut line).unwrap();
2842 assert_eq!(line, format!("POST /prefix/botroute-token/{method} HTTP/1.1\r\n"));
2843 loop {
2844 line.clear();
2845 if headers.read_line(&mut line).unwrap() == 0 || line == "\r\n" {
2846 break;
2847 }
2848 }
2849 let body = r#"{"ok":false,"description":"Unauthorized"}"#;
2850 write!(
2851 stream,
2852 "HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",
2853 body.len()
2854 )
2855 .unwrap();
2856 }
2857 });
2858 let chat = ChatId(-1_000_000_000_001);
2859 let msg = MessageId(7);
2860 let user = UserId(42);
2861 let media = || {
2862 InputMedia::Photo(crate::types::InputMediaPhoto::new(InputFile::file_id("1".into())))
2863 };
2864 macro_rules! check {
2865 ($call:expr) => {
2866 assert!(matches!(
2867 $call.await,
2868 Err(crate::RequestError::Api(crate::ApiError::InvalidToken))
2869 ));
2870 };
2871 }
2872 tokio::time::timeout(Duration::from_secs(10), async {
2873 check!(bot.edit_message_live_location(chat, msg, 1.0, 2.0));
2874 check!(bot.edit_message_live_location_inline("inline", 1.0, 2.0));
2875 check!(bot.stop_message_live_location(chat, msg));
2876 check!(bot.stop_message_live_location_inline("inline"));
2877 check!(bot.edit_message_text(chat, msg));
2878 check!(bot.edit_message_text_inline("inline"));
2879 check!(bot.edit_message_caption(chat, msg));
2880 check!(bot.edit_message_caption_inline("inline"));
2881 check!(bot.edit_message_media(chat, msg, media()));
2882 check!(bot.edit_message_media_inline("inline", media()));
2883 check!(bot.edit_message_widget_data(chat, msg));
2884 check!(bot.edit_message_widget_data_inline("inline"));
2885 check!(bot.edit_message_reply_markup(chat, msg));
2886 check!(bot.edit_message_reply_markup_inline("inline"));
2887 check!(bot.send_gift(user, GiftId("gift".into())));
2888 check!(bot.send_gift_chat(chat, GiftId("gift".into())));
2889 check!(bot.set_game_score(user, 42, chat, msg));
2890 check!(bot.set_game_score_inline(user, 42, "inline"));
2891 })
2892 .await
2893 .unwrap();
2894 server.join().unwrap();
2895 }
2896
2897 #[tokio::test]
2898 async fn second_send_does_not_hang_after_shared_reader_is_cancelled() {
2899 use crate::requests::Request;
2900 use std::time::Duration;
2901 let bot = Bot::new("test-token");
2902 let (reader, _writer) = tokio::io::duplex(128);
2903 let request = bot.set_chat_photo(ChatId(1), InputFile::read(reader));
2904 let mut first = Box::pin(request.send_ref());
2905 assert!(futures::poll!(&mut first).is_pending());
2906 drop(first);
2907 let result =
2908 tokio::time::timeout(Duration::from_secs(2), request.send_ref()).await.unwrap();
2909 assert!(
2910 matches!(result, Err(crate::RequestError::Io(error)) if error.kind() == std::io::ErrorKind::Interrupted)
2911 );
2912 }
2913}