telegrinder 0.4.2__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of telegrinder might be problematic. Click here for more details.

Files changed (233) hide show
  1. telegrinder/__init__.py +37 -55
  2. telegrinder/__meta__.py +1 -0
  3. telegrinder/api/__init__.py +6 -4
  4. telegrinder/api/api.py +100 -26
  5. telegrinder/api/error.py +42 -8
  6. telegrinder/api/response.py +4 -1
  7. telegrinder/api/token.py +2 -2
  8. telegrinder/bot/__init__.py +9 -25
  9. telegrinder/bot/bot.py +31 -25
  10. telegrinder/bot/cute_types/__init__.py +0 -0
  11. telegrinder/bot/cute_types/base.py +103 -61
  12. telegrinder/bot/cute_types/callback_query.py +447 -400
  13. telegrinder/bot/cute_types/chat_join_request.py +59 -62
  14. telegrinder/bot/cute_types/chat_member_updated.py +154 -157
  15. telegrinder/bot/cute_types/inline_query.py +41 -44
  16. telegrinder/bot/cute_types/message.py +2621 -2590
  17. telegrinder/bot/cute_types/pre_checkout_query.py +38 -42
  18. telegrinder/bot/cute_types/update.py +1 -8
  19. telegrinder/bot/cute_types/utils.py +1 -1
  20. telegrinder/bot/dispatch/__init__.py +10 -15
  21. telegrinder/bot/dispatch/abc.py +12 -11
  22. telegrinder/bot/dispatch/action.py +104 -0
  23. telegrinder/bot/dispatch/context.py +32 -26
  24. telegrinder/bot/dispatch/dispatch.py +61 -134
  25. telegrinder/bot/dispatch/handler/__init__.py +2 -0
  26. telegrinder/bot/dispatch/handler/abc.py +10 -8
  27. telegrinder/bot/dispatch/handler/audio_reply.py +2 -3
  28. telegrinder/bot/dispatch/handler/base.py +10 -33
  29. telegrinder/bot/dispatch/handler/document_reply.py +2 -3
  30. telegrinder/bot/dispatch/handler/func.py +55 -87
  31. telegrinder/bot/dispatch/handler/media_group_reply.py +2 -3
  32. telegrinder/bot/dispatch/handler/message_reply.py +2 -3
  33. telegrinder/bot/dispatch/handler/photo_reply.py +2 -3
  34. telegrinder/bot/dispatch/handler/sticker_reply.py +2 -3
  35. telegrinder/bot/dispatch/handler/video_reply.py +2 -3
  36. telegrinder/bot/dispatch/middleware/__init__.py +0 -0
  37. telegrinder/bot/dispatch/middleware/abc.py +79 -55
  38. telegrinder/bot/dispatch/middleware/global_middleware.py +18 -33
  39. telegrinder/bot/dispatch/process.py +84 -105
  40. telegrinder/bot/dispatch/return_manager/__init__.py +0 -0
  41. telegrinder/bot/dispatch/return_manager/abc.py +102 -65
  42. telegrinder/bot/dispatch/return_manager/callback_query.py +4 -5
  43. telegrinder/bot/dispatch/return_manager/inline_query.py +3 -4
  44. telegrinder/bot/dispatch/return_manager/message.py +8 -10
  45. telegrinder/bot/dispatch/return_manager/pre_checkout_query.py +4 -5
  46. telegrinder/bot/dispatch/view/__init__.py +4 -4
  47. telegrinder/bot/dispatch/view/abc.py +6 -16
  48. telegrinder/bot/dispatch/view/base.py +54 -178
  49. telegrinder/bot/dispatch/view/box.py +19 -18
  50. telegrinder/bot/dispatch/view/callback_query.py +4 -8
  51. telegrinder/bot/dispatch/view/chat_join_request.py +5 -6
  52. telegrinder/bot/dispatch/view/chat_member.py +5 -25
  53. telegrinder/bot/dispatch/view/error.py +9 -0
  54. telegrinder/bot/dispatch/view/inline_query.py +4 -8
  55. telegrinder/bot/dispatch/view/message.py +5 -25
  56. telegrinder/bot/dispatch/view/pre_checkout_query.py +4 -8
  57. telegrinder/bot/dispatch/view/raw.py +3 -109
  58. telegrinder/bot/dispatch/waiter_machine/__init__.py +2 -5
  59. telegrinder/bot/dispatch/waiter_machine/actions.py +6 -4
  60. telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +1 -3
  61. telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +1 -1
  62. telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +11 -7
  63. telegrinder/bot/dispatch/waiter_machine/hasher/message.py +0 -0
  64. telegrinder/bot/dispatch/waiter_machine/machine.py +43 -60
  65. telegrinder/bot/dispatch/waiter_machine/middleware.py +19 -23
  66. telegrinder/bot/dispatch/waiter_machine/short_state.py +6 -5
  67. telegrinder/bot/polling/__init__.py +0 -0
  68. telegrinder/bot/polling/abc.py +0 -0
  69. telegrinder/bot/polling/polling.py +209 -88
  70. telegrinder/bot/rules/__init__.py +3 -16
  71. telegrinder/bot/rules/abc.py +42 -122
  72. telegrinder/bot/rules/callback_data.py +29 -49
  73. telegrinder/bot/rules/chat_join.py +5 -23
  74. telegrinder/bot/rules/command.py +8 -4
  75. telegrinder/bot/rules/enum_text.py +3 -4
  76. telegrinder/bot/rules/func.py +7 -14
  77. telegrinder/bot/rules/fuzzy.py +3 -4
  78. telegrinder/bot/rules/inline.py +8 -20
  79. telegrinder/bot/rules/integer.py +2 -3
  80. telegrinder/bot/rules/is_from.py +12 -11
  81. telegrinder/bot/rules/logic.py +11 -5
  82. telegrinder/bot/rules/markup.py +22 -14
  83. telegrinder/bot/rules/mention.py +8 -7
  84. telegrinder/bot/rules/message_entities.py +8 -4
  85. telegrinder/bot/rules/node.py +23 -12
  86. telegrinder/bot/rules/payload.py +5 -4
  87. telegrinder/bot/rules/payment_invoice.py +6 -21
  88. telegrinder/bot/rules/regex.py +2 -4
  89. telegrinder/bot/rules/rule_enum.py +8 -7
  90. telegrinder/bot/rules/start.py +5 -6
  91. telegrinder/bot/rules/state.py +1 -1
  92. telegrinder/bot/rules/text.py +4 -15
  93. telegrinder/bot/rules/update.py +3 -4
  94. telegrinder/bot/scenario/__init__.py +0 -0
  95. telegrinder/bot/scenario/abc.py +6 -5
  96. telegrinder/bot/scenario/checkbox.py +1 -1
  97. telegrinder/bot/scenario/choice.py +30 -39
  98. telegrinder/client/__init__.py +3 -5
  99. telegrinder/client/abc.py +11 -6
  100. telegrinder/client/aiohttp.py +141 -27
  101. telegrinder/client/form_data.py +1 -1
  102. telegrinder/model.py +61 -89
  103. telegrinder/modules.py +325 -102
  104. telegrinder/msgspec_utils/__init__.py +40 -0
  105. telegrinder/msgspec_utils/abc.py +18 -0
  106. telegrinder/msgspec_utils/custom_types/__init__.py +6 -0
  107. telegrinder/msgspec_utils/custom_types/datetime.py +24 -0
  108. telegrinder/msgspec_utils/custom_types/enum_meta.py +43 -0
  109. telegrinder/msgspec_utils/custom_types/literal.py +25 -0
  110. telegrinder/msgspec_utils/custom_types/option.py +17 -0
  111. telegrinder/msgspec_utils/decoder.py +389 -0
  112. telegrinder/msgspec_utils/encoder.py +206 -0
  113. telegrinder/{msgspec_json.py → msgspec_utils/json.py} +6 -5
  114. telegrinder/msgspec_utils/tools.py +75 -0
  115. telegrinder/node/__init__.py +24 -7
  116. telegrinder/node/attachment.py +1 -0
  117. telegrinder/node/base.py +154 -72
  118. telegrinder/node/callback_query.py +5 -5
  119. telegrinder/node/collection.py +39 -0
  120. telegrinder/node/command.py +1 -2
  121. telegrinder/node/composer.py +121 -72
  122. telegrinder/node/container.py +11 -8
  123. telegrinder/node/context.py +48 -0
  124. telegrinder/node/either.py +27 -40
  125. telegrinder/node/error.py +41 -0
  126. telegrinder/node/event.py +37 -11
  127. telegrinder/node/exceptions.py +7 -0
  128. telegrinder/node/file.py +0 -0
  129. telegrinder/node/i18n.py +108 -0
  130. telegrinder/node/me.py +3 -2
  131. telegrinder/node/payload.py +1 -1
  132. telegrinder/node/polymorphic.py +63 -28
  133. telegrinder/node/reply_message.py +12 -0
  134. telegrinder/node/rule.py +6 -13
  135. telegrinder/node/scope.py +14 -5
  136. telegrinder/node/session.py +53 -0
  137. telegrinder/node/source.py +41 -9
  138. telegrinder/node/text.py +1 -2
  139. telegrinder/node/tools/__init__.py +0 -0
  140. telegrinder/node/tools/generator.py +3 -5
  141. telegrinder/node/utility.py +16 -0
  142. telegrinder/py.typed +0 -0
  143. telegrinder/rules.py +0 -0
  144. telegrinder/tools/__init__.py +48 -88
  145. telegrinder/tools/aio.py +103 -0
  146. telegrinder/tools/callback_data_serialization/__init__.py +5 -0
  147. telegrinder/tools/{callback_data_serilization → callback_data_serialization}/abc.py +0 -0
  148. telegrinder/tools/{callback_data_serilization → callback_data_serialization}/json_ser.py +2 -3
  149. telegrinder/tools/{callback_data_serilization → callback_data_serialization}/msgpack_ser.py +45 -27
  150. telegrinder/tools/final.py +21 -0
  151. telegrinder/tools/formatting/__init__.py +2 -18
  152. telegrinder/tools/formatting/deep_links/__init__.py +39 -0
  153. telegrinder/tools/formatting/{deep_links.py → deep_links/links.py} +12 -85
  154. telegrinder/tools/formatting/deep_links/parsing.py +90 -0
  155. telegrinder/tools/formatting/deep_links/validators.py +8 -0
  156. telegrinder/tools/formatting/html_formatter.py +18 -45
  157. telegrinder/tools/fullname.py +83 -0
  158. telegrinder/tools/global_context/__init__.py +4 -3
  159. telegrinder/tools/global_context/abc.py +17 -14
  160. telegrinder/tools/global_context/builtin_context.py +39 -0
  161. telegrinder/tools/global_context/global_context.py +138 -39
  162. telegrinder/tools/input_file_directory.py +0 -0
  163. telegrinder/tools/keyboard/__init__.py +39 -0
  164. telegrinder/tools/keyboard/abc.py +159 -0
  165. telegrinder/tools/keyboard/base.py +77 -0
  166. telegrinder/tools/keyboard/buttons/__init__.py +14 -0
  167. telegrinder/tools/keyboard/buttons/base.py +18 -0
  168. telegrinder/tools/{buttons.py → keyboard/buttons/buttons.py} +71 -23
  169. telegrinder/tools/keyboard/buttons/static_buttons.py +56 -0
  170. telegrinder/tools/keyboard/buttons/tools.py +18 -0
  171. telegrinder/tools/keyboard/data.py +20 -0
  172. telegrinder/tools/keyboard/keyboard.py +131 -0
  173. telegrinder/tools/keyboard/static_keyboard.py +83 -0
  174. telegrinder/tools/lifespan.py +87 -51
  175. telegrinder/tools/limited_dict.py +4 -1
  176. telegrinder/tools/loop_wrapper.py +332 -0
  177. telegrinder/tools/magic/__init__.py +32 -0
  178. telegrinder/tools/magic/annotations.py +165 -0
  179. telegrinder/tools/magic/dictionary.py +20 -0
  180. telegrinder/tools/magic/function.py +246 -0
  181. telegrinder/tools/magic/shortcut.py +111 -0
  182. telegrinder/tools/parse_mode.py +9 -3
  183. telegrinder/tools/singleton/__init__.py +4 -0
  184. telegrinder/tools/singleton/abc.py +14 -0
  185. telegrinder/tools/singleton/singleton.py +18 -0
  186. telegrinder/tools/state_storage/__init__.py +0 -0
  187. telegrinder/tools/state_storage/abc.py +6 -1
  188. telegrinder/tools/state_storage/memory.py +1 -1
  189. telegrinder/tools/strings.py +0 -0
  190. telegrinder/types/__init__.py +307 -268
  191. telegrinder/types/enums.py +64 -37
  192. telegrinder/types/input_file.py +3 -3
  193. telegrinder/types/methods.py +5699 -5055
  194. telegrinder/types/methods_utils.py +62 -0
  195. telegrinder/types/objects.py +7846 -7058
  196. telegrinder/verification_utils.py +3 -1
  197. telegrinder-0.5.0.dist-info/METADATA +162 -0
  198. telegrinder-0.5.0.dist-info/RECORD +200 -0
  199. {telegrinder-0.4.2.dist-info → telegrinder-0.5.0.dist-info}/licenses/LICENSE +2 -2
  200. telegrinder/bot/dispatch/waiter_machine/hasher/state.py +0 -20
  201. telegrinder/bot/rules/id.py +0 -24
  202. telegrinder/bot/rules/message.py +0 -15
  203. telegrinder/client/sonic.py +0 -212
  204. telegrinder/msgspec_utils.py +0 -478
  205. telegrinder/tools/adapter/__init__.py +0 -19
  206. telegrinder/tools/adapter/abc.py +0 -49
  207. telegrinder/tools/adapter/dataclass.py +0 -56
  208. telegrinder/tools/adapter/errors.py +0 -5
  209. telegrinder/tools/adapter/event.py +0 -61
  210. telegrinder/tools/adapter/node.py +0 -46
  211. telegrinder/tools/adapter/raw_event.py +0 -27
  212. telegrinder/tools/adapter/raw_update.py +0 -30
  213. telegrinder/tools/callback_data_serilization/__init__.py +0 -5
  214. telegrinder/tools/error_handler/__init__.py +0 -10
  215. telegrinder/tools/error_handler/abc.py +0 -30
  216. telegrinder/tools/error_handler/error.py +0 -9
  217. telegrinder/tools/error_handler/error_handler.py +0 -179
  218. telegrinder/tools/formatting/spec_html_formats.py +0 -75
  219. telegrinder/tools/functional.py +0 -8
  220. telegrinder/tools/global_context/telegrinder_ctx.py +0 -27
  221. telegrinder/tools/i18n/__init__.py +0 -12
  222. telegrinder/tools/i18n/abc.py +0 -32
  223. telegrinder/tools/i18n/middleware/__init__.py +0 -3
  224. telegrinder/tools/i18n/middleware/abc.py +0 -22
  225. telegrinder/tools/i18n/simple.py +0 -43
  226. telegrinder/tools/keyboard.py +0 -132
  227. telegrinder/tools/loop_wrapper/__init__.py +0 -4
  228. telegrinder/tools/loop_wrapper/abc.py +0 -20
  229. telegrinder/tools/loop_wrapper/loop_wrapper.py +0 -169
  230. telegrinder/tools/magic.py +0 -344
  231. telegrinder-0.4.2.dist-info/METADATA +0 -151
  232. telegrinder-0.4.2.dist-info/RECORD +0 -182
  233. {telegrinder-0.4.2.dist-info → telegrinder-0.5.0.dist-info}/WHEEL +0 -0
