-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
60 lines (51 loc) · 1.91 KB
/
Copy pathbot.py
File metadata and controls
60 lines (51 loc) · 1.91 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
52
53
54
55
56
57
58
59
60
import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.types import BotCommand
from handlers import services, admin # Теперь импортируем оба модуля
from utils.security import Security
# Настройка логирования
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('logs/bot.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
async def main():
"""Запуск бота"""
token = Security.get_token()
if not token:
logger.error("❌ Токен бота не найден в .env")
return
bot = Bot(
token=token,
default=DefaultBotProperties(parse_mode=ParseMode.HTML)
)
dp = Dispatcher()
# Регистрация роутеров
dp.include_router(services.router)
dp.include_router(admin.router) # Добавляем админский роутер
# Команды для меню
await bot.set_my_commands([
BotCommand(command="start", description="🏠 Главное меню"),
BotCommand(command="status", description="📊 Статус сервера"),
BotCommand(command="admin", description="🔐 Админ-панель"),
BotCommand(command="access", description="🔐 Проверить доступ"),
BotCommand(command="help", description="❓ Помощь")
])
logger.info("✅ Бот запущен!")
logger.info(f"👥 Админы: {Security.get_admin_ids()}")
try:
await dp.start_polling(bot)
except KeyboardInterrupt:
logger.info("🛑 Бот остановлен")
finally:
await bot.close()
if __name__ == "__main__":
import types
asyncio.run(main())