feat(vk): accept flexible inspection command order
This commit is contained in:
1 parent
af5c047e27
commit
cf99a8da35
3 files changed
+14
-2
No files matched your search
+7
-2
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user