|
|
@@ -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*` 等其他字段
|