astrbot_plugin_imagestudio/adapters/chat_commands.py

33 行
712 B
Python

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

"""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