fix: 命令事件的command参数处理错误 (#713)

This commit is contained in:
RockChinQ 2024-03-08 21:10:43 +08:00
parent 95784debbf
commit 53d09129b4
2 changed files with 7 additions and 7 deletions

View File

@ -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,

View File

@ -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} 阻止了默认行为执行')