feat(04-02): integrate AI client into bot lifecycle

Import init_ai_client and call it during post_init callback alongside
database initialization. Logs the configured AI router at startup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikkel Georgsen 2026-01-16 19:07:45 +00:00
parent f1a001f923
commit 821b419271

View file

@ -13,6 +13,7 @@ from telegram.ext import Application, ApplicationBuilder
from moai.bot.config import BotConfig from moai.bot.config import BotConfig
from moai.bot.handlers import register_handlers from moai.bot.handlers import register_handlers
from moai.core.ai_client import init_ai_client
from moai.core.database import close_db, create_tables, init_db from moai.core.database import close_db, create_tables, init_db
# Module-level config reference for post_init callback # Module-level config reference for post_init callback
@ -34,6 +35,9 @@ async def post_init(application: Application) -> None:
await create_tables() await create_tables()
logger.info("Database initialized") logger.info("Database initialized")
init_ai_client(_config)
logger.info("AI client initialized with %s", _config.ai_router)
async def post_shutdown(application: Application) -> None: async def post_shutdown(application: Application) -> None:
"""Clean up database on bot shutdown. """Clean up database on bot shutdown.