@@ -1,7 +1,9 @@
1
1
  import enum
2
2
 
3
+ from telegrinder.msgspec_utils import BaseEnumMeta
3
4
 
4
- class ProgrammingLanguage(str, enum.Enum):
5
+
6
+ class ProgrammingLanguage(enum.StrEnum, metaclass=BaseEnumMeta):
5
7
  """Type of ProgrammingLanguage."""
6
8
 
7
9
  ASSEMBLY = "assembly"
@@ -39,7 +41,7 @@ class ProgrammingLanguage(str, enum.Enum):
39
41
  MARKUP = "markup"
40
42
 
41
43
 
42
- class ChatAction(str, enum.Enum):
44
+ class ChatAction(enum.StrEnum, metaclass=BaseEnumMeta):
43
45
  """Type of ChatAction.
44
46
 
45
47
  Choose one, depending on what the user is about to receive:
@@ -68,7 +70,7 @@ class ChatAction(str, enum.Enum):
68
70
  UPLOAD_VIDEO_NOTE = "upload_video_note"
69
71
 
70
72
 
71
- class ReactionEmoji(str, enum.Enum):
73
+ class ReactionEmoji(enum.StrEnum, metaclass=BaseEnumMeta):
72
74
  """Type of ReactionEmoji.
73
75
 
