diff --git a/app/belki/vk_bot.py b/app/belki/vk_bot.py index 2aad881..a5a4e4a 100644 --- a/app/belki/vk_bot.py +++ b/app/belki/vk_bot.py @@ -333,8 +333,13 @@ def parse_text_command(text: str, *, _validation_skill: str | None = None) -> di parts = head_parts.split() if len(parts) < 3: raise ValueError("Формат: /осмотр дупло N Имя [ID] | ресурс=количество") - place, inspections = parts[0], int(parts[1]) - identity_text = " ".join(parts[2:]).strip() + if parts[0].casefold() in ("дупло", "расщелина") and parts[1].isdigit(): + place, inspections, identity_parts = parts[0].casefold(), int(parts[1]), parts[2:] + elif parts[0].isdigit() and parts[1].casefold() in ("дупло", "расщелина"): + place, inspections, identity_parts = parts[1].casefold(), int(parts[0]), parts[2:] + else: + raise ValueError("Укажите место и количество осмотров, например: дупло 6 или 6 дупло.") + identity_text = " ".join(identity_parts).strip() try: character_name, character_id = _person(identity_text) identity_fields = {"character_name": character_name, "character_id": character_id} diff --git a/structure_and_data.md b/structure_and_data.md index f8014bd..5cfaf54 100644 --- a/structure_and_data.md +++ b/structure_and_data.md @@ -86,6 +86,7 @@ - 2026-08-25: nested public API values now use the same strict numeric conversion as top-level fields: booleans cannot become IDs or amounts, malformed resources are rejected, and resource rows are bounded before conversion. - 2026-08-25: report copy now uses a plural construction for several kittens, normative `провёл(-ла)` for lessons, and a readable empty-resource line instead of a standalone `0`. - 2026-08-25: free-form inspection parsing now distinguishes a labelled count (or a count immediately after the place) from date fragments and character IDs; it also understands explicit character labels and both `+N ресурс` and legacy `ресурс=N` loot notation. +- 2026-08-25: the explicit `/осмотр` command now accepts both natural orders for its first fields: `дупло 6` and `6 дупло`. - 2026-08-25: free-form coaching input additionally normalizes Russian written month names and common abbreviations (for example, `24 августа` and `1-го сент`) into the existing `ДД.ММ` date field. - 2026-08-25: `/api/admin/auth` now permits five password attempts per source in a rolling 15-minute window and clears that local budget after a successful sign-in. Edge rate limiting and TLS remain required deployment controls. - 2026-08-25: server-memory admin sessions now expire after 12 hours and are capped at 100 active tokens; the browser cookie carries the same maximum age. diff --git a/tests/test_vk_conversation.py b/tests/test_vk_conversation.py index e169cd8..b60f74b 100644 --- a/tests/test_vk_conversation.py +++ b/tests/test_vk_conversation.py @@ -280,6 +280,12 @@ class VkConversationTests(unittest.TestCase): self.assertEqual(inspected["fields"]["character_id"], 1617140) self.assertIn("имени", " ".join(inspected["questions"]).lower()) + def test_explicit_inspection_command_accepts_count_before_place(self): + parsed = parse_text_command("/осмотр 6 расщелина Серолап [1617140] | паутина=2") + self.assertEqual(parsed["place"], "расщелина") + self.assertEqual(parsed["inspections"], 6) + self.assertEqual(parsed["resources"], [["паутина", 2]]) + def test_natural_inspection_does_not_confuse_date_or_id_with_count(self): inspected = inspect_bulk_text( "24.08 осмотр расщелина: 6 раз; персонаж Серолап id 1 617 140; +2 паутина, +1 паук"