@xwang152/claw-lark 0.1.11 → 0.1.12
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/README.md +39 -126
- package/README_zh.md +29 -100
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,44 +98,45 @@ openclaw gateway restart
|
|
|
98
98
|
| `contact:user.base:readonly` | User Info | Get basic user info (to resolve sender names and avoid identity confusion) |
|
|
99
99
|
| `im:message` | Message | Send and receive messages |
|
|
100
100
|
| `im:message.p2p_msg:readonly` | P2P Message | Read direct messages sent to the bot |
|
|
101
|
-
| `im:message.group_at_msg:readonly` | Group Message | Receive messages where the bot is
|
|
102
|
-
| `im:message:send_as_bot` | Send | Send messages as the bot |
|
|
103
|
-
| `im:resource` | Resource | Upload/
|
|
101
|
+
| `im:message.group_at_msg:readonly` | Group Message | Receive messages where the bot is mentioned in groups |
|
|
102
|
+
| `im:message:send_as_bot` | Send Message | Send messages as the bot |
|
|
103
|
+
| `im:resource` | Resource | Upload/Download images and files |
|
|
104
104
|
|
|
105
|
-
**Optional Permissions (
|
|
105
|
+
**Optional Permissions (Add as needed):**
|
|
106
106
|
|
|
107
107
|
| Permission | Scope | Description |
|
|
108
108
|
| :--- | :--- | :--- |
|
|
109
|
-
| `im:message.group_msg` | Group | Read all group messages (Sensitive
|
|
109
|
+
| `im:message.group_msg` | Group | Read all group messages (Sensitive) |
|
|
110
110
|
| `im:message:readonly` | Read | Get historical messages |
|
|
111
|
-
| `im:message:update` | Edit | Update/
|
|
111
|
+
| `im:message:update` | Edit | Update/Edit sent messages |
|
|
112
112
|
| `im:message:recall` | Recall | Recall sent messages |
|
|
113
|
-
| `im:message.reactions:read` |
|
|
114
|
-
| `im:chat` | Group | Get group
|
|
115
|
-
| `contact:user.employee:readonly` |
|
|
113
|
+
| `im:message.reactions:read` | Reactions | View message reactions |
|
|
114
|
+
| `im:chat` | Group | Get group chat information |
|
|
115
|
+
| `contact:user.employee:readonly` | User Info | Read employee info (Alternative to user.base) |
|
|
116
116
|
|
|
117
|
-
5. Note your **App ID** and **App Secret** from Credentials & Basic Info
|
|
117
|
+
5. Note down your **App ID** and **App Secret** from "Credentials & Basic Info"
|
|
118
118
|
|
|
119
|
-
6. Publish your app under Version Management
|
|
119
|
+
6. Publish your app under "Version Management & Release"
|
|
120
120
|
|
|
121
121
|
## Configuration
|
|
122
122
|
|
|
123
123
|
### Using Config Commands
|
|
124
124
|
|
|
125
125
|
```bash
|
|
126
|
-
# Required
|
|
126
|
+
# Required
|
|
127
127
|
openclaw config set channels.lark.accounts.default.appId 'cli_xxxxx'
|
|
128
128
|
openclaw config set channels.lark.accounts.default.appSecret 'your-app-secret'
|
|
129
129
|
openclaw config set channels.lark.accounts.default.connectionMode 'webhook'
|
|
130
130
|
|
|
131
|
-
# Optional
|
|
131
|
+
# Optional
|
|
132
132
|
openclaw config set channels.lark.accounts.default.webhookPort 3000
|
|
133
133
|
openclaw config set channels.lark.accounts.default.domain 'lark'
|
|
134
134
|
openclaw config set channels.lark.accounts.default.dmPolicy 'open'
|
|
135
135
|
openclaw config set channels.lark.accounts.default.groupPolicy 'open'
|
|
136
|
-
openclaw config set channels.lark.accounts.default.
|
|
136
|
+
openclaw config set channels.lark.accounts.default.requireMention true
|
|
137
|
+
openclaw config set channels.lark.accounts.default.renderMode 'auto'
|
|
137
138
|
|
|
138
|
-
# Security
|
|
139
|
+
# Security (from Lark Developer Console > Event Subscriptions > Encrypt Strategy)
|
|
139
140
|
openclaw config set channels.lark.accounts.default.encryptKey 'your-encrypt-key'
|
|
140
141
|
openclaw config set channels.lark.accounts.default.verificationToken 'your-verification-token'
|
|
141
142
|
```
|
|
@@ -148,7 +149,7 @@ For the default account, you can use environment variables:
|
|
|
148
149
|
LARK_APP_ID=cli_xxxxx
|
|
149
150
|
LARK_APP_SECRET=your-app-secret
|
|
150
151
|
|
|
151
|
-
# Security
|
|
152
|
+
# Security (from Lark Developer Console > Event Subscriptions > Encrypt Strategy)
|
|
152
153
|
LARK_ENCRYPT_KEY=your-encrypt-key # Optional, for decrypting event payloads
|
|
153
154
|
LARK_VERIFICATION_TOKEN=your-token # Optional, for verifying request authenticity
|
|
154
155
|
```
|
|
@@ -157,124 +158,36 @@ LARK_VERIFICATION_TOKEN=your-token # Optional, for verifying request aut
|
|
|
157
158
|
|
|
158
159
|
| Option | Type | Default | Description |
|
|
159
160
|
|--------|------|---------|-------------|
|
|
160
|
-
| `appId` | string | - | Lark App ID (
|
|
161
|
-
| `appSecret` | string | - | Lark App Secret (
|
|
161
|
+
| `appId` | string | - | Lark App ID (Required) |
|
|
162
|
+
| `appSecret` | string | - | Lark App Secret (Required) |
|
|
162
163
|
| `connectionMode` | string | `websocket` | `webhook` or `websocket` |
|
|
163
|
-
| `webhookPort` | number | `3000` |
|
|
164
|
+
| `webhookPort` | number | `3000` | Webhook server port |
|
|
164
165
|
| `domain` | string | `feishu` | `lark` (international) or `feishu` (China) |
|
|
165
|
-
| `encryptKey` | string | - |
|
|
166
|
-
| `verificationToken` | string | - | Token for verifying request authenticity
|
|
166
|
+
| `encryptKey` | string | - | Encryption key for decrypting event payloads |
|
|
167
|
+
| `verificationToken` | string | - | Token for verifying request authenticity |
|
|
167
168
|
| `dmPolicy` | string | `pairing` | `open`, `pairing`, or `allowlist` |
|
|
168
169
|
| `groupPolicy` | string | `open` | `open`, `allowlist`, or `disabled` |
|
|
169
|
-
| `requireMention` | boolean | `true` |
|
|
170
|
+
| `requireMention` | boolean | `true` | Whether mentions are required in groups |
|
|
170
171
|
| `renderMode` | string | `auto` | `auto`, `raw`, or `card` |
|
|
171
|
-
| `mediaMaxMb` | number | `30` | Max size for media files
|
|
172
|
-
| `historyLimit` | number | `10` | Number of
|
|
173
|
-
|
|
174
|
-
## Render Modes
|
|
175
|
-
|
|
176
|
-
| Mode | Description |
|
|
177
|
-
| :--- | :--- |
|
|
178
|
-
| **auto** | (Default) Automatically detects code blocks, lists, or tables to use card rendering; otherwise uses plain text |
|
|
179
|
-
| **raw** | Always use plain text; tables are converted to ASCII text |
|
|
180
|
-
| **card** | Always use Lark interactive cards; supports Markdown highlighting and advanced layouts |
|
|
181
|
-
|
|
182
|
-
## Webhook Mode Setup
|
|
183
|
-
|
|
184
|
-
Choose the setup method based on your deployment environment.
|
|
185
|
-
|
|
186
|
-
### 1. Development (Using ngrok)
|
|
187
|
-
|
|
188
|
-
Recommended for local development and testing.
|
|
189
|
-
|
|
190
|
-
> **Security & Privacy Notice**: ngrok exposes your local server to the internet. Keep the following in mind:
|
|
191
|
-
> - Never share your ngrok URL publicly — anyone with the URL can send requests to your local machine
|
|
192
|
-
> - Use a paid ngrok plan with authentication or IP restrictions for production use
|
|
193
|
-
> - Stop ngrok when not in use to close the tunnel
|
|
194
|
-
> - Consider using Lark's `encryptKey` and `verificationToken` for additional request validation
|
|
195
|
-
|
|
196
|
-
1. Start ngrok to expose your local webhook server:
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
ngrok http 3000
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
2. Copy the HTTPS URL from ngrok (e.g., `https://abc123.ngrok.io`)
|
|
203
|
-
|
|
204
|
-
3. Configure Events & Callbacks in Lark Developer Console:
|
|
205
|
-
- Add event subscription: `im.message.receive_v1`
|
|
206
|
-
- Set Request URL to your ngrok HTTPS URL (e.g., `https://abc123.ngrok.io`)
|
|
207
|
-
|
|
208
|
-
### 2. Production (Server Deployment)
|
|
209
|
-
|
|
210
|
-
When deploying on a server, ngrok is **not** required.
|
|
211
|
-
|
|
212
|
-
1. **Open Port**: Ensure your server's firewall (Security Group) allows traffic on the port used by the plugin (default is `3000`).
|
|
213
|
-
2. **Configure URL**: In Lark Developer Console, configure "Events & Callbacks":
|
|
214
|
-
- Set the "Request URL" to your server's public address: `http://your-server-ip:3000`.
|
|
215
|
-
3. **(Recommended) Reverse Proxy**: Use Nginx or Caddy to set up a reverse proxy with SSL (HTTPS) and forward traffic to port `3000`.
|
|
216
|
-
|
|
217
|
-
### 3. Start the Plugin
|
|
218
|
-
|
|
219
|
-
1. Start OpenClaw:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
openclaw start
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
2. The webhook server will start automatically and handle URL verification.
|
|
226
|
-
|
|
227
|
-
## WebSocket Mode
|
|
228
|
-
|
|
229
|
-
WebSocket mode is available for enterprise Lark accounts that support long connections. Set `connectionMode` to `websocket`:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
openclaw config set channels.lark.accounts.default.connectionMode 'websocket'
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
> **Note**: WebSocket mode requires enterprise Lark accounts and does not need a public IP or webhook configuration.
|
|
236
|
-
|
|
237
|
-
## Multiple Accounts
|
|
238
|
-
|
|
239
|
-
You can configure multiple Lark accounts:
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
openclaw config set channels.lark.accounts.work.appId 'cli_work_app'
|
|
243
|
-
openclaw config set channels.lark.accounts.work.appSecret 'work-secret'
|
|
244
|
-
openclaw config set channels.lark.accounts.personal.appId 'cli_personal_app'
|
|
245
|
-
openclaw config set channels.lark.accounts.personal.appSecret 'personal-secret'
|
|
246
|
-
```
|
|
172
|
+
| `mediaMaxMb` | number | `30` | Max size for media files (MB) |
|
|
173
|
+
| `historyLimit` | number | `10` | Number of history messages to fetch |
|
|
247
174
|
|
|
248
175
|
## Troubleshooting
|
|
249
176
|
|
|
250
|
-
###
|
|
251
|
-
|
|
252
|
-
1. Verify the event subscription `im.message.receive_v1` is added
|
|
253
|
-
2. Check that the callback URL is correctly configured
|
|
254
|
-
3. Ensure the required permissions are enabled
|
|
255
|
-
4. Make sure the app is published (not just saved as draft)
|
|
256
|
-
|
|
257
|
-
### Permission errors when sending images
|
|
258
|
-
|
|
259
|
-
Add the `im:resource` permission in Lark Developer Console and republish your app.
|
|
260
|
-
|
|
261
|
-
### Webhook server not starting
|
|
262
|
-
|
|
263
|
-
Check if port 3000 is already in use. Change the port:
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
openclaw config set channels.lark.accounts.default.webhookPort 3001
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Connection issues with WebSocket mode
|
|
270
|
-
|
|
271
|
-
WebSocket mode requires enterprise Lark accounts. If you have an individual account, use webhook mode instead.
|
|
272
|
-
|
|
273
|
-
## Contributing
|
|
274
|
-
|
|
275
|
-
Issues and pull requests are welcome! If you encounter bugs or have feature requests, please open an issue at https://github.com/xwang152-jack/claw-lark/issues.
|
|
177
|
+
### "Invalid config ... plugin not found: lark"
|
|
276
178
|
|
|
277
|
-
|
|
179
|
+
If you see this error after upgrading/renaming the plugin:
|
|
180
|
+
`Invalid config at .../openclaw.json: - plugins.entries.lark: plugin not found: lark`
|
|
278
181
|
|
|
279
|
-
|
|
182
|
+
This happens because the old plugin ID `lark` is still in your configuration but the plugin files are gone or renamed.
|
|
280
183
|
|
|
184
|
+
**Fix:**
|
|
185
|
+
1. Open `~/.openclaw/openclaw.json` (or your config file)
|
|
186
|
+
2. Remove the line `"lark": "lark"` or `"lark": "..."` from `plugins.entries`
|
|
187
|
+
3. Save the file
|
|
188
|
+
4. Re-install the plugin using the new name:
|
|
189
|
+
```bash
|
|
190
|
+
openclaw plugins install @xwang152/claw-lark
|
|
191
|
+
# or for manual install
|
|
192
|
+
openclaw plugins install --link .
|
|
193
|
+
```
|
package/README_zh.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
# OpenClaw 飞书/Lark 插件
|
|
2
3
|
|
|
3
4
|
[English Document](./README.md)
|
|
@@ -177,6 +178,26 @@ LARK_VERIFICATION_TOKEN=your-token # 可选,用于验证请求真实
|
|
|
177
178
|
| **raw** | 始终使用纯文本渲染;表格会被转换为 ASCII 文本 |
|
|
178
179
|
| **card** | 始终使用飞书交互式卡片渲染;支持 Markdown 语法高亮和高级布局 |
|
|
179
180
|
|
|
181
|
+
## 常见问题 / 迁移指南
|
|
182
|
+
|
|
183
|
+
### "Invalid config ... plugin not found: lark"
|
|
184
|
+
|
|
185
|
+
如果您在升级或重命名插件后看到此错误:
|
|
186
|
+
`Invalid config at .../openclaw.json: - plugins.entries.lark: plugin not found: lark`
|
|
187
|
+
|
|
188
|
+
这是因为旧的插件 ID `lark` 仍然存在于您的配置中,但插件文件已被移除或重命名。
|
|
189
|
+
|
|
190
|
+
**解决方法:**
|
|
191
|
+
1. 打开 `~/.openclaw/openclaw.json` (或您的配置文件)
|
|
192
|
+
2. 找到 `plugins.entries`,删除 `"lark": "lark"` 或类似行
|
|
193
|
+
3. 保存文件
|
|
194
|
+
4. 使用新名称重新安装插件:
|
|
195
|
+
```bash
|
|
196
|
+
openclaw plugins install @xwang152/claw-lark
|
|
197
|
+
# 或者手动安装
|
|
198
|
+
openclaw plugins install --link .
|
|
199
|
+
```
|
|
200
|
+
|
|
180
201
|
## Webhook 模式指引
|
|
181
202
|
|
|
182
203
|
根据您的部署环境选择设置方法。
|
|
@@ -197,106 +218,14 @@ LARK_VERIFICATION_TOKEN=your-token # 可选,用于验证请求真实
|
|
|
197
218
|
ngrok http 3000
|
|
198
219
|
```
|
|
199
220
|
|
|
200
|
-
2.
|
|
201
|
-
|
|
202
|
-
3. 在飞书开发者后台配置“事件订阅”:
|
|
203
|
-
- 添加事件订阅:`im.message.receive_v1`
|
|
204
|
-
- 将请求网址 URL 设置为您的 ngrok HTTPS URL (例如 `https://abc123.ngrok.io`)
|
|
205
|
-
|
|
206
|
-
### 2. 生产环境 (服务器部署)
|
|
207
|
-
|
|
208
|
-
部署在服务器上时,**不需要** ngrok。
|
|
209
|
-
|
|
210
|
-
1. **开放端口**:确保您服务器的防火墙 (安全组) 允许插件使用的端口流量 (默认为 `3000`)。
|
|
211
|
-
2. **配置 URL**:在飞书开发者后台,配置“事件订阅”:
|
|
212
|
-
- 将“请求网址 URL”设置为您服务器的公网地址:`http://your-server-ip:3000`。
|
|
213
|
-
3. **(推荐) 反向代理**:使用 Nginx 或 Caddy 设置带有 SSL (HTTPS) 的反向代理,并将流量转发到端口 `3000`。
|
|
214
|
-
|
|
215
|
-
### 3. 启动插件
|
|
216
|
-
|
|
217
|
-
1. 启动 OpenClaw:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
openclaw start
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
2. Webhook 服务器将自动启动并处理 URL 验证。
|
|
224
|
-
|
|
225
|
-
## WebSocket 模式
|
|
226
|
-
|
|
227
|
-
WebSocket 模式适用于支持长连接的企业自建应用。将 `connectionMode` 设置为 `websocket`:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
openclaw config set channels.lark.accounts.default.connectionMode 'websocket'
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
> **注意**:WebSocket 模式需要企业自建应用,无需配置公网 IP 或回调地址。
|
|
234
|
-
|
|
235
|
-
## 多账号配置
|
|
236
|
-
|
|
237
|
-
您可以配置多个飞书账号:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
openclaw config set channels.lark.accounts.work.appId 'cli_work_app'
|
|
241
|
-
openclaw config set channels.lark.accounts.work.appSecret 'work-secret'
|
|
242
|
-
openclaw config set channels.lark.accounts.personal.appId 'cli_personal_app'
|
|
243
|
-
openclaw config set channels.lark.accounts.personal.appSecret 'personal-secret'
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
## 故障排除
|
|
247
|
-
|
|
248
|
-
### 机器人无法接收消息
|
|
249
|
-
|
|
250
|
-
1. 验证是否已添加事件订阅 `im.message.receive_v1`
|
|
251
|
-
2. 检查回调 URL 是否配置正确
|
|
252
|
-
3. 确保已启用所需的权限
|
|
253
|
-
4. 确保应用已发布(不仅仅是保存为草稿)
|
|
254
|
-
|
|
255
|
-
### 发送图片时出现权限错误
|
|
256
|
-
|
|
257
|
-
在飞书开发者后台添加 `im:resource` 权限并重新发布应用。
|
|
258
|
-
|
|
259
|
-
### Webhook 服务无法启动
|
|
260
|
-
|
|
261
|
-
检查端口 3000 是否已被占用。更改端口:
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
openclaw config set channels.lark.accounts.default.webhookPort 3001
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### WebSocket 模式连接问题
|
|
268
|
-
|
|
269
|
-
WebSocket 模式需要企业自建应用。如果您是个人账号,请改用 webhook 模式。
|
|
270
|
-
|
|
271
|
-
## 开发者相关
|
|
272
|
-
|
|
273
|
-
欢迎提交 Issue 和 Pull Request!如果您遇到 Bug 或有功能请求,请在 https://github.com/xwang152-jack/claw-lark/issues 提交 Issue。
|
|
274
|
-
|
|
275
|
-
### 开发环境设置
|
|
276
|
-
|
|
277
|
-
如果您想参与开发:
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
# 克隆仓库
|
|
281
|
-
git clone https://github.com/xwang152-jack/claw-lark.git
|
|
282
|
-
cd claw-lark
|
|
283
|
-
|
|
284
|
-
# 安装依赖
|
|
285
|
-
npm install
|
|
286
|
-
|
|
287
|
-
# 运行类型检查
|
|
288
|
-
npm run typecheck
|
|
289
|
-
|
|
290
|
-
# 链接插件以进行本地开发
|
|
291
|
-
openclaw plugins install --link .
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### 常用命令
|
|
221
|
+
2. 复制生成的 HTTPS URL(例如 `https://xxxx-xx-xx-xx-xx.ngrok-free.app`)
|
|
295
222
|
|
|
296
|
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
223
|
+
3. 在飞书开发者后台中配置:
|
|
224
|
+
- 转到 **事件订阅**
|
|
225
|
+
- 将 **请求地址** 设置为您的 ngrok URL + `/webhook`
|
|
226
|
+
- 例如:`https://xxxx-xx-xx-xx-xx.ngrok-free.app/webhook`
|
|
299
227
|
|
|
300
|
-
|
|
228
|
+
### 2. 生产环境 (Docker/服务器)
|
|
301
229
|
|
|
302
|
-
|
|
230
|
+
1. 确保服务器的 3000 端口(或配置的端口)对外开放
|
|
231
|
+
2. 在飞书开发者后台中,将 **请求地址** 设置为您的服务器公网 IP/域名 + `/webhook`
|