File size: 999 Bytes
e35e6bc |
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 |
from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.fsm.storage.base import DefaultKeyBuilder
from aiogram.fsm.storage.redis import RedisStorage
from aiogram.utils.i18n.core import I18n
from aiohttp import web
from redis.asyncio import ConnectionPool, Redis
from bot.core.config import DEFAULT_LOCALE, I18N_DOMAIN, LOCALES_DIR, settings
app = web.Application()
token = settings.BOT_TOKEN
bot = Bot(token=token, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
redis_client = Redis(
connection_pool=ConnectionPool(
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
password=settings.REDIS_PASS,
db=0,
),
)
storage = RedisStorage(
redis=redis_client,
key_builder=DefaultKeyBuilder(with_bot_id=True),
)
dp = Dispatcher(storage=storage)
i18n: I18n = I18n(path=LOCALES_DIR, default_locale=DEFAULT_LOCALE, domain=I18N_DOMAIN)
DEBUG = settings.DEBUG
|