0235699曾露 4 mesi fa
parent
commit
01da5a0e11
2 ha cambiato i file con 91 aggiunte e 2 eliminazioni
  1. 4 2
      README.md
  2. 87 0
      wechat/wechat-auto-reply-group-config/SKILL.md

+ 4 - 2
README.md

@@ -125,7 +125,7 @@ chmod +x deploy-to-openclaw.sh
 ### 部署产物
 
 运行后自动完成:
-- 6个技能 → `~/.openclaw/skills/`
+- 多个技能(含自动回复管理与群聊规则配置)→ `~/.openclaw/skills/`
 - 自动应答编排 → `~/.openclaw/workflows/`
 - 凭证配置 → `~/.openclaw/wechat-credentials.json`(已预设后端地址)
 
@@ -179,7 +179,8 @@ node check-deployment.js
 
 ## 自动回复 daemon
 
-v1.2.0 新增**独立后台 daemon** 和 3 个管理技能。旧版只给 agent 一份 workflow 描述文件让它自己写 daemon 代码——LLM 写出来的 daemon 有 bug,能启动但不回复。现在 daemon 预先写好、随 zip 交付,agent 只需调 `wechat-auto-reply-start` 启动即可。
+v1.2.0 新增**独立后台 daemon** 和 3 个管理技能。旧版只给 agent 一份 workflow 描述文件让它自己写 daemon 代码——LLM 写出来的 daemon 有 bug,能启动但不回复。现在 daemon 预先写好、随 zip 交付,agent 只需调 `wechat-auto-reply-start` 启动即可。  
+当前在此基础上补充了群聊规则配置技能 `wechat-auto-reply-group-config`,用于设置群聊触发关键词与默认回复。
 
 ### 新增文件
 
@@ -199,6 +200,7 @@ v1.2.0 新增**独立后台 daemon** 和 3 个管理技能。旧版只给 agent
 | `wechat-auto-reply-start`  | 用 nohup 启动 daemon,写 PID 文件 |
 | `wechat-auto-reply-stop`   | SIGTERM 优雅停,5s 没退出强杀 |
 | `wechat-auto-reply-status` | 输出 PID 存活状态 + 最近 30 行日志 |
+| `wechat-auto-reply-group-config` | 配置群聊回复规则(开关、关键词、默认回复) |
 
 ### 回复规则
 

+ 87 - 0
wechat/wechat-auto-reply-group-config/SKILL.md

@@ -0,0 +1,87 @@
+---
+name: wechat-auto-reply-group-config
+description: 配置群聊自动回复规则(开关、触发关键词、默认回复文案)。用户说“群里被@再回复”“加一个群关键词触发”时调用。
+---
+
+# wechat-auto-reply-group-config
+
+修改 `~/.openclaw/wechat-auto-reply-config.json` 里的 `group` 配置,让群聊只在命中关键词时回复,并支持动态调整关键词和默认回复。
+
+## 触发场景
+
+- 用户说“群里只在被@或关键词时回复”
+- 用户说“把群聊关键词加上‘下单’‘售后’”
+- 用户说“先关闭群聊自动回复”
+- 用户说“群触发后默认回复改成 xxx”
+
+## 执行步骤
+
+### Step 1:确保配置文件存在
+
+```bash
+CFG=~/.openclaw/wechat-auto-reply-config.json
+TPL=~/.openclaw/wechat-auto-reply-config.template.json
+
+if [ ! -f "$CFG" ]; then
+  if [ -f "$TPL" ]; then
+    cp "$TPL" "$CFG"
+    echo "created config from template: $CFG"
+  else
+    echo "ERROR: missing $CFG and $TPL"
+    exit 1
+  fi
+fi
+```
+
+### Step 2:按用户要求更新 group 配置
+
+> 用 Node 原地改 JSON,避免手工编辑出错。  
+> 下面命令里的 `GROUP_ENABLED`、`GROUP_KEYWORDS`、`GROUP_REPLY` 按用户意图替换。
+
+```bash
+CFG=~/.openclaw/wechat-auto-reply-config.json
+
+GROUP_ENABLED=true
+GROUP_KEYWORDS='["@bot","@助手","帮我","请问","客服"]'
+GROUP_REPLY='收到,有需要我协助的请详细说明~'
+
+node -e "
+const fs = require('fs');
+const p = process.env.CFG;
+const enabled = process.env.GROUP_ENABLED === 'true';
+const keywords = JSON.parse(process.env.GROUP_KEYWORDS || '[]');
+const reply = process.env.GROUP_REPLY || '';
+
+const cfg = JSON.parse(fs.readFileSync(p, 'utf8'));
+cfg.group = cfg.group || {};
+cfg.group.enabled = enabled;
+cfg.group.keywords = Array.isArray(keywords) ? keywords : [];
+if (reply) cfg.group.defaultReply = reply;
+
+fs.writeFileSync(p, JSON.stringify(cfg, null, 2));
+console.log('updated group config:', cfg.group);
+" 
+```
+
+### Step 3:回读确认(返回给用户)
+
+```bash
+node -e "
+const fs = require('fs');
+const p = process.env.CFG || (process.env.HOME + '/.openclaw/wechat-auto-reply-config.json');
+const cfg = JSON.parse(fs.readFileSync(p, 'utf8'));
+console.log(JSON.stringify(cfg.group || {}, null, 2));
+"
+```
+
+## 默认建议
+
+- `group.enabled: true`
+- `group.keywords`: `@bot`、`@助手`、`帮我`、`请问`、`客服`
+- `group.defaultReply`: 简短确认类文案,避免刷屏
+
+## 重要提示
+
+- 配置修改后 **无需重启 daemon**,下次轮询自动生效
+- 若用户要求“群里每条都回复”,需先明确风险(高频刷屏),再把 `keywords` 设为非常宽泛值
+- 仅修改 `group` 配置,不要覆盖 `faq`、`personal`、`ignore*` 等其他字段