74
76
  Currently, it can be one of `👍`, `👎`, `❤`, `🔥`, `🥰`, `👏`,
@@ -156,7 +158,7 @@ class ReactionEmoji(str, enum.Enum):
156
158
  ENRAGED_FACE = "😡"
157
159
 
158
160
 
159
- class DefaultAccentColor(int, enum.Enum):
161
+ class DefaultAccentColor(enum.IntEnum, metaclass=BaseEnumMeta):
160
162
  """Type of DefaultAccentColor.
161
163
 
162
164
  One of 7 possible user colors:
@@ -180,7 +182,7 @@ class DefaultAccentColor(int, enum.Enum):
180
182
  PINK = 6
181
183
 
182
184
 
183
- class TopicIconColor(int, enum.Enum):
185
+ class TopicIconColor(enum.IntEnum, metaclass=BaseEnumMeta):
184
186
  """Type of TopicIconColor.
185
187
 
186
188
  Docs: https://github.com/telegramdesktop/tdesktop/blob/991fe491c5ae62705d77aa8fdd44a79caf639c45/Telegram/SourceFiles/data/data_forum_topic.cpp#L51-L56
@@ -194,7 +196,7 @@ class TopicIconColor(int, enum.Enum):
194
196
  RED = 0xFB6F5F
