Add multi-user features: i18n, payments, multi-model AI, focus areas
Replace single report type with composable analysis: depth levels (basic/standard/full) + focus area multi-select (psychology, business, marketing, content, audience, sentiment). Multi-step inline keyboard flow guides users through selection. - i18n: English + Russian, auto-detect from Telegram, /lang override - AI providers: Anthropic + OpenRouter via AIClient abstraction - Telegram Stars payments with per-depth pricing and free trial - SQLite (aiosqlite) for users, analyses, payments tracking - User middleware for auto-registration and language detection - Report persistence: save .md locally, offer file download - New commands: /features, /prices, /lang - Composable prompt system: depth modifiers + focus area fragments
This commit is contained in:
parent
8a84145e15
commit
c30b7e4675
27 changed files with 1155 additions and 280 deletions
|
|
@ -6,7 +6,9 @@ from aiogram import Bot, Dispatcher
|
|||
from telethon import TelegramClient
|
||||
|
||||
from bot.config import settings
|
||||
from bot.handlers import analyze, start
|
||||
from bot.db.engine import get_db, close_db
|
||||
from bot.handlers import analyze, features, lang, payment, prices, start
|
||||
from bot.middleware.user_middleware import UserMiddleware
|
||||
|
||||
SESSION_PATH = "/app/data/analyzer_session"
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ async def login() -> None:
|
|||
|
||||
|
||||
async def main() -> None:
|
||||
# Init database
|
||||
await get_db()
|
||||
log.info("Database initialized")
|
||||
|
||||
telethon_client = TelegramClient(
|
||||
SESSION_PATH,
|
||||
settings.telegram_api_id,
|
||||
|
|
@ -46,11 +52,19 @@ async def main() -> None:
|
|||
log.info("Telethon client started")
|
||||
|
||||
bot = Bot(token=settings.bot_token)
|
||||
# Attach telethon client to bot instance for handler access
|
||||
bot._telethon_client = telethon_client # type: ignore[attr-defined]
|
||||
|
||||
dp = Dispatcher()
|
||||
|
||||
# Register middleware
|
||||
dp.update.middleware(UserMiddleware())
|
||||
|
||||
# Register routers — payment.pre_checkout must come before analyze
|
||||
dp.include_router(start.router)
|
||||
dp.include_router(lang.router)
|
||||
dp.include_router(features.router)
|
||||
dp.include_router(prices.router)
|
||||
dp.include_router(payment.router)
|
||||
dp.include_router(analyze.router)
|
||||
|
||||
log.info("Starting bot polling...")
|
||||
|
|
@ -58,6 +72,7 @@ async def main() -> None:
|
|||
await dp.start_polling(bot)
|
||||
finally:
|
||||
await telethon_client.disconnect()
|
||||
await close_db()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue