From 2c6e342c36579347e39f1e140e08523b77e49603 Mon Sep 17 00:00:00 2001 From: foxplaying <166147707+foxplaying@users.noreply.github.com> Date: Fri, 26 Sep 2025 13:44:03 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin_system/core/events_manager.py | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/plugin_system/core/events_manager.py b/src/plugin_system/core/events_manager.py index beac2ca6..576f830c 100644 --- a/src/plugin_system/core/events_manager.py +++ b/src/plugin_system/core/events_manager.py @@ -340,9 +340,28 @@ class EventsManager: if event_type not in self._history_enable_map: raise ValueError(f"事件类型 {event_type} 未注册") try: - success, continue_processing, return_message, custom_result, modified_message = await handler.execute( - message - ) + result = await handler.execute(message) + + expected_fields = ["success", "continue_processing", "return_message", "custom_result", "modified_message"] + + if not isinstance(result, tuple) or len(result) != 5: + if isinstance(result, tuple): + annotated = ", ".join( + f"{name}={val!r}" for name, val in zip(expected_fields, result) + ) + actual_desc = f"{len(result)} 个元素 ({annotated})" + else: + actual_desc = f"非 tuple 类型: {type(result)}" + + logger.error( + f"[{self.__class__.__name__}] EventHandler {handler.handler_name} 返回值不符合预期:\n" + f" 模块来源: {handler.__class__.__module__}.{handler.__class__.__name__}\n" + f" 期望: 5 个元素 ({', '.join(expected_fields)})\n" + f" 实际: {actual_desc}" + ) + return True, None + + success, continue_processing, return_message, custom_result, modified_message = result if not success: logger.error(f"EventHandler {handler.handler_name} 执行失败: {return_message}") @@ -351,7 +370,9 @@ class EventsManager: if self._history_enable_map[event_type] and custom_result: self._events_result_history[event_type].append(custom_result) + return continue_processing, modified_message + except KeyError: logger.error(f"事件 {event_type} 注册的历史记录启用情况与实际不符合") return True, None @@ -359,6 +380,7 @@ class EventsManager: logger.error(f"EventHandler {handler.handler_name} 发生异常: {e}", exc_info=True) return True, None # 发生异常时默认不中断其他处理 + def _task_done_callback( self, task: asyncio.Task[Tuple[bool, bool, str | None, CustomEventHandlerResult | None, MaiMessages | None]], From ead6dc780c9ed84ea225e5b027fb49fdcdb52046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=A9=BA?= <3103908461@qq.com> Date: Tue, 30 Sep 2025 23:47:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E5=A5=BD=E7=8E=A9?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/bot_config_template.toml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index fa6b6b0b..1b786b77 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -151,6 +151,19 @@ regex_rules = [ { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" } ] +regex_rules = [ + { regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"], + reaction = """进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。 + +请严格按照以下“填空模板”,围绕“[action]”进行创作,使其充满滑稽的夸张感和天马行空的联想: + +我没要求你[action],我不是(与action关联的、宽容的角色)。 +可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧? +再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。 +作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。""" + }, +] + [response_post_process] enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器 @@ -197,4 +210,4 @@ key_file = "" # SSL密钥文件路径,仅在use_wss=true时有效 enable = true [experimental] #实验性功能 -none = false # 暂无 \ No newline at end of file +none = false # 暂无 From 770e9733c9ee1eaac94f7e19b4db48898cfcad39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=A9=BA?= <3103908461@qq.com> Date: Tue, 30 Sep 2025 23:54:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/bot_config_template.toml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 1b786b77..2e0347e4 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -148,10 +148,7 @@ keyword_rules = [ ] regex_rules = [ - { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" } -] - -regex_rules = [ + { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }, { regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"], reaction = """进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。 @@ -161,7 +158,7 @@ regex_rules = [ 可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧? 再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。 作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。""" - }, + } ] [response_post_process] From 0bef789be8a580f516f89f0d0df55aa4ec85b259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=A9=BA?= <3103908461@qq.com> Date: Wed, 1 Oct 2025 00:13:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/bot_config_template.toml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 2e0347e4..b749fb84 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -149,16 +149,8 @@ keyword_rules = [ regex_rules = [ { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }, - { regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"], - reaction = """进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。 - -请严格按照以下“填空模板”,围绕“[action]”进行创作,使其充满滑稽的夸张感和天马行空的联想: - -我没要求你[action],我不是(与action关联的、宽容的角色)。 -可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧? -再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。 -作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。""" - } + { regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"],reaction = "进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。请严格按照以下“填空模板”,围绕“[action]”进行创作,使其充满滑稽的夸张感和天马行空的联想:我没要求你[action],我不是(与action关联的、宽容的角色)。可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧?再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。"} +] ] [response_post_process] From c0cf02d4e8aef89074dafce28c7a84bcd576286b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=A9=BA?= <3103908461@qq.com> Date: Wed, 1 Oct 2025 00:14:32 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/bot_config_template.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index b749fb84..913371ce 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -151,7 +151,6 @@ regex_rules = [ { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }, { regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"],reaction = "进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。请严格按照以下“填空模板”,围绕“[action]”进行创作,使其充满滑稽的夸张感和天马行空的联想:我没要求你[action],我不是(与action关联的、宽容的角色)。可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧?再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。"} ] -] [response_post_process] enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器