195
197
 
196
198
 
197
- class ChatBoostSourceType(str, enum.Enum):
199
+ class ChatBoostSourceType(enum.StrEnum, metaclass=BaseEnumMeta):
198
200
  """Type of ChatBoostSourceType
199
201
  Docs: https://core.telegram.org/bots/api#chatboostsource
200
202
  """
@@ -204,20 +206,20 @@ class ChatBoostSourceType(str, enum.Enum):
204
206
  GIVEAWAY = "giveaway"
205
207
 
206
208
 
207
- class ContentType(str, enum.Enum):
209
+ class ContentType(enum.StrEnum, metaclass=BaseEnumMeta):
208
210
  """Type of ContentType."""
209
211
 
210
212
  TEXT = "text"
211
213
  ANIMATION = "animation"
212
214
  AUDIO = "audio"
213
215
  DOCUMENT = "document"
216
+ PAID_MEDIA = "paid_media"
214
217
  PHOTO = "photo"
215
218
  STICKER = "sticker"
216
219
  STORY = "story"
217
220
  VIDEO = "video"
218
221
  VIDEO_NOTE = "video_note"
219
222
  VOICE = "voice"
220
- HAS_MEDIA_SPOILER = "has_media_spoiler"
221
223
  CONTACT = "contact"
222
224
  DICE = "dice"
