feat(vk): relax explicit coaching schedule format
This commit is contained in:
1 parent
cf99a8da35
commit
2a21723237
3 files changed
+11
-1
No files matched your search
+6
-1
@@ -290,7 +290,12 @@ def parse_text_command(text: str, *, _validation_skill: str | None = None) -> di
|
|||||||
parts = [part.strip() for part in body.split("|")]
|
parts = [part.strip() for part in body.split("|")]
|
||||||
if len(parts) < 3:
|
if len(parts) < 3:
|
||||||
raise ValueError("Формат: /лу ДД.ММ HH:MM HH:MM | Имя [ID] | Котёнок [ID] | статус")
|
raise ValueError("Формат: /лу ДД.ММ HH:MM HH:MM | Имя [ID] | Котёнок [ID] | статус")
|
||||||
date, start, end = parts[0].split()
|
schedule = _normalise_natural_text(parts[0])
|
||||||
|
date_match = _DATE_RE.search(schedule)
|
||||||
|
times = _TIME_RE.findall(schedule)
|
||||||
|
if not date_match or len(times) < 2:
|
||||||
|
raise ValueError("Укажите дату и время, например: 15.08 11:00–11:20.")
|
||||||
|
date, start, end = date_match.group("date"), times[0], times[1]
|
||||||
escort_name, escort_id = _person(parts[1])
|
escort_name, escort_id = _person(parts[1])
|
||||||
kitten_entries = [_kitten_entry(item) for item in parts[2].split(",") if item.strip()]
|
kitten_entries = [_kitten_entry(item) for item in parts[2].split(",") if item.strip()]
|
||||||
if not kitten_entries:
|
if not kitten_entries:
|
||||||
|
|||||||
@@ -87,6 +87,7 @@
|
|||||||
- 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: the explicit `/осмотр` command now accepts both natural orders for its first fields: `дупло 6` and `6 дупло`.
|
||||||
|
- 2026-08-25: explicit `/лу` and `/зу` commands accept a time range with a dash and written Russian dates in their schedule segment, while still requiring exactly two valid clock values.
|
||||||
- 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.
|
||||||
|
|||||||
@@ -286,6 +286,10 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
self.assertEqual(parsed["inspections"], 6)
|
self.assertEqual(parsed["inspections"], 6)
|
||||||
self.assertEqual(parsed["resources"], [["паутина", 2]])
|
self.assertEqual(parsed["resources"], [["паутина", 2]])
|
||||||
|
|
||||||
|
def test_explicit_coaching_command_accepts_a_time_range_and_written_date(self):
|
||||||
|
parsed = parse_text_command("/лу 24 августа 21:00–22:00 | Белка [1] | Ученик [2] | сам")
|
||||||
|
self.assertEqual((parsed["date"], parsed["start"], parsed["end"]), ("24.08", "21:00", "22:00"))
|
||||||
|
|
||||||
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 паук"
|
||||||
|
|||||||
Reference in new issue
Block a user