first step
This commit is contained in:
41
main.py
Normal file
41
main.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from aiogram import Bot, Dispatcher
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
|
||||
from config import config
|
||||
from core import db
|
||||
from handlers import main_router, admin_router
|
||||
|
||||
# Настройка логирования
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
|
||||
# Инициализация бота и диспетчера
|
||||
bot = Bot(token=config.bot_token, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
|
||||
dp = Dispatcher()
|
||||
|
||||
# Регистрация роутеров
|
||||
dp.include_router(main_router)
|
||||
dp.include_router(admin_router)
|
||||
|
||||
|
||||
async def on_startup():
|
||||
"""Инициализация при запуске"""
|
||||
# Создаём БД и таблицы если нет
|
||||
await db.initialize()
|
||||
print("Бот запущен...")
|
||||
|
||||
|
||||
async def main():
|
||||
"""Запуск бота"""
|
||||
await on_startup()
|
||||
await dp.start_polling(bot)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user