telegrinder 0.3.4.post1__tar.gz → 0.4.1__tar.gz

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 (214) hide show
  1. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/LICENSE +2 -2
  2. telegrinder-0.4.1/PKG-INFO +143 -0
  3. telegrinder-0.4.1/pyproject.toml +162 -0
  4. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/readme.md +8 -2
  5. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/__init__.py +30 -31
  6. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/api/__init__.py +2 -1
  7. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/api/api.py +28 -20
  8. telegrinder-0.4.1/telegrinder/api/error.py +20 -0
  9. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/api/response.py +2 -2
  10. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/api/token.py +2 -2
  11. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/__init__.py +6 -0
  12. telegrinder-0.4.1/telegrinder/bot/bot.py +83 -0
  13. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/__init__.py +2 -0
  14. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/base.py +55 -129
  15. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/callback_query.py +76 -61
  16. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/chat_join_request.py +4 -3
  17. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/chat_member_updated.py +28 -31
  18. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/inline_query.py +5 -4
  19. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/message.py +555 -602
  20. telegrinder-0.4.1/telegrinder/bot/cute_types/pre_checkout_query.py +42 -0
  21. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/update.py +20 -12
  22. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/cute_types/utils.py +3 -36
  23. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/__init__.py +4 -0
  24. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/abc.py +8 -9
  25. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/context.py +5 -7
  26. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/dispatch.py +85 -33
  27. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/abc.py +5 -6
  28. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/audio_reply.py +2 -2
  29. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/base.py +3 -3
  30. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/document_reply.py +2 -2
  31. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/func.py +36 -42
  32. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/media_group_reply.py +5 -4
  33. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/message_reply.py +2 -2
  34. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/photo_reply.py +2 -2
  35. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/sticker_reply.py +2 -2
  36. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/video_reply.py +2 -2
  37. telegrinder-0.4.1/telegrinder/bot/dispatch/middleware/abc.py +97 -0
  38. telegrinder-0.4.1/telegrinder/bot/dispatch/middleware/global_middleware.py +70 -0
  39. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/process.py +44 -50
  40. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/return_manager/__init__.py +2 -0
  41. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/return_manager/abc.py +6 -10
  42. telegrinder-0.4.1/telegrinder/bot/dispatch/return_manager/pre_checkout_query.py +20 -0
  43. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/__init__.py +2 -0
  44. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/abc.py +10 -6
  45. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/base.py +81 -50
  46. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/box.py +20 -9
  47. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/callback_query.py +3 -4
  48. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/chat_join_request.py +2 -7
  49. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/chat_member.py +3 -5
  50. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/inline_query.py +3 -4
  51. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/message.py +3 -4
  52. telegrinder-0.4.1/telegrinder/bot/dispatch/view/pre_checkout_query.py +16 -0
  53. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/view/raw.py +42 -40
  54. telegrinder-0.4.1/telegrinder/bot/dispatch/waiter_machine/actions.py +14 -0
  55. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +0 -0
  56. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +0 -0
  57. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +9 -7
  58. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/hasher/message.py +0 -0
  59. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/hasher/state.py +3 -2
  60. telegrinder-0.4.1/telegrinder/bot/dispatch/waiter_machine/machine.py +251 -0
  61. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/middleware.py +15 -10
  62. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/short_state.py +7 -18
  63. telegrinder-0.4.1/telegrinder/bot/polling/polling.py +139 -0
  64. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/__init__.py +24 -1
  65. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/abc.py +17 -10
  66. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/callback_data.py +20 -61
  67. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/chat_join.py +6 -4
  68. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/command.py +4 -4
  69. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/enum_text.py +1 -4
  70. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/func.py +5 -3
  71. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/fuzzy.py +1 -1
  72. telegrinder-0.4.1/telegrinder/bot/rules/id.py +24 -0
  73. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/inline.py +6 -4
  74. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/integer.py +2 -1
  75. telegrinder-0.4.1/telegrinder/bot/rules/logic.py +18 -0
  76. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/markup.py +5 -6
  77. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/message.py +2 -4
  78. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/message_entities.py +1 -3
  79. telegrinder-0.4.1/telegrinder/bot/rules/node.py +33 -0
  80. telegrinder-0.4.1/telegrinder/bot/rules/payload.py +81 -0
  81. telegrinder-0.4.1/telegrinder/bot/rules/payment_invoice.py +29 -0
  82. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/regex.py +5 -6
  83. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/state.py +1 -3
  84. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/text.py +10 -5
  85. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/update.py +0 -0
  86. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/scenario/abc.py +2 -4
  87. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/scenario/checkbox.py +12 -14
  88. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/scenario/choice.py +6 -9
  89. telegrinder-0.4.1/telegrinder/client/__init__.py +12 -0
  90. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/client/abc.py +35 -10
  91. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/client/aiohttp.py +28 -24
  92. telegrinder-0.4.1/telegrinder/client/form_data.py +31 -0
  93. telegrinder-0.4.1/telegrinder/client/sonic.py +212 -0
  94. telegrinder-0.4.1/telegrinder/model.py +213 -0
  95. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/modules.py +3 -1
  96. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/msgspec_utils.py +136 -68
  97. telegrinder-0.4.1/telegrinder/node/__init__.py +121 -0
  98. telegrinder-0.4.1/telegrinder/node/attachment.py +168 -0
  99. telegrinder-0.4.1/telegrinder/node/base.py +294 -0
  100. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/callback_query.py +17 -16
  101. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/command.py +3 -2
  102. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/composer.py +40 -75
  103. telegrinder-0.4.1/telegrinder/node/container.py +33 -0
  104. telegrinder-0.4.1/telegrinder/node/either.py +82 -0
  105. telegrinder-0.4.1/telegrinder/node/event.py +54 -0
  106. telegrinder-0.4.1/telegrinder/node/file.py +51 -0
  107. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/me.py +4 -5
  108. telegrinder-0.4.1/telegrinder/node/payload.py +78 -0
  109. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/polymorphic.py +28 -9
  110. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/rule.py +2 -6
  111. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/scope.py +4 -6
  112. telegrinder-0.4.1/telegrinder/node/source.py +87 -0
  113. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/text.py +20 -8
  114. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/tools/generator.py +7 -11
  115. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/py.typed +0 -0
  116. telegrinder-0.4.1/telegrinder/rules.py +1 -0
  117. telegrinder-0.4.1/telegrinder/tools/__init__.py +205 -0
  118. telegrinder-0.4.1/telegrinder/tools/adapter/__init__.py +19 -0
  119. telegrinder-0.4.1/telegrinder/tools/adapter/abc.py +49 -0
  120. telegrinder-0.4.1/telegrinder/tools/adapter/dataclass.py +56 -0
  121. {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.1/telegrinder/tools}/adapter/event.py +8 -10
  122. {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.1/telegrinder/tools}/adapter/node.py +8 -10
  123. {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.1/telegrinder/tools}/adapter/raw_event.py +2 -2
  124. {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.1/telegrinder/tools}/adapter/raw_update.py +2 -2
  125. telegrinder-0.4.1/telegrinder/tools/buttons.py +109 -0
  126. telegrinder-0.4.1/telegrinder/tools/callback_data_serilization/__init__.py +5 -0
  127. telegrinder-0.4.1/telegrinder/tools/callback_data_serilization/abc.py +51 -0
  128. telegrinder-0.4.1/telegrinder/tools/callback_data_serilization/json_ser.py +60 -0
  129. telegrinder-0.4.1/telegrinder/tools/callback_data_serilization/msgpack_ser.py +172 -0
  130. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/error_handler/abc.py +4 -7
  131. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/error_handler/error.py +0 -0
  132. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/error_handler/error_handler.py +34 -48
  133. telegrinder-0.4.1/telegrinder/tools/formatting/__init__.py +101 -0
  134. telegrinder-0.4.1/telegrinder/tools/formatting/deep_links.py +541 -0
  135. telegrinder-0.3.4.post1/telegrinder/tools/formatting/html.py → telegrinder-0.4.1/telegrinder/tools/formatting/html_formatter.py +51 -79
  136. telegrinder-0.4.1/telegrinder/tools/formatting/spec_html_formats.py +75 -0
  137. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/functional.py +1 -5
  138. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/global_context/global_context.py +26 -51
  139. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/global_context/telegrinder_ctx.py +3 -3
  140. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/i18n/abc.py +0 -0
  141. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/i18n/middleware/abc.py +3 -6
  142. telegrinder-0.4.1/telegrinder/tools/input_file_directory.py +30 -0
  143. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/keyboard.py +9 -9
  144. telegrinder-0.4.1/telegrinder/tools/lifespan.py +105 -0
  145. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/limited_dict.py +5 -10
  146. telegrinder-0.4.1/telegrinder/tools/loop_wrapper/abc.py +20 -0
  147. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/loop_wrapper/loop_wrapper.py +40 -95
  148. telegrinder-0.4.1/telegrinder/tools/magic.py +344 -0
  149. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/state_storage/__init__.py +0 -0
  150. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/state_storage/abc.py +5 -9
  151. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/state_storage/memory.py +1 -1
  152. telegrinder-0.4.1/telegrinder/tools/strings.py +13 -0
  153. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/types/__init__.py +8 -0
  154. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/types/enums.py +31 -21
  155. telegrinder-0.4.1/telegrinder/types/input_file.py +51 -0
  156. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/types/methods.py +531 -109
  157. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/types/objects.py +934 -826
  158. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/verification_utils.py +0 -2
  159. telegrinder-0.3.4.post1/PKG-INFO +0 -110
  160. telegrinder-0.3.4.post1/pyproject.toml +0 -100
  161. telegrinder-0.3.4.post1/telegrinder/api/error.py +0 -16
  162. telegrinder-0.3.4.post1/telegrinder/bot/bot.py +0 -76
  163. telegrinder-0.3.4.post1/telegrinder/bot/dispatch/middleware/abc.py +0 -22
  164. telegrinder-0.3.4.post1/telegrinder/bot/dispatch/waiter_machine/actions.py +0 -13
  165. telegrinder-0.3.4.post1/telegrinder/bot/dispatch/waiter_machine/machine.py +0 -172
  166. telegrinder-0.3.4.post1/telegrinder/bot/polling/polling.py +0 -131
  167. telegrinder-0.3.4.post1/telegrinder/bot/rules/adapter/__init__.py +0 -17
  168. telegrinder-0.3.4.post1/telegrinder/bot/rules/adapter/abc.py +0 -31
  169. telegrinder-0.3.4.post1/telegrinder/bot/rules/node.py +0 -27
  170. telegrinder-0.3.4.post1/telegrinder/client/__init__.py +0 -4
  171. telegrinder-0.3.4.post1/telegrinder/model.py +0 -320
  172. telegrinder-0.3.4.post1/telegrinder/node/__init__.py +0 -60
  173. telegrinder-0.3.4.post1/telegrinder/node/attachment.py +0 -92
  174. telegrinder-0.3.4.post1/telegrinder/node/base.py +0 -166
  175. telegrinder-0.3.4.post1/telegrinder/node/container.py +0 -27
  176. telegrinder-0.3.4.post1/telegrinder/node/event.py +0 -65
  177. telegrinder-0.3.4.post1/telegrinder/node/message.py +0 -14
  178. telegrinder-0.3.4.post1/telegrinder/node/source.py +0 -71
  179. telegrinder-0.3.4.post1/telegrinder/node/update.py +0 -15
  180. telegrinder-0.3.4.post1/telegrinder/rules.py +0 -62
  181. telegrinder-0.3.4.post1/telegrinder/tools/__init__.py +0 -146
  182. telegrinder-0.3.4.post1/telegrinder/tools/buttons.py +0 -83
  183. telegrinder-0.3.4.post1/telegrinder/tools/formatting/__init__.py +0 -81
  184. telegrinder-0.3.4.post1/telegrinder/tools/formatting/links.py +0 -38
  185. telegrinder-0.3.4.post1/telegrinder/tools/formatting/spec_html_formats.py +0 -121
  186. telegrinder-0.3.4.post1/telegrinder/tools/kb_set/__init__.py +0 -4
  187. telegrinder-0.3.4.post1/telegrinder/tools/kb_set/base.py +0 -15
  188. telegrinder-0.3.4.post1/telegrinder/tools/kb_set/yaml.py +0 -63
  189. telegrinder-0.3.4.post1/telegrinder/tools/loop_wrapper/abc.py +0 -15
  190. telegrinder-0.3.4.post1/telegrinder/tools/magic.py +0 -168
  191. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/handler/__init__.py +0 -0
  192. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/middleware/__init__.py +0 -0
  193. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
  194. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
  195. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/return_manager/message.py +0 -0
  196. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
  197. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/polling/__init__.py +0 -0
  198. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/polling/abc.py +0 -0
  199. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/is_from.py +0 -0
  200. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/mention.py +0 -0
  201. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/rule_enum.py +0 -0
  202. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/rules/start.py +0 -0
  203. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/bot/scenario/__init__.py +0 -0
  204. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/msgspec_json.py +0 -0
  205. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/node/tools/__init__.py +0 -0
  206. {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.1/telegrinder/tools}/adapter/errors.py +0 -0
  207. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/error_handler/__init__.py +0 -0
  208. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/global_context/__init__.py +0 -0
  209. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/global_context/abc.py +0 -0
  210. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/i18n/__init__.py +0 -0
  211. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/i18n/middleware/__init__.py +0 -0
  212. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/i18n/simple.py +0 -0
  213. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/loop_wrapper/__init__.py +0 -0
  214. {telegrinder-0.3.4.post1 → telegrinder-0.4.1}/telegrinder/tools/parse_mode.py +0 -0
