diff --git a/app/belki/vk_bot.py b/app/belki/vk_bot.py index 9c31d75..be86f86 100644 --- a/app/belki/vk_bot.py +++ b/app/belki/vk_bot.py @@ -1181,7 +1181,7 @@ class BelkiDialog: """ Возвращает вопрос для следующего незаполненного поля в форме. - Если все поля заполнены, просит прислать скриншоты. + Если все поля заполнены, просит скриншот только для осмотра. """ for key, prompt in self._ORDERS[state["mode"]]: if not self._has_field(state, key): @@ -1214,11 +1214,14 @@ class BelkiDialog: if state["mode"] == "goal": state["confirm"] = True return self._confirmation(state) - state["awaiting_attachments"] = True - return ( - "Пришлите сюда скриншоты для этого отчёта. " - "После загрузки фотографий снова откройте меню и выберите «Готово»." - ) + if state["mode"] == "inspection": + state["awaiting_attachments"] = True + return ( + "Пришлите один скриншот истории для подтверждения осмотра и ресурсов, " + "затем нажмите «Готово»." + ) + state["confirm"] = True + return self._confirmation(state) @staticmethod def _has_field(state: dict[str, Any], key: str) -> bool: @@ -1315,8 +1318,8 @@ class BelkiDialog: parsed["mode"] = "coaching" self._states[peer_id] = parsed return "Данные распознаны, но не указан статус котёнка. Ответьте: самостоятельно или несамостоятельно." - self._states[peer_id] = {**parsed, "awaiting_attachments": True} - return "Пришлите сюда скриншоты для этого отчёта. После загрузки фотографий снова откройте меню и выберите «Готово»." + self._states[peer_id] = {**parsed, "confirm": True} + return self._confirmation(self._states[peer_id]) if command.lower() in ("/урок", "/тренировка"): state = {"mode": "training"} self._apply_known_profile(peer_id, state) diff --git a/tests/test_vk_conversation.py b/tests/test_vk_conversation.py index 884741f..1656bd0 100644 --- a/tests/test_vk_conversation.py +++ b/tests/test_vk_conversation.py @@ -44,8 +44,7 @@ class VkConversationTests(unittest.TestCase): self.assertIn("сопровождающ", dialog.handle(77, "11:20").lower()) self.assertIn("котён", dialog.handle(77, "Дикая Вишня [1604614]").lower()) self.assertIn("самостоятель", dialog.handle(77, "Серолап [1617140]").lower()) - self.assertIn("скриншот", dialog.handle(77, "самостоятельно").lower()) - confirmation = self.add_screenshot(dialog, 77) + confirmation = dialog.handle(77, "самостоятельно") self.assertIn("подтверд", confirmation.lower()) report = dialog.handle(77, "да") self.assertIn("Баллы белки: 4 балла.", report) @@ -86,7 +85,7 @@ class VkConversationTests(unittest.TestCase): for answer in ("15.08", "11:00", "12:00", "Дикая Вишня [1604614]"): dialog.handle(81, answer) response = dialog.handle(81, "Беззубик [1] самостоятельно, Малыш [2] несамостоятельно") - self.assertIn("скриншот", response.lower()) + self.assertIn("подтверд", response.lower()) def test_bulk_input_is_detected_and_confirmed(self): dialog = BelkiDialog() @@ -94,8 +93,6 @@ class VkConversationTests(unittest.TestCase): 88, "/лу 15.08 11:00 11:20 | Дикая Вишня [1604614] | Серолап [1617140] | самостоятельно", ) - self.assertIn("скриншот", confirmation.lower()) - confirmation = self.add_screenshot(dialog, 88) self.assertIn("распознал", confirmation.lower()) self.assertIn("11:00", confirmation) self.assertIn("подтверд", confirmation.lower()) @@ -141,7 +138,7 @@ class VkConversationTests(unittest.TestCase): response = dialog.handle(101, "ЛУ") self.assertIn("самостоятель", response.lower()) response = dialog.handle(101, "самостоятельно") - self.assertIn("скриншот", response.lower()) + self.assertIn("подтверд", response.lower()) def test_natural_bulk_input_extracts_people_before_time_range(self): for text in ( @@ -205,14 +202,12 @@ class VkConversationTests(unittest.TestCase): dialog = BelkiDialog() self.assertIn("сопровождающ", dialog.handle(102, "/урок").lower()) self.assertIn("котён", dialog.handle(102, "Дикая Вишня [1604614]").lower()) - self.assertIn("скриншот", dialog.handle(102, "Серолап [1617140]").lower()) - confirmation = self.add_screenshot(dialog, 102) + confirmation = dialog.handle(102, "Серолап [1617140]") + self.assertIn("подтверд", confirmation.lower()) self.assertIn("25", confirmation) self.assertIn("#урок", dialog.handle(102, "да")) natural = dialog.handle(103, "урок Дикая Вишня 1604614 Серолап 1617140") - self.assertIn("скриншот", natural.lower()) - natural = self.add_screenshot(dialog, 103) self.assertIn("25", natural) self.assertIn("подтверд", natural.lower()) @@ -256,8 +251,7 @@ class VkConversationTests(unittest.TestCase): dialog.queue_attachments(107, [{"type": "photo", "url": "https://example.test/photo.jpg"}]) dialog.handle(107, "/урок") dialog.handle(107, "Белка [1]") - self.assertIn("скриншот", dialog.handle(107, "Котёнок [2]").lower()) - confirmation = self.add_screenshot(dialog, 107) + confirmation = dialog.handle(107, "Котёнок [2]") self.assertIn("подтверд", confirmation.lower()) self.assertEqual(dialog._states[107]["attachments"][0]["url"], "https://example.test/photo.jpg") @@ -265,11 +259,8 @@ class VkConversationTests(unittest.TestCase): dialog = BelkiDialog() dialog.handle(109, "/урок") dialog.handle(109, "Белка [1]") - dialog.handle(109, "Котёнок [2]") - dialog.queue_attachments(109, [{"type": "photo", "attachment": f"photo1_{index}", "url": f"https://example.test/{index}.jpg"} for index in range(6)]) - confirmation = dialog.handle(109, "готово") + confirmation = dialog.handle(109, "Котёнок [2]") self.assertIn("подтверд", confirmation.lower()) - self.assertEqual(len(dialog._states[109]["attachments"]), 6) def test_photo_is_mirrored_before_history_save(self): mirrored = [] @@ -283,7 +274,6 @@ class VkConversationTests(unittest.TestCase): dialog.handle(108, "/урок") dialog.handle(108, "Белка [1]") dialog.handle(108, "Котёнок [2]") - self.add_screenshot(dialog, 108) dialog.handle(108, "да") self.assertEqual(mirrored[0], "https://vk.example/photo.jpg") @@ -361,14 +351,13 @@ class VkConversationTests(unittest.TestCase): dialog.handle(501, "/лу") for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"): dialog.handle(501, answer) - self.assertIn("скриншот", dialog.handle(501, "Самостоятельный").lower()) - confirmation = self.add_screenshot(dialog, 501) + confirmation = dialog.handle(501, "Самостоятельный") self.assertIn("самостоятельно", confirmation.lower()) dialog.handle(502, "/лу") for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"): dialog.handle(502, answer) - self.assertIn("скриншот", dialog.handle(502, "несам").lower()) + self.assertIn("подтверд", dialog.handle(502, "несам").lower()) def test_compact_zu_command_accepts_independence_variants(self): for value in ( @@ -403,7 +392,7 @@ class VkConversationTests(unittest.TestCase): self.assertEqual(labels[:2], ["Сам", "Несам"]) dialog.handle(503, "сам") labels = [button["action"]["label"] for row in dialog.keyboard_for(503)["buttons"] for button in row] - self.assertIn("Готово", labels) + self.assertEqual(labels, ["Да", "Нет"]) def test_quick_buttons_cover_safe_choices(self): dialog = BelkiDialog()