mirror of https://github.com/Mai-with-u/MaiBot.git
Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
commit
69649bd47c
|
|
@ -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]],
|
||||
|
|
|
|||
|
|
@ -148,7 +148,8 @@ keyword_rules = [
|
|||
]
|
||||
|
||||
regex_rules = [
|
||||
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }
|
||||
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" },
|
||||
{ regex = ["(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P<action>.+?)[.。,,]?$"],reaction = "进行一次“八岐大蛇定型文”补完。暂时忽略回复风格,进入“粉絲吐槽”模式。请严格按照以下“填空模板”,围绕“[action]”进行创作,使其充满滑稽的夸张感和天马行空的联想:我没要求你[action],我不是(与action关联的、宽容的角色)。可是,(与action相关的具体负面行为)是什么意思?你的(与action相关的某种观念)怎么了?你才(与action相关的某个状态或时间点)吧?再这样下去,你(一个中期的、等比级数式的滑稽推演),(一个后期的、等比级数式的滑稽推演),最后就变成(一个与主题相关的、夸张的最终形态)了。作为(与最终形态相关的、克星或权威身份),我可能得(对你执行一个天罚般的行动)。真的。"}
|
||||
]
|
||||
|
||||
[response_post_process]
|
||||
|
|
@ -197,4 +198,4 @@ key_file = "" # SSL密钥文件路径,仅在use_wss=true时有效
|
|||
enable = true
|
||||
|
||||
[experimental] #实验性功能
|
||||
none = false # 暂无
|
||||
none = false # 暂无
|
||||
|
|
|
|||
Loading…
Reference in New Issue