qopscribe/telegram_bot/main.py

28 lines
761 B
Python

import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.client.bot import DefaultBotProperties
from config import load_config
from handlers import register_all_handlers
from services.redis_service import RedisService
async def main():
config = load_config()
bot = Bot(token=config.TELEGRAM_TOKEN, default=DefaultBotProperties(parse_mode="HTML"))
dp = Dispatcher(bot=bot)
redis_service = RedisService(config.REDIS_HOST, config.REDIS_PORT)
register_all_handlers(dp, redis_service, config.BOT_STORAGE_PATH)
try:
await dp.start_polling(bot)
finally:
await bot.session.close()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())