import asyncio import logging from aiogram import Bot, Dispatcher from aiogram.fsm.storage.memory import MemoryStorage from aiogram.client.default import DefaultBotProperties from bot.config import BOT_TOKEN from bot.db.init import init_db from bot.handlers.bots import router as bots_router from bot.handlers.console import router as console_router from bot.handlers.inventory import router as inventory_router from bot.handlers.messages import router as messages_router from bot.handlers.navigation import router as navigation_router from bot.handlers.redeem import router as redeem_router from bot.handlers.start import router as start_router from bot.handlers.twofa import router as twofa_router logger = logging.getLogger(__name__) bot = Bot(token=BOT_TOKEN, default=DefaultBotProperties(parse_mode="HTML")) # type: ignore[arg-type] dp = Dispatcher(storage=MemoryStorage()) dp.include_router(start_router) dp.include_router(navigation_router) dp.include_router(console_router) dp.include_router(bots_router) dp.include_router(twofa_router) dp.include_router(inventory_router) dp.include_router(redeem_router) dp.include_router(messages_router) async def main() -> None: await init_db() await dp.start_polling(bot) if __name__ == "__main__": logging.basicConfig( level=logging.INFO, format="%(asctime)s | %(levelname)s | %(name)s | %(message)s", handlers=[ logging.FileHandler("bot.log", encoding="utf-8"), logging.StreamHandler(), ], ) try: asyncio.run(main()) except KeyboardInterrupt: logger.info("Получен сигнал остановки, бот завершает работу") except Exception: logger.exception("Бот завершился из-за необработанной ошибки") raise