From 3ad3d2be4eb6c4c7d6547ed2fed10fe1ebcf4e7b Mon Sep 17 00:00:00 2001 From: Aryun <1504887141@qq.com> Date: Tue, 7 Jul 2026 15:04:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(core):=20=E8=A7=A3=E9=99=A4=20call=5Fev?= =?UTF-8?q?ent=5Fhook=20=E4=B8=AD=20functools.partial=20=E5=8C=85=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 call_event_hook 中调用插件事件处理器前,解开 handler.handler 可能存在的 functools.partial 包装,避免因 star_manager 绑定导致的参数传递异常。 --- astrbot/core/pipeline/context_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/astrbot/core/pipeline/context_utils.py b/astrbot/core/pipeline/context_utils.py index 9402ce3e62..9c7876faa2 100644 --- a/astrbot/core/pipeline/context_utils.py +++ b/astrbot/core/pipeline/context_utils.py @@ -1,6 +1,7 @@ import inspect import traceback import typing as T +import functools from astrbot import logger from astrbot.core.message.message_event_result import CommandResult, MessageEventResult @@ -91,11 +92,14 @@ async def call_event_hook( ) for handler in handlers: try: - assert inspect.iscoroutinefunction(handler.handler) + _handler_fn = handler.handler + while isinstance(_handler_fn, functools.partial): + _handler_fn = _handler_fn.func + assert inspect.iscoroutinefunction(_handler_fn) logger.debug( f"hook({hook_type.name}) -> {star_map[handler.handler_module_path].name} - {handler.handler_name}", ) - await handler.handler(event, *args, **kwargs) + await _handler_fn(event, *args, **kwargs) except BaseException: logger.error(traceback.format_exc()) From c42fff3d5cb547ccd8a259f033c4096b325bff4e Mon Sep 17 00:00:00 2001 From: Aryun <1504887141@qq.com> Date: Tue, 7 Jul 2026 15:42:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BB=85=E7=94=A8=20=5Fhandler=5Ffn?= =?UTF-8?q?=20=E5=81=9A=E7=B1=BB=E5=9E=8B=E6=A3=80=E6=9F=A5=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=97=B6=E4=BF=9D=E7=95=99=20handler.handler?= =?UTF-8?q?=20=E4=BB=A5=E4=BF=9D=E6=8C=81=20partial=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/pipeline/context_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/core/pipeline/context_utils.py b/astrbot/core/pipeline/context_utils.py index 9c7876faa2..9cd9f87b80 100644 --- a/astrbot/core/pipeline/context_utils.py +++ b/astrbot/core/pipeline/context_utils.py @@ -99,7 +99,7 @@ async def call_event_hook( logger.debug( f"hook({hook_type.name}) -> {star_map[handler.handler_module_path].name} - {handler.handler_name}", ) - await _handler_fn(event, *args, **kwargs) + await handler.handler(event, *args, **kwargs) except BaseException: logger.error(traceback.format_exc())