feat(vk): accept flexible inspection command order

This commit is contained in:
nyan404 committed 2026-08-25 04:13:24 +03:00
1 parent af5c047e27
commit cf99a8da35
3 files changed
+14 -2

No files matched your search

+7 -2
View File
@@ -333,8 +333,13 @@ def parse_text_command(text: str, *, _validation_skill: str | None = None) -> di
parts = head_parts.split() parts = head_parts.split()
if len(parts) < 3: if len(parts) < 3:
raise ValueError("Формат: /осмотр дупло N Имя [ID] | ресурс=количество") raise ValueError("Формат: /осмотр дупло N Имя [ID] | ресурс=количество")
place, inspections = parts[0], int(parts[1]) if parts[0].casefold() in ("дупло", "расщелина") and parts[1].isdigit():
identity_text = " ".join(parts[2:]).strip() 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: try:
character_name, character_id = _person(identity_text) character_name, character_id = _person(identity_text)
identity_fields = {"character_name": character_name, "character_id": character_id} identity_fields = {"character_name": character_name, "character_id": character_id}
+1
View File
@@ -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: 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: 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: 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: 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: `/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. - 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.
+6
View File
@@ -280,6 +280,12 @@ class VkConversationTests(unittest.TestCase):
self.assertEqual(inspected["fields"]["character_id"], 1617140) self.assertEqual(inspected["fields"]["character_id"], 1617140)
self.assertIn("имени", " ".join(inspected["questions"]).lower()) 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): def test_natural_inspection_does_not_confuse_date_or_id_with_count(self):
inspected = inspect_bulk_text( inspected = inspect_bulk_text(
"24.08 осмотр расщелина: 6 раз; персонаж Серолап id 1 617 140; +2 паутина, +1 паук" "24.08 осмотр расщелина: 6 раз; персонаж Серолап id 1 617 140; +2 паутина, +1 паук"