@@ -1,7 +1,7 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2024 timoniq
4
- Copyright (c) 2024 luwqz1
3
+ Copyright (c) 2022-2025 timoniq
4
+ Copyright (c) 2024-2025 luwqz1
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.3
2
+ Name: telegrinder
3
+ Version: 0.4.1
4
+ Summary: Modern visionary telegram bot framework.
5
+ License: MIT License
6
+
7
+ Copyright (c) 2022-2025 timoniq
8
+ Copyright (c) 2024-2025 luwqz1
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Keywords: asyncio,api schema,async,bot building,bot api,custom rules,telegram,telegram bot api framework,telegrinder framework,middleware,composition,framework,telegrinder,waiter machine
28
+ Author: timoniq
29
+ Author-email: tesseradecades@mail.ru
30
+ Maintainer: luwqz1
31
+ Maintainer-email: howluwqz1@gmail.com
32
+ Requires-Python: >=3.12,<4.0
33
+ Classifier: Environment :: Console
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
39
+ Classifier: Topic :: Software Development :: Quality Assurance
40
+ Classifier: Typing :: Typed
41
+ Provides-Extra: all
42
+ Provides-Extra: fast
43
+ Provides-Extra: loguru
44
+ Provides-Extra: uvloop
45
+ Requires-Dist: aiohttp (>=3.11.11,<4.0.0)
46
+ Requires-Dist: certifi (>=2025.1.31)
47
+ Requires-Dist: choicelib (>=0.1.5,<0.2.0)
48
+ Requires-Dist: colorama (>=0.4.6,<0.5.0)
49
+ Requires-Dist: envparse (>=0.2.0,<0.3.0)
50
+ Requires-Dist: fntypes (>=0.1.4.post3,<0.2.0)
51
+ Requires-Dist: loguru (>=0.7.0) ; extra == "all"
52
+ Requires-Dist: loguru (>=0.7.0) ; extra == "loguru"
53
+ Requires-Dist: msgspec (>=0.19.0,<0.20.0)
54
+ Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
55
+ Requires-Dist: uvloop (>=0.21.0) ; extra == "all"
56
+ Requires-Dist: uvloop (>=0.21.0) ; extra == "fast"
57
+ Requires-Dist: uvloop (>=0.21.0) ; extra == "uvloop"
58
+ Requires-Dist: vbml (>=1.1.post1,<2.0)
59
+ Project-URL: Bug Tracker, https://github.com/timoniq/telegrinder/issues
60
+ Project-URL: Documentation, https://telegrinder.readthedocs.io/en/latest/
61
+ Project-URL: Source, https://github.com/timoniq/telegrinder
62
+ Description-Content-Type: text/markdown
63
+
64
+ # Telegrinder
65
+
66
+ Framework for effective and reliable telegram bot building.
67
+
68
+ Still in development.
69
+
70
+ * Type hinted
71
+ * Customizable and extensible
72
+ * Ready to use scenarios and rules
73
+ * Fast models built on [msgspec](https://github.com/jcrist/msgspec)
74
+ * Both low-level and high-level API
75
+ * Support [optional dependecies](https://github.com/timoniq/telegrinder/blob/dev/docs/guide/optional_dependencies.md)
76
+
77
+ # Getting started
78
+
79
+ Install using pip:
80
+
81
+ ```console
82
+ pip install telegrinder
83
+ ```
84
+
85
+ Using poetry:
86
+
87
+ ```console
88
+ poetry add telegrinder
89
+ ```
90
+
91
+ Install from github:
92
+
93
+ ```console
94
+ pip install -U https://github.com/timoniq/telegrinder/archive/dev.zip
95
+ ```
96
+
97
+ ```console
98
+ poetry add git+https://github.com/timoniq/telegrinder.git#dev
99
+ ```
100
+
101
+ Basic example:
102
+
103
+ ```python
104
+ from telegrinder import API, Message, Telegrinder, Token
105
+ from telegrinder.modules import logger
106
+ from telegrinder.rules import Text
107
+
108
+ api = API(token=Token("123:token"))
109
+ bot = Telegrinder(api)
110
+ logger.set_level("INFO")
111
+
112
+
113
+ @bot.on.message(Text("/start"))
114
+ async def start(message: Message):
115
+ me = (await api.get_me()).unwrap()
116
+ await message.answer(f"Hello, {message.from_user.full_name}! I'm {me.full_name}.")
117
+
118
+
119
+ bot.run_forever()
120
+ ```
121
+
122
+ # Documentation
123
+
124
+ [Readthedocs](https://telegrinder.readthedocs.io)
125
+
126
+ # Community
127
+
128
+ Join our [telegram forum](https://t.me/botoforum).
129
+
130
+ # [Contributing](https://github.com/timoniq/telegrinder/blob/main/contributing.md)
131
+
132
+ # License
133
+
134
+ Telegrinder is [MIT licensed](./LICENSE)\
135
+ Copyright © 2022-2025 [timoniq](https://github.com/timoniq)\
136
+ Copyright © 2024-2025 [luwqz1](https://github.com/luwqz1)
137
+
138
+ # Contributors
139
+
140
+ <a href="https://github.com/timoniq/telegrinder/graphs/contributors">
141
+ <img src="https://contributors-img.web.app/image?repo=timoniq/telegrinder" />
142
+ </a>
143
+
@@ -0,0 +1,162 @@
1
+ [build-system]
2
+ requires = ["poetry-core>=2.0.0"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [project]
6
+ requires-python = ">=3.12,<4.0"
7
+ name = "telegrinder"
8
+ version = "0.4.1"
9
+ description = "Modern visionary telegram bot framework."
10
+ authors = [
11
+ {name = "timoniq", email = "tesseradecades@mail.ru"}
12
+ ]
13
+ maintainers = [
14
+ {name = "luwqz1", email = "howluwqz1@gmail.com"}
15
+ ]
16
+ license = { file = "LICENSE" }
17
+ readme = "readme.md"
18
+ keywords = [
19
+ "asyncio",
20
+ "api schema",
21
+ "async",
22
+ "bot building",
23
+ "bot api",
24
+ "custom rules",
25
+ "telegram",
26
+ "telegram bot api framework",
27
+ "telegrinder framework",
28
+ "middleware",
29
+ "composition",
30
+ "framework",
31
+ "telegrinder",
32
+ "waiter machine"
33
+ ]
34
+ classifiers = [
35
+ "Environment :: Console",
36
+ "Intended Audience :: Developers",
37
+ "License :: OSI Approved :: MIT License",
38
+ "Programming Language :: Python :: 3.12",
39
+ "Programming Language :: Python :: 3.13",
40
+ "Topic :: Software Development :: Libraries :: Python Modules",
41
+ "Topic :: Software Development :: Quality Assurance",
42
+ "Typing :: Typed",
43
+ ]
44
+ dependencies = [
45
+ "aiohttp (>=3.11.11,<4.0.0)",
46
+ "colorama (>=0.4.6,<0.5.0)",
47
+ "vbml (>=1.1.post1,<2.0)",
48
+ "choicelib (>=0.1.5,<0.2.0)",
49
+ "envparse (>=0.2.0,<0.3.0)",
50
+ "certifi (>=2025.1.31)",
51
+ "msgspec (>=0.19.0,<0.20.0)",
52
+ "typing-extensions (>=4.12.2,<5.0.0)",
53
+ "fntypes (>=0.1.4.post3,<0.2.0)"
54
+ ]
55
+
56
+ [project.urls]
57
+ Source = "https://github.com/timoniq/telegrinder"
58
+ "Bug Tracker" = "https://github.com/timoniq/telegrinder/issues"
59
+ Documentation = "https://telegrinder.readthedocs.io/en/latest/"
60
+
61
+ [project.optional-dependencies]
62
+ all = [
63
+ "uvloop >= 0.21.0",
64
+ "loguru >= 0.7.0"
65
+ ]
66
+ fast = [
67
+ "uvloop >= 0.21.0"
68
+ ]
69
+ uvloop = [
70
+ "uvloop >= 0.21.0"
71
+ ]
72
+ loguru = [
73
+ "loguru >= 0.7.0"
74
+ ]
75
+
76
+ [tool.poetry]
77
+ package-mode = true
78
+
79
+ [tool.poetry.group.dev.dependencies]
80
+ pre-commit = ">=4.1.0,<5.0"
81
+ ruff = "^0.9.2"
82
+ basedpyright = "^1.28.1"
83
+ requests = "^2.28.1"
84
+ sort-all = "^1.2.0"
85
+ libcst = "^1.4.0"
86
+ pytest = "^8.0.0"
87
+ pytest-asyncio = ">=0.23.5,<0.26.0"
88
+ pytest-cov = ">=5,<7"
89
+ pytest-mock = "^3.10.0"
90
+
91
+ [tool.ruff]
92
+ line-length = 115
93
+ target-version = "py312"
94
+
95
+ [tool.ruff.format]
96
+ quote-style = "double"
97
+ docstring-code-line-length = "dynamic"
98
+
99
+ [tool.ruff.lint]
100
+ select = [
101
+ "I",
102
+ "D",
103
+ "N",
104
+ "PLR",
105
+ "Q",
106
+ "COM",
107
+ "TC",
108
+ "YTT",
109
+ "SIM"
110
+ ]
111
+ ignore = [
112
+ "COM812",
113
+ "N805",
114
+ "N818",
115
+ "TC001",
116
+ "TC002",
117
+ "TC003",
118
+ "TC004",
119
+ "D100",
120
+ "D101",
121
+ "D102",
122
+ "D103",
123
+ "D104",
124
+ "D105",
125
+ "D107",
126
+ "D202",
127
+ "D203",
128
+ "D205",
129
+ "D209",
130
+ "D211",
131
+ "D213",
132
+ "D400",
133
+ "D401",
134
+ "D404",
135
+ "D415",
136
+ "PLR2004",
137
+ "PLR0911",
138
+ "PLR0912",
139
+ "PLR0913"
140
+ ]
141
+ fixable = ["ALL"]
142
+
143
+ [tool.ruff.lint.per-file-ignores]
144
+ "__init__.py" = ["F401", "F403"]
145
+ "typegen/**.py" = ["N802"]
146
+
147
+ [tool.pytest.ini_options]
148
+ asyncio_mode = "auto"
149
+ asyncio_default_fixture_loop_scope = "function"
150
+
151
+ [tool.pyright]
152
+ exclude = [
153
+ "**/__pycache__",
154
+ "docs",
155
+ "local",
156
+ "telegrinder/client/sonic.py"
157
+ ]
158
+ typeCheckingMode = "basic"
159
+ pythonPlatform = "All"
160
+ pythonVersion = "3.12"
161
+ reportMissingImports = true
162
+ reportMissingTypeStubs = false
@@ -69,5 +69,11 @@ Join our [telegram forum](https://t.me/botoforum).
69
69
  # License
70
70
 
71
71
  Telegrinder is [MIT licensed](./LICENSE)\
72
- Copyright © 2022-2024 [timoniq](https://github.com/timoniq)\
73
- Copyright © 2024 [luwqz1](https://github.com/luwqz1)
72
+ Copyright © 2022-2025 [timoniq](https://github.com/timoniq)\
73
+ Copyright © 2024-2025 [luwqz1](https://github.com/luwqz1)
74
+
75
+ # Contributors
76
+
77
+ <a href="https://github.com/timoniq/telegrinder/graphs/contributors">
78
+ <img src="https://contributors-img.web.app/image?repo=timoniq/telegrinder" />
79
+ </a>
@@ -33,7 +33,7 @@ bot.run_forever()
33
33
 
34
34
  import typing
35
35
 
36
- from .api import API, APIError, APIResponse, Token
36
+ from .api import API, APIError, APIResponse, APIServerError, Token
37
37
  from .bot import (
38
38
  CALLBACK_QUERY_FOR_MESSAGE,
39
39
  CALLBACK_QUERY_FROM_CHAT,
@@ -82,6 +82,9 @@ from .bot import (
82
82
  MessageView,
83
83
  PhotoReplyHandler,
84
84
  Polling,
85
+ PreCheckoutQueryCute,
86
+ PreCheckoutQueryManager,
87
+ PreCheckoutQueryView,
85
88
  RawEventView,
86
89
  ShortState,
87
90
  StateViewHasher,
@@ -93,45 +96,37 @@ from .bot import (
93
96
  WaiterMachine,
94
97
  register_manager,
95
98
  )
96
- from .bot.rules import StateMeta
97
- from .client import ABCClient, AiohttpClient
99
+ from .client import ABCClient, AiohttpClient, AiosonicClient
98
100
  from .model import Model
99
101
  from .modules import logger
100
- from .tools import (
101
- ABCErrorHandler,
102
- ABCGlobalContext,
103
- ABCLoopWrapper,
104
- ABCStateStorage,
102
+ from .tools.error_handler import ABCErrorHandler, ErrorHandler
103
+ from .tools.formatting import HTMLFormatter
104
+ from .tools.global_context import ABCGlobalContext, CtxVar, GlobalContext, ctx_var
105
+ from .tools.i18n import (
105
106
  ABCTranslator,
106
107
  ABCTranslatorMiddleware,
108
+ I18nEnum,
109
+ SimpleI18n,
110
+ SimpleTranslator,
111
+ )
112
+ from .tools.input_file_directory import InputFileDirectory
113
+ from .tools.keyboard import (
107
114
  AnyMarkup,
108
115
  Button,
109
- CtxVar,
110
- DelayedTask,
111
- ErrorHandler,
112
- FormatString,
113
- GlobalContext,
114
- HTMLFormatter,
115
- I18nEnum,
116
116
  InlineButton,
117
117
  InlineKeyboard,
118
118
  Keyboard,
119
- KeyboardSetBase,
120
- KeyboardSetYAML,
121
- Lifespan,
122
- LoopWrapper,
123
- MemoryStateStorage,
124
- ParseMode,
125
119
  RowButtons,
126
- SimpleI18n,
127
- SimpleTranslator,
128
- StateData,
129
- ctx_var,
130
- magic_bundle,
131
120
  )
121
+ from .tools.lifespan import Lifespan
122
+ from .tools.loop_wrapper import ABCLoopWrapper, DelayedTask, LoopWrapper
123
+ from .tools.magic import cache_translation, get_cached_translation, magic_bundle
124
+ from .tools.parse_mode import ParseMode
125
+ from .tools.state_storage import ABCStateStorage, MemoryStateStorage, StateData
132
126
 
133
127
  Update: typing.TypeAlias = UpdateCute
134
128
  Message: typing.TypeAlias = MessageCute
129
+ PreCheckoutQuery: typing.TypeAlias = PreCheckoutQueryCute
135
130
  ChatJoinRequest: typing.TypeAlias = ChatJoinRequestCute
136
131
  ChatMemberUpdated: typing.TypeAlias = ChatMemberUpdatedCute
137
132
  CallbackQuery: typing.TypeAlias = CallbackQueryCute
@@ -160,7 +155,9 @@ __all__ = (
160
155
  "API",
161
156
  "APIError",
162
157
  "APIResponse",
158
+ "APIServerError",
163
159
  "AiohttpClient",
160
+ "AiosonicClient",
164
161
  "AnyMarkup",
165
162
  "AudioReplyHandler",
166
163
  "BaseCute",
@@ -192,7 +189,6 @@ __all__ = (
192
189
  "Dispatch",
193
190
  "DocumentReplyHandler",
194
191
  "ErrorHandler",
195
- "FormatString",
196
192
  "FuncHandler",
197
193
  "GlobalContext",
198
194
  "HTMLFormatter",
@@ -204,9 +200,8 @@ __all__ = (
204
200
  "InlineQueryCute",
205
201
  "InlineQueryReturnManager",
206
202
  "InlineQueryRule",
203
+ "InputFileDirectory",
207
204
  "Keyboard",
208
- "KeyboardSetBase",
209
- "KeyboardSetYAML",
210
205
  "Lifespan",
211
206
  "LoopWrapper",
212
207
  "MESSAGE_FROM_USER",
@@ -226,6 +221,10 @@ __all__ = (
226
221
  "ParseMode",
227
222
  "PhotoReplyHandler",
228
223
  "Polling",
224
+ "PreCheckoutQuery",
225
+ "PreCheckoutQueryCute",
226
+ "PreCheckoutQueryManager",
227
+ "PreCheckoutQueryView",
229
228
  "RawEventView",
230
229
  "RowButtons",
231
230
  "ShortState",
@@ -233,8 +232,6 @@ __all__ = (
233
232
  "SimpleTranslator",
234
233
  "StateData",
235
234
  "StateData",
236
- "StateMeta",
237
- "StateMeta",
238
235
  "StateViewHasher",
239
236
  "StickerReplyHandler",
240
237
  "Telegrinder",
@@ -244,7 +241,9 @@ __all__ = (
244
241
  "VideoReplyHandler",
245
242
  "ViewBox",
246
243
  "WaiterMachine",
244
+ "cache_translation",
247
245
  "ctx_var",
246
+ "get_cached_translation",
248
247
  "logger",
249
248
  "magic_bundle",
250
249
  "register_manager",
@@ -1,5 +1,5 @@
1
1
  from .api import API
2
- from .error import APIError, InvalidTokenError
2
+ from .error import APIError, APIServerError, InvalidTokenError
3
3
  from .response import APIResponse
4
4
  from .token import Token
5
5
 
@@ -7,6 +7,7 @@ __all__ = (
7
7
  "API",
8
8
  "APIError",
9
9
  "APIResponse",
10
+ "APIServerError",
10
11
  "InvalidTokenError",
11
12
  "Token",
12
13
  )
@@ -1,39 +1,44 @@
1
- import typing
2
1
  from functools import cached_property
3
2
 
4
3
  import msgspec
4
+ import typing_extensions as typing
5
5
  from fntypes.result import Error, Ok, Result
6
6
 
7
7
  from telegrinder.api.error import APIError
8
8
  from telegrinder.api.response import APIResponse
9
9
  from telegrinder.api.token import Token
10
- from telegrinder.client import ABCClient, AiohttpClient
11
- from telegrinder.model import DataConverter, decoder
10
+ from telegrinder.client import ABCClient, AiohttpClient, MultipartFormProto
11
+ from telegrinder.model import decoder
12
12
  from telegrinder.types.methods import APIMethods
13
13
 
14
+ HTTPClient = typing.TypeVar("HTTPClient", bound=ABCClient, default=AiohttpClient)
14
15
 
15
- def compose_data(
16
- client: ABCClient,
16
+ type Json = str | int | float | bool | list[Json] | dict[str, Json] | None
17
+
18
+
19
+ def compose_data[MultipartForm: MultipartFormProto](
20
+ client: ABCClient[MultipartForm],
17
21
  data: dict[str, typing.Any],
18
22
  files: dict[str, tuple[str, bytes]],
19
- ) -> typing.Any:
20
- converter = DataConverter(_files=files.copy())
21
- return client.get_form(
22
- data={k: converter(v) for k, v in data.items()},
23
- files=converter.files,
24
- )
23
+ ) -> MultipartForm:
24
+ if not data and not files:
25
+ return client.multipart_form_factory()
26
+ return client.get_form(data=data, files=files)
25
27
 
26
28
 
27
- class API(APIMethods):
29
+ class API(APIMethods[HTTPClient], typing.Generic[HTTPClient]):
28
30
  """Bot API with available API methods and http client."""
29
31
 
30
32
  API_URL = "https://api.telegram.org/"
31
33
  API_FILE_URL = "https://api.telegram.org/file/"
32
34
 
33
- def __init__(self, token: Token, *, http: ABCClient | None = None) -> None:
35
+ token: Token
36
+ http: HTTPClient
37
+
38
+ def __init__(self, token: Token, *, http: HTTPClient | None = None) -> None:
34
39
  self.token = token
35
- self.http = http or AiohttpClient()
36
- super().__init__(self)
40
+ self.http = http or AiohttpClient() # type: ignore
41
+ super().__init__(api=self)
37
42
 
38
43
  def __repr__(self) -> str:
39
44
  return "<{}: token={!r}, http={!r}>".format(
@@ -62,19 +67,20 @@ class API(APIMethods):
62
67
  method: str,
63
68
  data: dict[str, typing.Any] | None = None,
64
69
  files: dict[str, tuple[str, bytes]] | None = None,
65
- ) -> Result[dict[str, typing.Any] | list[typing.Any] | bool, APIError]:
70
+ ) -> Result[Json, APIError]:
71
+ """Request a `JSON` response with the `POST` HTTP method and passing data, files as `multipart/form-data`."""
66
72
  response = await self.http.request_json(
67
73
  url=self.request_url + method,
74
+ method="POST",
68
75
  data=compose_data(self.http, data or {}, files or {}),
69
76
  )
70
- if response.get("ok"):
71
- assert "result" in response
77
+ if response.get("ok", False) is True:
72
78
  return Ok(response["result"])
73
79
  return Error(
74
80
  APIError(
75
81
  code=response.get("error_code", 400),
76
- error=response.get("description"),
77
- )
82
+ error=response.get("description", "Something went wrong"),
83
+ ),
78
84
  )
79
85
 
80
86
  async def request_raw(
@@ -83,8 +89,10 @@ class API(APIMethods):
83
89
  data: dict[str, typing.Any] | None = None,
84
90
  files: dict[str, tuple[str, bytes]] | None = None,
85
91
  ) -> Result[msgspec.Raw, APIError]:
92
+ """Request a `raw` response with the `POST` HTTP method and passing data, files as `multipart/form-data`."""
86
93
  response_bytes = await self.http.request_bytes(
87
94
  url=self.request_url + method,
95
+ method="POST",
88
96
  data=compose_data(self.http, data or {}, files or {}),
89
97
  )
90
98
  return decoder.decode(response_bytes, type=APIResponse).to_result()
@@ -0,0 +1,20 @@
1
+ class APIError(Exception):
2
+ def __init__(self, code: int, error: str) -> None:
3
+ self.code, self.error = code, error
4
+
5
+ def __str__(self) -> str:
6
+ return f"[{self.code}] {self.error}"
7
+
8
+ def __repr__(self) -> str:
9
+ return f"<APIError: {self.__str__()}>"
10
+
11
+
12
+ class APIServerError(Exception):
13
+ pass
14
+
15
+
16
+ class InvalidTokenError(BaseException):
17
+ pass
18
+
19
+
20
+ __all__ = ("APIError", "APIServerError", "InvalidTokenError")
@@ -8,8 +8,8 @@ from telegrinder.model import Model
8
8
  class APIResponse(Model):
9
9
  ok: bool = False
10
10
  result: msgspec.Raw = msgspec.Raw(b"")
11
- error_code: int = 0
12
- description: str = ""
11
+ error_code: int = 400
12
+ description: str = "Something went wrong"
13
13
 
14
14
  def to_result(self) -> Result[msgspec.Raw, APIError]:
15
15
  if self.ok:
@@ -8,9 +8,9 @@ from .error import InvalidTokenError
8
8
 
9
9
 
10
10
  class Token(str):
11
- def __new__(cls, token: str) -> typing.Self:
11
+ def __new__(cls, token: str, /) -> typing.Self:
12
12
  if token.count(":") != 1 or not token.split(":")[0].isdigit():
13
- raise InvalidTokenError("Invalid token, it should look like this '123:ABC'.")
13
+ raise InvalidTokenError("Invalid token, it should look like this: 12345:ABCdef")
14
14
  return super().__new__(cls, token)
15
15
 
16
16
  def __repr__(self) -> str:
@@ -6,6 +6,7 @@ from telegrinder.bot.cute_types import (
6
6
  ChatMemberUpdatedCute,
7
7
  InlineQueryCute,
8
8
  MessageCute,
9
+ PreCheckoutQueryCute,
9
10
  UpdateCute,
10
11
  )
11
12
  from telegrinder.bot.dispatch import (
@@ -41,6 +42,8 @@ from telegrinder.bot.dispatch import (
41
42
  MessageReturnManager,
42
43
  MessageView,
43
44
  PhotoReplyHandler,
45
+ PreCheckoutQueryManager,
46
+ PreCheckoutQueryView,
44
47
  RawEventView,
45
48
  ShortState,
46
49
  StateViewHasher,
@@ -110,6 +113,9 @@ __all__ = (
110
113
  "MessageView",
111
114
  "PhotoReplyHandler",
112
115
  "Polling",
116
+ "PreCheckoutQueryCute",
117
+ "PreCheckoutQueryManager",
118
+ "PreCheckoutQueryView",
113
119
  "RawEventView",
114
120
  "ShortState",
115
121
  "StateViewHasher",