astrbot_plugin_imagestudio/adapters/chat_commands.py

34 行
712 B
Python

2026-07-05 22:48:40 +08:00
"""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