33 行
712 B
Python
33 行
712 B
Python
"""Shared chat command parsing helpers."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
|
||
|
||
WORKBENCH_ALIASES = frozenset(
|
||
{
|
||
"imagestudio",
|
||
"image studio",
|
||
"is",
|
||
"图像工作台",
|
||
"打开图像工作台",
|
||
"工作台",
|
||
"打开工作台",
|
||
"生图工作台",
|
||
"打开生图工作台",
|
||
}
|
||
)
|
||
|
||
|
||
def normalize_command_text(text: str) -> str:
|
||
normalized = str(text or "").replace("/", "/").strip().lower()
|
||
return re.sub(r"\s+", " ", normalized)
|
||
|
||
|
||
def command_key(text: str) -> str:
|
||
return normalize_command_text(text).lstrip("/")
|
||
|
||
|
||
def is_workbench_command(text: str) -> bool:
|
||
return command_key(text) in WORKBENCH_ALIASES
|