pyTelegramBotAPI 4.22.0__tar.gz → 4.23.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.
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/PKG-INFO +2 -4
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/README.md +1 -1
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/conf.py +1 -1
- pytelegrambotapi-4.23.0/examples/asynchronous_telebot/custom_states.py +154 -0
- pytelegrambotapi-4.23.0/examples/asynchronous_telebot/mini_app.py +33 -0
- pytelegrambotapi-4.23.0/examples/custom_states.py +153 -0
- pytelegrambotapi-4.23.0/examples/mini_app.py +32 -0
- pytelegrambotapi-4.23.0/examples/mini_app_web/index.html +163 -0
- pytelegrambotapi-4.23.0/examples/mini_app_web/script.js +318 -0
- pytelegrambotapi-4.23.0/examples/mini_app_web/style.css +338 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/pyproject.toml +47 -48
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/requirements.txt +4 -4
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/__init__.py +261 -31
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/apihelper.py +36 -11
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/async_telebot.py +268 -31
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/asyncio_filters.py +23 -27
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/asyncio_handler_backends.py +98 -137
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/asyncio_helper.py +41 -12
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/asyncio_storage/__init__.py +13 -13
- pytelegrambotapi-4.23.0/telebot/asyncio_storage/base_storage.py +123 -0
- pytelegrambotapi-4.23.0/telebot/asyncio_storage/memory_storage.py +225 -0
- pytelegrambotapi-4.23.0/telebot/asyncio_storage/pickle_storage.py +274 -0
- pytelegrambotapi-4.23.0/telebot/asyncio_storage/redis_storage.py +339 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/custom_filters.py +21 -28
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/handler_backends.py +258 -295
- pytelegrambotapi-4.23.0/telebot/states/__init__.py +128 -0
- pytelegrambotapi-4.23.0/telebot/states/asyncio/__init__.py +7 -0
- pytelegrambotapi-4.23.0/telebot/states/asyncio/context.py +153 -0
- pytelegrambotapi-4.23.0/telebot/states/asyncio/middleware.py +21 -0
- pytelegrambotapi-4.23.0/telebot/states/sync/__init__.py +7 -0
- pytelegrambotapi-4.23.0/telebot/states/sync/context.py +143 -0
- pytelegrambotapi-4.23.0/telebot/states/sync/middleware.py +21 -0
- pytelegrambotapi-4.23.0/telebot/storage/__init__.py +13 -0
- pytelegrambotapi-4.23.0/telebot/storage/base_storage.py +118 -0
- pytelegrambotapi-4.23.0/telebot/storage/memory_storage.py +225 -0
- pytelegrambotapi-4.23.0/telebot/storage/pickle_storage.py +263 -0
- pytelegrambotapi-4.23.0/telebot/storage/redis_storage.py +324 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/types.py +143 -41
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/util.py +720 -700
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/version.py +1 -1
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_handler_backends.py +285 -285
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_telebot.py +705 -703
- pytelegrambotapi-4.22.0/examples/asynchronous_telebot/custom_states.py +0 -91
- pytelegrambotapi-4.22.0/examples/custom_states.py +0 -106
- pytelegrambotapi-4.22.0/telebot/asyncio_storage/base_storage.py +0 -68
- pytelegrambotapi-4.22.0/telebot/asyncio_storage/memory_storage.py +0 -66
- pytelegrambotapi-4.22.0/telebot/asyncio_storage/pickle_storage.py +0 -110
- pytelegrambotapi-4.22.0/telebot/asyncio_storage/redis_storage.py +0 -179
- pytelegrambotapi-4.22.0/telebot/storage/__init__.py +0 -13
- pytelegrambotapi-4.22.0/telebot/storage/base_storage.py +0 -68
- pytelegrambotapi-4.22.0/telebot/storage/memory_storage.py +0 -69
- pytelegrambotapi-4.22.0/telebot/storage/pickle_storage.py +0 -116
- pytelegrambotapi-4.22.0/telebot/storage/redis_storage.py +0 -183
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.github/ISSUE_TEMPLATE +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.github/workflows/setup_python.yml +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.gitignore +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.readthedocs.yml +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/.travis.yml +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/LICENSE +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/doc_req.txt +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/Makefile +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/_static/logo.png +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/_static/logo2.png +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/async_version/index.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/calldata.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/formatting.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/index.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/install.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/async_version.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/calldata.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/formatting.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/index.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/install.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/quick_start.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/sync_version.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/types.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/en/LC_MESSAGES/util.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/async_version.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/calldata.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/formatting.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/index.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/install.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/quick_start.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/sync_version.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/types.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/locales/ru/LC_MESSAGES/util.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/quick_start.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/sync_version/index.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/types.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/docs/source/util.rst +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/anonymous_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/callback_data_examples/advanced_calendar_example/filters.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/callback_data_examples/advanced_calendar_example/keyboards.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/callback_data_examples/advanced_calendar_example/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/callback_data_examples/simple_products_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/chat_join_request.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/chat_member_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/continue_handling.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/admin_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/advanced_text_filter.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/general_custom_filters.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/id_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/is_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/custom_filters/text_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/detect_changes.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/download_file_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/exception_handler.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/formatting_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/message_reaction_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/flooding_middleware.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/i18n_base_midddleware.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/keyboards.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/locales/en/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/locales/ru/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/locales/uz_Latn/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/middleware/i18n_middleware_example/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/multibot/README.MD +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/multibot/config.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/multibot/handlers.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/multibot/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/multibot/nginx_conf.conf +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/register_handler.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/send_file_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/set_command_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/skip_updates_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/timer_bot_async.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/update_listener.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/webhooks/async_webhook_aiohttp_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/webhooks/run_webhooks.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/asynchronous_telebot/webhooks/webhook_starlette_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/callback_data_examples/advanced_calendar_example/filters.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/callback_data_examples/advanced_calendar_example/keyboards.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/callback_data_examples/advanced_calendar_example/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/callback_data_examples/simple_products_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/chat_join_request.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/chat_member_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/continue_handling.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/create_invite_link.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/admin_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/advanced_text_filter.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/general_custom_filters.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/id_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/is_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/custom_filters/text_filter_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/deep_linking.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/detailed_example/detailed_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/detailed_example/kitten.jpg +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/detailed_example/rooster.jpg +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/detect_changes.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/download_file_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/formatting_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/inline_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/inline_keyboard_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/message_reaction_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/README.md +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/antiflood_middleware.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/basic_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/i18n_base_middleware.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/keyboards.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/locales/en/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/locales/ru/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/locales/uz_Latn/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/class_based/i18n_middleware/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/i18n_class.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/keyboards.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/locales/en/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/locales/ru/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/locales/uz_Latn/LC_MESSAGES/messages.po +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/i18n_gettext/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/middleware/function_based/session.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/multibot/README.MD +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/multibot/config.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/multibot/handlers.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/multibot/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/multibot/nginx_conf.conf +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/payments_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/poll_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/register_handler.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/reply_keyboard_markup_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/aws_lambda_function.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/azure_functions +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/flask_google_cloud_bot/.gcloudignore +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/flask_google_cloud_bot/app.yaml +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/flask_google_cloud_bot/main.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/serverless/flask_google_cloud_bot/requirements.txt +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/set_command_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/skip_updates_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/step_example.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/telebot_bot/telebot_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/timer_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/README.md +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/run_webhooks.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_aiohttp_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_cherrypy_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_cpython_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_fastapi_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_flask_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_flask_heroku_echo.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_tornado_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/examples/webhook_examples/webhook_twisted_echo_bot.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/callback_data.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/__init__.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/aio/__init__.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/aio/webhooks.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/reloader.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/sync/__init__.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/ext/sync/webhooks.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/formatting.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/telebot/service_utils.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/__init__.py +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_data/record.mp3 +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_data/record.ogg +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_data/record.wav +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_data/test_video.mp4 +0 -0
- {pytelegrambotapi-4.22.0 → pytelegrambotapi-4.23.0}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pyTelegramBotAPI
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.23.0
|
|
4
4
|
Summary: Python Telegram bot api.
|
|
5
5
|
Project-URL: Homepage, https://github.com/eternnoir/pyTelegramBotAPI
|
|
6
6
|
Project-URL: Documentation, https://pytba.readthedocs.org
|
|
@@ -23,8 +23,6 @@ Requires-Python: >=3.8
|
|
|
23
23
|
Requires-Dist: requests
|
|
24
24
|
Provides-Extra: aiohttp
|
|
25
25
|
Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
26
|
-
Provides-Extra: aioredis
|
|
27
|
-
Requires-Dist: aioredis; extra == 'aioredis'
|
|
28
26
|
Provides-Extra: coloredlogs
|
|
29
27
|
Requires-Dist: coloredlogs; extra == 'coloredlogs'
|
|
30
28
|
Provides-Extra: fastapi
|
|
@@ -55,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
55
53
|
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
|
|
56
54
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
57
55
|
|
|
58
|
-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api
|
|
56
|
+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#september-6-2024"><img src="https://img.shields.io/badge/Bot%20API-7.10-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
59
57
|
|
|
60
58
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
61
59
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
|
|
11
11
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
12
12
|
|
|
13
|
-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api
|
|
13
|
+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#september-6-2024"><img src="https://img.shields.io/badge/Bot%20API-7.10-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
14
14
|
|
|
15
15
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
16
16
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -22,7 +22,7 @@ author = 'coder2020official'
|
|
|
22
22
|
copyright = f'2022-{datetime.now().year}, {author}'
|
|
23
23
|
|
|
24
24
|
# The full version, including alpha/beta/rc tags
|
|
25
|
-
release = '4.
|
|
25
|
+
release = '4.23.0'
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
# -- General configuration ---------------------------------------------------
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from telebot import async_telebot, asyncio_filters, types
|
|
2
|
+
from telebot.asyncio_storage import StateMemoryStorage
|
|
3
|
+
from telebot.states import State, StatesGroup
|
|
4
|
+
from telebot.states.asyncio.context import StateContext
|
|
5
|
+
|
|
6
|
+
# Initialize the bot
|
|
7
|
+
state_storage = StateMemoryStorage() # don't use this in production; switch to redis
|
|
8
|
+
bot = async_telebot.AsyncTeleBot("TOKEN", state_storage=state_storage)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Define states
|
|
12
|
+
class MyStates(StatesGroup):
|
|
13
|
+
name = State()
|
|
14
|
+
age = State()
|
|
15
|
+
color = State()
|
|
16
|
+
hobby = State()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Start command handler
|
|
20
|
+
@bot.message_handler(commands=["start"])
|
|
21
|
+
async def start_ex(message: types.Message, state: StateContext):
|
|
22
|
+
await state.set(MyStates.name)
|
|
23
|
+
await bot.send_message(
|
|
24
|
+
message.chat.id,
|
|
25
|
+
"Hello! What is your first name?",
|
|
26
|
+
reply_to_message_id=message.message_id,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Cancel command handler
|
|
31
|
+
@bot.message_handler(state="*", commands=["cancel"])
|
|
32
|
+
async def any_state(message: types.Message, state: StateContext):
|
|
33
|
+
await state.delete()
|
|
34
|
+
await bot.send_message(
|
|
35
|
+
message.chat.id,
|
|
36
|
+
"Your information has been cleared. Type /start to begin again.",
|
|
37
|
+
reply_to_message_id=message.message_id,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# Handler for name input
|
|
42
|
+
@bot.message_handler(state=MyStates.name)
|
|
43
|
+
async def name_get(message: types.Message, state: StateContext):
|
|
44
|
+
await state.set(MyStates.age)
|
|
45
|
+
await bot.send_message(
|
|
46
|
+
message.chat.id, "How old are you?", reply_to_message_id=message.message_id
|
|
47
|
+
)
|
|
48
|
+
await state.add_data(name=message.text)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Handler for age input
|
|
52
|
+
@bot.message_handler(state=MyStates.age, is_digit=True)
|
|
53
|
+
async def ask_color(message: types.Message, state: StateContext):
|
|
54
|
+
await state.set(MyStates.color)
|
|
55
|
+
await state.add_data(age=message.text)
|
|
56
|
+
|
|
57
|
+
# Define reply keyboard for color selection
|
|
58
|
+
keyboard = types.ReplyKeyboardMarkup(row_width=2)
|
|
59
|
+
colors = ["Red", "Green", "Blue", "Yellow", "Purple", "Orange", "Other"]
|
|
60
|
+
buttons = [types.KeyboardButton(color) for color in colors]
|
|
61
|
+
keyboard.add(*buttons)
|
|
62
|
+
|
|
63
|
+
await bot.send_message(
|
|
64
|
+
message.chat.id,
|
|
65
|
+
"What is your favorite color? Choose from the options below.",
|
|
66
|
+
reply_markup=keyboard,
|
|
67
|
+
reply_to_message_id=message.message_id,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Handler for color input
|
|
72
|
+
@bot.message_handler(state=MyStates.color)
|
|
73
|
+
async def ask_hobby(message: types.Message, state: StateContext):
|
|
74
|
+
await state.set(MyStates.hobby)
|
|
75
|
+
await state.add_data(color=message.text)
|
|
76
|
+
|
|
77
|
+
# Define reply keyboard for hobby selection
|
|
78
|
+
keyboard = types.ReplyKeyboardMarkup(row_width=2)
|
|
79
|
+
hobbies = ["Reading", "Traveling", "Gaming", "Cooking"]
|
|
80
|
+
buttons = [types.KeyboardButton(hobby) for hobby in hobbies]
|
|
81
|
+
keyboard.add(*buttons)
|
|
82
|
+
|
|
83
|
+
await bot.send_message(
|
|
84
|
+
message.chat.id,
|
|
85
|
+
"What is one of your hobbies? Choose from the options below.",
|
|
86
|
+
reply_markup=keyboard,
|
|
87
|
+
reply_to_message_id=message.message_id,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# Handler for hobby input; use filters to ease validation
|
|
92
|
+
@bot.message_handler(
|
|
93
|
+
state=MyStates.hobby, text=["Reading", "Traveling", "Gaming", "Cooking"]
|
|
94
|
+
)
|
|
95
|
+
async def finish(message: types.Message, state: StateContext):
|
|
96
|
+
async with state.data() as data:
|
|
97
|
+
name = data.get("name")
|
|
98
|
+
age = data.get("age")
|
|
99
|
+
color = data.get("color")
|
|
100
|
+
hobby = message.text # Get the hobby from the message text
|
|
101
|
+
|
|
102
|
+
# Provide a fun fact based on color
|
|
103
|
+
color_facts = {
|
|
104
|
+
"Red": "Red is often associated with excitement and passion.",
|
|
105
|
+
"Green": "Green is the color of nature and tranquility.",
|
|
106
|
+
"Blue": "Blue is known for its calming and serene effects.",
|
|
107
|
+
"Yellow": "Yellow is a cheerful color often associated with happiness.",
|
|
108
|
+
"Purple": "Purple signifies royalty and luxury.",
|
|
109
|
+
"Orange": "Orange is a vibrant color that stimulates enthusiasm.",
|
|
110
|
+
"Other": "Colors have various meanings depending on context.",
|
|
111
|
+
}
|
|
112
|
+
color_fact = color_facts.get(
|
|
113
|
+
color, "Colors have diverse meanings, and yours is unique!"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
msg = (
|
|
117
|
+
f"Thank you for sharing! Here is a summary of your information:\n"
|
|
118
|
+
f"First Name: {name}\n"
|
|
119
|
+
f"Age: {age}\n"
|
|
120
|
+
f"Favorite Color: {color}\n"
|
|
121
|
+
f"Fun Fact about your color: {color_fact}\n"
|
|
122
|
+
f"Favorite Hobby: {hobby}"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
await bot.send_message(
|
|
126
|
+
message.chat.id, msg, parse_mode="html", reply_to_message_id=message.message_id
|
|
127
|
+
)
|
|
128
|
+
await state.delete()
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Handler for incorrect age input
|
|
132
|
+
@bot.message_handler(state=MyStates.age, is_digit=False)
|
|
133
|
+
async def age_incorrect(message: types.Message):
|
|
134
|
+
await bot.send_message(
|
|
135
|
+
message.chat.id,
|
|
136
|
+
"Please enter a valid number for age.",
|
|
137
|
+
reply_to_message_id=message.message_id,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# Add custom filters
|
|
142
|
+
bot.add_custom_filter(asyncio_filters.StateFilter(bot))
|
|
143
|
+
bot.add_custom_filter(asyncio_filters.IsDigitFilter())
|
|
144
|
+
bot.add_custom_filter(asyncio_filters.TextMatchFilter())
|
|
145
|
+
|
|
146
|
+
# necessary for state parameter in handlers.
|
|
147
|
+
from telebot.states.asyncio.middleware import StateMiddleware
|
|
148
|
+
|
|
149
|
+
bot.setup_middleware(StateMiddleware(bot))
|
|
150
|
+
|
|
151
|
+
# Start polling
|
|
152
|
+
import asyncio
|
|
153
|
+
|
|
154
|
+
asyncio.run(bot.polling())
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# The source of the "https://pytelegrambotminiapp.vercel.app" can be found in https://github.com/eternnoir/pyTelegramBotAPI/tree/master/examples/mini_app_web
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from telebot.async_telebot import AsyncTeleBot
|
|
5
|
+
from telebot.types import (
|
|
6
|
+
ReplyKeyboardMarkup,
|
|
7
|
+
KeyboardButton,
|
|
8
|
+
WebAppInfo,
|
|
9
|
+
InlineKeyboardMarkup,
|
|
10
|
+
InlineKeyboardButton
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
BOT_TOKEN = ""
|
|
14
|
+
WEB_URL = "https://pytelegrambotminiapp.vercel.app"
|
|
15
|
+
|
|
16
|
+
bot = AsyncTeleBot(BOT_TOKEN)
|
|
17
|
+
|
|
18
|
+
@bot.message_handler(commands=["start"])
|
|
19
|
+
async def start(message):
|
|
20
|
+
reply_keyboard_markup = ReplyKeyboardMarkup(resize_keyboard=True)
|
|
21
|
+
reply_keyboard_markup.row(KeyboardButton("Start MiniApp", web_app=WebAppInfo(WEB_URL)))
|
|
22
|
+
|
|
23
|
+
inline_keyboard_markup = InlineKeyboardMarkup()
|
|
24
|
+
inline_keyboard_markup.row(InlineKeyboardButton('Start MiniApp', web_app=WebAppInfo(WEB_URL)))
|
|
25
|
+
|
|
26
|
+
await bot.reply_to(message, "Click the bottom inline button to start MiniApp", reply_markup=inline_keyboard_markup)
|
|
27
|
+
await bot.reply_to(message, "Click keyboard button to start MiniApp", reply_markup=reply_keyboard_markup)
|
|
28
|
+
|
|
29
|
+
@bot.message_handler(content_types=['web_app_data'])
|
|
30
|
+
async def web_app(message):
|
|
31
|
+
await bot.reply_to(message, f'Your message is "{message.web_app_data.data}"')
|
|
32
|
+
|
|
33
|
+
asyncio.run(bot.polling())
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import telebot
|
|
2
|
+
from telebot import custom_filters, types
|
|
3
|
+
from telebot.states import State, StatesGroup
|
|
4
|
+
from telebot.states.sync.context import StateContext
|
|
5
|
+
from telebot.storage import StateMemoryStorage
|
|
6
|
+
|
|
7
|
+
# Initialize the bot
|
|
8
|
+
state_storage = StateMemoryStorage() # don't use this in production; switch to redis
|
|
9
|
+
bot = telebot.TeleBot("TOKEN", state_storage=state_storage, use_class_middlewares=True)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Define states
|
|
13
|
+
class MyStates(StatesGroup):
|
|
14
|
+
name = State()
|
|
15
|
+
age = State()
|
|
16
|
+
color = State()
|
|
17
|
+
hobby = State()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Start command handler
|
|
21
|
+
@bot.message_handler(commands=["start"])
|
|
22
|
+
def start_ex(message: types.Message, state: StateContext):
|
|
23
|
+
state.set(MyStates.name)
|
|
24
|
+
bot.send_message(
|
|
25
|
+
message.chat.id,
|
|
26
|
+
"Hello! What is your first name?",
|
|
27
|
+
reply_to_message_id=message.message_id,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Cancel command handler
|
|
32
|
+
@bot.message_handler(state="*", commands=["cancel"])
|
|
33
|
+
def any_state(message: types.Message, state: StateContext):
|
|
34
|
+
state.delete()
|
|
35
|
+
bot.send_message(
|
|
36
|
+
message.chat.id,
|
|
37
|
+
"Your information has been cleared. Type /start to begin again.",
|
|
38
|
+
reply_to_message_id=message.message_id,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Handler for name input
|
|
43
|
+
@bot.message_handler(state=MyStates.name)
|
|
44
|
+
def name_get(message: types.Message, state: StateContext):
|
|
45
|
+
state.set(MyStates.age)
|
|
46
|
+
bot.send_message(
|
|
47
|
+
message.chat.id, "How old are you?", reply_to_message_id=message.message_id
|
|
48
|
+
)
|
|
49
|
+
state.add_data(name=message.text)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Handler for age input
|
|
53
|
+
@bot.message_handler(state=MyStates.age, is_digit=True)
|
|
54
|
+
def ask_color(message: types.Message, state: StateContext):
|
|
55
|
+
state.set(MyStates.color)
|
|
56
|
+
state.add_data(age=message.text)
|
|
57
|
+
|
|
58
|
+
# Define reply keyboard for color selection
|
|
59
|
+
keyboard = types.ReplyKeyboardMarkup(row_width=2)
|
|
60
|
+
colors = ["Red", "Green", "Blue", "Yellow", "Purple", "Orange", "Other"]
|
|
61
|
+
buttons = [types.KeyboardButton(color) for color in colors]
|
|
62
|
+
keyboard.add(*buttons)
|
|
63
|
+
|
|
64
|
+
bot.send_message(
|
|
65
|
+
message.chat.id,
|
|
66
|
+
"What is your favorite color? Choose from the options below.",
|
|
67
|
+
reply_markup=keyboard,
|
|
68
|
+
reply_to_message_id=message.message_id,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# Handler for color input
|
|
73
|
+
@bot.message_handler(state=MyStates.color)
|
|
74
|
+
def ask_hobby(message: types.Message, state: StateContext):
|
|
75
|
+
state.set(MyStates.hobby)
|
|
76
|
+
state.add_data(color=message.text)
|
|
77
|
+
|
|
78
|
+
# Define reply keyboard for hobby selection
|
|
79
|
+
keyboard = types.ReplyKeyboardMarkup(row_width=2)
|
|
80
|
+
hobbies = ["Reading", "Traveling", "Gaming", "Cooking"]
|
|
81
|
+
buttons = [types.KeyboardButton(hobby) for hobby in hobbies]
|
|
82
|
+
keyboard.add(*buttons)
|
|
83
|
+
|
|
84
|
+
bot.send_message(
|
|
85
|
+
message.chat.id,
|
|
86
|
+
"What is one of your hobbies? Choose from the options below.",
|
|
87
|
+
reply_markup=keyboard,
|
|
88
|
+
reply_to_message_id=message.message_id,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Handler for hobby input
|
|
93
|
+
@bot.message_handler(
|
|
94
|
+
state=MyStates.hobby, text=["Reading", "Traveling", "Gaming", "Cooking"]
|
|
95
|
+
)
|
|
96
|
+
def finish(message: types.Message, state: StateContext):
|
|
97
|
+
with state.data() as data:
|
|
98
|
+
name = data.get("name")
|
|
99
|
+
age = data.get("age")
|
|
100
|
+
color = data.get("color")
|
|
101
|
+
hobby = message.text # Get the hobby from the message text
|
|
102
|
+
|
|
103
|
+
# Provide a fun fact based on color
|
|
104
|
+
color_facts = {
|
|
105
|
+
"Red": "Red is often associated with excitement and passion.",
|
|
106
|
+
"Green": "Green is the color of nature and tranquility.",
|
|
107
|
+
"Blue": "Blue is known for its calming and serene effects.",
|
|
108
|
+
"Yellow": "Yellow is a cheerful color often associated with happiness.",
|
|
109
|
+
"Purple": "Purple signifies royalty and luxury.",
|
|
110
|
+
"Orange": "Orange is a vibrant color that stimulates enthusiasm.",
|
|
111
|
+
"Other": "Colors have various meanings depending on context.",
|
|
112
|
+
}
|
|
113
|
+
color_fact = color_facts.get(
|
|
114
|
+
color, "Colors have diverse meanings, and yours is unique!"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
msg = (
|
|
118
|
+
f"Thank you for sharing! Here is a summary of your information:\n"
|
|
119
|
+
f"First Name: {name}\n"
|
|
120
|
+
f"Age: {age}\n"
|
|
121
|
+
f"Favorite Color: {color}\n"
|
|
122
|
+
f"Fun Fact about your color: {color_fact}\n"
|
|
123
|
+
f"Favorite Hobby: {hobby}"
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
bot.send_message(
|
|
127
|
+
message.chat.id, msg, parse_mode="html", reply_to_message_id=message.message_id
|
|
128
|
+
)
|
|
129
|
+
state.delete()
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# Handler for incorrect age input
|
|
133
|
+
@bot.message_handler(state=MyStates.age, is_digit=False)
|
|
134
|
+
def age_incorrect(message: types.Message):
|
|
135
|
+
bot.send_message(
|
|
136
|
+
message.chat.id,
|
|
137
|
+
"Please enter a valid number for age.",
|
|
138
|
+
reply_to_message_id=message.message_id,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# Add custom filters
|
|
143
|
+
bot.add_custom_filter(custom_filters.StateFilter(bot))
|
|
144
|
+
bot.add_custom_filter(custom_filters.IsDigitFilter())
|
|
145
|
+
bot.add_custom_filter(custom_filters.TextMatchFilter())
|
|
146
|
+
|
|
147
|
+
# necessary for state parameter in handlers.
|
|
148
|
+
from telebot.states.sync.middleware import StateMiddleware
|
|
149
|
+
|
|
150
|
+
bot.setup_middleware(StateMiddleware(bot))
|
|
151
|
+
|
|
152
|
+
# Start polling
|
|
153
|
+
bot.infinity_polling()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# The source of the "https://pytelegrambotminiapp.vercel.app" can be found in https://github.com/eternnoir/pyTelegramBotAPI/tree/master/examples/mini_app_web
|
|
2
|
+
|
|
3
|
+
from telebot import TeleBot
|
|
4
|
+
from telebot.types import (
|
|
5
|
+
ReplyKeyboardMarkup,
|
|
6
|
+
KeyboardButton,
|
|
7
|
+
WebAppInfo,
|
|
8
|
+
InlineKeyboardMarkup,
|
|
9
|
+
InlineKeyboardButton
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
BOT_TOKEN = ""
|
|
13
|
+
WEB_URL = "https://pytelegrambotminiapp.vercel.app"
|
|
14
|
+
|
|
15
|
+
bot = TeleBot(BOT_TOKEN)
|
|
16
|
+
|
|
17
|
+
@bot.message_handler(commands=["start"])
|
|
18
|
+
def start(message):
|
|
19
|
+
reply_keyboard_markup = ReplyKeyboardMarkup(resize_keyboard=True)
|
|
20
|
+
reply_keyboard_markup.row(KeyboardButton("Start MiniApp", web_app=WebAppInfo(WEB_URL)))
|
|
21
|
+
|
|
22
|
+
inline_keyboard_markup = InlineKeyboardMarkup()
|
|
23
|
+
inline_keyboard_markup.row(InlineKeyboardButton('Start MiniApp', web_app=WebAppInfo(WEB_URL)))
|
|
24
|
+
|
|
25
|
+
bot.reply_to(message, "Click the bottom inline button to start MiniApp", reply_markup=inline_keyboard_markup)
|
|
26
|
+
bot.reply_to(message, "Click keyboard button to start MiniApp", reply_markup=reply_keyboard_markup)
|
|
27
|
+
|
|
28
|
+
@bot.message_handler(content_types=['web_app_data'])
|
|
29
|
+
def web_app(message):
|
|
30
|
+
bot.reply_to(message, f'Your message is "{message.web_app_data.data}"')
|
|
31
|
+
|
|
32
|
+
bot.infinity_polling()
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<script src="https://telegram.org/js/telegram-web-app.js"></script>
|
|
7
|
+
<title>PyTelegramBotApi MiniApp</title>
|
|
8
|
+
<link href="style.css" rel="stylesheet">
|
|
9
|
+
</head>
|
|
10
|
+
<body class='body'>
|
|
11
|
+
<div class='content-block content-block_send-message send-message'>
|
|
12
|
+
<input class="send-message__input" type="text" placeholder="type your message here">
|
|
13
|
+
<button class="send-message__button" id="send-message-button"> send the message </button>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<p class="header-text"> client buttons </p>
|
|
17
|
+
<div class="content-block content-block_client-btn client">
|
|
18
|
+
<button class="default-button default-button_disable" id='back-button' value="disable"> back </button>
|
|
19
|
+
<button class="default-button" id='main-button' value="enable"> main </button>
|
|
20
|
+
<button class="default-button default-button_disable" id='settings-button' value="disable"> settings </button>
|
|
21
|
+
</div>
|
|
22
|
+
<p class="header-text"> hapticFeedback (notification) </p>
|
|
23
|
+
<div class="content-block content-block_haptic-feedback haptic_feedback">
|
|
24
|
+
<button class="default-button" id='success-button'> success </button>
|
|
25
|
+
<button class="default-button default-button_yellow" id='warning-button'> warning </button>
|
|
26
|
+
<button class="default-button default-button_red" id='error-button'> error </button>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<p class="header-text"> tweak color [Bot API 6.1+]</p>
|
|
30
|
+
<div class="content-block content-block_tweak-color tweak-color">
|
|
31
|
+
<div class="tweak-color__header">
|
|
32
|
+
<p class="tweak-color__text">Header color: </p>
|
|
33
|
+
<div class="tweak-color__circle-block">
|
|
34
|
+
<div class="tweak-color__circle tweak-color__circle_yellow" id="header-yellow"> </div>
|
|
35
|
+
<div class="tweak-color__circle tweak-color__circle_button" id="header-button_color"> </div>
|
|
36
|
+
<div class="tweak-color__circle tweak-color__circle_red" id="header-red"> </div>
|
|
37
|
+
<div class="tweak-color__circle tweak-color__circle_header" id="header-default"> </div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="tweak-color__background">
|
|
41
|
+
<p class="tweak-color__text">Background color: </p>
|
|
42
|
+
<div class="tweak-color__circle-block">
|
|
43
|
+
<div class="tweak-color__circle tweak-color__circle_yellow" id="background-yellow"> </div>
|
|
44
|
+
<div class="tweak-color__circle tweak-color__circle_button" id="background-button_color"> </div>
|
|
45
|
+
<div class="tweak-color__circle tweak-color__circle_red" id="background-red"> </div>
|
|
46
|
+
<div class="tweak-color__circle tweak-color__circle_background" id="background-default"> </div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<p class="header-text"> popup and alert [Bot API 6.2+] </p>
|
|
52
|
+
<div class="content-block content-block_popup-alert popup-alert">
|
|
53
|
+
<button class="default-button" id="popup-button"> popup </button>
|
|
54
|
+
<button class="default-button" id="alert-button"> alert </button>
|
|
55
|
+
<button class="default-button" id="confirm-button"> confirm </button>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<p class="header-text"> request [Bot API 6.9+]</p>
|
|
59
|
+
<div class="content-block content-block_request block_request">
|
|
60
|
+
<button class="default-button" id="contact-button"> contact </button>
|
|
61
|
+
<button class="default-button" id="write-access-button"> write access </button>
|
|
62
|
+
<button class="default-button" id="biometrics-button"> biometrics </button>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<p class="header-text"> story [Bot API 7.8+]</p>
|
|
66
|
+
<div class="content-block content-block_story story">
|
|
67
|
+
<button class="default-button" id="post-story-photo-button"> story (photo) </button>
|
|
68
|
+
<button class="default-button" id="post-story-video-button"> story (video) </button>
|
|
69
|
+
<button class="default-button" id="post-story-with-link-button"> story + link</button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<p class="header-text"> cloud storage [Bot API 6.9+] </p>
|
|
73
|
+
<div class="content-block content-block_cloud-storage cloud-storage">
|
|
74
|
+
<div class="cloud-storage__input-block">
|
|
75
|
+
<input class="cloud-storage__input cloud-storage__input_add-key" type="text" name="" value="" placeholder="key">
|
|
76
|
+
<input class="cloud-storage__input cloud-storage__input_add-value" type="text" name="" value="" placeholder="value">
|
|
77
|
+
</div>
|
|
78
|
+
<button class="cloud-storage__button cloud-storage__button_add" id="cloud-add-button"> add to cloud storage </button>
|
|
79
|
+
<table class="cloud-storage__table" id="cloud-storage-table">
|
|
80
|
+
<tr>
|
|
81
|
+
<th id="cloud-storage-key"> key </th>
|
|
82
|
+
<th id="cloud-storage-value"> value </th>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr id="null-storage-row">
|
|
85
|
+
<td> - </td>
|
|
86
|
+
<td> - </td>
|
|
87
|
+
</tr>
|
|
88
|
+
</table>
|
|
89
|
+
<div class="cloud-storage__input-block cloud-storage__input-block_remove">
|
|
90
|
+
<input class="cloud-storage__input cloud-storage__input_remove" type="text" value="" placeholder="key">
|
|
91
|
+
<button class="cloud-storage__button cloud-storage__button_remove" id='cloud-remove-button'> remove from cloud storage </button>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<p class="header-text"> data from telegram </p>
|
|
95
|
+
<div class="content-block content-block_data">
|
|
96
|
+
<div class="data__content" id="initDataUnsafe-block">
|
|
97
|
+
<p class="content-block__text"> initDataUnsafe </p>
|
|
98
|
+
</div>
|
|
99
|
+
<div class="data__content" id="themeParams-block">
|
|
100
|
+
<p class="content-block__text"> ThemeParams </p>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="data__content" id="biometrics-block">
|
|
103
|
+
<p class="content-block__text"> Biometrics Manager</p>
|
|
104
|
+
<table class="biometrics__table" id="biometrics-table">
|
|
105
|
+
<tr id="null-biometrics-row">
|
|
106
|
+
<td>support</td>
|
|
107
|
+
<td>Unsupported in this platform</td>
|
|
108
|
+
</tr>
|
|
109
|
+
</table>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<p class="header-text"> event from telegram </p>
|
|
114
|
+
<div class="content-block content-block_event event">
|
|
115
|
+
<div class="event__content" id="event-block">
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<p class="header-text"> vertical scroll behaviour [Bot API 7.7+] </p>
|
|
120
|
+
<div class="content-block content-block_scroll-behaviour scroll-behaviour">
|
|
121
|
+
<p class="content-block__text"> close the miniapp when scroll vertically </p>
|
|
122
|
+
<div class="scroll-behaviour__toggle-box">
|
|
123
|
+
<button class="default-button" id="enable-scroll-button" value="enable"> Enable </button>
|
|
124
|
+
<button class="default-button default-button_disable" id="disable-scroll-button" value="disable"> Disable </button>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<p class="header-text"> closing confirmation [Bot API 6.2+]</p>
|
|
129
|
+
<div class="content-block content-block_close-confirmation close-confirmation">
|
|
130
|
+
<p class="content-block__text"> Confimation dialog when closing miniapp </p>
|
|
131
|
+
<div class="content-block__toggle-box">
|
|
132
|
+
<button class="default-button default-button_disable" id="enable-close-confirm-button" value="disable"> Enable </button>
|
|
133
|
+
<button class="default-button" id="disable-close-confirm-button" value="enable"> Disable </button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<p class="header-text"> links </p>
|
|
138
|
+
<div class="content-block content-block_link link">
|
|
139
|
+
<ul class="link__list">
|
|
140
|
+
<li>
|
|
141
|
+
<p class="link__text"> <a class="link__text link__text_blue" id="telegram-link" href="javascript:telegram.openTelegramLink(https://t.me/joinchat/Bn4ixj84FIZVkwhk2jag6A)"> pyTelegramBotApi </a> - opens telegram link in telegram </p>
|
|
142
|
+
</li>
|
|
143
|
+
<li>
|
|
144
|
+
<p class="link__text"> <a class="link__text link__text_blue" id="internal-link" href="javascript:telegram.openLink(https://telegram.org)"> Telegram </a> - opens link inside telegram in browser. </p>
|
|
145
|
+
</li>
|
|
146
|
+
</ul>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<p class="header-text"> other </p>
|
|
150
|
+
<div class="content-block content-block_other other">
|
|
151
|
+
<button class="default-button" id="show-QR-button"> show QR </button>
|
|
152
|
+
<button class="default-button" id="expand-button"> expand </button>
|
|
153
|
+
<button class="default-button default-button_red" id="close-button"> close </button>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="description-block">
|
|
157
|
+
<pre class="description__text" id="version-text"> version: </pre>
|
|
158
|
+
<pre class="description__text" id="platform-text"> platform: </pre>
|
|
159
|
+
<pre class="description__text" id="color-scheme-text"> color scheme: </pre>
|
|
160
|
+
</div>
|
|
161
|
+
</body>
|
|
162
|
+
<script src="script.js"></script>
|
|
163
|
+
</html>
|