telegrinder 0.3.4.post1__tar.gz → 0.4.0__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.
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/LICENSE +2 -2
- telegrinder-0.4.0/PKG-INFO +144 -0
- telegrinder-0.4.0/pyproject.toml +164 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/readme.md +8 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/__init__.py +30 -31
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/api/__init__.py +2 -1
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/api/api.py +28 -20
- telegrinder-0.4.0/telegrinder/api/error.py +20 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/api/response.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/api/token.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/__init__.py +6 -0
- telegrinder-0.4.0/telegrinder/bot/bot.py +83 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/__init__.py +2 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/base.py +54 -128
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/callback_query.py +76 -61
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/chat_join_request.py +4 -3
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/chat_member_updated.py +28 -31
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/inline_query.py +5 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/message.py +555 -602
- telegrinder-0.4.0/telegrinder/bot/cute_types/pre_checkout_query.py +42 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/update.py +20 -12
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/cute_types/utils.py +3 -36
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/__init__.py +4 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/abc.py +8 -9
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/context.py +5 -7
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/dispatch.py +85 -33
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/abc.py +5 -6
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/audio_reply.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/base.py +3 -3
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/document_reply.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/func.py +36 -42
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/media_group_reply.py +5 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/message_reply.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/photo_reply.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/sticker_reply.py +2 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/video_reply.py +2 -2
- telegrinder-0.4.0/telegrinder/bot/dispatch/middleware/abc.py +97 -0
- telegrinder-0.4.0/telegrinder/bot/dispatch/middleware/global_middleware.py +70 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/process.py +44 -50
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/return_manager/__init__.py +2 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/return_manager/abc.py +6 -10
- telegrinder-0.4.0/telegrinder/bot/dispatch/return_manager/pre_checkout_query.py +20 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/__init__.py +2 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/abc.py +10 -6
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/base.py +81 -50
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/box.py +20 -9
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/callback_query.py +3 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/chat_join_request.py +2 -7
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/chat_member.py +3 -5
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/inline_query.py +3 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/message.py +3 -4
- telegrinder-0.4.0/telegrinder/bot/dispatch/view/pre_checkout_query.py +16 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/view/raw.py +42 -40
- telegrinder-0.4.0/telegrinder/bot/dispatch/waiter_machine/actions.py +14 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +9 -7
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/hasher/message.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/hasher/state.py +3 -2
- telegrinder-0.4.0/telegrinder/bot/dispatch/waiter_machine/machine.py +251 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/middleware.py +15 -10
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/short_state.py +7 -18
- telegrinder-0.4.0/telegrinder/bot/polling/polling.py +139 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/__init__.py +24 -1
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/abc.py +17 -10
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/callback_data.py +20 -61
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/chat_join.py +6 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/command.py +4 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/enum_text.py +1 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/func.py +5 -3
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/fuzzy.py +1 -1
- telegrinder-0.4.0/telegrinder/bot/rules/id.py +24 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/inline.py +6 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/integer.py +2 -1
- telegrinder-0.4.0/telegrinder/bot/rules/logic.py +18 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/markup.py +5 -6
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/message.py +2 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/message_entities.py +1 -3
- telegrinder-0.4.0/telegrinder/bot/rules/node.py +33 -0
- telegrinder-0.4.0/telegrinder/bot/rules/payload.py +81 -0
- telegrinder-0.4.0/telegrinder/bot/rules/payment_invoice.py +29 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/regex.py +5 -6
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/state.py +1 -3
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/text.py +10 -5
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/update.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/scenario/abc.py +2 -4
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/scenario/checkbox.py +12 -14
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/scenario/choice.py +6 -9
- telegrinder-0.4.0/telegrinder/client/__init__.py +12 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/client/abc.py +35 -10
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/client/aiohttp.py +28 -24
- telegrinder-0.4.0/telegrinder/client/form_data.py +31 -0
- telegrinder-0.4.0/telegrinder/client/sonic.py +212 -0
- telegrinder-0.4.0/telegrinder/model.py +213 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/modules.py +3 -1
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/msgspec_utils.py +136 -68
- telegrinder-0.4.0/telegrinder/node/__init__.py +121 -0
- telegrinder-0.4.0/telegrinder/node/attachment.py +168 -0
- telegrinder-0.4.0/telegrinder/node/base.py +294 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/callback_query.py +17 -16
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/command.py +3 -2
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/composer.py +40 -75
- telegrinder-0.4.0/telegrinder/node/container.py +33 -0
- telegrinder-0.4.0/telegrinder/node/either.py +82 -0
- telegrinder-0.4.0/telegrinder/node/event.py +54 -0
- telegrinder-0.4.0/telegrinder/node/file.py +51 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/me.py +4 -5
- telegrinder-0.4.0/telegrinder/node/payload.py +78 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/polymorphic.py +27 -8
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/rule.py +2 -6
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/scope.py +4 -6
- telegrinder-0.4.0/telegrinder/node/source.py +87 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/text.py +20 -8
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/tools/generator.py +7 -11
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/py.typed +0 -0
- telegrinder-0.4.0/telegrinder/rules.py +1 -0
- telegrinder-0.4.0/telegrinder/tools/__init__.py +205 -0
- telegrinder-0.4.0/telegrinder/tools/adapter/__init__.py +19 -0
- telegrinder-0.4.0/telegrinder/tools/adapter/abc.py +49 -0
- telegrinder-0.4.0/telegrinder/tools/adapter/dataclass.py +56 -0
- {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.0/telegrinder/tools}/adapter/event.py +8 -10
- {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.0/telegrinder/tools}/adapter/node.py +8 -10
- {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.0/telegrinder/tools}/adapter/raw_event.py +2 -2
- {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.0/telegrinder/tools}/adapter/raw_update.py +2 -2
- telegrinder-0.4.0/telegrinder/tools/buttons.py +109 -0
- telegrinder-0.4.0/telegrinder/tools/callback_data_serilization/__init__.py +5 -0
- telegrinder-0.4.0/telegrinder/tools/callback_data_serilization/abc.py +51 -0
- telegrinder-0.4.0/telegrinder/tools/callback_data_serilization/json_ser.py +60 -0
- telegrinder-0.4.0/telegrinder/tools/callback_data_serilization/msgpack_ser.py +172 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/error_handler/abc.py +4 -7
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/error_handler/error.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/error_handler/error_handler.py +34 -48
- telegrinder-0.4.0/telegrinder/tools/formatting/__init__.py +101 -0
- telegrinder-0.4.0/telegrinder/tools/formatting/deep_links.py +541 -0
- telegrinder-0.3.4.post1/telegrinder/tools/formatting/html.py → telegrinder-0.4.0/telegrinder/tools/formatting/html_formatter.py +51 -79
- telegrinder-0.4.0/telegrinder/tools/formatting/spec_html_formats.py +75 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/functional.py +1 -5
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/global_context/global_context.py +26 -51
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/global_context/telegrinder_ctx.py +3 -3
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/i18n/abc.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/i18n/middleware/abc.py +3 -6
- telegrinder-0.4.0/telegrinder/tools/input_file_directory.py +30 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/keyboard.py +9 -9
- telegrinder-0.4.0/telegrinder/tools/lifespan.py +105 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/limited_dict.py +5 -10
- telegrinder-0.4.0/telegrinder/tools/loop_wrapper/abc.py +20 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/loop_wrapper/loop_wrapper.py +40 -95
- telegrinder-0.4.0/telegrinder/tools/magic.py +318 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/state_storage/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/state_storage/abc.py +5 -9
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/state_storage/memory.py +1 -1
- telegrinder-0.4.0/telegrinder/tools/strings.py +13 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/types/__init__.py +8 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/types/enums.py +31 -21
- telegrinder-0.4.0/telegrinder/types/input_file.py +51 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/types/methods.py +531 -109
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/types/objects.py +934 -826
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/verification_utils.py +0 -2
- telegrinder-0.3.4.post1/PKG-INFO +0 -110
- telegrinder-0.3.4.post1/pyproject.toml +0 -100
- telegrinder-0.3.4.post1/telegrinder/api/error.py +0 -16
- telegrinder-0.3.4.post1/telegrinder/bot/bot.py +0 -76
- telegrinder-0.3.4.post1/telegrinder/bot/dispatch/middleware/abc.py +0 -22
- telegrinder-0.3.4.post1/telegrinder/bot/dispatch/waiter_machine/actions.py +0 -13
- telegrinder-0.3.4.post1/telegrinder/bot/dispatch/waiter_machine/machine.py +0 -172
- telegrinder-0.3.4.post1/telegrinder/bot/polling/polling.py +0 -131
- telegrinder-0.3.4.post1/telegrinder/bot/rules/adapter/__init__.py +0 -17
- telegrinder-0.3.4.post1/telegrinder/bot/rules/adapter/abc.py +0 -31
- telegrinder-0.3.4.post1/telegrinder/bot/rules/node.py +0 -27
- telegrinder-0.3.4.post1/telegrinder/client/__init__.py +0 -4
- telegrinder-0.3.4.post1/telegrinder/model.py +0 -320
- telegrinder-0.3.4.post1/telegrinder/node/__init__.py +0 -60
- telegrinder-0.3.4.post1/telegrinder/node/attachment.py +0 -92
- telegrinder-0.3.4.post1/telegrinder/node/base.py +0 -166
- telegrinder-0.3.4.post1/telegrinder/node/container.py +0 -27
- telegrinder-0.3.4.post1/telegrinder/node/event.py +0 -65
- telegrinder-0.3.4.post1/telegrinder/node/message.py +0 -14
- telegrinder-0.3.4.post1/telegrinder/node/source.py +0 -71
- telegrinder-0.3.4.post1/telegrinder/node/update.py +0 -15
- telegrinder-0.3.4.post1/telegrinder/rules.py +0 -62
- telegrinder-0.3.4.post1/telegrinder/tools/__init__.py +0 -146
- telegrinder-0.3.4.post1/telegrinder/tools/buttons.py +0 -83
- telegrinder-0.3.4.post1/telegrinder/tools/formatting/__init__.py +0 -81
- telegrinder-0.3.4.post1/telegrinder/tools/formatting/links.py +0 -38
- telegrinder-0.3.4.post1/telegrinder/tools/formatting/spec_html_formats.py +0 -121
- telegrinder-0.3.4.post1/telegrinder/tools/kb_set/__init__.py +0 -4
- telegrinder-0.3.4.post1/telegrinder/tools/kb_set/base.py +0 -15
- telegrinder-0.3.4.post1/telegrinder/tools/kb_set/yaml.py +0 -63
- telegrinder-0.3.4.post1/telegrinder/tools/loop_wrapper/abc.py +0 -15
- telegrinder-0.3.4.post1/telegrinder/tools/magic.py +0 -168
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/handler/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/middleware/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/return_manager/message.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/polling/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/polling/abc.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/is_from.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/mention.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/rule_enum.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/rules/start.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/bot/scenario/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/msgspec_json.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/node/tools/__init__.py +0 -0
- {telegrinder-0.3.4.post1/telegrinder/bot/rules → telegrinder-0.4.0/telegrinder/tools}/adapter/errors.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/error_handler/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/global_context/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/global_context/abc.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/i18n/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/i18n/middleware/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/i18n/simple.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/loop_wrapper/__init__.py +0 -0
- {telegrinder-0.3.4.post1 → telegrinder-0.4.0}/telegrinder/tools/parse_mode.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
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,144 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: telegrinder
|
|
3
|
+
Version: 0.4.0
|
|
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: pyyaml (>=6.0.2,<7.0.0)
|
|
55
|
+
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
|
|
56
|
+
Requires-Dist: uvloop (>=0.21.0) ; extra == "all"
|
|
57
|
+
Requires-Dist: uvloop (>=0.21.0) ; extra == "fast"
|
|
58
|
+
Requires-Dist: uvloop (>=0.21.0) ; extra == "uvloop"
|
|
59
|
+
Requires-Dist: vbml (>=1.1.post1,<2.0)
|
|
60
|
+
Project-URL: Bug Tracker, https://github.com/timoniq/telegrinder/issues
|
|
61
|
+
Project-URL: Documentation, https://telegrinder.readthedocs.io/en/latest/
|
|
62
|
+
Project-URL: Source, https://github.com/timoniq/telegrinder
|
|
63
|
+
Description-Content-Type: text/markdown
|
|
64
|
+
|
|
65
|
+
# Telegrinder
|
|
66
|
+
|
|
67
|
+
Framework for effective and reliable telegram bot building.
|
|
68
|
+
|
|
69
|
+
Still in development.
|
|
70
|
+
|
|
71
|
+
* Type hinted
|
|
72
|
+
* Customizable and extensible
|
|
73
|
+
* Ready to use scenarios and rules
|
|
74
|
+
* Fast models built on [msgspec](https://github.com/jcrist/msgspec)
|
|
75
|
+
* Both low-level and high-level API
|
|
76
|
+
* Support [optional dependecies](https://github.com/timoniq/telegrinder/blob/dev/docs/guide/optional_dependencies.md)
|
|
77
|
+
|
|
78
|
+
# Getting started
|
|
79
|
+
|
|
80
|
+
Install using pip:
|
|
81
|
+
|
|
82
|
+
```console
|
|
83
|
+
pip install telegrinder
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Using poetry:
|
|
87
|
+
|
|
88
|
+
```console
|
|
89
|
+
poetry add telegrinder
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Install from github:
|
|
93
|
+
|
|
94
|
+
```console
|
|
95
|
+
pip install -U https://github.com/timoniq/telegrinder/archive/dev.zip
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```console
|
|
99
|
+
poetry add git+https://github.com/timoniq/telegrinder.git#dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Basic example:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from telegrinder import API, Message, Telegrinder, Token
|
|
106
|
+
from telegrinder.modules import logger
|
|
107
|
+
from telegrinder.rules import Text
|
|
108
|
+
|
|
109
|
+
api = API(token=Token("123:token"))
|
|
110
|
+
bot = Telegrinder(api)
|
|
111
|
+
logger.set_level("INFO")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@bot.on.message(Text("/start"))
|
|
115
|
+
async def start(message: Message):
|
|
116
|
+
me = (await api.get_me()).unwrap()
|
|
117
|
+
await message.answer(f"Hello, {message.from_user.full_name}! I'm {me.full_name}.")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
bot.run_forever()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
# Documentation
|
|
124
|
+
|
|
125
|
+
[Readthedocs](https://telegrinder.readthedocs.io)
|
|
126
|
+
|
|
127
|
+
# Community
|
|
128
|
+
|
|
129
|
+
Join our [telegram forum](https://t.me/botoforum).
|
|
130
|
+
|
|
131
|
+
# [Contributing](https://github.com/timoniq/telegrinder/blob/main/contributing.md)
|
|
132
|
+
|
|
133
|
+
# License
|
|
134
|
+
|
|
135
|
+
Telegrinder is [MIT licensed](./LICENSE)\
|
|
136
|
+
Copyright © 2022-2025 [timoniq](https://github.com/timoniq)\
|
|
137
|
+
Copyright © 2024-2025 [luwqz1](https://github.com/luwqz1)
|
|
138
|
+
|
|
139
|
+
# Contributors
|
|
140
|
+
|
|
141
|
+
<a href="https://github.com/timoniq/telegrinder/graphs/contributors">
|
|
142
|
+
<img src="https://contributors-img.web.app/image?repo=timoniq/telegrinder" />
|
|
143
|
+
</a>
|
|
144
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
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.0"
|
|
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
|
+
"pyyaml (>=6.0.2,<7.0.0)",
|
|
51
|
+
"certifi (>=2025.1.31)",
|
|
52
|
+
"msgspec (>=0.19.0,<0.20.0)",
|
|
53
|
+
"typing-extensions (>=4.12.2,<5.0.0)",
|
|
54
|
+
"fntypes (>=0.1.4.post3,<0.2.0)"
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[project.urls]
|
|
58
|
+
Source = "https://github.com/timoniq/telegrinder"
|
|
59
|
+
"Bug Tracker" = "https://github.com/timoniq/telegrinder/issues"
|
|
60
|
+
Documentation = "https://telegrinder.readthedocs.io/en/latest/"
|
|
61
|
+
|
|
62
|
+
[project.optional-dependencies]
|
|
63
|
+
all = [
|
|
64
|
+
"uvloop >= 0.21.0",
|
|
65
|
+
"loguru >= 0.7.0"
|
|
66
|
+
]
|
|
67
|
+
fast = [
|
|
68
|
+
"uvloop >= 0.21.0"
|
|
69
|
+
]
|
|
70
|
+
uvloop = [
|
|
71
|
+
"uvloop >= 0.21.0"
|
|
72
|
+
]
|
|
73
|
+
loguru = [
|
|
74
|
+
"loguru >= 0.7.0"
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[tool.poetry]
|
|
78
|
+
package-mode = true
|
|
79
|
+
|
|
80
|
+
[tool.poetry.group.dev.dependencies]
|
|
81
|
+
pre-commit = ">=4.1.0,<5.0"
|
|
82
|
+
ruff = "^0.9.2"
|
|
83
|
+
basedpyright = "^1.26.0"
|
|
84
|
+
requests = "^2.28.1"
|
|
85
|
+
sort-all = "^1.2.0"
|
|
86
|
+
libcst = "^1.4.0"
|
|
87
|
+
pytest = "^8.0.0"
|
|
88
|
+
pytest-asyncio = ">=0.23.5,<0.26.0"
|
|
89
|
+
pytest-cov = ">=5,<7"
|
|
90
|
+
pytest-mock = "^3.10.0"
|
|
91
|
+
|
|
92
|
+
[tool.ruff]
|
|
93
|
+
line-length = 115
|
|
94
|
+
target-version = "py312"
|
|
95
|
+
|
|
96
|
+
[tool.ruff.format]
|
|
97
|
+
quote-style = "double"
|
|
98
|
+
docstring-code-line-length = "dynamic"
|
|
99
|
+
|
|
100
|
+
[tool.ruff.lint]
|
|
101
|
+
select = [
|
|
102
|
+
"I",
|
|
103
|
+
"D",
|
|
104
|
+
"N",
|
|
105
|
+
"PLR",
|
|
106
|
+
"Q",
|
|
107
|
+
"COM",
|
|
108
|
+
"TC",
|
|
109
|
+
"YTT",
|
|
110
|
+
"SIM"
|
|
111
|
+
]
|
|
112
|
+
ignore = [
|
|
113
|
+
"COM812",
|
|
114
|
+
"N805",
|
|
115
|
+
"N818",
|
|
116
|
+
"TC001",
|
|
117
|
+
"TC002",
|
|
118
|
+
"TC003",
|
|
119
|
+
"TC004",
|
|
120
|
+
"D100",
|
|
121
|
+
"D101",
|
|
122
|
+
"D102",
|
|
123
|
+
"D103",
|
|
124
|
+
"D104",
|
|
125
|
+
"D105",
|
|
126
|
+
"D107",
|
|
127
|
+
"D202",
|
|
128
|
+
"D203",
|
|
129
|
+
"D205",
|
|
130
|
+
"D209",
|
|
131
|
+
"D211",
|
|
132
|
+
"D213",
|
|
133
|
+
"D400",
|
|
134
|
+
"D401",
|
|
135
|
+
"D404",
|
|
136
|
+
"D415",
|
|
137
|
+
"PLR2004",
|
|
138
|
+
"PLR0911",
|
|
139
|
+
"PLR0912",
|
|
140
|
+
"PLR0913"
|
|
141
|
+
]
|
|
142
|
+
fixable = ["ALL"]
|
|
143
|
+
|
|
144
|
+
[tool.ruff.lint.per-file-ignores]
|
|
145
|
+
"__init__.py" = ["F401", "F403"]
|
|
146
|
+
"typegen/**.py" = ["N802"]
|
|
147
|
+
|
|
148
|
+
[tool.pytest.ini_options]
|
|
149
|
+
asyncio_mode = "auto"
|
|
150
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
151
|
+
|
|
152
|
+
[tool.pyright]
|
|
153
|
+
exclude = [
|
|
154
|
+
"**/__pycache__",
|
|
155
|
+
"docs",
|
|
156
|
+
"local",
|
|
157
|
+
"telegrinder/client/sonic.py"
|
|
158
|
+
]
|
|
159
|
+
typeCheckingMode = "basic"
|
|
160
|
+
pythonPlatform = "All"
|
|
161
|
+
pythonVersion = "3.12"
|
|
162
|
+
reportMissingImports = true
|
|
163
|
+
reportMissingTypeStubs = false
|
|
164
|
+
enableExperimentalFeatures = true
|
|
@@ -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-
|
|
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 .
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
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
|
-
) ->
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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[
|
|
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 =
|
|
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
|
|
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",
|