Skip to content

Commit

Permalink
fix: 命令事件的command参数处理错误 (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Mar 8, 2024
1 parent 95784de commit 53d0912
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions pkg/pipeline/process/handlers/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ async def handle(
"""处理
"""

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(
Expand Down Expand Up @@ -73,8 +74,6 @@ async def handle(

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,
Expand Down
5 changes: 3 additions & 2 deletions pkg/plugin/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ async def emit_event(self, event: events.BaseEventModel) -> context.EventContext
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:
Expand All @@ -151,6 +150,8 @@ async def emit_event(self, event: events.BaseEventModel) -> context.EventContext
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} 阻止了默认行为执行')

Expand Down

0 comments on commit 53d0912

Please sign in to comment.