223
225
  GAME = "game"
@@ -239,12 +241,16 @@ class ContentType(str, enum.Enum):
239
241
  PINNED_MESSAGE = "pinned_message"
240
242
  INVOICE = "invoice"
241
243
  SUCCESSFUL_PAYMENT = "successful_payment"
244
+ REFUNDED_PAYMENT = "refunded_payment"
242
245
  USERS_SHARED = "users_shared"
243
246
  CHAT_SHARED = "chat_shared"
247
+ GIFT = "gift"
248
+ UNIQUE_GIFT = "unique_gift"
244
249
  CONNECTED_WEBSITE = "connected_website"
245
250
  WRITE_ACCESS_ALLOWED = "write_access_allowed"
246
251
  PASSPORT_DATA = "passport_data"
247
252
  PROXIMITY_ALERT_TRIGGERED = "proximity_alert_triggered"
253
+ CHAT_BACKGROUND_SET = "chat_background_set"
248
254
  FORUM_TOPIC_CREATED = "forum_topic_created"
249
255
  FORUM_TOPIC_EDITED = "forum_topic_edited"
250
256
  FORUM_TOPIC_CLOSED = "forum_topic_closed"
@@ -255,6 +261,7 @@ class ContentType(str, enum.Enum):
255
261
  GIVEAWAY = "giveaway"
256
262
  GIVEAWAY_WINNERS = "giveaway_winners"
257
263
  GIVEAWAY_COMPLETED = "giveaway_completed"
264
+ PAID_MESSAGE_PRICE_CHANGED = "paid_message_price_changed"
258
265
  VIDEO_CHAT_SCHEDULED = "video_chat_scheduled"
259
266
  VIDEO_CHAT_STARTED = "video_chat_started"
260
267
  VIDEO_CHAT_ENDED = "video_chat_ended"
@@ -264,7 +271,7 @@ class ContentType(str, enum.Enum):
264
271
  UNKNOWN = "unknown"
265
272
 
266
273
 
267
- class Currency(str, enum.Enum):
274
+ class Currency(enum.StrEnum, metaclass=BaseEnumMeta):
268
275
  """Type of Currency.
269
276
  Docs: https://core.telegram.org/bots/payments#supported-currencies
270
277
  """
@@ -359,7 +366,7 @@ class Currency(str, enum.Enum):
359
366
  """Telegram stars."""
360
367
 
361
368
 
362
- class InlineQueryResultType(str, enum.Enum):
369
+ class InlineQueryResultType(enum.StrEnum, metaclass=BaseEnumMeta):
363
370
  """Type of InlineQueryResultType.
364
371
  Docs: https://core.telegram.org/bots/api#inlinequeryresult
365
372
  """
@@ -379,7 +386,7 @@ class InlineQueryResultType(str, enum.Enum):
379
386
  VENUE = "venue"
380
387
 
381
388
 
382
- class MenuButtonType(str, enum.Enum):
389
+ class MenuButtonType(enum.StrEnum, metaclass=BaseEnumMeta):
383
390
  """TType of MenuButtonType.
384
391
  Docs: https://core.telegram.org/bots/api#menubuttondefault
385
392
  """
@@ -389,7 +396,7 @@ class MenuButtonType(str, enum.Enum):
389
396
  WEB_APP = "web_app"
390
397
 
391
398
 
392
- class InputMediaType(str, enum.Enum):
399
+ class InputMediaType(enum.StrEnum, metaclass=BaseEnumMeta):
393
400
  """Type of InputMediaType.
394
401
  Docs: https://core.telegram.org/bots/api#inputmedia
395
402
  """
@@ -401,7 +408,7 @@ class InputMediaType(str, enum.Enum):
401
408
  VIDEO = "video"
