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
30 lines
670 B
Python
30 lines
670 B
Python
from enum import Enum
|
|
|
|
from bot.i18n.strings import STRINGS
|
|
|
|
|
|
class Lang(Enum):
|
|
EN = "en"
|
|
RU = "ru"
|
|
|
|
|
|
def t(key: str, lang: Lang | str = Lang.EN, **kwargs: object) -> str:
|
|
if isinstance(lang, Lang):
|
|
lang_str = lang.value
|
|
elif lang in ("en", "ru"):
|
|
lang_str = lang
|
|
else:
|
|
lang_str = "en"
|
|
entry = STRINGS.get(key)
|
|
if not entry:
|
|
return key
|
|
text = entry.get(lang_str, entry.get("en", key))
|
|
if kwargs:
|
|
text = text.format(**kwargs)
|
|
return text
|
|
|
|
|
|
def detect_lang(language_code: str | None) -> Lang:
|
|
if language_code and language_code.startswith("ru"):
|
|
return Lang.RU
|
|
return Lang.EN
|