Fixes for dialoge

This commit is contained in:
nyan404 committed 2026-08-16 20:37:59 +03:00
1 parent b1f47a5c18
commit 6db39f0d51
3 files changed
+27 -11

No files matched your search

+2 -2
View File
@@ -74,9 +74,9 @@ deploy:
--from-literal=BELKI_ADMIN_PASSWORD="$BELKI_ADMIN_PASSWORD" \ --from-literal=BELKI_ADMIN_PASSWORD="$BELKI_ADMIN_PASSWORD" \
--dry-run=client -o yaml | kubectl apply -f - --dry-run=client -o yaml | kubectl apply -f -
- > - >
sed -E "s#(image: reg.nyan404.ru/cwshed-clone/belki:)[^[:space:]]+#\\1$DOCKER_IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA#g" deploy/k8s/production.yaml | kubectl apply -f - sed -E "s#image: reg.nyan404.ru/cwshed-clone/belki:[^[:space:]]+#image: $DOCKER_IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA#g" deploy/k8s/production.yaml | kubectl apply -f -
- > - >
sed -E "s#(image: reg.nyan404.ru/cwshed:)[^[:space:]]+#\\1$GATEWAY_IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA#g" deploy/k8s/gateway.yaml | kubectl apply -f - sed -E "s#image: reg.nyan404.ru/cwshed:[^[:space:]]+#image: $GATEWAY_IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA#g" deploy/k8s/gateway.yaml | kubectl apply -f -
- kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-postgres --timeout=180s - kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-postgres --timeout=180s
- kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-web --timeout=180s - kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-web --timeout=180s
- kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-bot --timeout=180s - kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-bot --timeout=180s
+16 -8
View File
@@ -605,8 +605,10 @@ class BelkiDialog:
return "Похоже, здесь данные для ЛУ или ЗУ. Укажите навык: ЛУ или ЗУ." return "Похоже, здесь данные для ЛУ или ЗУ. Укажите навык: ЛУ или ЗУ."
return None return None
if command.lower() in ("/лу", "/зу"): if command.lower() in ("/лу", "/зу"):
self._states[peer_id] = {"mode": "coaching", "skill": "ЛУ" if command.lower() == "/лу" else "ЗУ"} state = {"mode": "coaching", "skill": "ЛУ" if command.lower() == "/лу" else "ЗУ"}
return self._ask_next(self._states[peer_id]) self._apply_known_profile(peer_id, state)
self._states[peer_id] = state
return self._ask_next(state)
if command.lower().startswith(("/лу ", "/лазание ", "/зу ", "/зоркость ")): if command.lower().startswith(("/лу ", "/лазание ", "/зу ", "/зоркость ")):
try: try:
parsed = parse_text_command(command) parsed = parse_text_command(command)
@@ -621,8 +623,10 @@ class BelkiDialog:
self._states[peer_id] = {**parsed, "awaiting_attachments": True} self._states[peer_id] = {**parsed, "awaiting_attachments": True}
return "Пришлите сюда скриншоты для этого отчёта. После загрузки всех фотографий нажмите «Готово»." return "Пришлите сюда скриншоты для этого отчёта. После загрузки всех фотографий нажмите «Готово»."
if command.lower() in ("/урок", "/тренировка"): if command.lower() in ("/урок", "/тренировка"):
self._states[peer_id] = {"mode": "training"} state = {"mode": "training"}
return self._ask_next(self._states[peer_id]) self._apply_known_profile(peer_id, state)
self._states[peer_id] = state
return self._ask_next(state)
if command.lower() in ("/осмотр", "/осмотры"): if command.lower() in ("/осмотр", "/осмотры"):
state = {"mode": "inspection"} state = {"mode": "inspection"}
self._apply_known_profile(peer_id, state) self._apply_known_profile(peer_id, state)
@@ -639,11 +643,15 @@ class BelkiDialog:
return None return None
def _apply_known_profile(self, actor_id: int, state: dict[str, Any]) -> None: def _apply_known_profile(self, actor_id: int, state: dict[str, Any]) -> None:
"""Use the author's saved character for self-referential inspections.""" """Use the author's saved character as the default report participant."""
if state.get("mode") != "inspection" or self._has_field(state, "character"):
return
profile = self.identity_directory.profile(actor_id=actor_id) profile = self.identity_directory.profile(actor_id=actor_id)
if profile: if not profile:
return
if state.get("mode") in ("coaching", "training") and not self._has_field(state, "escort"):
state["escort_name"] = profile.name
state["escort_id"] = profile.character_id
state["escort"] = True
elif state.get("mode") == "inspection" and not self._has_field(state, "character"):
state["character_name"] = profile.name state["character_name"] = profile.name
state["character_id"] = profile.character_id state["character_id"] = profile.character_id
+9 -1
View File
@@ -177,10 +177,18 @@ class VkConversationTests(unittest.TestCase):
self.assertIn("Привет, Дикая Вишня", welcome) self.assertIn("Привет, Дикая Вишня", welcome)
self.assertIn("/осмотр", welcome) self.assertIn("/осмотр", welcome)
self.assertIn("дат", dialog.handle(500, "/лу", user_id=700).lower()) self.assertIn("дат", dialog.handle(500, "/лу", user_id=700).lower())
restarted = BelkiDialog(IdentityDirectory(db_path=f"{directory}/identities.sqlite3"), onboarding=True) restarted = BelkiDialog(IdentityDirectory(db_path=f"{directory}/identities.sqlite3"), onboarding=True)
self.assertIn("дат", restarted.handle(500, "/лу", user_id=700).lower()) self.assertIn("дат", restarted.handle(500, "/лу", user_id=700).lower())
def test_saved_author_is_used_as_coaching_escort(self):
identities = IdentityDirectory()
identities.remember_profile(actor_id=700, name="Дикая Вишня", character_id=1604614)
dialog = BelkiDialog(identities)
response = dialog.handle(501, "/лу", user_id=700)
self.assertIn("дат", response.lower())
self.assertNotIn("сопровождающего", response.lower())
self.assertEqual(dialog._states[700]["escort_id"], 1604614)
def test_inspection_reuses_onboarded_author_character(self): def test_inspection_reuses_onboarded_author_character(self):
with TemporaryDirectory() as directory: with TemporaryDirectory() as directory:
identities = IdentityDirectory(db_path=f"{directory}/identities.sqlite3") identities = IdentityDirectory(db_path=f"{directory}/identities.sqlite3")