@love19861018/wecom-openclaw-plugin 1.0.10
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 +193 -0
- package/dist/index.cjs.js +1946 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.esm.js +1942 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/src/channel.d.ts +3 -0
- package/dist/src/const.d.ts +48 -0
- package/dist/src/dm-policy.d.ts +29 -0
- package/dist/src/group-policy.d.ts +29 -0
- package/dist/src/interface.d.ts +144 -0
- package/dist/src/media-handler.d.ts +36 -0
- package/dist/src/message-parser.d.ts +72 -0
- package/dist/src/message-sender.d.ts +23 -0
- package/dist/src/monitor.d.ts +27 -0
- package/dist/src/onboarding.d.ts +5 -0
- package/dist/src/reqid-store.d.ts +31 -0
- package/dist/src/runtime.d.ts +3 -0
- package/dist/src/state-manager.d.ts +76 -0
- package/dist/src/timeout.d.ts +20 -0
- package/dist/src/utils.d.ts +59 -0
- package/openclaw.plugin.json +11 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# 🤖 WeCom OpenClaw Plugin
|
|
2
|
+
|
|
3
|
+
**WeCom channel plugin for [OpenClaw](https://github.com/openclaw)** — by the Tencent WeCom team.
|
|
4
|
+
|
|
5
|
+
> A bot plugin powered by WeCom AI Bot WebSocket persistent connections. Supports direct messages & group chats, streaming replies, and proactive messaging.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
📖 [WeCom AI Bot Official Documentation](https://open.work.weixin.qq.com/help?doc_id=21657)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## ✨ Features
|
|
13
|
+
|
|
14
|
+
- 🔗 WebSocket persistent connection for stable communication
|
|
15
|
+
- 💬 Supports both direct messages (DM) and group chat
|
|
16
|
+
- 📤 Proactive messaging to specific users or groups
|
|
17
|
+
- 🖼️ Receives and processes image and file messages with automatic downloading
|
|
18
|
+
- ⏳ Streaming replies with "thinking" placeholder messages
|
|
19
|
+
- 📝 Markdown formatting support for replies
|
|
20
|
+
- 🔒 Built-in access control: DM Policy (pairing / open / allowlist / disabled) and Group Policy (open / allowlist / disabled)
|
|
21
|
+
- ⚡ Auto heartbeat keep-alive and reconnection (up to 100 reconnect attempts)
|
|
22
|
+
- 🧙 Interactive CLI setup wizard
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🚀 Getting Started
|
|
27
|
+
|
|
28
|
+
### Requirements
|
|
29
|
+
|
|
30
|
+
- OpenClaw `>= 2026.2.13`
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
openclaw plugins install @wecom/wecom-openclaw-plugin
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Configuration
|
|
39
|
+
|
|
40
|
+
#### Option 1: Interactive Setup
|
|
41
|
+
|
|
42
|
+
```shell
|
|
43
|
+
openclaw channels add
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Follow the prompts to enter your WeCom bot's **Bot ID** and **Secret**.
|
|
47
|
+
|
|
48
|
+
#### Option 2: CLI Quick Setup
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
openclaw config set channels.wecom.bots[0].botId <YOUR_BOT_ID>
|
|
52
|
+
openclaw config set channels.wecom.bots[0].secret <YOUR_BOT_SECRET>
|
|
53
|
+
openclaw config set channels.wecom.bots[0].tinyId <OPTIONAL_SHORT_ID>
|
|
54
|
+
openclaw config set channels.wecom.bots[0].enabled true
|
|
55
|
+
openclaw gateway restart
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Configuration Reference
|
|
59
|
+
|
|
60
|
+
The plugin supports multiple bots. Configure them in the `channels.wecom.bots` array.
|
|
61
|
+
|
|
62
|
+
| Config Path | Description | Options | Default |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `channels.wecom.bots[n].botId` | WeCom bot ID | — | — |
|
|
65
|
+
| `channels.wecom.bots[n].secret` | WeCom bot secret | — | — |
|
|
66
|
+
| `channels.wecom.bots[n].tinyId` | Short ID for session isolation | — | `botId` |
|
|
67
|
+
| `channels.wecom.bots[n].enabled` | Enable this bot | `true` / `false` | `false` |
|
|
68
|
+
| `channels.wecom.bots[n].name` | Display name for logs/UI | — | — |
|
|
69
|
+
| `channels.wecom.bots[n].websocketUrl` | WebSocket endpoint | — | `wss://openws.work.weixin.qq.com` |
|
|
70
|
+
| `channels.wecom.bots[n].dmPolicy` | DM access policy | `pairing` / `open` / `allowlist` / `disabled` | `pairing` |
|
|
71
|
+
| `channels.wecom.bots[n].allowFrom` | DM allowlist (user IDs) | — | `[]` |
|
|
72
|
+
| `channels.wecom.bots[n].groupPolicy` | Group chat access policy | `open` / `allowlist` / `disabled` | `open` |
|
|
73
|
+
| `channels.wecom.bots[n].groupAllowFrom` | Group allowlist (group IDs) | — | `[]` |
|
|
74
|
+
| `channels.wecom.bots[n].sendThinkingMessage` | Send "thinking" placeholder | `true` / `false` | `true` |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🔒 Access Control
|
|
79
|
+
|
|
80
|
+
### DM (Direct Message) Access
|
|
81
|
+
|
|
82
|
+
**Default**: `dmPolicy: "pairing"` — unrecognized users will receive a pairing code.
|
|
83
|
+
|
|
84
|
+
#### Approve Pairing
|
|
85
|
+
|
|
86
|
+
```shell
|
|
87
|
+
openclaw pairing list wecom # View pending pairing requests
|
|
88
|
+
openclaw pairing approve wecom <CODE> # Approve a pairing request
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If you have multiple bots, specify the `tinyId` or `botId` using the `--account` flag:
|
|
92
|
+
```shell
|
|
93
|
+
openclaw pairing approve wecom <CODE> --account bot1
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Allowlist Mode
|
|
97
|
+
|
|
98
|
+
Configure allowed user IDs via `allowFrom` for each bot:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"channels": {
|
|
103
|
+
"wecom": {
|
|
104
|
+
"bots": [
|
|
105
|
+
{
|
|
106
|
+
"tinyId": "bot1",
|
|
107
|
+
"botId": "...",
|
|
108
|
+
"secret": "...",
|
|
109
|
+
"dmPolicy": "allowlist",
|
|
110
|
+
"allowFrom": ["user_id_1"]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Open Mode
|
|
119
|
+
|
|
120
|
+
Set `dmPolicy: "open"` to allow all users to send direct messages without approval.
|
|
121
|
+
|
|
122
|
+
#### Disabled Mode
|
|
123
|
+
|
|
124
|
+
Set `dmPolicy: "disabled"` to completely block all direct messages.
|
|
125
|
+
|
|
126
|
+
### Group Access
|
|
127
|
+
|
|
128
|
+
#### Group Policy (`channels.wecom.groupPolicy`)
|
|
129
|
+
|
|
130
|
+
- `"open"` — Allow messages from all groups (default)
|
|
131
|
+
- `"allowlist"` — Only allow groups listed in `groupAllowFrom`
|
|
132
|
+
- `"disabled"` — Disable all group messages
|
|
133
|
+
|
|
134
|
+
### Group Configuration Examples
|
|
135
|
+
|
|
136
|
+
#### Allow All Groups (Default Behavior)
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"channels": {
|
|
141
|
+
"wecom": {
|
|
142
|
+
"groupPolicy": "open"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Allow Only Specific Groups
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"channels": {
|
|
153
|
+
"wecom": {
|
|
154
|
+
"groupPolicy": "allowlist",
|
|
155
|
+
"groupAllowFrom": ["group_id_1", "group_id_2"]
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Allow Only Specific Senders Within a Group (Sender Allowlist)
|
|
162
|
+
|
|
163
|
+
In addition to the group allowlist, you can restrict which members within a group are allowed to interact with the bot. Only messages from users listed in `groups.<chatId>.allowFrom` will be processed; messages from other members will be silently ignored. This is a sender-level allowlist that applies to **all messages**.
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"channels": {
|
|
168
|
+
"wecom": {
|
|
169
|
+
"groupPolicy": "allowlist",
|
|
170
|
+
"groupAllowFrom": ["group_id_1"],
|
|
171
|
+
"groups": {
|
|
172
|
+
"group_id_1": {
|
|
173
|
+
"allowFrom": ["user_id_1", "user_id_2"]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 📦 Update
|
|
184
|
+
|
|
185
|
+
```shell
|
|
186
|
+
openclaw plugins update wecom-openclaw-plugin
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 📄 License
|
|
192
|
+
|
|
193
|
+
MIT
|