Fixes for dialoge
This commit is contained in:
1 parent
b1f47a5c18
commit
6db39f0d51
3 files changed
+27
-11
No files matched your search
+2
-2
@@ -74,9 +74,9 @@ deploy:
|
||||
--from-literal=BELKI_ADMIN_PASSWORD="$BELKI_ADMIN_PASSWORD" \
|
||||
--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-web --timeout=180s
|
||||
- kubectl -n "$KUBE_NAMESPACE" rollout status deployment/belki-bot --timeout=180s
|
||||
|
||||
+16
-8
@@ -605,8 +605,10 @@ class BelkiDialog:
|
||||
return "Похоже, здесь данные для ЛУ или ЗУ. Укажите навык: ЛУ или ЗУ."
|
||||
return None
|
||||
if command.lower() in ("/лу", "/зу"):
|
||||
self._states[peer_id] = {"mode": "coaching", "skill": "ЛУ" if command.lower() == "/лу" else "ЗУ"}
|
||||
return self._ask_next(self._states[peer_id])
|
||||
state = {"mode": "coaching", "skill": "ЛУ" if command.lower() == "/лу" else "ЗУ"}
|
||||
self._apply_known_profile(peer_id, state)
|
||||
self._states[peer_id] = state
|
||||
return self._ask_next(state)
|
||||
if command.lower().startswith(("/лу ", "/лазание ", "/зу ", "/зоркость ")):
|
||||
try:
|
||||
parsed = parse_text_command(command)
|
||||
@@ -621,8 +623,10 @@ class BelkiDialog:
|
||||
self._states[peer_id] = {**parsed, "awaiting_attachments": True}
|
||||
return "Пришлите сюда скриншоты для этого отчёта. После загрузки всех фотографий нажмите «Готово»."
|
||||
if command.lower() in ("/урок", "/тренировка"):
|
||||
self._states[peer_id] = {"mode": "training"}
|
||||
return self._ask_next(self._states[peer_id])
|
||||
state = {"mode": "training"}
|
||||
self._apply_known_profile(peer_id, state)
|
||||
self._states[peer_id] = state
|
||||
return self._ask_next(state)
|
||||
if command.lower() in ("/осмотр", "/осмотры"):
|
||||
state = {"mode": "inspection"}
|
||||
self._apply_known_profile(peer_id, state)
|
||||
@@ -639,11 +643,15 @@ class BelkiDialog:
|
||||
return None
|
||||
|
||||
def _apply_known_profile(self, actor_id: int, state: dict[str, Any]) -> None:
|
||||
"""Use the author's saved character for self-referential inspections."""
|
||||
if state.get("mode") != "inspection" or self._has_field(state, "character"):
|
||||
return
|
||||
"""Use the author's saved character as the default report participant."""
|
||||
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_id"] = profile.character_id
|
||||
|
||||
|
||||
@@ -177,10 +177,18 @@ class VkConversationTests(unittest.TestCase):
|
||||
self.assertIn("Привет, Дикая Вишня", welcome)
|
||||
self.assertIn("/осмотр", welcome)
|
||||
self.assertIn("дат", dialog.handle(500, "/лу", user_id=700).lower())
|
||||
|
||||
restarted = BelkiDialog(IdentityDirectory(db_path=f"{directory}/identities.sqlite3"), onboarding=True)
|
||||
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):
|
||||
with TemporaryDirectory() as directory:
|
||||
identities = IdentityDirectory(db_path=f"{directory}/identities.sqlite3")
|
||||
|
||||
Reference in new issue
Block a user