notification-hub 通知集成 —— 集中收集所有技能通知,并根据优先级分发以减少通知疲劳。
🎯 目的
集中管理来自所有技能的多样化通知,并根据重要性在适当的时间和渠道分发。
📥 通知来源
从 events/ 目录中收集所有事件文件:
events/
├── health-2026-02-14.json (health-monitor)
├── scrape-result-2026-02-14.json (data-scraper)
├── dm-check-2026-02-14.json (insta-post)
├── competitor-2026-02-14.json (competitor-watch)
└── workflow-2026-02-14.json (skill-composer)
🚦 优先级过滤
条件:安全问题(异常登录,疑似访问)
系统错误(OpenClaw 停止,浏览器断开连接)
成本超过(API 使用 90%+)
关键提及
分发:Discord DM(在 TOOLS.md 中配置的频道 ID)
立即发送(在 1 分钟内)
示例: 🚨 Urgent:浏览器断开连接 Port 18800 无响应。自动恢复尝试失败。需要手动检查:openclaw 浏览器启动
条件:新 Instagram DM(未读)
趋势关键词激增
竞争对手推出新服务
Git 推送需要(10+ 未推送的提交)
分发:包含在下一个心跳响应中(~30 分钟间隔)
在单个消息中捆绑多个通知
示例: 📢 3 条更新 📩 2 条 Instagram DM(iam.dawn.kim,partner_xyz) 📈 趋势:“AI 代理”激增(+150%) 🔄 Git:12 个提交等待推送
条件:常规统计更新
每日令牌使用情况
已完成的工作流程
常规系统日志
分发:包含在每日报告技能执行时
每天发送摘要一次
示例: 📊 每日报告(2026-02-14) ✅ 3 个工作流程已完成 📊 令牌:45,230 / 100,000(45%) 📝 内存:3.2 GB 🔧 健康检查:OK
🔕 重复防止
永远不要为同一事件发送多次通知。
重复检测
{
"event_id": "health-check-2026-02-14-07:00",
"fingerprint": "sha256(source + type + key_data)",
"notified_at": "2026-02-14T07:05:00+09:00"
}
历史存储
memory/notifications/
├── sent-2026-02-14.json
├── sent-2026-02-13.json
└── ...
sent-YYYY-MM-DD.json 结构:
{
"date": "2026-02-14",
"notifications": [
{
"id": "health-check-2026-02-14-07:00",
"priority": "info",
"sent_at": "2026-02-14T07:05:00+09:00",
"channel": "discord_dm",
"source": "health-monitor"
}
]
}
📢 分发渠道
Discord DM 频道 ID:在 TOOLS.md 中配置
目的:紧急、重要通知
格式:Markdown(表情符号 + 标题 + 内容)
心跳响应
目的:捆绑重要通知
格式:简洁的项目符号列表
每日报告
目的:信息通知摘要
格式:结构化部分组织
🎤 触发器
使用以下关键词激活技能:“notification settings” “notification” “check notifications” “anything new”
🚀 使用示例
检查通知
“Anything new?”→ 立即总结重要+ 通知
通知设置
“Set Instagram DMs to immediate notification”→ 将 dm-check 事件提升到紧急
通知历史
“Show today's notification history”→ 读取 memory/notifications/sent-2026-02-14.json
⚙️ 实现指南
// 扫描 events/ 目录
const events = fs.readdirSync('events/')
.filter(f => f.endsWith('.json'))
.map(f => JSON.parse(fs.readFileSync(
events/${f})));
const urgent = events.filter(e => e.priority === 'urgent');
const important = events.filter(e => e.priority === 'important');
const info = events.filter(e => e.priority === 'info');
const sent = loadSentHistory(today);
const newEvents = events.filter(e => !sent.notifications.some(n => n.id === e.id) );
// urgent → 立即 Discord DM
if (urgent.length > 0) {
await sendDiscordDM(urgent);
}
// important → 添加到心跳队列
if (important.length > 0) {
await addToHeartbeatQueue(important);
}
// info → 添加到每日报告队列
if (info.length > 0) {
await addToDailyReportQueue(info);
}
saveSentHistory(today, newlySentNotifications);
📊 事件优先级指南
指导每个技能在创建事件时包含优先级字段:
{
"timestamp": "2026-02-14T07:58:00+09:00",
"skill": "health-monitor",
"priority": "urgent", // urgent | important | info
"message": "浏览器断开连接",
"data": { ... }
}
🐧 由 무펭이 — Mupengism 生态系统技能构建