402
409
 
403
410
 
404
- class UpdateType(str, enum.Enum):
411
+ class UpdateType(enum.StrEnum, metaclass=BaseEnumMeta):
405
412
  """Type of update."""
406
413
 
407
414
  MESSAGE = "message"
@@ -415,6 +422,7 @@ class UpdateType(str, enum.Enum):
415
422
  CALLBACK_QUERY = "callback_query"
416
423
  SHIPPING_QUERY = "shipping_query"
417
424
  PRE_CHECKOUT_QUERY = "pre_checkout_query"
425
+ PURCHASED_PAID_MEDIA = "purchased_paid_media"
418
426
  POLL = "poll"
419
427
  POLL_ANSWER = "poll_answer"
420
428
  MY_CHAT_MEMBER = "my_chat_member"
@@ -425,10 +433,10 @@ class UpdateType(str, enum.Enum):
425
433
  BUSINESS_CONNECTION = "business_connection"
426
434
  BUSINESS_MESSAGE = "business_message"
427
435
  EDITED_BUSINESS_MESSAGE = "edited_business_message"
428
- DELETE_BUSINESS_MESSAGE = "delete_business_messages"
436
+ DELETED_BUSINESS_MESSAGES = "deleted_business_messages"
429
437
 
430
438
 
431
- class BotCommandScopeType(str, enum.Enum):
439
+ class BotCommandScopeType(enum.StrEnum, metaclass=BaseEnumMeta):
432
440
  """Type of BotCommandScope.
433
441
  Represents the scope to which bot commands are applied.
434
442
  """
@@ -442,7 +450,7 @@ class BotCommandScopeType(str, enum.Enum):
442
450
  CHAT_MEMBER = "chat_member"
443
451
 
444
452
 
445
- class ChatType(str, enum.Enum):
453
+ class ChatType(enum.StrEnum, metaclass=BaseEnumMeta):
446
454
  """Type of chat, can be either `private`, `group`, `supergroup` or `channel`."""
447
455
 
448
456
  PRIVATE = "private"
@@ -452,7 +460,7 @@ class ChatType(str, enum.Enum):
452
460
  SENDER = "sender"
453
461
 
454
462
 
455
- class ChatMemberStatus(str, enum.Enum):
463
+ class ChatMemberStatus(enum.StrEnum, metaclass=BaseEnumMeta):
456
464
  """Type of ChatMemberStatus."""
457
465
 
458
466
  CREATOR = "creator"
@@ -463,7 +471,7 @@ class ChatMemberStatus(str, enum.Enum):
463
471
  KICKED = "kicked"
464
472
 
465
473
 
466
- class DiceEmoji(str, enum.Enum):
474
+ class DiceEmoji(enum.StrEnum, metaclass=BaseEnumMeta):
467
475
  """Emoji on which the dice throw animation is based."""
468
476
 
469
477
  DICE = "🎲"
@@ -474,7 +482,7 @@ class DiceEmoji(str, enum.Enum):
474
482
  BOWLING = "🎳"
475
483
 
476
484
 
477
- class MessageEntityType(str, enum.Enum):
485
+ class MessageEntityType(enum.StrEnum, metaclass=BaseEnumMeta):
478
486
  """Type of the entity. Currently, can be `mention` (@username), `hashtag`
479
487
  (#hashtag or #hashtag@chatusername), `cashtag` ($USD or $USD@chatusername),
480
488
  `bot_command` (/start@jobs_bot), `url` (https://telegram.org), `email`
@@ -484,8 +492,7 @@ class MessageEntityType(str, enum.Enum):
484
492
  `blockquote` (block quotation), `expandable_blockquote` (collapsed-by-default
485
493
  block quotation), `code` (monowidth string), `pre` (monowidth block),
486
494
  `text_link` (for clickable text URLs), `text_mention` (for users without
487
- usernames), `custom_emoji` (for inline custom emoji stickers).
488
- """
495
+ usernames), `custom_emoji` (for inline custom emoji stickers)."""
489
496
 
490
497
  MENTION = "mention"
491
498
  HASHTAG = "hashtag"
@@ -508,14 +515,14 @@ class MessageEntityType(str, enum.Enum):
508
515
  EXPANDABLE_BLOCKQUOTE = "expandable_blockquote"
509
516
 
510
517
 
511
- class PollType(str, enum.Enum):
518
+ class PollType(enum.StrEnum, metaclass=BaseEnumMeta):
512
519
  """Poll type, currently can be `regular` or `quiz`."""
513
520
 
514
521
  REGULAR = "regular"
515
522
  QUIZ = "quiz"
516
523
 
517
524
 
518
- class StickerType(str, enum.Enum):
525
+ class StickerType(enum.StrEnum, metaclass=BaseEnumMeta):
519
526
  """Type of the sticker, currently one of `regular`, `mask`, `custom_emoji`.
