Feat: changed bot starting

This commit is contained in:
2024-12-26 16:08:32 +03:00
parent 2882688ff4
commit 53bb09f41c
4 changed files with 25 additions and 10 deletions

View File

@@ -1 +1,2 @@
from nwxraybot.bot import NwXrayBot
from nwxraybot.config import Settings

View File

@@ -0,0 +1,14 @@
from aiogram import Bot, Dispatcher, Router
class NwXrayBot:
def __init__(self, token: str) -> None:
self.bot = Bot(token=token)
self.dp = Dispatcher()
def include_routers(self, *routers: Router):
for router in routers:
self.dp.include_router(router)
async def start(self, skip_updates: bool = False) -> None:
await self.dp.start_polling(self.bot, skip_updates=skip_updates)

View File

@@ -1,12 +1,14 @@
from aiogram import Bot, Router
from aiogram import Router
from nwxraybot import NwXrayBot
class Handler:
bot: Bot
bot: NwXrayBot
router: Router
def __init__(self, bot: Bot) -> None:
assert isinstance(bot, Bot)
def __init__(self, bot: NwXrayBot) -> None:
assert isinstance(bot, NwXrayBot)
self.bot = bot
self.router = Router()