From 3da0c77e87085239525f2ea7519bc862ac6ae708 Mon Sep 17 00:00:00 2001 From: Ocetars Date: Wed, 3 Dec 2025 14:34:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(command):=20=E4=BF=AE=E6=AD=A3=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=86=B2=E7=AA=81=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/star/command_management.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/astrbot/core/star/command_management.py b/astrbot/core/star/command_management.py index b8b6442e1..cf3cd2195 100644 --- a/astrbot/core/star/command_management.py +++ b/astrbot/core/star/command_management.py @@ -131,13 +131,16 @@ async def list_commands() -> list[dict[str, Any]]: config_records = await db_helper.get_command_configs() config_map = {cfg.handler_full_name: cfg for cfg in config_records} - # 检测冲突:按 original_command 分组 + for desc in descriptors: + if cfg := config_map.get(desc.handler_full_name): + _bind_descriptor_with_config(desc, cfg) + + # 检测冲突:按 effective_command 分组 conflict_groups: dict[str, list[CommandDescriptor]] = defaultdict(list) for desc in descriptors: - if desc.original_command: - conflict_groups[desc.original_command].append(desc) + if desc.effective_command: + conflict_groups[desc.effective_command].append(desc) - # 标记冲突的指令 conflict_handler_names: set[str] = set() for key, group in conflict_groups.items(): if len(group) > 1: @@ -146,8 +149,6 @@ async def list_commands() -> list[dict[str, Any]]: result = [] for desc in descriptors: - if cfg := config_map.get(desc.handler_full_name): - _bind_descriptor_with_config(desc, cfg) desc.has_conflict = desc.handler_full_name in conflict_handler_names result.append(_descriptor_to_dict(desc)) return result @@ -164,9 +165,9 @@ async def list_command_conflicts() -> list[dict[str, Any]]: conflicts = defaultdict(list) for desc in descriptors: - if not desc.original_command: + if not desc.effective_command: continue - conflicts[desc.original_command].append(desc) + conflicts[desc.effective_command].append(desc) details = [] for key, group in conflicts.items():