diff --git a/main.py b/main.py index 0178396..3f0bca9 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -import asyncio import logging from sys import exit @@ -21,5 +20,5 @@ if __name__ == "__main__": # Start bot bot = NwXrayBot(config.bot_token.get_secret_value()) - bot.include_routers(HelloHandler(bot), MenuHandler(bot)) + bot.include_routers(HelloHandler(), MenuHandler()) uvloop.run(bot.start(skip_updates=True)) diff --git a/nwxraybot/handlers/menu.py b/nwxraybot/handlers/menu.py index 660881c..a261978 100644 --- a/nwxraybot/handlers/menu.py +++ b/nwxraybot/handlers/menu.py @@ -6,8 +6,8 @@ from nwxraybot.models import User class MenuHandler(Handler): - def __init__(self, bot) -> None: - super().__init__(bot) + def __init__(self) -> None: + super().__init__() @self.router.message() async def menu(message: types.Message) -> None: diff --git a/nwxraybot/meta/router.py b/nwxraybot/meta/router.py index c66f282..9646d7a 100644 --- a/nwxraybot/meta/router.py +++ b/nwxraybot/meta/router.py @@ -1,13 +1,16 @@ +from typing import Optional + from aiogram import Bot, Router class Handler: - bot: Bot + bot: Optional[Bot] router: Router - def __init__(self, bot) -> None: - assert isinstance(bot.bot, Bot) - self.bot = bot.bot + def __init__(self, bot: Optional[Bot] = None) -> None: + if bot: + assert isinstance(bot.bot, Optional[Bot]) + self.bot = bot.bot self.router = Router() def __call__(self) -> Router: