From 110dc9f27bc0dbc463eeb1c5dfa92e87a91fce35 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 25 Oct 2025 10:23:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(plugin):=20=E9=80=82=E9=85=8D=20messag?= =?UTF-8?q?e=20=E5=AF=B9=E8=B1=A1=E7=9A=84=20plain=5Ftext=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 `PlusCommand` 基类中对 `message.plain_text` 的引用更新为 `message.processed_plain_text`,以适配 `Message` 数据结构的变更。同时,优化了群聊判断逻辑,直接使用 `group_id` 进行判断。 --- src/plugin_system/base/plus_command.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugin_system/base/plus_command.py b/src/plugin_system/base/plus_command.py index cfe42e5d9..e442d76c1 100644 --- a/src/plugin_system/base/plus_command.py +++ b/src/plugin_system/base/plus_command.py @@ -66,7 +66,7 @@ class PlusCommand(ABC): # 验证聊天类型限制 if not self._validate_chat_type(): - is_group = hasattr(self.message, "is_group_message") and self.message.is_group_message + is_group = self.message.message_info.group_info.group_id logger.warning( f"{self.log_prefix} 命令 '{self.command_name}' 不支持当前聊天类型: " f"{'群聊' if is_group else '私聊'}, 允许类型: {self.chat_type_allow.value}" @@ -74,11 +74,11 @@ class PlusCommand(ABC): def _parse_command(self) -> None: """解析命令和参数""" - if not hasattr(self.message, "plain_text") or not self.message.plain_text: + if not hasattr(self.message, "processed_plain_text") or not self.message.processed_plain_text: self.args = CommandArgs("") return - plain_text = self.message.plain_text.strip() + plain_text = self.message.processed_plain_text.strip() # 获取配置的命令前缀 prefixes = global_config.command.command_prefixes @@ -152,10 +152,10 @@ class PlusCommand(ABC): def _is_exact_command_call(self) -> bool: """检查是否是精确的命令调用(无参数)""" - if not hasattr(self.message, "plain_text") or not self.message.plain_text: + if not hasattr(self.message, "plain_text") or not self.message.processed_plain_text: return False - plain_text = self.message.plain_text.strip() + plain_text = self.message.processed_plain_text.strip() # 获取配置的命令前缀 prefixes = global_config.command.command_prefixes @@ -435,3 +435,4 @@ def create_plus_command_adapter(plus_command_class): # 兼容旧的命名 PlusCommandAdapter = create_plus_command_adapter +