From 6ba1c51cd21916643b6cc7e9f1d99e7d59c8e032 Mon Sep 17 00:00:00 2001 From: Ocetars Date: Tue, 2 Dec 2025 20:55:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=E5=91=BD=E4=BB=A4=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=9B=86=E6=88=90=E5=88=B0=20Star=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/star/filter/command.py | 1 + astrbot/core/star/filter/command_group.py | 1 + astrbot/core/star/star_handler.py | 4 ++++ astrbot/core/star/star_manager.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/astrbot/core/star/filter/command.py b/astrbot/core/star/filter/command.py index 2a9868fdc..51ad5f089 100755 --- a/astrbot/core/star/filter/command.py +++ b/astrbot/core/star/filter/command.py @@ -40,6 +40,7 @@ class CommandFilter(HandlerFilter): ): self.command_name = command_name self.alias = alias if alias else set() + self._original_command_name = command_name self.parent_command_names = ( parent_command_names if parent_command_names is not None else [""] ) diff --git a/astrbot/core/star/filter/command_group.py b/astrbot/core/star/filter/command_group.py index e1c2efb22..4cbd2c007 100755 --- a/astrbot/core/star/filter/command_group.py +++ b/astrbot/core/star/filter/command_group.py @@ -18,6 +18,7 @@ class CommandGroupFilter(HandlerFilter): ): self.group_name = group_name self.alias = alias if alias else set() + self._original_group_name = group_name self.sub_command_filters: list[CommandFilter | CommandGroupFilter] = [] self.custom_filter_list: list[CustomFilter] = [] self.parent_group = parent_group diff --git a/astrbot/core/star/star_handler.py b/astrbot/core/star/star_handler.py index 141f9180a..69a779b41 100644 --- a/astrbot/core/star/star_handler.py +++ b/astrbot/core/star/star_handler.py @@ -40,6 +40,8 @@ class StarHandlerRegistry(Generic[T]): # 过滤事件类型 if handler.event_type != event_type: continue + if not handler.enabled: + continue # 过滤启用状态 if only_activated: plugin = star_map.get(handler.handler_module_path) @@ -139,6 +141,8 @@ class StarHandlerMetadata: extras_configs: dict = field(default_factory=dict) """插件注册的一些其他的信息, 如 priority 等""" + enabled: bool = True + def __lt__(self, other: StarHandlerMetadata): """定义小于运算符以支持优先队列""" return self.extras_configs.get("priority", 0) < other.extras_configs.get( diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index abdedc249..f92cda9e7 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -23,6 +23,7 @@ from astrbot.core.utils.astrbot_path import ( from astrbot.core.utils.io import remove_dir from . import StarMetadata +from .command_management import sync_command_configs from .context import Context from .filter.permission import PermissionType, PermissionTypeFilter from .star import star_map, star_registry @@ -618,6 +619,7 @@ class PluginManager: # 清除 pip.main 导致的多余的 logging handlers for handler in logging.root.handlers[:]: logging.root.removeHandler(handler) + await sync_command_configs() if not fail_rec: return True, None