520
527
  The type of the sticker is independent from its format, which is determined
521
528
  by the fields `is_animated` and `is_video`.
@@ -526,7 +533,7 @@ class StickerType(str, enum.Enum):
526
533
  CUSTOM_EMOJI = "custom_emoji"
527
534
 
528
535
 
529
- class MessageOriginType(str, enum.Enum):
536
+ class MessageOriginType(enum.StrEnum, metaclass=BaseEnumMeta):
530
537
  """Type of MessageOriginType
531
538
  Docs: https://core.telegram.org/bots/api#messageorigin
532
539
  """
@@ -537,7 +544,7 @@ class MessageOriginType(str, enum.Enum):
537
544
  CHANNEL = "channel"
538
545
 
539
546
 
540
- class StickerSetStickerType(str, enum.Enum):
547
+ class StickerSetStickerType(enum.StrEnum, metaclass=BaseEnumMeta):
541
548
  """Type of stickers in the set, currently one of `regular`, `mask`, `custom_emoji`."""
542
549
 
543
550
  REGULAR = "regular"
@@ -545,7 +552,7 @@ class StickerSetStickerType(str, enum.Enum):
545
552
  CUSTOM_EMOJI = "custom_emoji"
546
553
 
547
554
 
548
- class MaskPositionPoint(str, enum.Enum):
555
+ class MaskPositionPoint(enum.StrEnum, metaclass=BaseEnumMeta):
549
556
  """The part of the face relative to which the mask should be placed. One of `forehead`,
550
557
  `eyes`, `mouth`, or `chin`.
551
558
  """
@@ -556,7 +563,7 @@ class MaskPositionPoint(str, enum.Enum):
556
563
  CHIN = "chin"
557
564
 
558
565
 
559
- class InlineQueryChatType(str, enum.Enum):
566
+ class InlineQueryChatType(enum.StrEnum, metaclass=BaseEnumMeta):
560
567
  """Type of the chat from which the inline query was sent. Can be
561
568
  either `sender` for a private chat with the inline query sender, `private`,
562
569
  `group`, `supergroup`, or `channel`. The chat type should be always known
@@ -571,14 +578,14 @@ class InlineQueryChatType(str, enum.Enum):
571
578
  CHANNEL = "channel"
572
579
 
573
580
 
574
- class InlineQueryResultMimeType(str, enum.Enum):
581
+ class InlineQueryResultMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
575
582
  """MIME type of the content of the video URL, `text/html` or `video/mp4`."""
576
583
 
577
584
  TEXT_HTML = "text/html"
578
585
  VIDEO_MP4 = "video/mp4"
579
586
 
580
587
 
581
- class InlineQueryResultThumbnailMimeType(str, enum.Enum):
588
+ class InlineQueryResultThumbnailMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
582
589
  """MIME type of the thumbnail, must be one of `image/jpeg`, `image/gif`,
583
590
  or `video/mp4`. Defaults to `image/jpeg`
584
591
  """
@@ -588,7 +595,7 @@ class InlineQueryResultThumbnailMimeType(str, enum.Enum):
588
595
  VIDEO_MP4 = "video/mp4"
589
596
 
590
597
 
591
- class PassportElementErrorType(str, enum.Enum):
598
+ class PassportElementErrorType(enum.StrEnum, metaclass=BaseEnumMeta):
592
599
  """Type of PassportElementErrorType.
593
600
  Docs: https://core.telegram.org/bots/api#passportelementerror
594
601
  """
@@ -604,7 +611,7 @@ class PassportElementErrorType(str, enum.Enum):
604
611
  UNSPECIFIED = "unspecified"
605
612
 
606
613
 
607
- class ReactionTypeType(str, enum.Enum):
614
+ class ReactionTypeType(enum.StrEnum, metaclass=BaseEnumMeta):
608
615
  """Type of ReactionTypeType.
609
616
  Docs: https://core.telegram.org/bots/api#reactiontype
610
617
  """
@@ -613,7 +620,7 @@ class ReactionTypeType(str, enum.Enum):
613
620
  CUSTOM_EMOJI = "custom_emoji"
614
621
 
615
622
 
616
- class InlineQueryResultGifThumbnailMimeType(str, enum.Enum):
623
+ class InlineQueryResultGifThumbnailMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
617
624
  """MIME type of the thumbnail, must be one of `image/jpeg`, `image/gif`,
618
625
  or `video/mp4`. Defaults to `image/jpeg`.
