1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
// We can't change Telegram API
#![allow(clippy::too_many_arguments)]

use url::Url;

use crate::{errors::AsResponseParameters, payloads::*, requests::Request, types::*};

/// Telegram Bot API client.
///
/// This trait is implemented by all bots & bot adaptors.
///
/// ## Calling Telegram Bot API methods
///
/// To call Telegram's methods you first need to get a [`Bot`] instance or any
/// other type which implement this trait.
///
/// Then you can simply call the method you want and pass required parameters to
/// it. Optional parameters can be supplied by calling setters (like
/// `parse_mode` in the example below). Lastly, you need to `.await` the request
/// created in previous steps, to actually send it to telegram and wait for the
/// response.
///
/// ```
/// # async {
/// # let chat_id = ChatId(-1);
/// use teloxide_core::{
///     prelude::*,
///     types::{ChatId, ParseMode},
/// };
///
/// // Bot implements `Requester`
/// let bot = Bot::new("TOKEN");
///
/// // Required parameters are supplied to the `Requester` methods:
/// bot.send_message(chat_id, "<b>Text</b>")
///     // Optional parameters can be supplied by calling setters
///     .parse_mode(ParseMode::Html)
///     // To send request to telegram you need to `.await` the request
///     .await?;
/// # Ok::<_, teloxide_core::RequestError>(())
/// # };
/// ```
///
/// ## Adaptors
///
/// Similarly to how [`Iterator`] has iterator adaptors ([`FlatMap`],
/// [`Filter`], etc) that wrap an [`Iterator`] and alter its behaviour, Teloxide
/// has a similar story with `Requester`.
///
/// [`adaptors`] module provides a handful of `Requester` adaptors that can be
/// created via [`RequesterExt`] methods. For example using [`.parse_mode(...)`]
/// on a bot will wrap it in [`DefaultParseMode`] adaptor which sets the parse
/// mode to a default value:
///
/// ```rust
/// # async {
/// # let chat_id = ChatId(-1);
/// use teloxide_core::{
///     prelude::*,
///     types::{ChatId, ParseMode},
/// };
///
/// let bot = Bot::new("TOKEN")
///     // Wrap the bot in an adaptor
///     .parse_mode(ParseMode::Html);
///
/// // This will use `ParseMode::Html`
/// bot.send_message(chat_id, "<b>Text</b>").await?;
///
/// // This will use `ParseMode::MarkdownV2`
/// bot.send_message(chat_id, "**Text**").parse_mode(ParseMode::MarkdownV2).await?;
/// # Ok::<_, teloxide_core::RequestError>(())
/// # };
/// ```
///
/// Note that just as with iterators, adaptors change type:
///
/// ```compile_fail
/// # use teloxide_core::{prelude::*, types::{ChatId, ParseMode}};
/// let bot: Bot = Bot::new("TOKEN").parse_mode(ParseMode::Html);
/// ```
/// ```rust
/// # use teloxide_core::{prelude::*, types::{ChatId, ParseMode}, adaptors::DefaultParseMode};
/// let bot: DefaultParseMode<Bot> = Bot::new("TOKEN").parse_mode(ParseMode::Html);
/// ```
///
/// Because of this it's oftentimes more convinient to have a type alias:
///
/// ```rust,no_run
/// # #[cfg(feature = "throttle")] {
/// # use teloxide_core::{adaptors::{DefaultParseMode, Throttle}, requests::RequesterExt, types::ParseMode};
/// type Bot = DefaultParseMode<Throttle<teloxide_core::Bot>>;
///
/// let bot: Bot = teloxide_core::Bot::new("TOKEN")
///     .throttle(<_>::default())
///     .parse_mode(ParseMode::Html);
/// # let _ = bot;
/// # };
/// ```
///
/// Also note that most adaptors require specific cargo features to be enabled.
/// For example, to use [`Throttle`] you need to enable `throttle` feature in
/// your `Cargo.toml`:
///
/// ```toml
/// teloxide_core = { version = "...", features = ["throttle"] }
/// ```
///
/// Refer to adaptor's documentation for information about what features it
/// requires.
///
/// ## Using `Requester` in a generic context
///
/// When writing helper function you may be indifferent to which exact type is
/// being used as a bot and instead only care that it implements `Requester`
/// trait. In this case you can use generic bounds to express this exact thing:
///
/// ```
/// use teloxide_core::{
///     prelude::*,
///     types::{ChatId, Message},
/// };
///
/// async fn send_hi<R>(bot: R, chat: ChatId) -> Message
/// where
///     R: Requester,
/// {
///     bot.send_message(chat, "hi").await.expect("error")
/// }
///
/// // `send_hi` can be called with `Bot`, `DefaultParseMode<Bot>` and so on, and so forth
/// ```
///
/// [`Bot`]: crate::Bot
/// [`FlatMap`]: std::iter::FlatMap
/// [`Filter`]: std::iter::Filter
/// [`adaptors`]: crate::adaptors
/// [`DefaultParseMode`]: crate::adaptors::DefaultParseMode
/// [`Throttle`]: crate::adaptors::Throttle
/// [`RequesterExt`]: crate::requests::RequesterExt
/// [`.parse_mode(...)`]: crate::requests::RequesterExt::parse_mode
#[cfg_attr(all(any(docsrs, dep_docsrs), feature = "nightly"), doc(notable_trait))]
pub trait Requester {
    /// Error type returned by all requests.
    type Err: std::error::Error + Send + AsResponseParameters;

    // START BLOCK requester_methods
    // Generated by `codegen_requester_methods`, do not edit by hand.

    type GetUpdates: Request<Payload = GetUpdates, Err = Self::Err>;

    /// For Telegram documentation see [`GetUpdates`].
    fn get_updates(&self) -> Self::GetUpdates;

    type SetWebhook: Request<Payload = SetWebhook, Err = Self::Err>;

    /// For Telegram documentation see [`SetWebhook`].
    fn set_webhook(&self, url: Url) -> Self::SetWebhook;

