@ssfxx44533/onebot-qq 0.1.2
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 +119 -0
- package/index.ts +3 -0
- package/openclaw.plugin.json +192 -0
- package/package.json +47 -0
- package/setup-entry.ts +3 -0
- package/src/channel.ts +549 -0
- package/src/config.js +380 -0
- package/src/inbound.ts +587 -0
- package/src/message.js +235 -0
- package/src/onebot-client.js +226 -0
- package/src/plugin.ts +16 -0
- package/src/runtime.js +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @ssfxx44533/onebot-qq
|
|
2
|
+
|
|
3
|
+
OpenClaw 原生 `ChannelPlugin`,直接把 NapCat / OneBot QQ 接到 OpenClaw。
|
|
4
|
+
|
|
5
|
+
设计目标:
|
|
6
|
+
|
|
7
|
+
- 不再做独立 bridge + main + cron 的拼装服务
|
|
8
|
+
- 不在接入层持有模型 API token
|
|
9
|
+
- QQ 入站消息直接进入 OpenClaw 原生 session / reply pipeline
|
|
10
|
+
- 出站统一走 OpenClaw channel 能力,支持文本、图片、音频、视频、文件
|
|
11
|
+
|
|
12
|
+
## 当前范围
|
|
13
|
+
|
|
14
|
+
已实现:
|
|
15
|
+
|
|
16
|
+
- NapCat WebSocket 长连接与自动重连(指数退避重连)
|
|
17
|
+
- QQ 私聊入站
|
|
18
|
+
- QQ 群聊入站,默认要求 `@机器人`
|
|
19
|
+
- OpenClaw 原生 session 路由与自动回复分发
|
|
20
|
+
- DM pairing 审批流
|
|
21
|
+
- 入站图片 / 音频 / 视频自动缓存到本地媒体目录
|
|
22
|
+
- 入站文件附件元数据提取(`file` / `onlinefile`)
|
|
23
|
+
- 文本回复(超长自动分块,默认 1200 字)
|
|
24
|
+
- 图片 / 音频 / 视频消息发送
|
|
25
|
+
- 普通文件上传
|
|
26
|
+
- 基础 `allowFrom` / `groupAllowFrom` / `dmPolicy` / `groupPolicy`
|
|
27
|
+
- per-group `requireMention` / `systemPrompt` / `allowFrom`
|
|
28
|
+
|
|
29
|
+
暂未实现:
|
|
30
|
+
|
|
31
|
+
- OneBot 反向 HTTP webhook 模式
|
|
32
|
+
- 多账号复杂编排
|
|
33
|
+
|
|
34
|
+
## 安装
|
|
35
|
+
|
|
36
|
+
本地开发链接:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
openclaw plugins install -l /root/openclaw-onebot-qq
|
|
40
|
+
openclaw plugins enable onebot-qq
|
|
41
|
+
openclaw gateway restart
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
后续发布到 npm 后:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
openclaw plugins install @ssfxx44533/onebot-qq
|
|
48
|
+
openclaw plugins enable onebot-qq
|
|
49
|
+
openclaw gateway restart
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 配置
|
|
53
|
+
|
|
54
|
+
最小配置:
|
|
55
|
+
|
|
56
|
+
```json5
|
|
57
|
+
{
|
|
58
|
+
channels: {
|
|
59
|
+
"onebot-qq": {
|
|
60
|
+
enabled: true,
|
|
61
|
+
wsUrl: "ws://localhost:3001/?access_token=napcat_ws"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
plugins: {
|
|
65
|
+
entries: {
|
|
66
|
+
"onebot-qq": {
|
|
67
|
+
enabled: true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
常用配置:
|
|
75
|
+
|
|
76
|
+
```json5
|
|
77
|
+
{
|
|
78
|
+
channels: {
|
|
79
|
+
"onebot-qq": {
|
|
80
|
+
enabled: true,
|
|
81
|
+
wsUrl: "ws://localhost:3001/?access_token=napcat_ws",
|
|
82
|
+
selfId: "3546821676",
|
|
83
|
+
requireMention: true,
|
|
84
|
+
dmPolicy: "pairing",
|
|
85
|
+
mediaMaxMb: 20,
|
|
86
|
+
groupPolicy: "open",
|
|
87
|
+
allowFrom: ["123456789"],
|
|
88
|
+
groupAllowFrom: ["123456789"],
|
|
89
|
+
groups: {
|
|
90
|
+
"987654321": {
|
|
91
|
+
requireMention: true,
|
|
92
|
+
systemPrompt: "这是内部群,优先简洁回复。"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 出站目标格式
|
|
101
|
+
|
|
102
|
+
- 私聊:直接填 QQ 号,例如 `123456789`
|
|
103
|
+
- 私聊:也可以用 `qq:123456789` 或 `private:123456789`
|
|
104
|
+
- 群聊:用 `group:987654321`
|
|
105
|
+
|
|
106
|
+
## 开发检查
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd /root/openclaw-onebot-qq
|
|
110
|
+
npm test
|
|
111
|
+
npm run check
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 兼容性说明
|
|
115
|
+
|
|
116
|
+
当前 OpenClaw 插件安装器只会对插件 `package.json` 里的 `dependencies`
|
|
117
|
+
执行隔离目录内的 `npm install`。因此本插件显式声明了 `openclaw`
|
|
118
|
+
运行时依赖,避免首次安装后出现
|
|
119
|
+
`Cannot find module 'openclaw/plugin-sdk/...` 这类宿主 SDK 解析失败。
|
package/index.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "onebot-qq",
|
|
3
|
+
"kind": "channel",
|
|
4
|
+
"channels": ["onebot-qq"],
|
|
5
|
+
"name": "OneBot QQ",
|
|
6
|
+
"description": "OpenClaw channel plugin for NapCat / OneBot QQ",
|
|
7
|
+
"configSchema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"enabled": {
|
|
12
|
+
"type": "boolean"
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"wsUrl": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"accessToken": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"selfId": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"defaultTo": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"dmPolicy": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["open", "allowlist", "pairing", "disabled"]
|
|
32
|
+
},
|
|
33
|
+
"groupPolicy": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
36
|
+
},
|
|
37
|
+
"allowFrom": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"groupAllowFrom": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"requireMention": {
|
|
50
|
+
"type": "boolean"
|
|
51
|
+
},
|
|
52
|
+
"mediaMaxMb": {
|
|
53
|
+
"type": "number",
|
|
54
|
+
"minimum": 0
|
|
55
|
+
},
|
|
56
|
+
"maxChunkLength": {
|
|
57
|
+
"type": "integer",
|
|
58
|
+
"minimum": 1
|
|
59
|
+
},
|
|
60
|
+
"callTimeoutMs": {
|
|
61
|
+
"type": "integer",
|
|
62
|
+
"minimum": 1
|
|
63
|
+
},
|
|
64
|
+
"reconnectBaseMs": {
|
|
65
|
+
"type": "integer",
|
|
66
|
+
"minimum": 1
|
|
67
|
+
},
|
|
68
|
+
"reconnectMaxMs": {
|
|
69
|
+
"type": "integer",
|
|
70
|
+
"minimum": 1
|
|
71
|
+
},
|
|
72
|
+
"groups": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"enabled": {
|
|
79
|
+
"type": "boolean"
|
|
80
|
+
},
|
|
81
|
+
"requireMention": {
|
|
82
|
+
"type": "boolean"
|
|
83
|
+
},
|
|
84
|
+
"systemPrompt": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"allowFrom": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "string"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"accounts": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"properties": {
|
|
102
|
+
"enabled": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
},
|
|
105
|
+
"name": {
|
|
106
|
+
"type": "string"
|
|
107
|
+
},
|
|
108
|
+
"wsUrl": {
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"accessToken": {
|
|
112
|
+
"type": "string"
|
|
113
|
+
},
|
|
114
|
+
"selfId": {
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"defaultTo": {
|
|
118
|
+
"type": "string"
|
|
119
|
+
},
|
|
120
|
+
"dmPolicy": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"enum": ["open", "allowlist", "pairing", "disabled"]
|
|
123
|
+
},
|
|
124
|
+
"groupPolicy": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
127
|
+
},
|
|
128
|
+
"allowFrom": {
|
|
129
|
+
"type": "array",
|
|
130
|
+
"items": {
|
|
131
|
+
"type": "string"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"groupAllowFrom": {
|
|
135
|
+
"type": "array",
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "string"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"requireMention": {
|
|
141
|
+
"type": "boolean"
|
|
142
|
+
},
|
|
143
|
+
"mediaMaxMb": {
|
|
144
|
+
"type": "number",
|
|
145
|
+
"minimum": 0
|
|
146
|
+
},
|
|
147
|
+
"maxChunkLength": {
|
|
148
|
+
"type": "integer",
|
|
149
|
+
"minimum": 1
|
|
150
|
+
},
|
|
151
|
+
"callTimeoutMs": {
|
|
152
|
+
"type": "integer",
|
|
153
|
+
"minimum": 1
|
|
154
|
+
},
|
|
155
|
+
"reconnectBaseMs": {
|
|
156
|
+
"type": "integer",
|
|
157
|
+
"minimum": 1
|
|
158
|
+
},
|
|
159
|
+
"reconnectMaxMs": {
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"minimum": 1
|
|
162
|
+
},
|
|
163
|
+
"groups": {
|
|
164
|
+
"type": "object",
|
|
165
|
+
"additionalProperties": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"additionalProperties": false,
|
|
168
|
+
"properties": {
|
|
169
|
+
"enabled": {
|
|
170
|
+
"type": "boolean"
|
|
171
|
+
},
|
|
172
|
+
"requireMention": {
|
|
173
|
+
"type": "boolean"
|
|
174
|
+
},
|
|
175
|
+
"systemPrompt": {
|
|
176
|
+
"type": "string"
|
|
177
|
+
},
|
|
178
|
+
"allowFrom": {
|
|
179
|
+
"type": "array",
|
|
180
|
+
"items": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ssfxx44533/onebot-qq",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "OpenClaw channel plugin for NapCat / OneBot QQ",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"src/",
|
|
15
|
+
"index.ts",
|
|
16
|
+
"setup-entry.ts",
|
|
17
|
+
"openclaw.plugin.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test",
|
|
22
|
+
"check": "node --check src/*.js && node --test"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"openclaw": ">=2026.3.13"
|
|
26
|
+
},
|
|
27
|
+
"openclaw": {
|
|
28
|
+
"extensions": [
|
|
29
|
+
"./index.ts"
|
|
30
|
+
],
|
|
31
|
+
"setupEntry": "./setup-entry.ts",
|
|
32
|
+
"channel": {
|
|
33
|
+
"id": "onebot-qq",
|
|
34
|
+
"label": "OneBot QQ",
|
|
35
|
+
"selectionLabel": "OneBot QQ",
|
|
36
|
+
"docsPath": "/channels/onebot-qq",
|
|
37
|
+
"docsLabel": "OneBot QQ",
|
|
38
|
+
"blurb": "Direct NapCat / OneBot QQ channel plugin for OpenClaw.",
|
|
39
|
+
"order": 76
|
|
40
|
+
},
|
|
41
|
+
"install": {
|
|
42
|
+
"npmSpec": "@ssfxx44533/onebot-qq",
|
|
43
|
+
"defaultChoice": "npm",
|
|
44
|
+
"minHostVersion": ">=2026.3.13"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/setup-entry.ts
ADDED