2025-02-23 14:12:10 +01:00
|
|
|
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():
|
2025-03-03 02:46:27 +01:00
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.INFO,
|
|
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
|
|
)
|
|
|
|
|
2025-02-23 14:12:10 +01:00
|
|
|
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)
|
2025-03-03 02:46:27 +01:00
|
|
|
logging.info(f"Подключение к Redis: {config.REDIS_HOST}:{config.REDIS_PORT}")
|
2025-02-23 14:12:10 +01:00
|
|
|
|
|
|
|
register_all_handlers(dp, redis_service, config.BOT_STORAGE_PATH)
|
|
|
|
|
|
|
|
try:
|
2025-03-03 02:46:27 +01:00
|
|
|
logging.info("Запуск бота")
|
2025-02-23 14:12:10 +01:00
|
|
|
await dp.start_polling(bot)
|
|
|
|
finally:
|
|
|
|
await bot.session.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
asyncio.run(main())
|