    type DeleteWebhook: Request<Payload = DeleteWebhook, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteWebhook`].
    fn delete_webhook(&self) -> Self::DeleteWebhook;

    type GetWebhookInfo: Request<Payload = GetWebhookInfo, Err = Self::Err>;

    /// For Telegram documentation see [`GetWebhookInfo`].
    fn get_webhook_info(&self) -> Self::GetWebhookInfo;

    type GetMe: Request<Payload = GetMe, Err = Self::Err>;

    /// For Telegram documentation see [`GetMe`].
    fn get_me(&self) -> Self::GetMe;

    type LogOut: Request<Payload = LogOut, Err = Self::Err>;

    /// For Telegram documentation see [`LogOut`].
    fn log_out(&self) -> Self::LogOut;

    type Close: Request<Payload = Close, Err = Self::Err>;

    /// For Telegram documentation see [`Close`].
    fn close(&self) -> Self::Close;

    type SendMessage: Request<Payload = SendMessage, Err = Self::Err>;

    /// For Telegram documentation see [`SendMessage`].
    fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage
    where
        C: Into<Recipient>,
        T: Into<String>;

    type ForwardMessage: Request<Payload = ForwardMessage, Err = Self::Err>;

    /// For Telegram documentation see [`ForwardMessage`].
    fn forward_message<C, F>(
        &self,
        chat_id: C,
        from_chat_id: F,
        message_id: MessageId,
    ) -> Self::ForwardMessage
    where
        C: Into<Recipient>,
        F: Into<Recipient>;

    type ForwardMessages: Request<Payload = ForwardMessages, Err = Self::Err>;

    /// For Telegram documentation see [`ForwardMessages`].
    fn forward_messages<C, F, M>(
        &self,
        chat_id: C,
        from_chat_id: F,
        message_ids: M,
    ) -> Self::ForwardMessages
    where
        C: Into<Recipient>,
        F: Into<Recipient>,
        M: IntoIterator<Item = MessageId>;

    type CopyMessage: Request<Payload = CopyMessage, Err = Self::Err>;

    /// For Telegram documentation see [`CopyMessage`].
    fn copy_message<C, F>(
        &self,
        chat_id: C,
        from_chat_id: F,
        message_id: MessageId,
    ) -> Self::CopyMessage
    where
        C: Into<Recipient>,
        F: Into<Recipient>;

    type CopyMessages: Request<Payload = CopyMessages, Err = Self::Err>;

    /// For Telegram documentation see [`CopyMessages`].
    fn copy_messages<C, F, M>(
        &self,
        chat_id: C,
        from_chat_id: F,
        message_ids: M,
    ) -> Self::CopyMessages
    where
        C: Into<Recipient>,
        F: Into<Recipient>,
        M: IntoIterator<Item = MessageId>;

    type SendPhoto: Request<Payload = SendPhoto, Err = Self::Err>;

    /// For Telegram documentation see [`SendPhoto`].
    fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto
    where
        C: Into<Recipient>;

    type SendAudio: Request<Payload = SendAudio, Err = Self::Err>;

    /// For Telegram documentation see [`SendAudio`].
    fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio
    where
        C: Into<Recipient>;

    type SendDocument: Request<Payload = SendDocument, Err = Self::Err>;

    /// For Telegram documentation see [`SendDocument`].
    fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument
    where
        C: Into<Recipient>;

    type SendVideo: Request<Payload = SendVideo, Err = Self::Err>;

    /// For Telegram documentation see [`SendVideo`].
    fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo
    where
        C: Into<Recipient>;

    type SendAnimation: Request<Payload = SendAnimation, Err = Self::Err>;

    /// For Telegram documentation see [`SendAnimation`].
    fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation
    where
        C: Into<Recipient>;

    type SendVoice: Request<Payload = SendVoice, Err = Self::Err>;

    /// For Telegram documentation see [`SendVoice`].
    fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice
    where
        C: Into<Recipient>;

    type SendVideoNote: Request<Payload = SendVideoNote, Err = Self::Err>;

    /// For Telegram documentation see [`SendVideoNote`].
    fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote
    where
        C: Into<Recipient>;

    type SendMediaGroup: Request<Payload = SendMediaGroup, Err = Self::Err>;

    /// For Telegram documentation see [`SendMediaGroup`].
    fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
    where
        C: Into<Recipient>,
        M: IntoIterator<Item = InputMedia>;

    type SendLocation: Request<Payload = SendLocation, Err = Self::Err>;

    /// For Telegram documentation see [`SendLocation`].
    fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation
    where
        C: Into<Recipient>;

    type EditMessageLiveLocation: Request<Payload = EditMessageLiveLocation, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageLiveLocation`].
    fn edit_message_live_location<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
        latitude: f64,
        longitude: f64,
    ) -> Self::EditMessageLiveLocation
    where
        C: Into<Recipient>;

    type EditMessageLiveLocationInline: Request<
        Payload = EditMessageLiveLocationInline,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`EditMessageLiveLocationInline`].
    fn edit_message_live_location_inline<I>(
        &self,
        inline_message_id: I,
        latitude: f64,
        longitude: f64,
    ) -> Self::EditMessageLiveLocationInline
    where
        I: Into<String>;

    type StopMessageLiveLocation: Request<Payload = StopMessageLiveLocation, Err = Self::Err>;

    /// For Telegram documentation see [`StopMessageLiveLocation`].
    fn stop_message_live_location<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
    ) -> Self::StopMessageLiveLocation
    where
        C: Into<Recipient>;

    type StopMessageLiveLocationInline: Request<
        Payload = StopMessageLiveLocationInline,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`StopMessageLiveLocationInline`].
    fn stop_message_live_location_inline<I>(
        &self,
        inline_message_id: I,
    ) -> Self::StopMessageLiveLocationInline
    where
        I: Into<String>;

    type SendVenue: Request<Payload = SendVenue, Err = Self::Err>;

    /// For Telegram documentation see [`SendVenue`].
    fn send_venue<C, T, A>(
        &self,
        chat_id: C,
        latitude: f64,
        longitude: f64,
        title: T,
        address: A,
    ) -> Self::SendVenue
    where
        C: Into<Recipient>,
        T: Into<String>,
        A: Into<String>;

    type SendContact: Request<Payload = SendContact, Err = Self::Err>;

    /// For Telegram documentation see [`SendContact`].
    fn send_contact<C, P, F>(
        &self,
        chat_id: C,
        phone_number: P,
        first_name: F,
    ) -> Self::SendContact
    where
        C: Into<Recipient>,
        P: Into<String>,
        F: Into<String>;

    type SendPoll: Request<Payload = SendPoll, Err = Self::Err>;

    /// For Telegram documentation see [`SendPoll`].
    fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
    where
        C: Into<Recipient>,
        Q: Into<String>,
        O: IntoIterator<Item = String>;

    type SendDice: Request<Payload = SendDice, Err = Self::Err>;

    /// For Telegram documentation see [`SendDice`].
    fn send_dice<C>(&self, chat_id: C) -> Self::SendDice
    where
        C: Into<Recipient>;

    type SendChatAction: Request<Payload = SendChatAction, Err = Self::Err>;

    /// For Telegram documentation see [`SendChatAction`].
    fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction
    where
        C: Into<Recipient>;

    type SetMessageReaction: Request<Payload = SetMessageReaction, Err = Self::Err>;

    /// For Telegram documentation see [`SetMessageReaction`].
    fn set_message_reaction<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
    ) -> Self::SetMessageReaction
    where
        C: Into<Recipient>;

    type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;

    /// For Telegram documentation see [`GetUserProfilePhotos`].
    fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos;

    type GetFile: Request<Payload = GetFile, Err = Self::Err>;

    /// For Telegram documentation see [`GetFile`].
    fn get_file<F>(&self, file_id: F) -> Self::GetFile
    where
        F: Into<String>;

    type BanChatMember: Request<Payload = BanChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`BanChatMember`].
    fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember
    where
        C: Into<Recipient>;

    type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`KickChatMember`].
    fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember
    where
        C: Into<Recipient>;

    type UnbanChatMember: Request<Payload = UnbanChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`UnbanChatMember`].
    fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember
    where
        C: Into<Recipient>;

    type RestrictChatMember: Request<Payload = RestrictChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`RestrictChatMember`].
    fn restrict_chat_member<C>(
        &self,
        chat_id: C,
        user_id: UserId,
        permissions: ChatPermissions,
    ) -> Self::RestrictChatMember
    where
        C: Into<Recipient>;

    type PromoteChatMember: Request<Payload = PromoteChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`PromoteChatMember`].
    fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember
    where
        C: Into<Recipient>;

    type SetChatAdministratorCustomTitle: Request<
        Payload = SetChatAdministratorCustomTitle,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`SetChatAdministratorCustomTitle`].
    fn set_chat_administrator_custom_title<Ch, C>(
        &self,
        chat_id: Ch,
        user_id: UserId,
        custom_title: C,
    ) -> Self::SetChatAdministratorCustomTitle
    where
        Ch: Into<Recipient>,
        C: Into<String>;

    type BanChatSenderChat: Request<Payload = BanChatSenderChat, Err = Self::Err>;

    /// For Telegram documentation see [`BanChatSenderChat`].
    fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat
    where
        C: Into<Recipient>,
        S: Into<ChatId>;

    type UnbanChatSenderChat: Request<Payload = UnbanChatSenderChat, Err = Self::Err>;

    /// For Telegram documentation see [`UnbanChatSenderChat`].
    fn unban_chat_sender_chat<C, S>(
        &self,
        chat_id: C,
        sender_chat_id: S,
    ) -> Self::UnbanChatSenderChat
    where
        C: Into<Recipient>,
        S: Into<ChatId>;

    type SetChatPermissions: Request<Payload = SetChatPermissions, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatPermissions`].
    fn set_chat_permissions<C>(
        &self,
        chat_id: C,
        permissions: ChatPermissions,
    ) -> Self::SetChatPermissions
    where
        C: Into<Recipient>;

    type ExportChatInviteLink: Request<Payload = ExportChatInviteLink, Err = Self::Err>;

    /// For Telegram documentation see [`ExportChatInviteLink`].
    fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
    where
        C: Into<Recipient>;

    type CreateChatInviteLink: Request<Payload = CreateChatInviteLink, Err = Self::Err>;

    /// For Telegram documentation see [`CreateChatInviteLink`].
    fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
    where
        C: Into<Recipient>;

    type EditChatInviteLink: Request<Payload = EditChatInviteLink, Err = Self::Err>;

    /// For Telegram documentation see [`EditChatInviteLink`].
    fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
    where
        C: Into<Recipient>,
        I: Into<String>;

    type RevokeChatInviteLink: Request<Payload = RevokeChatInviteLink, Err = Self::Err>;

    /// For Telegram documentation see [`RevokeChatInviteLink`].
    fn revoke_chat_invite_link<C, I>(
        &self,
        chat_id: C,
        invite_link: I,
    ) -> Self::RevokeChatInviteLink
    where
        C: Into<Recipient>,
        I: Into<String>;

    type ApproveChatJoinRequest: Request<Payload = ApproveChatJoinRequest, Err = Self::Err>;

    /// For Telegram documentation see [`ApproveChatJoinRequest`].
    fn approve_chat_join_request<C>(
        &self,
        chat_id: C,
        user_id: UserId,
    ) -> Self::ApproveChatJoinRequest
    where
        C: Into<Recipient>;

    type DeclineChatJoinRequest: Request<Payload = DeclineChatJoinRequest, Err = Self::Err>;

    /// For Telegram documentation see [`DeclineChatJoinRequest`].
    fn decline_chat_join_request<C>(
        &self,
        chat_id: C,
        user_id: UserId,
    ) -> Self::DeclineChatJoinRequest
    where
        C: Into<Recipient>;

    type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatPhoto`].
    fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
    where
        C: Into<Recipient>;

    type DeleteChatPhoto: Request<Payload = DeleteChatPhoto, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteChatPhoto`].
    fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
    where
        C: Into<Recipient>;

    type SetChatTitle: Request<Payload = SetChatTitle, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatTitle`].
    fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
    where
        C: Into<Recipient>,
        T: Into<String>;

    type SetChatDescription: Request<Payload = SetChatDescription, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatDescription`].
    fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
    where
        C: Into<Recipient>;

    type PinChatMessage: Request<Payload = PinChatMessage, Err = Self::Err>;

    /// For Telegram documentation see [`PinChatMessage`].
    fn pin_chat_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::PinChatMessage
    where
        C: Into<Recipient>;

    type UnpinChatMessage: Request<Payload = UnpinChatMessage, Err = Self::Err>;

    /// For Telegram documentation see [`UnpinChatMessage`].
    fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
    where
        C: Into<Recipient>;

    type UnpinAllChatMessages: Request<Payload = UnpinAllChatMessages, Err = Self::Err>;

    /// For Telegram documentation see [`UnpinAllChatMessages`].
    fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
    where
        C: Into<Recipient>;

    type LeaveChat: Request<Payload = LeaveChat, Err = Self::Err>;

    /// For Telegram documentation see [`LeaveChat`].
    fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
    where
        C: Into<Recipient>;

    type GetChat: Request<Payload = GetChat, Err = Self::Err>;

    /// For Telegram documentation see [`GetChat`].
    fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
    where
        C: Into<Recipient>;

    type GetChatAdministrators: Request<Payload = GetChatAdministrators, Err = Self::Err>;

    /// For Telegram documentation see [`GetChatAdministrators`].
    fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
    where
        C: Into<Recipient>;

    type GetChatMemberCount: Request<Payload = GetChatMemberCount, Err = Self::Err>;

    /// For Telegram documentation see [`GetChatMemberCount`].
    fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
    where
        C: Into<Recipient>;

    type GetChatMembersCount: Request<Payload = GetChatMembersCount, Err = Self::Err>;

    /// For Telegram documentation see [`GetChatMembersCount`].
    fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
    where
        C: Into<Recipient>;

    type GetChatMember: Request<Payload = GetChatMember, Err = Self::Err>;

    /// For Telegram documentation see [`GetChatMember`].
    fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember
    where
        C: Into<Recipient>;

    type SetChatStickerSet: Request<Payload = SetChatStickerSet, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatStickerSet`].
    fn set_chat_sticker_set<C, S>(
        &self,
        chat_id: C,
        sticker_set_name: S,
    ) -> Self::SetChatStickerSet
    where
        C: Into<Recipient>,
        S: Into<String>;

    type DeleteChatStickerSet: Request<Payload = DeleteChatStickerSet, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteChatStickerSet`].
    fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
    where
        C: Into<Recipient>;

    type GetForumTopicIconStickers: Request<Payload = GetForumTopicIconStickers, Err = Self::Err>;

    /// For Telegram documentation see [`GetForumTopicIconStickers`].
    fn get_forum_topic_icon_stickers(&self) -> Self::GetForumTopicIconStickers;

    type CreateForumTopic: Request<Payload = CreateForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`CreateForumTopic`].
    fn create_forum_topic<C, N, I>(
        &self,
        chat_id: C,
        name: N,
        icon_color: u32,
        icon_custom_emoji_id: I,
    ) -> Self::CreateForumTopic
    where
        C: Into<Recipient>,
        N: Into<String>,
        I: Into<String>;

    type EditForumTopic: Request<Payload = EditForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`EditForumTopic`].
    fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic
    where
        C: Into<Recipient>;

    type CloseForumTopic: Request<Payload = CloseForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`CloseForumTopic`].
    fn close_forum_topic<C>(
        &self,
        chat_id: C,
        message_thread_id: ThreadId,
    ) -> Self::CloseForumTopic
    where
        C: Into<Recipient>;

    type ReopenForumTopic: Request<Payload = ReopenForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`ReopenForumTopic`].
    fn reopen_forum_topic<C>(
        &self,
        chat_id: C,
        message_thread_id: ThreadId,
    ) -> Self::ReopenForumTopic
    where
        C: Into<Recipient>;

    type DeleteForumTopic: Request<Payload = DeleteForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteForumTopic`].
    fn delete_forum_topic<C>(
        &self,
        chat_id: C,
        message_thread_id: ThreadId,
    ) -> Self::DeleteForumTopic
    where
        C: Into<Recipient>;

    type UnpinAllForumTopicMessages: Request<Payload = UnpinAllForumTopicMessages, Err = Self::Err>;

    /// For Telegram documentation see [`UnpinAllForumTopicMessages`].
    fn unpin_all_forum_topic_messages<C>(
        &self,
        chat_id: C,
        message_thread_id: ThreadId,
    ) -> Self::UnpinAllForumTopicMessages
    where
        C: Into<Recipient>;

    type EditGeneralForumTopic: Request<Payload = EditGeneralForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`EditGeneralForumTopic`].
    fn edit_general_forum_topic<C, N>(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic
    where
        C: Into<Recipient>,
        N: Into<String>;

    type CloseGeneralForumTopic: Request<Payload = CloseGeneralForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`CloseGeneralForumTopic`].
    fn close_general_forum_topic<C>(&self, chat_id: C) -> Self::CloseGeneralForumTopic
    where
        C: Into<Recipient>;

    type ReopenGeneralForumTopic: Request<Payload = ReopenGeneralForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`ReopenGeneralForumTopic`].
    fn reopen_general_forum_topic<C>(&self, chat_id: C) -> Self::ReopenGeneralForumTopic
    where
        C: Into<Recipient>;

    type HideGeneralForumTopic: Request<Payload = HideGeneralForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`HideGeneralForumTopic`].
    fn hide_general_forum_topic<C>(&self, chat_id: C) -> Self::HideGeneralForumTopic
    where
        C: Into<Recipient>;

    type UnhideGeneralForumTopic: Request<Payload = UnhideGeneralForumTopic, Err = Self::Err>;

    /// For Telegram documentation see [`UnhideGeneralForumTopic`].
    fn unhide_general_forum_topic<C>(&self, chat_id: C) -> Self::UnhideGeneralForumTopic
    where
        C: Into<Recipient>;

    type UnpinAllGeneralForumTopicMessages: Request<
        Payload = UnpinAllGeneralForumTopicMessages,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`UnpinAllGeneralForumTopicMessages`].
    fn unpin_all_general_forum_topic_messages<C>(
        &self,
        chat_id: C,
    ) -> Self::UnpinAllGeneralForumTopicMessages
    where
        C: Into<Recipient>;

    type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>;

    /// For Telegram documentation see [`AnswerCallbackQuery`].
    fn answer_callback_query<C>(&self, callback_query_id: C) -> Self::AnswerCallbackQuery
    where
        C: Into<String>;

    type GetUserChatBoosts: Request<Payload = GetUserChatBoosts, Err = Self::Err>;

    /// For Telegram documentation see [`GetUserChatBoosts`].
    fn get_user_chat_boosts<C>(&self, chat_id: C, user_id: UserId) -> Self::GetUserChatBoosts
    where
        C: Into<Recipient>;

    type SetMyCommands: Request<Payload = SetMyCommands, Err = Self::Err>;

    /// For Telegram documentation see [`SetMyCommands`].
    fn set_my_commands<C>(&self, commands: C) -> Self::SetMyCommands
    where
        C: IntoIterator<Item = BotCommand>;

    type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;

    /// For Telegram documentation see [`GetMyCommands`].
    fn get_my_commands(&self) -> Self::GetMyCommands;

    type SetMyName: Request<Payload = SetMyName, Err = Self::Err>;

    /// For Telegram documentation see [`SetMyName`].
    fn set_my_name(&self) -> Self::SetMyName;

    type GetMyName: Request<Payload = GetMyName, Err = Self::Err>;

    /// For Telegram documentation see [`GetMyName`].
    fn get_my_name(&self) -> Self::GetMyName;

    type SetMyDescription: Request<Payload = SetMyDescription, Err = Self::Err>;

    /// For Telegram documentation see [`SetMyDescription`].
    fn set_my_description(&self) -> Self::SetMyDescription;

    type GetMyDescription: Request<Payload = GetMyDescription, Err = Self::Err>;

    /// For Telegram documentation see [`GetMyDescription`].
    fn get_my_description(&self) -> Self::GetMyDescription;

    type SetMyShortDescription: Request<Payload = SetMyShortDescription, Err = Self::Err>;

    /// For Telegram documentation see [`SetMyShortDescription`].
    fn set_my_short_description(&self) -> Self::SetMyShortDescription;

    type GetMyShortDescription: Request<Payload = GetMyShortDescription, Err = Self::Err>;

    /// For Telegram documentation see [`GetMyShortDescription`].
    fn get_my_short_description(&self) -> Self::GetMyShortDescription;

    type SetChatMenuButton: Request<Payload = SetChatMenuButton, Err = Self::Err>;

    /// For Telegram documentation see [`SetChatMenuButton`].
    fn set_chat_menu_button(&self) -> Self::SetChatMenuButton;

    type GetChatMenuButton: Request<Payload = GetChatMenuButton, Err = Self::Err>;

    /// For Telegram documentation see [`GetChatMenuButton`].
    fn get_chat_menu_button(&self) -> Self::GetChatMenuButton;

    type SetMyDefaultAdministratorRights: Request<
        Payload = SetMyDefaultAdministratorRights,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`SetMyDefaultAdministratorRights`].
    fn set_my_default_administrator_rights(&self) -> Self::SetMyDefaultAdministratorRights;

    type GetMyDefaultAdministratorRights: Request<
        Payload = GetMyDefaultAdministratorRights,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`GetMyDefaultAdministratorRights`].
    fn get_my_default_administrator_rights(&self) -> Self::GetMyDefaultAdministratorRights;

    type DeleteMyCommands: Request<Payload = DeleteMyCommands, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteMyCommands`].
    fn delete_my_commands(&self) -> Self::DeleteMyCommands;

    type AnswerInlineQuery: Request<Payload = AnswerInlineQuery, Err = Self::Err>;

    /// For Telegram documentation see [`AnswerInlineQuery`].
    fn answer_inline_query<I, R>(&self, inline_query_id: I, results: R) -> Self::AnswerInlineQuery
    where
        I: Into<String>,
        R: IntoIterator<Item = InlineQueryResult>;

    type AnswerWebAppQuery: Request<Payload = AnswerWebAppQuery, Err = Self::Err>;

    /// For Telegram documentation see [`AnswerWebAppQuery`].
    fn answer_web_app_query<W>(
        &self,
        web_app_query_id: W,
        result: InlineQueryResult,
    ) -> Self::AnswerWebAppQuery
    where
        W: Into<String>;

    type EditMessageText: Request<Payload = EditMessageText, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageText`].
    fn edit_message_text<C, T>(
        &self,
        chat_id: C,
        message_id: MessageId,
        text: T,
    ) -> Self::EditMessageText
    where
        C: Into<Recipient>,
        T: Into<String>;

    type EditMessageTextInline: Request<Payload = EditMessageTextInline, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageTextInline`].
    fn edit_message_text_inline<I, T>(
        &self,
        inline_message_id: I,
        text: T,
    ) -> Self::EditMessageTextInline
    where
        I: Into<String>,
        T: Into<String>;

    type EditMessageCaption: Request<Payload = EditMessageCaption, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageCaption`].
    fn edit_message_caption<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
    ) -> Self::EditMessageCaption
    where
        C: Into<Recipient>;

    type EditMessageCaptionInline: Request<Payload = EditMessageCaptionInline, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageCaptionInline`].
    fn edit_message_caption_inline<I>(
        &self,
        inline_message_id: I,
    ) -> Self::EditMessageCaptionInline
    where
        I: Into<String>;

    type EditMessageMedia: Request<Payload = EditMessageMedia, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageMedia`].
    fn edit_message_media<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
        media: InputMedia,
    ) -> Self::EditMessageMedia
    where
        C: Into<Recipient>;

    type EditMessageMediaInline: Request<Payload = EditMessageMediaInline, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageMediaInline`].
    fn edit_message_media_inline<I>(
        &self,
        inline_message_id: I,
        media: InputMedia,
    ) -> Self::EditMessageMediaInline
    where
        I: Into<String>;

    type EditMessageReplyMarkup: Request<Payload = EditMessageReplyMarkup, Err = Self::Err>;

    /// For Telegram documentation see [`EditMessageReplyMarkup`].
    fn edit_message_reply_markup<C>(
        &self,
        chat_id: C,
        message_id: MessageId,
    ) -> Self::EditMessageReplyMarkup
    where
        C: Into<Recipient>;

    type EditMessageReplyMarkupInline: Request<
        Payload = EditMessageReplyMarkupInline,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`EditMessageReplyMarkupInline`].
    fn edit_message_reply_markup_inline<I>(
        &self,
        inline_message_id: I,
    ) -> Self::EditMessageReplyMarkupInline
    where
        I: Into<String>;

    type StopPoll: Request<Payload = StopPoll, Err = Self::Err>;

    /// For Telegram documentation see [`StopPoll`].
    fn stop_poll<C>(&self, chat_id: C, message_id: MessageId) -> Self::StopPoll
    where
        C: Into<Recipient>;

    type DeleteMessage: Request<Payload = DeleteMessage, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteMessage`].
    fn delete_message<C>(&self, chat_id: C, message_id: MessageId) -> Self::DeleteMessage
    where
        C: Into<Recipient>;

    type DeleteMessages: Request<Payload = DeleteMessages, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteMessages`].
    fn delete_messages<C, M>(&self, chat_id: C, message_ids: M) -> Self::DeleteMessages
    where
        C: Into<Recipient>,
        M: IntoIterator<Item = MessageId>;

    type SendSticker: Request<Payload = SendSticker, Err = Self::Err>;

    /// For Telegram documentation see [`SendSticker`].
    fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker
    where
        C: Into<Recipient>;

    type GetStickerSet: Request<Payload = GetStickerSet, Err = Self::Err>;

    /// For Telegram documentation see [`GetStickerSet`].
    fn get_sticker_set<N>(&self, name: N) -> Self::GetStickerSet
    where
        N: Into<String>;

    type GetCustomEmojiStickers: Request<Payload = GetCustomEmojiStickers, Err = Self::Err>;

    /// For Telegram documentation see [`GetCustomEmojiStickers`].
    fn get_custom_emoji_stickers<C>(&self, custom_emoji_ids: C) -> Self::GetCustomEmojiStickers
    where
        C: IntoIterator<Item = String>;

    type UploadStickerFile: Request<Payload = UploadStickerFile, Err = Self::Err>;

    /// For Telegram documentation see [`UploadStickerFile`].
    fn upload_sticker_file(
        &self,
        user_id: UserId,
        sticker: InputFile,
        sticker_format: StickerFormat,
    ) -> Self::UploadStickerFile;

    type CreateNewStickerSet: Request<Payload = CreateNewStickerSet, Err = Self::Err>;

    /// For Telegram documentation see [`CreateNewStickerSet`].
    fn create_new_sticker_set<N, T, S>(
        &self,
        user_id: UserId,
        name: N,
        title: T,
        stickers: S,
        sticker_format: StickerFormat,
    ) -> Self::CreateNewStickerSet
    where
        N: Into<String>,
        T: Into<String>,
        S: IntoIterator<Item = InputSticker>;

    type AddStickerToSet: Request<Payload = AddStickerToSet, Err = Self::Err>;

    /// For Telegram documentation see [`AddStickerToSet`].
    fn add_sticker_to_set<N>(
        &self,
        user_id: UserId,
        name: N,
        sticker: InputSticker,
    ) -> Self::AddStickerToSet
    where
        N: Into<String>;

    type SetStickerPositionInSet: Request<Payload = SetStickerPositionInSet, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerPositionInSet`].
    fn set_sticker_position_in_set<S>(
        &self,
        sticker: S,
        position: u32,
    ) -> Self::SetStickerPositionInSet
    where
        S: Into<String>;

    type DeleteStickerFromSet: Request<Payload = DeleteStickerFromSet, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteStickerFromSet`].
    fn delete_sticker_from_set<S>(&self, sticker: S) -> Self::DeleteStickerFromSet
    where
        S: Into<String>;

    type SetStickerSetThumbnail: Request<Payload = SetStickerSetThumbnail, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerSetThumbnail`].
    fn set_sticker_set_thumbnail<N>(
        &self,
        name: N,
        user_id: UserId,
    ) -> Self::SetStickerSetThumbnail
    where
        N: Into<String>;

    type SetCustomEmojiStickerSetThumbnail: Request<
        Payload = SetCustomEmojiStickerSetThumbnail,
        Err = Self::Err,
    >;

    /// For Telegram documentation see [`SetCustomEmojiStickerSetThumbnail`].
    fn set_custom_emoji_sticker_set_thumbnail<N>(
        &self,
        name: N,
    ) -> Self::SetCustomEmojiStickerSetThumbnail
    where
        N: Into<String>;

    type SetStickerSetTitle: Request<Payload = SetStickerSetTitle, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerSetTitle`].
    fn set_sticker_set_title<N, T>(&self, name: N, title: T) -> Self::SetStickerSetTitle
    where
        N: Into<String>,
        T: Into<String>;

    type DeleteStickerSet: Request<Payload = DeleteStickerSet, Err = Self::Err>;

    /// For Telegram documentation see [`DeleteStickerSet`].
    fn delete_sticker_set<N>(&self, name: N) -> Self::DeleteStickerSet
    where
        N: Into<String>;

    type SetStickerEmojiList: Request<Payload = SetStickerEmojiList, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerEmojiList`].
    fn set_sticker_emoji_list<S, E>(&self, sticker: S, emoji_list: E) -> Self::SetStickerEmojiList
    where
        S: Into<String>,
        E: IntoIterator<Item = String>;

    type SetStickerKeywords: Request<Payload = SetStickerKeywords, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerKeywords`].
    fn set_sticker_keywords<S>(&self, sticker: S) -> Self::SetStickerKeywords
    where
        S: Into<String>;

    type SetStickerMaskPosition: Request<Payload = SetStickerMaskPosition, Err = Self::Err>;

    /// For Telegram documentation see [`SetStickerMaskPosition`].
    fn set_sticker_mask_position<S>(&self, sticker: S) -> Self::SetStickerMaskPosition
    where
        S: Into<String>;

    type SendInvoice: Request<Payload = SendInvoice, Err = Self::Err>;

    /// For Telegram documentation see [`SendInvoice`].
    fn send_invoice<Ch, T, D, Pa, P, C, Pri>(
        &self,
        chat_id: Ch,
        title: T,
        description: D,
        payload: Pa,
        provider_token: P,
        currency: C,
        prices: Pri,
    ) -> Self::SendInvoice
    where
        Ch: Into<Recipient>,
        T: Into<String>,
        D: Into<String>,
        Pa: Into<String>,
        P: Into<String>,
        C: Into<String>,
        Pri: IntoIterator<Item = LabeledPrice>;

    type CreateInvoiceLink: Request<Payload = CreateInvoiceLink, Err = Self::Err>;

    /// For Telegram documentation see [`CreateInvoiceLink`].
    fn create_invoice_link<T, D, Pa, P, C, Pri>(
        &self,
        title: T,
        description: D,
        payload: Pa,
        provider_token: P,
        currency: C,
        prices: Pri,
    ) -> Self::CreateInvoiceLink
    where
        T: Into<String>,
        D: Into<String>,
        Pa: Into<String>,
        P: Into<String>,
        C: Into<String>,
        Pri: IntoIterator<Item = LabeledPrice>;

    type AnswerShippingQuery: Request<Payload = AnswerShippingQuery, Err = Self::Err>;

    /// For Telegram documentation see [`AnswerShippingQuery`].
    fn answer_shipping_query<S>(&self, shipping_query_id: S, ok: bool) -> Self::AnswerShippingQuery
    where
        S: Into<String>;

    type AnswerPreCheckoutQuery: Request<Payload = AnswerPreCheckoutQuery, Err = Self::Err>;

    /// For Telegram documentation see [`AnswerPreCheckoutQuery`].
    fn answer_pre_checkout_query<P>(
        &self,
        pre_checkout_query_id: P,
        ok: bool,
    ) -> Self::AnswerPreCheckoutQuery
    where
        P: Into<String>;

    type SetPassportDataErrors: Request<Payload = SetPassportDataErrors, Err = Self::Err>;

    /// For Telegram documentation see [`SetPassportDataErrors`].
    fn set_passport_data_errors<E>(
        &self,
        user_id: UserId,
        errors: E,
    ) -> Self::SetPassportDataErrors
    where
        E: IntoIterator<Item = PassportElementError>;

    type SendGame: Request<Payload = SendGame, Err = Self::Err>;

    /// For Telegram documentation see [`SendGame`].
    fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
    where
        C: Into<ChatId>,
        G: Into<String>;

    type SetGameScore: Request<Payload = SetGameScore, Err = Self::Err>;

    /// For Telegram documentation see [`SetGameScore`].
    fn set_game_score(
        &self,
        user_id: UserId,
        score: u64,
        chat_id: u32,
        message_id: MessageId,
    ) -> Self::SetGameScore;

    type SetGameScoreInline: Request<Payload = SetGameScoreInline, Err = Self::Err>;

    /// For Telegram documentation see [`SetGameScoreInline`].
    fn set_game_score_inline<I>(
        &self,
        user_id: UserId,
        score: u64,
        inline_message_id: I,
    ) -> Self::SetGameScoreInline
    where
        I: Into<String>;

    type GetGameHighScores: Request<Payload = GetGameHighScores, Err = Self::Err>;

    /// For Telegram documentation see [`GetGameHighScores`].
    fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
    where
        T: Into<TargetMessage>;
    // END BLOCK requester_methods
}

macro_rules! fty {
    ($T:ident) => {
        B::$T
    };
}

macro_rules! fwd_deref {
    ($m:ident $this:ident ($($arg:ident : $T:ty),*)) => {
        core::ops::Deref::deref($this).$m($($arg),*)
    };
}

macro_rules! forward_all {
    ($body:ident, $ty:ident) => {
        requester_forward! {
            get_me,
            log_out,
            close,
            get_updates,
            set_webhook,
            delete_webhook,
            get_webhook_info,
            forward_message,
            forward_messages,
            copy_message,
            copy_messages,
            send_message,
            send_photo,
            send_audio,
            send_document,
            send_video,
            send_animation,
            send_voice,
            send_video_note,
            send_media_group,
            send_location,
            edit_message_live_location,
            edit_message_live_location_inline,
            stop_message_live_location,
            stop_message_live_location_inline,
            send_venue,
            send_contact,
            send_poll,
            send_dice,
            send_chat_action,
            set_message_reaction,
            get_user_profile_photos,
            get_file,
            kick_chat_member,
            ban_chat_member,
            unban_chat_member,
            restrict_chat_member,
            promote_chat_member,
            set_chat_administrator_custom_title,
            ban_chat_sender_chat,
            unban_chat_sender_chat,
            set_chat_permissions,
            export_chat_invite_link,
            create_chat_invite_link,
            edit_chat_invite_link,
            revoke_chat_invite_link,
            set_chat_photo,
            delete_chat_photo,
            set_chat_title,
            set_chat_description,
            pin_chat_message,
            unpin_chat_message,
            unpin_all_chat_messages,
            leave_chat,
            get_chat,
            get_chat_administrators,
            get_chat_members_count,
            get_chat_member_count,
            get_chat_member,
            set_chat_sticker_set,
            delete_chat_sticker_set,
            get_forum_topic_icon_stickers,
            create_forum_topic,
            edit_forum_topic,
            close_forum_topic,
            reopen_forum_topic,
            delete_forum_topic,
            unpin_all_forum_topic_messages,
            edit_general_forum_topic,
            close_general_forum_topic,
            reopen_general_forum_topic,
            hide_general_forum_topic,
            unhide_general_forum_topic,
            unpin_all_general_forum_topic_messages,
            answer_callback_query,
            get_user_chat_boosts,
            set_my_commands,
            get_my_commands,
            set_my_name,
            get_my_name,
            set_my_description,
            get_my_description,
            set_my_short_description,
            get_my_short_description,
            set_chat_menu_button,
            get_chat_menu_button,
            set_my_default_administrator_rights,
            get_my_default_administrator_rights,
            delete_my_commands,
            answer_inline_query,
            answer_web_app_query,
            edit_message_text,
            edit_message_text_inline,
            edit_message_caption,
            edit_message_caption_inline,
            edit_message_media,
            edit_message_media_inline,
            edit_message_reply_markup,
            edit_message_reply_markup_inline,
            stop_poll,
            delete_message,
            delete_messages,
            send_sticker,
            get_sticker_set,
            get_custom_emoji_stickers,
            upload_sticker_file,
            create_new_sticker_set,
            add_sticker_to_set,
            set_sticker_position_in_set,
            delete_sticker_from_set,
            set_sticker_set_thumbnail,
            set_custom_emoji_sticker_set_thumbnail,
            set_sticker_set_title,
            delete_sticker_set,
            set_sticker_emoji_list,
            set_sticker_keywords,
            set_sticker_mask_position,
            send_invoice,
            create_invoice_link,
            answer_shipping_query,
            answer_pre_checkout_query,
            set_passport_data_errors,
            send_game,
            set_game_score,
            set_game_score_inline,
            get_game_high_scores,
            approve_chat_join_request,
            decline_chat_join_request
            => $body, $ty
        }
    };
    () => {
        forward_all! { fwd_deref, fty }
    };
}

impl<B> Requester for &B
where
    B: Requester,
{
    type Err = B::Err;

    forward_all! {}
}

impl<B> Requester for &mut B
where
    B: Requester,
{
    type Err = B::Err;

    forward_all! {}
}

impl<B> Requester for Box<B>
where
    B: Requester,
{
    type Err = B::Err;

    forward_all! {}
}

impl<B> Requester for std::sync::Arc<B>
where
    B: Requester,
{
    type Err = B::Err;

    forward_all! {}
}

impl<B> Requester for std::rc::Rc<B>
where
    B: Requester,
{
    type Err = B::Err;

    forward_all! {}
}

// macro_rules! fty_either {
//     ($T:ident) => {
//         either::Either<LR::$T, RR::$T>
//     };
// }

// macro_rules! fwd_either {
//     ($m:ident $this:ident ($($arg:ident : $T:ty),*)) => {
//         match ($this) {
//             either::Either::Left(l) => either::Either::Left(l.$m($($arg),*)),
//             either::Either::Right(r) =>
// either::Either::Right(r.$m($($arg),*)),         }
//     };
// }

// impl<LR, RR> Requester for either::Either<LR, RR>
// where
//     LR: Requester,
//     RR: Requester<Err = LR::Err>,
// {
//     type Err = LR::Err;

//     forward_all! { fwd_either, fty_either }
// }

#[test]
// waffle: efficiency is not important here, and I don't want to rewrite this
#[allow(clippy::format_collect)]
fn codegen_requester_methods() {
    use crate::codegen::{
        add_hidden_preamble,
        convert::{convert_for, Convert},
        ensure_file_contents, min_prefix, project_root, reformat, replace_block,
        schema::{self, Type},
        to_uppercase,
    };
    use indexmap::IndexMap;
    use itertools::Itertools;

    let schema = schema::get();

    let methods = schema
        .methods
        .iter()
        .map(|m| {
            let mut convert_params = m
                .params
                .iter()
                .filter(|p| !matches!(p.ty, Type::Option(_)))
                .map(|p| (&p.name, convert_for(&p.ty)))
                .filter(|(_, c)| !matches!(c, Convert::Id(_)))
                .map(|(name, _)| &**name)
                .collect::<Vec<_>>();

            convert_params.sort_unstable();

            let prefixes: IndexMap<_, _> = convert_params
                .iter()
                .copied()
                // Workaround to output the last type as the first letter
                .chain(["\0"])
                .tuple_windows()
                .map(|(l, r)| (l, min_prefix(l, r)))
                .collect();

            let args = m
                .params
                .iter()
                .filter(|p| !matches!(p.ty, schema::Type::Option(_)))
                .map(|p| match prefixes.get(&*p.name) {
                    Some(prefix) => format!("{}: {}", p.name, to_uppercase(prefix)),
                    None => format!("{}: {}", p.name, p.ty),
                })
                .join(", ");

            let generics = m
                .params
                .iter()
                .flat_map(|p| prefixes.get(&*p.name))
                .copied()
                .map(to_uppercase)
                .join(", ");
            let where_clause = m
                .params
                .iter()
                .filter(|p| !matches!(p.ty, Type::Option(_)))
                .flat_map(|p| match convert_for(&p.ty) {
                    Convert::Id(_) => None,
                    Convert::Into(ty) => {
                        Some(format!("{}: Into<{}>", &to_uppercase(prefixes[&*p.name]), ty))
                    }
                    Convert::Collect(ty) => Some(format!(
                        "{}: IntoIterator<Item = {}>",
                        &to_uppercase(prefixes[&*p.name]),
                        ty
                    )),
                })
                .join(",\n        ");

            let generics =
                if generics.is_empty() { String::from("") } else { format!("<{generics}>") };

            let where_clause = if where_clause.is_empty() {
                String::from("")
            } else {
                format!(" where {where_clause}")
            };

            format!(
                "
type {Method}: Request<Payload = {Method}, Err = Self::Err>;

/// For Telegram documentation see [`{Method}`].
fn {method} {generics} (&self, {args}) -> Self::{Method}{where_clause};
            ",
                Method = m.names.1,
                method = m.names.2,
            )
        })
        .collect::<String>();

    let path = project_root().join("src/requests/requester.rs");

    ensure_file_contents(
        &path,
        &reformat(replace_block(
            &path,
            "requester_methods",
            &add_hidden_preamble("codegen_requester_methods", methods),
        )),
    );
}