-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (43 loc) · 1.36 KB
/
main.py
File metadata and controls
51 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# main.py
import asyncio
import logging
import os
from aiogram import Bot, Dispatcher
from config.config import BOT_TOKEN
from database.database import init_db
from handlers import admin, monitoring, services, system, network, backup, start_help, user_management
from utils.notifications import SystemMonitor
# Настройка логирования
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('bot.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
async def main():
logger.info("Инициализация базы данных...")
init_db()
logger.info("Запуск бота...")
bot = Bot(token=BOT_TOKEN)
dp = Dispatcher()
# Добавляем роутеры
dp.include_routers(
start_help.router,
admin.router,
monitoring.router,
services.router,
system.router,
network.router,
backup.router,
user_management.router
)
# Запускаем мониторинг в отдельной задаче
monitor = SystemMonitor(bot)
asyncio.create_task(monitor.start_monitoring())
logger.info("Бот запущен и готов к работе")
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())