refactor(telegram): every user-facing string lives in TelegramTexts with English defaults
This commit is contained in:
1 parent
cae2ed4161
commit
90d0fb0f00
6 files changed
+227
-120
No files matched your search
@@ -7,8 +7,10 @@ import re
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
from beaver_gateway.frontends.telegram.texts import TOOL_LABELS
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Mapping
|
||||
|
||||
__all__ = ["LIMIT", "chunks", "status_label", "to_html", "to_html_tail"]
|
||||
|
||||
@@ -37,27 +39,6 @@ _ITALIC_U = re.compile(r"(?<![\w_])_(?!\s)(.+?)(?<!\s)_(?![\w_])")
|
||||
_STRIKE = re.compile(r"~~(.+?)~~")
|
||||
_SPOILER = re.compile(r"\|\|(.+?)\|\|")
|
||||
|
||||
_LABELS: dict[str, str] = {
|
||||
"Read": "читаю vault",
|
||||
"Glob": "ищу файлы",
|
||||
"Grep": "ищу в vault",
|
||||
"Edit": "правлю файл",
|
||||
"Write": "пишу файл",
|
||||
"MultiEdit": "правлю файлы",
|
||||
"Bash": "выполняю команду",
|
||||
"WebSearch": "ищу в сети",
|
||||
"WebFetch": "читаю страницу",
|
||||
"Task": "запустил сабагента",
|
||||
"Agent": "запустил сабагента",
|
||||
"AskUserQuestion": "спрашиваю",
|
||||
"TodoWrite": "планирую",
|
||||
"Skill": "открываю скилл",
|
||||
"mcp__gateway__spawn": "открываю разговор",
|
||||
"mcp__gateway__read_conversation": "читаю разговор",
|
||||
"mcp__gateway__say": "говорю",
|
||||
"mcp__gateway__schedule": "ставлю напоминание",
|
||||
"mcp__gateway__inject": "передаю в другой разговор",
|
||||
}
|
||||
|
||||
_Kind = Literal["fence", "quote", "table", "text"]
|
||||
|
||||
@@ -100,8 +81,12 @@ def chunks(text: str, limit: int = LIMIT) -> list[str]:
|
||||
return out
|
||||
|
||||
|
||||
def status_label(name: str, tool_input: dict[str, Any] | None = None) -> str:
|
||||
label = _LABELS.get(name)
|
||||
def status_label(
|
||||
name: str,
|
||||
tool_input: dict[str, Any] | None = None,
|
||||
labels: Mapping[str, str] | None = None,
|
||||
) -> str:
|
||||
label = (labels if labels is not None else TOOL_LABELS).get(name)
|
||||
if label is not None:
|
||||
return label
|
||||
if name.startswith("mcp__"):
|
||||
|
||||
Reference in new issue
Block a user