Skip to content

[Bug] stop_event() 疑似在 star_request.py 的 handler 循环中不生效 #7898

@lingyun14beta

Description

@lingyun14beta

What happened / 发生了什么

在 star_request.py 的 process 方法中,for 循环遍历 activated_handlers 时,
没有在每次 handler 执行后检查 event.is_stopped()。
导致某个 handler 调用 stop_event() 后,后续的 handler 仍然会继续执行,
与文档中"stop_event() 调用后所有后续步骤不会被执行"的描述不符。

相关代码位于:
astrbot/core/pipeline/process_stage/method/star_request.py

for handler in activated_handlers:
# 缺少 if event.is_stopped(): break
wrapper = call_handler(event, handler.handler, **params)
async for ret in wrapper:
yield ret
event.clear_result()

Reproduce / 如何复现?

  1. 安装任意使用 @filter.event_message_type(ALL, priority=1) + stop_event() 的插件
  2. 开启 DEBUG 日志级别
  3. 发送一条消息触发该插件的 stop_event()
  4. 观察 star_request.py 的 debug 输出,可见 stop_event() 之后其他 handler 仍然被依次调用

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

v4.23.6 / Windows 服务器 /QQ 个人号

OS

Windows

Logs / 报错日志

[method.star_request:44]: plugin -> astrbot_plugin_temp_block - intercept_temp_message
[astrbot_plugin_temp_block.main:46]: [temp_block] 临时会话拦截:3946770218 的临时会话已被屏蔽
(此处 stop_event() 已被调用)
[method.star_request:44]: plugin -> astrbot_plugin_keywords_reply - on_message
[method.star_request:44]: plugin -> astrbot_plugin_music - on_search_song
[method.star_request:44]: plugin -> astrbot_plugin_uapipro_toolbox - cmd_hitokoto
(后续 handler 仍然执行)

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreThe bug / feature is about astrbot's core, backendbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions