From da9f1d297ad5b3af8d896f107f8de4dd54a820ab Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 24 Aug 2026 07:40:29 +0800 Subject: [PATCH] refactor: keep message handler within complexity budget --- app/chain/message.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/chain/message.py b/app/chain/message.py index 1a6b735ed..3e88c1cda 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -91,6 +91,13 @@ class MessageChain(ChainBase): expired_handler=self._schedule_agent_session_clear, ) + def _plugin_input_interaction_handler(self) -> PluginInputInteractionHandler: + """构造使用当前 Chain 消息与事件端口的插件输入处理器。""" + return PluginInputInteractionHandler( + messenger=self, + event_publisher=self.eventmanager, + ) + @dataclass class _ProcessingStatus: channel: NotificationChannel @@ -253,10 +260,7 @@ class MessageChain(ChainBase): is_channel_admin=is_channel_admin, ) - if PluginInputInteractionHandler( - messenger=self, - event_publisher=self.eventmanager, - ).handle_text( + if self._plugin_input_interaction_handler().handle_text( context=interaction_context, text=text, reply_to_message_id=reply_to_message_id, @@ -418,10 +422,7 @@ class MessageChain(ChainBase): ) return False - if PluginInputInteractionHandler( - messenger=self, - event_publisher=self.eventmanager, - ).handle_text( + if self._plugin_input_interaction_handler().handle_text( context=context, text=text, reply_to_message_id=reply_to_message_id,