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