47 lines
2.3 KiB
JSON
47 lines
2.3 KiB
JSON
{
|
|
"module": "messenger",
|
|
"purpose": "统一消息处理者——生产者与消费者解耦,按 job 配置路由消息通道",
|
|
"human_help": {
|
|
"title": "统一消息处理者",
|
|
"description": [
|
|
"messenger 是 MoFin 的统一消息处理者。所有脚本发送消息时调用 messenger,不需要关心消息去哪个通道。",
|
|
"消息去向由【生产者是谁】(哪个 cron job)决定,配置在 jobs.json 的 delivery 字段。",
|
|
"通道:broadcast(只写播报表) / xmpp(推用户+归档) / both(两者)。"
|
|
],
|
|
"usage": [
|
|
"脚本接入:文件开头加 from messenger import install_stdio_hook; install_stdio_hook()",
|
|
"发送消息:messenger.send(title=..., content=..., source=脚本名)",
|
|
"通道配置:健康 Tab cron 列表的'消息通道'列点击切换。",
|
|
"操作推荐:messenger.send_action_recommendation() 强制走 xmpp。"
|
|
],
|
|
"troubleshooting": [
|
|
"消息没推 xmpp:检查该脚本的 delivery 配置是否为 broadcast。",
|
|
"消息没进播报:检查 messenger 是否正确安装 hook。",
|
|
"递归嵌套:已修复(写表直接操作DB不经send)。"
|
|
]
|
|
},
|
|
"ai_spec": {
|
|
"purpose": "消息生产者与消费者解耦,统一通道路由",
|
|
"apis": [
|
|
{"method": "fn", "path": "messenger.send(title, content, source, channel, job_name)", "returns": "通道(broadcast/xmpp)"},
|
|
{"method": "fn", "path": "messenger.send_action_recommendation(title, content, source)", "returns": "强制xmpp"},
|
|
{"method": "fn", "path": "messenger.install_stdio_hook(script_name)", "returns": "当前通道"},
|
|
{"method": "fn", "path": "messenger.get_channel(script)", "returns": "脚本通道配置"}
|
|
],
|
|
"dependencies": ["jobs.json delivery", "broadcast_messages表"],
|
|
"constraints": [
|
|
"消费者按生产者(job)判通道,不按内容",
|
|
"所有通道都写 broadcast_messages 归档",
|
|
"xmpp 通道输出 stdout 供 hermes 捕获推 xmpp"
|
|
],
|
|
"must_not": [
|
|
"禁止按消息内容决定通道(内容分类仅用于 broadcast 表展示)",
|
|
"禁止脚本绕过 messenger 直接 print 用户消息"
|
|
],
|
|
"related_files": [
|
|
"deploy/profile-scripts/messenger.py",
|
|
"hermes jobs.json (delivery字段)"
|
|
]
|
|
}
|
|
}
|