Two or more cats fixes

This commit is contained in:
nyan404 committed 2026-08-16 22:37:22 +03:00
1 parent d58a3c7e93
commit 9be3e92a5d
2 files changed
+20 -5

No files matched your search

+9 -5
View File
@@ -49,6 +49,8 @@ class VkError(RuntimeError):
def _person(value: str) -> tuple[str, int]:
# Users often copy the example sentence together with its final period.
value = value.strip().rstrip(".!?").strip()
# VK users sometimes add a grouping space inside a long ID: [1 566767].
value = re.sub(r"\[(\d[\d\s]*)\]", lambda match: f"[{match.group(1).replace(' ', '')}]", value)
match = _PERSON_RE.fullmatch(value)
if not match:
raise ValueError("Укажите имя и ID в формате Имя [12345]")
@@ -620,9 +622,12 @@ class BelkiDialog:
f"Ресурсы: {resources}\n"
"Подтвердить? Ответьте «да» или «нет»."
)
extra_line = (
f"Дополнительные котята: {', '.join(f'{name} [{kitten_id}]' for name, kitten_id, _ in state.get('extra_kittens', []))}\n"
if state.get("extra_kittens") else ""
kittens = [(state["kitten_name"], state["kitten_id"])] + [
(name, kitten_id) for name, kitten_id, _ in state.get("extra_kittens", [])
]
kitten_lines = "\n".join(
f"Котёнок {index}: {name} [{kitten_id}]"
for index, (name, kitten_id) in enumerate(kittens, start=1)
)
return (
"Я распознал данные:\n"
@@ -630,9 +635,8 @@ class BelkiDialog:
f"Дата: {state['date']}\n"
f"Время: {state['start']}–{state['end']}\n"
f"Сопровождающий: {state['escort_name']} [{state['escort_id']}]\n"
f"Котёнок: {state['kitten_name']} [{state['kitten_id']}]\n"
f"{kitten_lines}\n"
f"Статус: {state['kitten_independence']}\n"
f"{extra_line}"
"Подтвердить? Ответьте «да» или «нет»."
)