openclawwechat 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONFIG.md ADDED
@@ -0,0 +1,171 @@
1
+ # OpenClawWeChat 插件配置说明
2
+
3
+ ## 📋 快速开始
4
+
5
+ ### 🔑 获取 API Key
6
+
7
+ 在开始配置之前,你需要先获取 API Key:
8
+
9
+ 1. 打开微信小程序 **ClawChat**
10
+ 2. 进入我的页面 APIKey管理 复制API Key
11
+ 3. 找到并复制你的 API Key(格式:`bot_id:secret`)
12
+
13
+ > 💡 **提示:** API Key 是连接 OpenClaw 和微信小程序的凭证,请妥善保管。
14
+
15
+ ### 推荐方式:使用配置脚本(最简单)
16
+
17
+ ```bash
18
+ npm run config-init
19
+ # 或
20
+ node scripts/config-init.js
21
+ ```
22
+
23
+ 脚本会引导你完成配置,**只保存你自定义的配置项**,使用默认值的配置不会写入文件。
24
+
25
+ ### 手动配置
26
+
27
+ 配置文件位置:`~/.openclaw/openclaw.json`
28
+
29
+ ## ⚙️ 配置项说明
30
+
31
+ | 配置项 | 类型 | 必需 | 默认值 | 说明 |
32
+ |--------|------|------|--------|------|
33
+ | `apiKey` | string | ✅ 是 | `YOUR_API_KEY_HERE` | API Key(格式:`bot_id:secret`) |
34
+ | `pollIntervalMs` | number | ❌ 否 | `2000` | 轮询间隔(毫秒) |
35
+ | `sessionKeyPrefix` | string | ❌ 否 | `agent:main:wechat:miniprogram:` | Session Key 前缀 |
36
+ | `debug` | boolean | ❌ 否 | `false` | 是否启用调试日志 |
37
+
38
+ **重要提示:**
39
+ - ✅ **只配置需要自定义的项**,使用默认值的配置**不需要写入**配置文件
40
+ - ✅ OpenClaw 会自动从插件清单中读取默认值
41
+ - ✅ 配置文件更简洁,只显示你自定义的配置
42
+
43
+ ## 📝 配置示例
44
+
45
+ ### 最小配置(推荐)
46
+
47
+ 如果你只配置 API Key,其他使用默认值:
48
+
49
+ ```json
50
+ {
51
+ "plugins": {
52
+ "entries": {
53
+ "openclawwechat": {
54
+ "enabled": true,
55
+ "config": {
56
+ "apiKey": "20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345"
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### 自定义部分配置
65
+
66
+ 如果你修改了轮询间隔:
67
+
68
+ ```json
69
+ {
70
+ "plugins": {
71
+ "entries": {
72
+ "openclawwechat": {
73
+ "enabled": true,
74
+ "config": {
75
+ "apiKey": "20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345",
76
+ "pollIntervalMs": 3000
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ ### 自定义多个配置
85
+
86
+ ```json
87
+ {
88
+ "plugins": {
89
+ "entries": {
90
+ "openclawwechat": {
91
+ "enabled": true,
92
+ "config": {
93
+ "apiKey": "20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345",
94
+ "pollIntervalMs": 3000,
95
+ "debug": true
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ ## 🔑 API Key 格式
104
+
105
+ **获取方式:** API Key 需要从**微信小程序 ClawChat** 中获取。
106
+
107
+ API Key 格式:`<bot_id>:<secret>`
108
+
109
+ **示例:** `20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345`
110
+
111
+ - `bot_id`: 数字id
112
+ - `secret`: 35 位随机字符串
113
+
114
+ > 💡 **提示:** 打开微信小程序 ClawChat,在设置或账户页面可以找到你的 API Key。
115
+
116
+ ## 🔧 配置方法
117
+
118
+ ### 方法 1:使用配置脚本(推荐)
119
+
120
+ ```bash
121
+ # 在插件目录下运行
122
+ npm run config-init
123
+ # 或
124
+ node scripts/config-init.js
125
+ ```
126
+
127
+ 脚本会:
128
+ - ✅ 交互式引导配置
129
+ - ✅ 验证 API Key 格式
130
+ - ✅ 自动过滤默认值
131
+ - ✅ 只保存你自定义的配置
132
+
133
+ ### 方法 2:手动编辑配置文件
134
+
135
+ ```bash
136
+ # 编辑配置文件
137
+ nano ~/.openclaw/openclaw.json
138
+ # 或
139
+ code ~/.openclaw/openclaw.json
140
+ ```
141
+
142
+ **提示:** 手动编辑时,只需添加需要自定义的配置项,默认值不需要写入。
143
+
144
+ ## ✅ 验证配置
145
+
146
+ 配置完成后,重启 OpenClaw Gateway:
147
+
148
+ ```bash
149
+ openclaw gateway restart
150
+ ```
151
+
152
+ 查看日志确认插件已加载:
153
+
154
+ ```bash
155
+ openclaw logs --follow | grep "openclawwechat"
156
+ ```
157
+
158
+ 进入小程序,查看链接状态,或者测试发送。
159
+
160
+ ## 💡 配置最佳实践
161
+
162
+ 1. **使用配置脚本**:推荐使用 `config-init.js` 脚本,避免手动编辑错误
163
+ 2. **最小化配置**:只配置需要自定义的项,让配置文件保持简洁
164
+ 3. **默认值管理**:默认值由插件清单统一管理,修改默认值时只需更新 `openclaw.plugin.json`
165
+ 4. **配置验证**:配置脚本会自动验证 API Key 格式,确保配置正确
166
+
167
+ ## 📚 相关文档
168
+
169
+ - [README.md](./README.md) - 插件使用说明
170
+ - [CONFIG-INIT.md](./CONFIG-INIT.md) - 配置脚本使用指南
171
+ - [INSTALL.md](./INSTALL.md) - 安装指南
package/INSTALL.md ADDED
@@ -0,0 +1,230 @@
1
+ # OpenClawWeChat 插件安装指南
2
+
3
+ ## 📋 前置要求
4
+
5
+ - OpenClaw 已安装并配置
6
+ - Python 3.x 或 Bash(用于运行安装脚本)
7
+ - 有效的 API Key(格式:`bot_id:secret`)
8
+ - 💡 **获取方式:** 打开微信小程序 **ClawChat**,在设置或账户页面可以找到你的 API Key
9
+
10
+ ## 🚀 快速安装
11
+
12
+ ### 方法一:使用安装脚本(推荐)
13
+
14
+ 安装脚本会自动完成插件安装和配置,是最简单的方式。
15
+
16
+ #### Bash 脚本(Linux/macOS)
17
+
18
+ ```bash
19
+ cd OpenClawWeChat
20
+ ./install.sh "your_bot_id:your_secret"
21
+ ```
22
+
23
+ #### Python 脚本(跨平台)
24
+
25
+ ```bash
26
+ cd OpenClawWeChat
27
+ python3 install.py "your_bot_id:your_secret"
28
+ ```
29
+
30
+ ### 方法二:手动安装
31
+
32
+ 如果不想使用安装脚本,可以手动安装:
33
+
34
+ ```bash
35
+ # 1. 安装插件
36
+ openclaw plugins install /path/to/OpenClawWeChat
37
+
38
+ # 2. 编辑配置文件 ~/.openclaw/openclaw.json
39
+ # 添加插件配置(见下方配置示例)
40
+
41
+ # 3. 重启 Gateway
42
+ openclaw gateway restart
43
+ ```
44
+
45
+ ## ⚙️ 安装脚本选项
46
+
47
+ ### 基本用法
48
+
49
+ ```bash
50
+ # 交互式输入 API Key
51
+ ./install.sh
52
+
53
+ # 直接提供 API Key
54
+ ./install.sh "20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345"
55
+ ```
56
+
57
+ ### 高级选项
58
+
59
+ ```bash
60
+ # 从 NPM 安装(如果已发布)
61
+ ./install.sh "your_api_key" --method npm
62
+
63
+ # 自定义轮询间隔(毫秒)
64
+ ./install.sh "your_api_key" --poll-interval 3000
65
+
66
+ # 自定义 Session Key 前缀
67
+ ./install.sh "your_api_key" --session-prefix "custom:prefix:"
68
+
69
+ # 启用调试日志
70
+ ./install.sh "your_api_key" --debug
71
+
72
+ # 只更新配置(不安装插件)
73
+ ./install.sh "your_api_key" --skip-install
74
+
75
+ # 查看帮助
76
+ ./install.sh --help
77
+ ```
78
+
79
+ ## 📝 配置说明
80
+
81
+ 安装脚本会自动在 `~/.openclaw/openclaw.json` 中添加以下配置:
82
+
83
+ ```json
84
+ {
85
+ "plugins": {
86
+ "entries": {
87
+ "openclawwechat": {
88
+ "enabled": true,
89
+ "config": {
90
+ "apiKey": "your_bot_id:your_secret",
91
+ "pollIntervalMs": 2000,
92
+ "sessionKeyPrefix": "agent:main:wechat:miniprogram:",
93
+ "debug": false
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### 配置项说明
102
+
103
+ | 配置项 | 类型 | 必需 | 默认值 | 说明 |
104
+ |--------|------|------|--------|------|
105
+ | `apiKey` | string | ✅ | - | API Key(格式:`bot_id:secret`),从微信小程序 ClawChat 中获取 |
106
+ | `pollIntervalMs` | number | ❌ | `2000` | 轮询间隔(毫秒) |
107
+ | `sessionKeyPrefix` | string | ❌ | `agent:main:wechat:miniprogram:` | Session Key 前缀 |
108
+ | `debug` | boolean | ❌ | `false` | 是否启用调试日志 |
109
+
110
+ ## ✅ 验证安装
111
+
112
+ 安装完成后,执行以下步骤验证:
113
+
114
+ ### 1. 检查插件状态
115
+
116
+ ```bash
117
+ openclaw plugins list | grep openclawwechat
118
+ ```
119
+
120
+ 应该看到插件已启用。
121
+
122
+ ### 2. 验证配置
123
+
124
+ ```bash
125
+ openclaw config validate
126
+ ```
127
+
128
+ ### 3. 重启 Gateway
129
+
130
+ ```bash
131
+ openclaw gateway restart
132
+ ```
133
+
134
+ ### 4. 查看日志
135
+
136
+ ```bash
137
+ openclaw logs --follow | grep "openclawwechat"
138
+ ```
139
+
140
+ 应该看到插件加载成功的日志。
141
+
142
+ ## 🔧 故障排查
143
+
144
+ ### 问题 1:OpenClaw 未找到
145
+
146
+ **错误信息:**
147
+ ```
148
+ OpenClaw 未安装或不在 PATH 中
149
+ ```
150
+
151
+ **解决方法:**
152
+ 1. 确认 OpenClaw 已安装:`openclaw --version`
153
+ 2. 如果未安装,参考 [OpenClaw 安装文档](https://docs.openclaw.ai/install)
154
+ 3. 确保 OpenClaw 在 PATH 中
155
+
156
+ ### 问题 2:配置文件不存在
157
+
158
+ **错误信息:**
159
+ ```
160
+ 配置文件不存在: ~/.openclaw/openclaw.json
161
+ ```
162
+
163
+ **解决方法:**
164
+ 安装脚本会自动创建配置文件,如果失败,可以手动创建:
165
+
166
+ ```bash
167
+ mkdir -p ~/.openclaw
168
+ cat > ~/.openclaw/openclaw.json << 'EOF'
169
+ {
170
+ "plugins": {
171
+ "enabled": true,
172
+ "entries": {}
173
+ }
174
+ }
175
+ EOF
176
+ ```
177
+
178
+ ### 问题 3:API Key 格式错误
179
+
180
+ **错误信息:**
181
+ ```
182
+ API Key 格式可能不正确
183
+ ```
184
+
185
+ **解决方法:**
186
+ - API Key 可从**微信小程序 ClawChat** 中获取
187
+ - API Key 格式应为:`bot_id:secret`
188
+ - `bot_id` 应为数字
189
+ - `secret` 应为 35 位字符
190
+ - 示例:`20231227:EXAMPLE_SECRET_KEY_35_CHARS_LONG_12345`
191
+
192
+ ### 问题 4:插件安装失败
193
+
194
+ **错误信息:**
195
+ ```
196
+ 插件安装失败
197
+ ```
198
+
199
+ **解决方法:**
200
+ 1. 检查插件目录是否存在且完整
201
+ 2. 检查 OpenClaw 扩展目录权限:`ls -la ~/.openclaw/extensions`
202
+ 3. 查看详细错误信息:`openclaw plugins install /path/to/OpenClawWeChat`
203
+
204
+ ### 问题 5:配置更新失败
205
+
206
+ **错误信息:**
207
+ ```
208
+ 配置更新失败
209
+ ```
210
+
211
+ **解决方法:**
212
+ 1. 检查配置文件权限:`ls -la ~/.openclaw/openclaw.json`
213
+ 2. 手动编辑配置文件添加插件配置
214
+ 3. 确保 JSON 格式正确
215
+
216
+ ## 📚 相关文档
217
+
218
+ - [README.md](./README.md) - 插件使用说明
219
+ - [CONFIG.md](./CONFIG.md) - 详细配置说明
220
+ - [EXAMPLE.md](./EXAMPLE.md) - 使用示例
221
+ - [OpenClaw 插件文档](https://docs.openclaw.ai/plugins)
222
+
223
+ ## 🤝 获取帮助
224
+
225
+ 如果遇到问题:
226
+
227
+ 1. 查看日志:`openclaw logs --follow`
228
+ 2. 检查配置:`openclaw config validate`
229
+ 3. 查看插件状态:`openclaw plugins list`
230
+ 4. 提交 Issue:[GitHub Issues](https://github.com/hillghost86/OpenClawWeChat/issues)