Fix bugs, add README and Makefile

This commit is contained in:
2026-01-16 20:39:51 +03:00
parent 3e515c66ec
commit a065c6b7be
30 changed files with 695 additions and 286 deletions

View File

@@ -1,14 +1,17 @@
import aiogram
from aiogram.filters import Command
from aiogram_dialog import DialogManager
from birthday_pool_bot.repositories import RepositoriesContainer
from . import constants, handlers
from .callback_data import (
AddSubscriptionCallbackData,
AddSubscriptionConfirmCallbackData,
ConfirmAnswerEnum,
MenuCallbackData,
NewSubscriptionCallbackData,
NewSubscriptionConfirmCallbackData,
PoolActionEnum,
PoolCallbackData,
PoolsBackCallbackData,
PoolsCallbackData,
SubscriptionActionEnum,
SubscriptionCallbackData,
SubscriptionsCallbackData,
@@ -16,12 +19,12 @@ from .callback_data import (
from .middlewares import (
AuthMiddleware,
DependsMiddleware,
TypingMiddleware,
# TypingMiddleware,
)
from .states import (
AddSubscriptionPoolState,
AddSubscriptionState,
MenuState,
NewSubscriptionPoolState,
NewSubscriptionState,
SetProfileBirthdayState,
SetProfileGiftPaymentDataState,
SetProfileNameState,
@@ -33,7 +36,7 @@ def setup_dispatcher(
dispatcher: aiogram.Dispatcher,
repositories_container: RepositoriesContainer,
):
typing_middleware = TypingMiddleware()
# typing_middleware = TypingMiddleware()
auth_middleware = AuthMiddleware(users_repository=repositories_container.users)
users_repository_middleware = DependsMiddleware(
name="users_repository",
@@ -175,9 +178,9 @@ def setup_router(router: aiogram.Router) -> aiogram.Router:
SubscriptionsCallbackData.filter(),
)
router.callback_query.register(
handlers.add_subscription_callback_handler,
handlers.new_subscription_callback_handler,
MenuState.SUBSCRIPTIONS,
AddSubscriptionCallbackData.filter(),
NewSubscriptionCallbackData.filter(),
)
router.callback_query.register(
handlers.menu_callback_handler,
@@ -203,107 +206,132 @@ def setup_router(router: aiogram.Router) -> aiogram.Router:
### Add new subscription
router.message.register(
handlers.add_subscription_message_handler,
AddSubscriptionState.WAITING_FOR_PHONE,
handlers.new_subscription_message_handler,
NewSubscriptionState.WAITING_FOR_PHONE,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_user_message_handler,
AddSubscriptionState.WAITING_FOR_PHONE,
handlers.set_new_subscription_user_message_handler,
NewSubscriptionState.WAITING_FOR_PHONE,
)
router.message.register(
handlers.ask_add_subscription_user_message_handler,
AddSubscriptionState.WAITING_FOR_DATE,
handlers.ask_new_subscription_user_message_handler,
NewSubscriptionState.WAITING_FOR_DATE,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_user_birthday_message_handler,
AddSubscriptionState.WAITING_FOR_DATE,
handlers.set_new_subscription_user_birthday_message_handler,
NewSubscriptionState.WAITING_FOR_DATE,
)
router.message.register(
handlers.ask_add_subscription_user_message_handler,
AddSubscriptionState.WAITING_FOR_NAME,
handlers.ask_new_subscription_user_message_handler,
NewSubscriptionState.WAITING_FOR_NAME,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_name_message_handler,
AddSubscriptionState.WAITING_FOR_NAME,
handlers.set_new_subscription_name_message_handler,
NewSubscriptionState.WAITING_FOR_NAME,
)
router.message.register(
handlers.ask_add_subscription_pool_description_message_handler,
AddSubscriptionState.WAITING_FOR_POOL_DECISION,
handlers.ask_new_subscription_pool_description_message_handler,
NewSubscriptionState.WAITING_FOR_POOL_DECISION,
aiogram.F.text == constants.CREATE_POOL_BUTTON,
)
router.message.register(
handlers.show_add_subscription_pools_message_handler,
AddSubscriptionState.WAITING_FOR_POOL_DECISION,
handlers.show_new_subscription_choosing_pools_message_handler,
NewSubscriptionState.WAITING_FOR_POOL_DECISION,
aiogram.F.text == constants.JOIN_EXISTING_POOL_BUTTON,
)
router.message.register(
handlers.ask_add_subscription_confirmation_message_handler,
AddSubscriptionState.WAITING_FOR_POOL_DECISION,
handlers.ask_new_subscription_confirmation_message_handler,
NewSubscriptionState.WAITING_FOR_POOL_DECISION,
aiogram.F.text == constants.DECLINE_POOL_BUTTON,
)
router.message.register(
handlers.ask_add_subscription_name_message_handler,
AddSubscriptionState.WAITING_FOR_POOL_DECISION,
handlers.ask_new_subscription_name_message_handler,
NewSubscriptionState.WAITING_FOR_POOL_DECISION,
aiogram.F.text == constants.BACK_BUTTON,
)
router.callback_query.register(
handlers.confirm_add_subscription_callback_handler,
AddSubscriptionState.WAITING_FOR_CONFIRMATION,
AddSubscriptionConfirmCallbackData.filter(
handlers.confirm_new_subscription_callback_handler,
NewSubscriptionState.WAITING_FOR_CONFIRMATION,
NewSubscriptionConfirmCallbackData.filter(
aiogram.F.answer == ConfirmAnswerEnum.YES,
),
)
router.callback_query.register(
handlers.subscriptions_callback_handler,
AddSubscriptionState.WAITING_FOR_CONFIRMATION,
AddSubscriptionConfirmCallbackData.filter(
NewSubscriptionState.WAITING_FOR_CONFIRMATION,
NewSubscriptionConfirmCallbackData.filter(
aiogram.F.answer == ConfirmAnswerEnum.NO,
),
)
#### Add new subscription pool
router.message.register(
handlers.ask_add_subscription_pool_payment_phone_message_handler,
AddSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
handlers.ask_new_subscription_pool_payment_phone_message_handler,
NewSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
aiogram.F.text == constants.SKIP_BUTTON,
)
router.message.register(
handlers.ask_add_subscription_pool_decision_message_handler,
AddSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
handlers.ask_new_subscription_pool_decision_message_handler,
NewSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_pool_description_message_handler,
AddSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
handlers.set_new_subscription_pool_description_message_handler,
NewSubscriptionPoolState.WAITING_FOR_DESCRIPTION,
)
router.message.register(
handlers.set_add_subscription_pool_payment_data_from_profile_message_handler,
AddSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
handlers.set_new_subscription_pool_payment_data_from_profile_message_handler,
NewSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
aiogram.F.text == constants.USE_PROFILE_GIFT_PAYMENT_DATA,
)
router.message.register(
handlers.ask_add_subscription_pool_description_message_handler,
AddSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
handlers.ask_new_subscription_pool_description_message_handler,
NewSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_pool_payment_phone_message_handler,
AddSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
handlers.set_new_subscription_pool_payment_phone_message_handler,
NewSubscriptionPoolState.WAITING_FOR_PAYMENT_PHONE,
)
router.message.register(
handlers.set_add_subscription_pool_payment_phone_message_handler,
AddSubscriptionPoolState.WAITING_FOR_PAYMENT_BANK,
handlers.set_new_subscription_pool_payment_phone_message_handler,
NewSubscriptionPoolState.WAITING_FOR_PAYMENT_BANK,
aiogram.F.text == constants.BACK_BUTTON,
)
router.message.register(
handlers.set_add_subscription_pool_payment_bank_message_handler,
AddSubscriptionPoolState.WAITING_FOR_PAYMENT_BANK,
handlers.set_new_subscription_pool_payment_bank_message_handler,
NewSubscriptionPoolState.WAITING_FOR_PAYMENT_BANK,
)
#### Choose pool for subscription
router.callback_query.register(
handlers.show_new_subscription_choosing_pools_callback_handler,
NewSubscriptionState.WAITING_FOR_CHOOSE_POOL,
PoolsCallbackData.filter(),
)
router.callback_query.register(
handlers.ask_new_subscription_pool_decision_callback_handler,
NewSubscriptionState.WAITING_FOR_CHOOSE_POOL,
PoolsBackCallbackData.filter(),
)
router.callback_query.register(
handlers.show_new_subscription_choosing_pool_callback_handler,
NewSubscriptionState.WAITING_FOR_CHOOSE_POOL,
PoolCallbackData.filter(aiogram.F.action == PoolActionEnum.SHOW),
)
router.callback_query.register(
handlers.choose_new_subscription_pool_callback_handler,
NewSubscriptionState.WAITING_FOR_CHOOSE_POOL,
PoolCallbackData.filter(aiogram.F.action == PoolActionEnum.CHOOSE),
)
router.callback_query.register(
handlers.show_new_subscription_choosing_pools_callback_handler,
NewSubscriptionState.WAITING_FOR_CHOOSE_POOL,
PoolsCallbackData.filter(),
)
# Fallback
router.message.register(handlers.fallback_message_handler)