619
626
  """
@@ -623,7 +630,7 @@ class InlineQueryResultGifThumbnailMimeType(str, enum.Enum):
623
630
  VIDEO_MP4 = "video/mp4"
624
631
 
625
632
 
626
- class InlineQueryResultMpeg4GifThumbnailMimeType(str, enum.Enum):
633
+ class InlineQueryResultMpeg4GifThumbnailMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
627
634
  """MIME type of the thumbnail, must be one of `image/jpeg`, `image/gif`,
628
635
  or `video/mp4`. Defaults to `image/jpeg`.
629
636
  """
@@ -633,21 +640,21 @@ class InlineQueryResultMpeg4GifThumbnailMimeType(str, enum.Enum):
633
640
  VIDEO_MP4 = "video/mp4"
634
641
 
635
642
 
636
- class InlineQueryResultVideoMimeType(str, enum.Enum):
643
+ class InlineQueryResultVideoMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
637
644
  """MIME type of the content of the video URL, `text/html` or `video/mp4`."""
638
645
 
639
646
  TEXT_HTML = "text/html"
640
647
  VIDEO_MP4 = "video/mp4"
641
648
 
642
649
 
643
- class InlineQueryResultDocumentMimeType(str, enum.Enum):
650
+ class InlineQueryResultDocumentMimeType(enum.StrEnum, metaclass=BaseEnumMeta):
644
651
  """MIME type of the content of the file, either `application/pdf` or `application/zip`."""
645
652
 
646
653
  APPLICATION_PDF = "application/pdf"
647
654
  APPLICATION_ZIP = "application/zip"
648
655
 
649
656
 
650
- class EncryptedPassportElementType(str, enum.Enum):
657
+ class EncryptedPassportElementType(enum.StrEnum, metaclass=BaseEnumMeta):
651
658
  """Element type. One of `personal_details`, `passport`, `driver_license`,
652
659
  `identity_card`, `internal_passport`, `address`, `utility_bill`,
653
660
  `bank_statement`, `rental_agreement`, `passport_registration`,
@@ -669,7 +676,7 @@ class EncryptedPassportElementType(str, enum.Enum):
669
676
  EMAIL = "email"
670
677
 
671
678
 
672
- class StickerFormat(str, enum.Enum):
679
+ class StickerFormat(enum.StrEnum, metaclass=BaseEnumMeta):
673
680
  """Format of the sticker."""
674
681
 
675
682
  STATIC = "static"
@@ -677,6 +684,24 @@ class StickerFormat(str, enum.Enum):
677
684
  VIDEO = "video"
678
685
 
679
686
 
687
+ class TransactionPartnerUserTransactionType(enum.StrEnum, metaclass=BaseEnumMeta):
688
+ """This object represents type of the transaction that were made by partner user."""
689
+
690
+ INVOICE_PAYMENT = "invoice_payment"
691
+ PAID_MEDIA_PAYMENT = "paid_media_payment"
692
+ GIFT_PURCHASE = "gift_purchase"
693
+ PREMIUM_PURCHASE = "premium_purchase"
694
+ BUSINESS_ACCOUNT_TRANSFER = "business_account_transfer"
695
+
696
+
697
+ class UniqueGiftInfoOriginType(enum.StrEnum, metaclass=BaseEnumMeta):
698
+ """Origin of the gift. Currently, either `upgrade`, `transfer` or `resale`."""
699
+
700
+ UPGRADE = "upgrade"
701
+ TRANSFER = "transfer"
702
+ RESALE = "resale"
703
+
704
+
680
705
  __all__ = (
681
706
  "BotCommandScopeType",
682
707
  "ChatAction",
@@ -707,5 +732,7 @@ __all__ = (
707
732
  "StickerSetStickerType",
708
733
  "StickerType",
709
734
  "TopicIconColor",
735
+ "TransactionPartnerUserTransactionType",
736
+ "UniqueGiftInfoOriginType",
710
737
  "UpdateType",
711
738
  )
@@ -27,7 +27,7 @@ class InputFile:
27
27
 
28
28
  def __repr__(self) -> str:
29
29
  return "{}(filename={!r}, data={!r})".format(
30
- self.__class__.__name__,
30
+ type(self).__name__,
31
31
  self.filename,
32
32
  (self.data[:30] + b"...") if len(self.data) > 30 else self.data,
33
33
  )
@@ -44,8 +44,8 @@ class InputFile:
44
44
 
45
45
 
46
46
  @encoder.add_enc_hook(InputFile)
47
- def encode_inputfile(inputfile: InputFile, files: Files) -> str:
48
- return inputfile._to_multipart(files)
47
+ def encode_input_file(input_file: InputFile, files: Files) -> str:
48
+ return input_file._to_multipart(files)
49
49
 
50
50
 
51
51
  __all__ = ("InputFile",)