From 53d09129b4bdfbc487ae2a45221a2b19e0da7227 Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Fri, 8 Mar 2024 21:10:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=91=BD=E4=BB=A4=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=9A=84command=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20(#713)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/pipeline/process/handlers/command.py | 9 ++++----- pkg/plugin/manager.py | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/pipeline/process/handlers/command.py b/pkg/pipeline/process/handlers/command.py index 7a669c50..7179fd39 100644 --- a/pkg/pipeline/process/handlers/command.py +++ b/pkg/pipeline/process/handlers/command.py @@ -19,15 +19,16 @@ class CommandHandler(handler.MessageHandler): """处理 """ - event_class = events.PersonCommandSent if query.launcher_type == core_entities.LauncherTypes.PERSON else events.GroupCommandSent - + command_text = str(query.message_chain).strip()[1:] privilege = 1 if f'{query.launcher_type.value}_{query.launcher_id}' in self.ap.system_cfg.data['admin-sessions']: privilege = 2 - spt = str(query.message_chain).strip().split(' ') + spt = command_text.split(' ') + + event_class = events.PersonCommandSent if query.launcher_type == core_entities.LauncherTypes.PERSON else events.GroupCommandSent event_ctx = await self.ap.plugin_mgr.emit_event( event=event_class( @@ -73,8 +74,6 @@ class CommandHandler(handler.MessageHandler): session = await self.ap.sess_mgr.get_session(query) - command_text = str(query.message_chain).strip()[1:] - async for ret in self.ap.cmd_mgr.execute( command_text=command_text, query=query, diff --git a/pkg/plugin/manager.py b/pkg/plugin/manager.py index 65646f45..06e94f98 100644 --- a/pkg/plugin/manager.py +++ b/pkg/plugin/manager.py @@ -137,9 +137,8 @@ class PluginManager: for plugin in self.plugins: if plugin.enabled: if event.__class__ in plugin.event_handlers: + self.ap.logger.debug(f'插件 {plugin.plugin_name} 触发事件 {event.__class__.__name__}') - emitted_plugins.append(plugin) - is_prevented_default_before_call = ctx.is_prevented_default() try: @@ -151,6 +150,8 @@ class PluginManager: self.ap.logger.error(f'插件 {plugin.plugin_name} 触发事件 {event.__class__.__name__} 时发生错误: {e}') self.ap.logger.debug(f"Traceback: {traceback.format_exc()}") + emitted_plugins.append(plugin) + if not is_prevented_default_before_call and ctx.is_prevented_default(): self.ap.logger.debug(f'插件 {plugin.plugin_name} 阻止了默认行为执行')