-
Notifications
You must be signed in to change notification settings - Fork 5.1k
/
constants.py
1749 lines (1433 loc) · 66.7 KB
/
constants.py
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
# python-telegram-bot - a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# by the python-telegram-bot contributors <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains several constants that are relevant for working with the Bot API.
Unless noted otherwise, all constants in this module were extracted from the
`Telegram Bots FAQ <https://core.telegram.org/bots/faq>`_ and
`Telegram Bots API <https://core.telegram.org/bots/api>`_.
Most of the following constants are related to specific classes or topics and are grouped into
enums. If they are related to a specific class, then they are also available as attributes of
those classes.
.. versionchanged:: 20.0
* Most of the constants in this module are grouped into enums.
"""
# TODO: Remove this when https://github.com/PyCQA/pylint/issues/6887 is resolved.
# pylint: disable=invalid-enum-extension
__all__ = [
"BOT_API_VERSION",
"BOT_API_VERSION_INFO",
"BotCommandLimit",
"BotCommandScopeType",
"BotDescriptionLimit",
"BotNameLimit",
"CallbackQueryLimit",
"ChatAction",
"ChatID",
"ChatInviteLinkLimit",
"ChatLimit",
"ChatMemberStatus",
"ChatPhotoSize",
"ChatType",
"ContactLimit",
"CustomEmojiStickerLimit",
"DiceEmoji",
"DiceLimit",
"FileSizeLimit",
"FloodLimit",
"ForumIconColor",
"ForumTopicLimit",
"InlineKeyboardButtonLimit",
"InlineKeyboardMarkupLimit",
"InlineQueryLimit",
"InlineQueryResultLimit",
"InlineQueryResultsButtonLimit",
"InlineQueryResultType",
"InputMediaType",
"InvoiceLimit",
"LocationLimit",
"MaskPosition",
"MediaGroupLimit",
"MenuButtonType",
"MessageAttachmentType",
"MessageEntityType",
"MessageLimit",
"MessageType",
"PollingLimit",
"ParseMode",
"PollLimit",
"PollType",
"ReplyLimit",
"SUPPORTED_WEBHOOK_PORTS",
"StickerFormat",
"StickerLimit",
"StickerSetLimit",
"StickerType",
"WebhookLimit",
"UpdateType",
"UserProfilePhotosLimit",
]
import sys
from typing import Final, List, NamedTuple
from telegram._utils.enum import IntEnum, StringEnum
class _BotAPIVersion(NamedTuple):
"""Similar behavior to sys.version_info.
So far TG has only published X.Y releases. We can add X.Y.Z(a(S)) if needed.
"""
major: int
minor: int
def __repr__(self) -> str:
"""Unfortunately calling super().__repr__ doesn't work with typing.NamedTuple, so we
do this manually.
"""
return f"BotAPIVersion(major={self.major}, minor={self.minor})"
def __str__(self) -> str:
return f"{self.major}.{self.minor}"
#: :class:`typing.NamedTuple`: A tuple containing the two components of the version number:
# ``major`` and ``minor``. Both values are integers.
#: The components can also be accessed by name, so ``BOT_API_VERSION_INFO[0]`` is equivalent
#: to ``BOT_API_VERSION_INFO.major`` and so on. Also available as
#: :data:`telegram.__bot_api_version_info__`.
#:
#: .. versionadded:: 20.0
BOT_API_VERSION_INFO: Final[_BotAPIVersion] = _BotAPIVersion(major=6, minor=8)
#: :obj:`str`: Telegram Bot API
#: version supported by this version of `python-telegram-bot`. Also available as
#: :data:`telegram.__bot_api_version__`.
#:
#: .. versionadded:: 13.4
BOT_API_VERSION: Final[str] = str(BOT_API_VERSION_INFO)
# constants above this line are tested
#: List[:obj:`int`]: Ports supported by
#: :paramref:`telegram.Bot.set_webhook.url`.
SUPPORTED_WEBHOOK_PORTS: Final[List[int]] = [443, 80, 88, 8443]
class BotCommandLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.BotCommand` and
:meth:`telegram.Bot.set_my_commands`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_COMMAND = 1
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.BotCommand.command` parameter of
:class:`telegram.BotCommand`.
"""
MAX_COMMAND = 32
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.BotCommand.command` parameter of
:class:`telegram.BotCommand`.
"""
MIN_DESCRIPTION = 1
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.BotCommand.description`
parameter of :class:`telegram.BotCommand`.
"""
MAX_DESCRIPTION = 256
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.BotCommand.description`
parameter of :class:`telegram.BotCommand`.
"""
MAX_COMMAND_NUMBER = 100
""":obj:`int`: Maximum number of bot commands passed in a :obj:`list` to the
:paramref:`~telegram.Bot.set_my_commands.commands`
parameter of :meth:`telegram.Bot.set_my_commands`.
"""
class BotCommandScopeType(StringEnum):
"""This enum contains the available types of :class:`telegram.BotCommandScope`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
DEFAULT = "default"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeDefault`."""
ALL_PRIVATE_CHATS = "all_private_chats"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeAllPrivateChats`."""
ALL_GROUP_CHATS = "all_group_chats"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeAllGroupChats`."""
ALL_CHAT_ADMINISTRATORS = "all_chat_administrators"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeAllChatAdministrators`."""
CHAT = "chat"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeChat`."""
CHAT_ADMINISTRATORS = "chat_administrators"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeChatAdministrators`."""
CHAT_MEMBER = "chat_member"
""":obj:`str`: The type of :class:`telegram.BotCommandScopeChatMember`."""
class BotDescriptionLimit(IntEnum):
"""This enum contains limitations for the methods :meth:`telegram.Bot.set_my_description` and
:meth:`telegram.Bot.set_my_short_description`. The enum members of this enumeration are
instances of :class:`int` and can be treated as such.
.. versionadded:: 20.2
"""
__slots__ = ()
MAX_DESCRIPTION_LENGTH = 512
""":obj:`int`: Maximum length for the parameter
:paramref:`~telegram.Bot.set_my_description.description` of
:meth:`telegram.Bot.set_my_description`
"""
MAX_SHORT_DESCRIPTION_LENGTH = 120
""":obj:`int`: Maximum length for the parameter
:paramref:`~telegram.Bot.set_my_short_description.short_description` of
:meth:`telegram.Bot.set_my_short_description`
"""
class BotNameLimit(IntEnum):
"""This enum contains limitations for the methods :meth:`telegram.Bot.set_my_name`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.3
"""
__slots__ = ()
MAX_NAME_LENGTH = 64
""":obj:`int`: Maximum length for the parameter :paramref:`~telegram.Bot.set_my_name.name` of
:meth:`telegram.Bot.set_my_name`
"""
class CallbackQueryLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.CallbackQuery`/
:meth:`telegram.Bot.answer_callback_query`. The enum members of this enumeration are instances
of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
ANSWER_CALLBACK_QUERY_TEXT_LENGTH = 200
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.answer_callback_query.text` parameter of
:meth:`telegram.Bot.answer_callback_query`."""
class ChatAction(StringEnum):
"""This enum contains the available chat actions for :meth:`telegram.Bot.send_chat_action`.
The enum members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
CHOOSE_STICKER = "choose_sticker"
""":obj:`str`: Chat action indicating that the bot is selecting a sticker."""
FIND_LOCATION = "find_location"
""":obj:`str`: Chat action indicating that the bot is selecting a location."""
RECORD_VOICE = "record_voice"
""":obj:`str`: Chat action indicating that the bot is recording a voice message."""
RECORD_VIDEO = "record_video"
""":obj:`str`: Chat action indicating that the bot is recording a video."""
RECORD_VIDEO_NOTE = "record_video_note"
""":obj:`str`: Chat action indicating that the bot is recording a video note."""
TYPING = "typing"
""":obj:`str`: A chat indicating the bot is typing."""
UPLOAD_VOICE = "upload_voice"
""":obj:`str`: Chat action indicating that the bot is uploading a voice message."""
UPLOAD_DOCUMENT = "upload_document"
""":obj:`str`: Chat action indicating that the bot is uploading a document."""
UPLOAD_PHOTO = "upload_photo"
""":obj:`str`: Chat action indicating that the bot is uploading a photo."""
UPLOAD_VIDEO = "upload_video"
""":obj:`str`: Chat action indicating that the bot is uploading a video."""
UPLOAD_VIDEO_NOTE = "upload_video_note"
""":obj:`str`: Chat action indicating that the bot is uploading a video note."""
class ChatID(IntEnum):
"""This enum contains some special chat IDs. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
ANONYMOUS_ADMIN = 1087968824
""":obj:`int`: User ID in groups for messages sent by anonymous admins.
Note:
:attr:`telegram.Message.from_user` will contain this ID for backwards compatibility only.
It's recommended to use :attr:`telegram.Message.sender_chat` instead.
"""
SERVICE_CHAT = 777000
""":obj:`int`: Telegram service chat, that also acts as sender of channel posts forwarded to
discussion groups.
Note:
:attr:`telegram.Message.from_user` will contain this ID for backwards compatibility only.
It's recommended to use :attr:`telegram.Message.sender_chat` instead.
"""
FAKE_CHANNEL = 136817688
""":obj:`int`: User ID in groups when message is sent on behalf of a channel.
Note:
* :attr:`telegram.Message.from_user` will contain this ID for backwards compatibility only.
It's recommended to use :attr:`telegram.Message.sender_chat` instead.
* This value is undocumented and might be changed by Telegram.
"""
class ChatInviteLinkLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.ChatInviteLink`/
:meth:`telegram.Bot.create_chat_invite_link`/:meth:`telegram.Bot.edit_chat_invite_link`. The
enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_MEMBER_LIMIT = 1
""":obj:`int`: Minimum value allowed for the
:paramref:`~telegram.Bot.create_chat_invite_link.member_limit` parameter of
:meth:`telegram.Bot.create_chat_invite_link` and
:paramref:`~telegram.Bot.edit_chat_invite_link.member_limit` of
:meth:`telegram.Bot.edit_chat_invite_link`.
"""
MAX_MEMBER_LIMIT = 99999
""":obj:`int`: Maximum value allowed for the
:paramref:`~telegram.Bot.create_chat_invite_link.member_limit` parameter of
:meth:`telegram.Bot.create_chat_invite_link` and
:paramref:`~telegram.Bot.edit_chat_invite_link.member_limit` of
:meth:`telegram.Bot.edit_chat_invite_link`.
"""
NAME_LENGTH = 32
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.create_chat_invite_link.name` parameter of
:meth:`telegram.Bot.create_chat_invite_link` and
:paramref:`~telegram.Bot.edit_chat_invite_link.name` of
:meth:`telegram.Bot.edit_chat_invite_link`.
"""
class ChatLimit(IntEnum):
"""This enum contains limitations for
:meth:`telegram.Bot.set_chat_administrator_custom_title`,
:meth:`telegram.Bot.set_chat_description`, and :meth:`telegram.Bot.set_chat_title`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
CHAT_ADMINISTRATOR_CUSTOM_TITLE_LENGTH = 16
""":obj:`int`: Maximum length of a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_administrator_custom_title.custom_title` parameter of
:meth:`telegram.Bot.set_chat_administrator_custom_title`.
"""
CHAT_DESCRIPTION_LENGTH = 255
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_description.description` parameter of
:meth:`telegram.Bot.set_chat_description`.
"""
MIN_CHAT_TITLE_LENGTH = 1
""":obj:`int`: Minimum length of a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_title.title` parameter of
:meth:`telegram.Bot.set_chat_title`.
"""
MAX_CHAT_TITLE_LENGTH = 128
""":obj:`int`: Maximum length of a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_title.title` parameter of
:meth:`telegram.Bot.set_chat_title`.
"""
class ChatMemberStatus(StringEnum):
"""This enum contains the available states for :class:`telegram.ChatMember`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
ADMINISTRATOR = "administrator"
""":obj:`str`: A :class:`telegram.ChatMember` who is administrator of the chat."""
OWNER = "creator"
""":obj:`str`: A :class:`telegram.ChatMember` who is the owner of the chat."""
BANNED = "kicked"
""":obj:`str`: A :class:`telegram.ChatMember` who was banned in the chat."""
LEFT = "left"
""":obj:`str`: A :class:`telegram.ChatMember` who has left the chat."""
MEMBER = "member"
""":obj:`str`: A :class:`telegram.ChatMember` who is a member of the chat."""
RESTRICTED = "restricted"
""":obj:`str`: A :class:`telegram.ChatMember` who was restricted in this chat."""
class ChatPhotoSize(IntEnum):
"""This enum contains limitations for :class:`telegram.ChatPhoto`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
SMALL = 160
""":obj:`int`: Width and height of a small chat photo, ID of which is passed in
:paramref:`~telegram.ChatPhoto.small_file_id` and
:paramref:`~telegram.ChatPhoto.small_file_unique_id` parameters of
:class:`telegram.ChatPhoto`.
"""
BIG = 640
""":obj:`int`: Width and height of a big chat photo, ID of which is passed in
:paramref:`~telegram.ChatPhoto.big_file_id` and
:paramref:`~telegram.ChatPhoto.big_file_unique_id` parameters of
:class:`telegram.ChatPhoto`.
"""
class ChatType(StringEnum):
"""This enum contains the available types of :class:`telegram.Chat`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
SENDER = "sender"
""":obj:`str`: A :class:`telegram.Chat` that represents the chat of a :class:`telegram.User`
sending an :class:`telegram.InlineQuery`. """
PRIVATE = "private"
""":obj:`str`: A :class:`telegram.Chat` that is private."""
GROUP = "group"
""":obj:`str`: A :class:`telegram.Chat` that is a group."""
SUPERGROUP = "supergroup"
""":obj:`str`: A :class:`telegram.Chat` that is a supergroup."""
CHANNEL = "channel"
""":obj:`str`: A :class:`telegram.Chat` that is a channel."""
class ContactLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineQueryResultContact`,
:class:`telegram.InputContactMessageContent`, and :meth:`telegram.Bot.send_contact`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
VCARD = 2048
""":obj:`int`: Maximum value allowed for:
* :paramref:`~telegram.Bot.send_contact.vcard` parameter of :meth:`~telegram.Bot.send_contact`
* :paramref:`~telegram.InlineQueryResultContact.vcard` parameter of
:class:`~telegram.InlineQueryResultContact`
* :paramref:`~telegram.InputContactMessageContent.vcard` parameter of
:class:`~telegram.InputContactMessageContent`
"""
class CustomEmojiStickerLimit(IntEnum):
"""This enum contains limitations for :meth:`telegram.Bot.get_custom_emoji_stickers`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
CUSTOM_EMOJI_IDENTIFIER_LIMIT = 200
""":obj:`int`: Maximum amount of custom emoji identifiers which can be specified for the
:paramref:`~telegram.Bot.get_custom_emoji_stickers.custom_emoji_ids` parameter of
:meth:`telegram.Bot.get_custom_emoji_stickers`.
"""
class DiceEmoji(StringEnum):
"""This enum contains the available emoji for :class:`telegram.Dice`/
:meth:`telegram.Bot.send_dice`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
DICE = "🎲"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🎲``."""
DARTS = "🎯"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🎯``."""
BASKETBALL = "🏀"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🏀``."""
FOOTBALL = "⚽"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``⚽``."""
SLOT_MACHINE = "🎰"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🎰``."""
BOWLING = "🎳"
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🎳``."""
class DiceLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.Dice`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_VALUE = 1
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` (any emoji).
"""
MAX_VALUE_BASKETBALL = 5
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.BASKETBALL`.
"""
MAX_VALUE_BOWLING = 6
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.BOWLING`.
"""
MAX_VALUE_DARTS = 6
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.DARTS`.
"""
MAX_VALUE_DICE = 6
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.DICE`.
"""
MAX_VALUE_FOOTBALL = 5
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.FOOTBALL`.
"""
MAX_VALUE_SLOT_MACHINE = 64
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
:tg-const:`telegram.constants.DiceEmoji.SLOT_MACHINE`.
"""
class FileSizeLimit(IntEnum):
"""This enum contains limitations regarding the upload and download of files. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
FILESIZE_DOWNLOAD = int(20e6) # (20MB)
""":obj:`int`: Bots can download files of up to 20MB in size."""
FILESIZE_UPLOAD = int(50e6) # (50MB)
""":obj:`int`: Bots can upload non-photo files of up to 50MB in size."""
FILESIZE_UPLOAD_LOCAL_MODE = int(2e9) # (2000MB)
""":obj:`int`: Bots can upload non-photo files of up to 2000MB in size when using a local bot
API server.
"""
FILESIZE_DOWNLOAD_LOCAL_MODE = sys.maxsize
""":obj:`int`: Bots can download files without a size limit when using a local bot API server.
"""
PHOTOSIZE_UPLOAD = int(10e6) # (10MB)
""":obj:`int`: Bots can upload photo files of up to 10MB in size."""
VOICE_NOTE_FILE_SIZE = int(1e6) # (1MB)
""":obj:`int`: File size limit for the :meth:`~telegram.Bot.send_voice` method of
:class:`telegram.Bot`. Bots can send :mimetype:`audio/ogg` files of up to 1MB in size as
a voice note. Larger voice notes (up to 20MB) will be sent as files."""
# It seems OK to link 20MB limit to FILESIZE_DOWNLOAD rather than creating a new constant
class FloodLimit(IntEnum):
"""This enum contains limitations regarding flood limits. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MESSAGES_PER_SECOND_PER_CHAT = 1
""":obj:`int`: The number of messages that can be sent per second in a particular chat.
Telegram may allow short bursts that go over this limit, but eventually you'll begin
receiving 429 errors.
"""
MESSAGES_PER_SECOND = 30
""":obj:`int`: The number of messages that can roughly be sent in an interval of 30 seconds
across all chats.
"""
MESSAGES_PER_MINUTE_PER_GROUP = 20
""":obj:`int`: The number of messages that can roughly be sent to a particular group within one
minute.
"""
class ForumIconColor(IntEnum):
"""This enum contains the available colors for use in
:paramref:`telegram.Bot.create_forum_topic.icon_color`. The enum members of this enumeration
are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
BLUE = 0x6FB9F0
""":obj:`int`: An icon with a color which corresponds to blue (``0x6FB9F0``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#6FB9F0;"></div>
"""
YELLOW = 0xFFD67E
""":obj:`int`: An icon with a color which corresponds to yellow (``0xFFD67E``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#FFD67E;"></div>
"""
PURPLE = 0xCB86DB
""":obj:`int`: An icon with a color which corresponds to purple (``0xCB86DB``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#CB86DB;"></div>
"""
GREEN = 0x8EEE98
""":obj:`int`: An icon with a color which corresponds to green (``0x8EEE98``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#8EEE98;"></div>
"""
PINK = 0xFF93B2
""":obj:`int`: An icon with a color which corresponds to pink (``0xFF93B2``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#FF93B2;"></div>
"""
RED = 0xFB6F5F
""":obj:`int`: An icon with a color which corresponds to red (``0xFB6F5F``).
.. raw:: html
<div style="height:15px; width:15px; background-color:#FB6F5F;"></div>
"""
class InlineKeyboardButtonLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineKeyboardButton`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_CALLBACK_DATA = 1
""":obj:`int`: Minimum value allowed for
:paramref:`~telegram.InlineKeyboardButton.callback_data` parameter of
:class:`telegram.InlineKeyboardButton`
"""
MAX_CALLBACK_DATA = 64
""":obj:`int`: Maximum value allowed for
:paramref:`~telegram.InlineKeyboardButton.callback_data` parameter of
:class:`telegram.InlineKeyboardButton`
"""
class InlineKeyboardMarkupLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineKeyboardMarkup`/
:meth:`telegram.Bot.send_message` & friends. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
TOTAL_BUTTON_NUMBER = 100
""":obj:`int`: Maximum number of buttons that can be attached to a message.
Note:
This value is undocumented and might be changed by Telegram.
"""
BUTTONS_PER_ROW = 8
""":obj:`int`: Maximum number of buttons that can be attached to a message per row.
Note:
This value is undocumented and might be changed by Telegram.
"""
class InputMediaType(StringEnum):
"""This enum contains the available types of :class:`telegram.InputMedia`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
ANIMATION = "animation"
""":obj:`str`: Type of :class:`telegram.InputMediaAnimation`."""
DOCUMENT = "document"
""":obj:`str`: Type of :class:`telegram.InputMediaDocument`."""
AUDIO = "audio"
""":obj:`str`: Type of :class:`telegram.InputMediaAudio`."""
PHOTO = "photo"
""":obj:`str`: Type of :class:`telegram.InputMediaPhoto`."""
VIDEO = "video"
""":obj:`str`: Type of :class:`telegram.InputMediaVideo`."""
class InlineQueryLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineQuery`/
:meth:`telegram.Bot.answer_inline_query`. The enum members of this enumeration are instances
of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
RESULTS = 50
""":obj:`int`: Maximum number of results that can be passed to
:meth:`telegram.Bot.answer_inline_query`."""
MAX_OFFSET_LENGTH = 64
""":obj:`int`: Maximum number of bytes in a :obj:`str` passed as the
:paramref:`~telegram.Bot.answer_inline_query.next_offset` parameter of
:meth:`telegram.Bot.answer_inline_query`."""
MAX_QUERY_LENGTH = 256
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.InlineQuery.query` parameter of :class:`telegram.InlineQuery`."""
MIN_SWITCH_PM_TEXT_LENGTH = 1
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.answer_inline_query.switch_pm_parameter` parameter of
:meth:`telegram.Bot.answer_inline_query`.
.. deprecated:: 20.3
Deprecated in favor of :attr:`InlineQueryResultsButtonLimit.MIN_START_PARAMETER_LENGTH`.
"""
MAX_SWITCH_PM_TEXT_LENGTH = 64
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.answer_inline_query.switch_pm_parameter` parameter of
:meth:`telegram.Bot.answer_inline_query`.
.. deprecated:: 20.3
Deprecated in favor of :attr:`InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`.
"""
class InlineQueryResultLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineQueryResult` and its subclasses.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_ID_LENGTH = 1
""":obj:`int`: Minimum number of bytes in a :obj:`str` passed as the
:paramref:`~telegram.InlineQueryResult.id` parameter of
:class:`telegram.InlineQueryResult` and its subclasses
"""
MAX_ID_LENGTH = 64
""":obj:`int`: Maximum number of bytes in a :obj:`str` passed as the
:paramref:`~telegram.InlineQueryResult.id` parameter of
:class:`telegram.InlineQueryResult` and its subclasses
"""
class InlineQueryResultsButtonLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.InlineQueryResultsButton`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.3
"""
__slots__ = ()
MIN_START_PARAMETER_LENGTH = InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.InlineQueryResultsButton.start_parameter` parameter of
:meth:`telegram.InlineQueryResultsButton`."""
MAX_START_PARAMETER_LENGTH = InlineQueryLimit.MAX_SWITCH_PM_TEXT_LENGTH
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.InlineQueryResultsButton.start_parameter` parameter of
:meth:`telegram.InlineQueryResultsButton`."""
class InlineQueryResultType(StringEnum):
"""This enum contains the available types of :class:`telegram.InlineQueryResult`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
AUDIO = "audio"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultAudio` and
:class:`telegram.InlineQueryResultCachedAudio`.
"""
DOCUMENT = "document"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultDocument` and
:class:`telegram.InlineQueryResultCachedDocument`.
"""
GIF = "gif"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultGif` and
:class:`telegram.InlineQueryResultCachedGif`.
"""
MPEG4GIF = "mpeg4_gif"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultMpeg4Gif` and
:class:`telegram.InlineQueryResultCachedMpeg4Gif`.
"""
PHOTO = "photo"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultPhoto` and
:class:`telegram.InlineQueryResultCachedPhoto`.
"""
STICKER = "sticker"
""":obj:`str`: Type of and :class:`telegram.InlineQueryResultCachedSticker`."""
VIDEO = "video"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultVideo` and
:class:`telegram.InlineQueryResultCachedVideo`.
"""
VOICE = "voice"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultVoice` and
:class:`telegram.InlineQueryResultCachedVoice`.
"""
ARTICLE = "article"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultArticle`."""
CONTACT = "contact"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultContact`."""
GAME = "game"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultGame`."""
LOCATION = "location"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultLocation`."""
VENUE = "venue"
""":obj:`str`: Type of :class:`telegram.InlineQueryResultVenue`."""
class LocationLimit(IntEnum):
"""This enum contains limitations for
:class:`telegram.Location`/:class:`telegram.ChatLocation`/
:meth:`telegram.Bot.edit_message_live_location`/:meth:`telegram.Bot.send_location`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_CHAT_LOCATION_ADDRESS = 1
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.ChatLocation.address` parameter
of :class:`telegram.ChatLocation`
"""
MAX_CHAT_LOCATION_ADDRESS = 64
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.ChatLocation.address` parameter
of :class:`telegram.ChatLocation`
"""
HORIZONTAL_ACCURACY = 1500
""":obj:`int`: Maximum value allowed for:
* :paramref:`~telegram.Location.horizontal_accuracy` parameter of :class:`telegram.Location`
* :paramref:`~telegram.InlineQueryResultLocation.horizontal_accuracy` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.horizontal_accuracy` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.horizontal_accuracy` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.horizontal_accuracy` parameter of
:meth:`telegram.Bot.send_location`
"""
MIN_HEADING = 1
""":obj:`int`: Minimum value allowed for:
* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
* :paramref:`~telegram.InlineQueryResultLocation.heading` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.heading` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.heading` parameter of
:meth:`telegram.Bot.send_location`
"""
MAX_HEADING = 360
""":obj:`int`: Maximum value allowed for:
* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
* :paramref:`~telegram.InlineQueryResultLocation.heading` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.heading` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.heading` parameter of
:meth:`telegram.Bot.send_location`
"""
MIN_LIVE_PERIOD = 60
""":obj:`int`: Minimum value allowed for:
* :paramref:`~telegram.InlineQueryResultLocation.live_period` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.live_period` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
:meth:`telegram.Bot.send_location`
"""
MAX_LIVE_PERIOD = 86400
""":obj:`int`: Maximum value allowed for:
* :paramref:`~telegram.InlineQueryResultLocation.live_period` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.live_period` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
:meth:`telegram.Bot.send_location`
"""
MIN_PROXIMITY_ALERT_RADIUS = 1
""":obj:`int`: Minimum value allowed for:
* :paramref:`~telegram.InlineQueryResultLocation.proximity_alert_radius` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.proximity_alert_radius` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.send_location`
"""
MAX_PROXIMITY_ALERT_RADIUS = 100000
""":obj:`int`: Maximum value allowed for:
* :paramref:`~telegram.InlineQueryResultLocation.proximity_alert_radius` parameter of
:class:`telegram.InlineQueryResultLocation`
* :paramref:`~telegram.InputLocationMessageContent.proximity_alert_radius` parameter of
:class:`telegram.InputLocationMessageContent`
* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.send_location`
"""
class MaskPosition(StringEnum):
"""This enum contains the available positions for :class:`telegram.MaskPosition`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
FOREHEAD = "forehead"
""":obj:`str`: Mask position for a sticker on the forehead."""
EYES = "eyes"
""":obj:`str`: Mask position for a sticker on the eyes."""
MOUTH = "mouth"
""":obj:`str`: Mask position for a sticker on the mouth."""
CHIN = "chin"
""":obj:`str`: Mask position for a sticker on the chin."""
class MediaGroupLimit(IntEnum):
"""This enum contains limitations for :meth:`telegram.Bot.send_media_group`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()