-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
48 lines (35 loc) · 1.56 KB
/
bot.py
File metadata and controls
48 lines (35 loc) · 1.56 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
from handlers import user_handlers, admin_handlers, other_handlers, streamer_handlers
from aiogram.fsm.storage.memory import MemoryStorage
from config_data.config import Config, load_config
from keyboard.set_menu import set_main_menu
from aiogram import Bot, Dispatcher
import asyncio
import logging
logger = logging.getLogger(__name__)
async def main():
# Конфигурируем логирование
logging.basicConfig(
level=logging.INFO,
format='%(filename)s:%(lineno)d #%(levelname)-8s '
'[%(asctime)s] - %(name)s - %(message)s')
# Выводим в консоль информацию о начале запуска бота
logger.info('Starting bot')
# Загружаем конфиг в переменную config
config: Config = load_config()
storage = MemoryStorage()
# Инициализируем бот и диспетчер
bot = Bot(token=config.tg_bot.token,
parse_mode='HTML')
dp = Dispatcher(storage=storage)
# Регистрируем роутера в диспетчере
dp.include_router(streamer_handlers.router)
dp.include_router(admin_handlers.router)
dp.include_router(user_handlers.router)
dp.include_router(other_handlers.router)
# Настраиваем кнопку Menu
await set_main_menu(bot)
# Пропускаем накопившиеся апдейты и запускаем polling
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())