From 822d84524124a689bb02faf2c047c876676efa12 Mon Sep 17 00:00:00 2001 From: hteppl Date: Sun, 8 Dec 2024 04:23:59 +0300 Subject: [PATCH] Include routers only if payment method enabled in the config --- handlers/payments/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/handlers/payments/__init__.py b/handlers/payments/__init__.py index 969f4913..231dd68a 100644 --- a/handlers/payments/__init__.py +++ b/handlers/payments/__init__.py @@ -2,6 +2,7 @@ __all__ = ('router',) from aiogram import Router +from config import ROBOKASSA_ENABLE, STARS_ENABLE, CRYPTO_BOT_ENABLE, FREEKASSA_ENABLE, YOOKASSA_ENABLE from .cryprobot_pay import router as cryprobot_router from .freekassa_pay import router as freekassa_router from .robokassa_pay import router as robokassa_router @@ -10,10 +11,13 @@ from .yookassa_pay import router as yookassa_router router = Router(name='payments_main_router') -router.include_routers( - cryprobot_router, - stars_router, - freekassa_router, - robokassa_router, - yookassa_router, -) +if YOOKASSA_ENABLE: + router.include_router(yookassa_router) +if FREEKASSA_ENABLE: + router.include_router(freekassa_router) +if ROBOKASSA_ENABLE: + router.include_router(robokassa_router) +if CRYPTO_BOT_ENABLE: + router.include_router(cryprobot_router) +if STARS_ENABLE: + router.include_router(stars_router)