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
18 lines
491 B
Python
18 lines
491 B
Python
import os
|
|
from datetime import datetime, timezone
|
|
|
|
from bot.config import settings
|
|
|
|
|
|
async def save_report(
|
|
telegram_id: int,
|
|
channel: str,
|
|
report_md: str,
|
|
) -> str:
|
|
os.makedirs(settings.reports_dir, exist_ok=True)
|
|
ts = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
|
|
filename = f"{telegram_id}_{channel}_{ts}.md"
|
|
path = os.path.join(settings.reports_dir, filename)
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(report_md)
|
|
return path
|