-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (29 loc) · 994 Bytes
/
main.py
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
import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.filters import ExceptionTypeFilter
from aiogram_dialog import setup_dialogs
from aiogram_dialog.api.exceptions import UnknownIntent
from config_data.config import load_config
from aiogram.fsm.storage.redis import RedisStorage, Redis
import handlers.handlers
redis = Redis(host="localhost")
async def main():
logging.basicConfig(
level=logging.INFO,
format='%(filename)s:%(lineno)d #%(levelname)-8s '
'[%(asctime)s] - %(name)s - %(message)s'
)
config = load_config()
storage = RedisStorage(redis=redis)
bot = Bot(token=config.tg_bot.token)
dp = Dispatcher()
dp.include_router(handlers.handlers.router)
dp.errors.register(
handlers.handlers.on_unknown_intent,
ExceptionTypeFilter(UnknownIntent),
)
setup_dialogs(dp)
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot)
asyncio.run(main())