@karinjs/adapter-qqbot 1.3.1 → 2.0.0
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 +222 -766
- package/dist/apps/login.d.ts +20 -0
- package/dist/apps/login.js +57 -0
- package/dist/config-H7LrvlNU.js +197 -0
- package/dist/index.d.ts +589 -418
- package/dist/index.js +2844 -97
- package/dist/onboard-BX8g8Wik.js +249 -0
- package/dist/utils-DO4gEkVN.js +3 -0
- package/dist/web.config.d.ts +20 -23
- package/dist/web.config.js +170 -221
- package/package.json +24 -18
- package/dist/chunk-PYOUSZ6B.js +0 -1501
package/dist/web.config.js
CHANGED
|
@@ -1,224 +1,173 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
writeConfig
|
|
5
|
-
} from "./chunk-PYOUSZ6B.js";
|
|
1
|
+
import { a as pkg, n as config, o as writeConfig } from "./config-H7LrvlNU.js";
|
|
2
|
+
import "./utils-DO4gEkVN.js";
|
|
3
|
+
import { components, defineConfig } from "node-karin";
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
import { defineConfig, components } from "node-karin";
|
|
5
|
+
//#region src/web.config.ts
|
|
9
6
|
var web_config_default = defineConfig({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
})
|
|
174
|
-
]
|
|
175
|
-
}),
|
|
176
|
-
components.input.create("event:wsUrl", {
|
|
177
|
-
label: "ws\u5730\u5740",
|
|
178
|
-
description: "\u8BF7\u8F93\u5165\u4F60\u7684ws\u5730\u5740"
|
|
179
|
-
}),
|
|
180
|
-
components.input.create("event:wsToken", {
|
|
181
|
-
label: "wsToken",
|
|
182
|
-
description: "\u8BF7\u8F93\u5165\u4F60\u7684wsToken"
|
|
183
|
-
})
|
|
184
|
-
]
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
|
-
];
|
|
189
|
-
},
|
|
190
|
-
/** 前端点击保存之后调用的方法 */
|
|
191
|
-
save: (config) => {
|
|
192
|
-
const data = [];
|
|
193
|
-
config.qqbot.forEach((item) => {
|
|
194
|
-
data.push({
|
|
195
|
-
...item,
|
|
196
|
-
regex: item.regex.map((item2) => {
|
|
197
|
-
const [reg, rep] = item2.split(" ");
|
|
198
|
-
return {
|
|
199
|
-
reg: reg.replace(/^<|>$|$/g, ""),
|
|
200
|
-
rep: rep.replace(/^<|>$|$/g, "")
|
|
201
|
-
};
|
|
202
|
-
}),
|
|
203
|
-
markdown: {
|
|
204
|
-
mode: item["markdown:mode"] ?? 0,
|
|
205
|
-
id: item["markdown:id"] ?? "",
|
|
206
|
-
kv: item["markdown:kv"] ?? []
|
|
207
|
-
},
|
|
208
|
-
event: {
|
|
209
|
-
type: item["event:type"] ?? 0,
|
|
210
|
-
wsUrl: item["event:wsUrl"] ?? "",
|
|
211
|
-
wsToken: item["event:wsToken"] ?? ""
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
writeConfig(data);
|
|
216
|
-
return {
|
|
217
|
-
success: true,
|
|
218
|
-
message: "\u4FDD\u5B58\u6210\u529F"
|
|
219
|
-
};
|
|
220
|
-
}
|
|
7
|
+
info: {
|
|
8
|
+
id: pkg().name,
|
|
9
|
+
name: "QQBot 适配器",
|
|
10
|
+
version: pkg().version,
|
|
11
|
+
description: "为 karin 提供 QQ 官方 Bot 连接能力(2.0)",
|
|
12
|
+
author: [{
|
|
13
|
+
name: "shijin",
|
|
14
|
+
avatar: "https://github.com/sj817.png"
|
|
15
|
+
}]
|
|
16
|
+
},
|
|
17
|
+
components: () => {
|
|
18
|
+
const data = [];
|
|
19
|
+
config().forEach((item) => {
|
|
20
|
+
data.push({
|
|
21
|
+
title: item.name || item.appId,
|
|
22
|
+
subtitle: item.appId,
|
|
23
|
+
name: item.name,
|
|
24
|
+
appId: item.appId,
|
|
25
|
+
secret: item.secret,
|
|
26
|
+
prodApi: item.prodApi,
|
|
27
|
+
sandboxApi: item.sandboxApi,
|
|
28
|
+
tokenApi: item.tokenApi,
|
|
29
|
+
sandbox: item.sandbox,
|
|
30
|
+
qqEnable: item.qqEnable,
|
|
31
|
+
guildEnable: item.guildEnable,
|
|
32
|
+
guildMode: item.guildMode === 1,
|
|
33
|
+
regex: item.regex.map((r) => `${r.reg} ${r.rep}`),
|
|
34
|
+
"keyboard:enable": item.keyboard?.enable !== false,
|
|
35
|
+
"event:type": String(item.event?.type ?? 2)
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return [components.accordionPro.create("qqbot", data, {
|
|
39
|
+
label: "QQBot",
|
|
40
|
+
description: "QQBot 配置",
|
|
41
|
+
children: {
|
|
42
|
+
key: "qqbotConfig",
|
|
43
|
+
children: [
|
|
44
|
+
components.input.create("name", {
|
|
45
|
+
label: "机器人名称",
|
|
46
|
+
description: "机器人名称,扫码登录会自动获取"
|
|
47
|
+
}),
|
|
48
|
+
components.input.create("appId", {
|
|
49
|
+
label: "AppID",
|
|
50
|
+
description: "机器人 AppID",
|
|
51
|
+
isRequired: true
|
|
52
|
+
}),
|
|
53
|
+
components.input.create("secret", {
|
|
54
|
+
label: "Secret",
|
|
55
|
+
description: "机器人 Secret",
|
|
56
|
+
isRequired: true
|
|
57
|
+
}),
|
|
58
|
+
components.input.create("prodApi", {
|
|
59
|
+
label: "正式环境 API",
|
|
60
|
+
defaultValue: "https://api.sgroup.qq.com",
|
|
61
|
+
isRequired: true
|
|
62
|
+
}),
|
|
63
|
+
components.input.create("sandboxApi", {
|
|
64
|
+
label: "沙盒环境 API",
|
|
65
|
+
defaultValue: "https://sandbox.api.sgroup.qq.com",
|
|
66
|
+
isRequired: true
|
|
67
|
+
}),
|
|
68
|
+
components.input.create("tokenApi", {
|
|
69
|
+
label: "AccessToken 接口",
|
|
70
|
+
defaultValue: "https://bots.qq.com/app/getAppAccessToken",
|
|
71
|
+
isRequired: true
|
|
72
|
+
}),
|
|
73
|
+
components.switch.create("sandbox", {
|
|
74
|
+
label: "沙盒环境",
|
|
75
|
+
description: "启用后调用沙盒 API",
|
|
76
|
+
defaultSelected: false
|
|
77
|
+
}),
|
|
78
|
+
components.switch.create("qqEnable", {
|
|
79
|
+
label: "QQ 场景",
|
|
80
|
+
description: "是否处理私聊和群聊消息",
|
|
81
|
+
defaultSelected: true
|
|
82
|
+
}),
|
|
83
|
+
components.switch.create("guildEnable", {
|
|
84
|
+
label: "频道场景",
|
|
85
|
+
description: "是否处理频道消息",
|
|
86
|
+
defaultSelected: true
|
|
87
|
+
}),
|
|
88
|
+
components.switch.create("guildMode", {
|
|
89
|
+
label: "频道私域模式",
|
|
90
|
+
description: "开启 = 私域机器人;关闭 = 公域机器人",
|
|
91
|
+
defaultSelected: false
|
|
92
|
+
}),
|
|
93
|
+
components.input.group("regex", {
|
|
94
|
+
data: [],
|
|
95
|
+
label: "消息正则替换",
|
|
96
|
+
description: "每行格式:正则表达式 替换内容。如:^/ #",
|
|
97
|
+
template: components.input.create("regex", {
|
|
98
|
+
label: "正则规则",
|
|
99
|
+
placeholder: "^/ #"
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
components.switch.create("keyboard:enable", {
|
|
103
|
+
label: "URL 自动按钮",
|
|
104
|
+
description: "将文本中的链接自动转为 keyboard 按钮",
|
|
105
|
+
defaultSelected: true
|
|
106
|
+
}),
|
|
107
|
+
components.radio.group("event:type", {
|
|
108
|
+
label: "事件接收方式",
|
|
109
|
+
description: "选择 QQ 官方推送事件的方式",
|
|
110
|
+
defaultValue: "2",
|
|
111
|
+
radio: [
|
|
112
|
+
components.radio.create("0", {
|
|
113
|
+
label: "关闭",
|
|
114
|
+
value: "0",
|
|
115
|
+
description: "不接收任何事件"
|
|
116
|
+
}),
|
|
117
|
+
components.radio.create("1", {
|
|
118
|
+
label: "Webhook",
|
|
119
|
+
value: "1",
|
|
120
|
+
description: "QQ 官方主动推送事件到本机"
|
|
121
|
+
}),
|
|
122
|
+
components.radio.create("2", {
|
|
123
|
+
label: "WebSocket",
|
|
124
|
+
value: "2",
|
|
125
|
+
description: "主动连接 QQ 官方 WebSocket 网关接收事件(推荐)"
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
})];
|
|
132
|
+
},
|
|
133
|
+
save: (input) => {
|
|
134
|
+
if (!Array.isArray(input.qqbot)) return {
|
|
135
|
+
success: false,
|
|
136
|
+
message: "保存失败:配置格式错误"
|
|
137
|
+
};
|
|
138
|
+
const data = input.qqbot.map((item) => {
|
|
139
|
+
const guildMode = item.guildMode === true ? 1 : 0;
|
|
140
|
+
const eventType = Number(item["event:type"] ?? 0);
|
|
141
|
+
const regex = (item.regex || []).map((str) => {
|
|
142
|
+
const parts = str.split(" ");
|
|
143
|
+
return {
|
|
144
|
+
reg: parts[0]?.replace(/^<|>$/g, "") || "",
|
|
145
|
+
rep: parts[1]?.replace(/^<|>$/g, "") || ""
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
name: item.name || "",
|
|
150
|
+
appId: item.appId || "",
|
|
151
|
+
secret: item.secret || "",
|
|
152
|
+
prodApi: item.prodApi || "https://api.sgroup.qq.com",
|
|
153
|
+
sandboxApi: item.sandboxApi || "https://sandbox.api.sgroup.qq.com",
|
|
154
|
+
tokenApi: item.tokenApi || "https://bots.qq.com/app/getAppAccessToken",
|
|
155
|
+
sandbox: !!item.sandbox,
|
|
156
|
+
qqEnable: !!item.qqEnable,
|
|
157
|
+
guildEnable: !!item.guildEnable,
|
|
158
|
+
guildMode,
|
|
159
|
+
regex,
|
|
160
|
+
keyboard: { enable: item["keyboard:enable"] !== false },
|
|
161
|
+
event: { type: eventType }
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
writeConfig(data);
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
message: "保存成功"
|
|
168
|
+
};
|
|
169
|
+
}
|
|
221
170
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { web_config_default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karinjs/adapter-qqbot",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "karin
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "karin adapter for QQ Official Bot (2.0)",
|
|
5
5
|
"homepage": "https://github.com/KarinJS/karin-plugin-adapter-qqbot",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/KarinJS/karin-plugin-adapter-qqbot/issues"
|
|
@@ -13,41 +13,47 @@
|
|
|
13
13
|
"author": "shijin",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
16
17
|
"files": [
|
|
17
18
|
"dist"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "tsc &&
|
|
21
|
-
"dev": "tsx src/app.ts",
|
|
21
|
+
"build": "tsc && tsdown",
|
|
22
|
+
"dev": "tsx watch --include \"src/**/*.ts\" src/app.ts",
|
|
22
23
|
"karin": "karin",
|
|
24
|
+
"lint": "eslint src",
|
|
25
|
+
"lint:fix": "eslint src --fix",
|
|
23
26
|
"pub": "npm publish --access public",
|
|
24
|
-
"pub-beta": "npm publish --tag beta",
|
|
25
27
|
"sort": "npx sort-package-json"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
30
|
"@karinjs/geturls": "^1.0.2",
|
|
29
|
-
"form-data": "^4.0.
|
|
30
|
-
"image-size": "^
|
|
31
|
+
"form-data": "^4.0.5",
|
|
32
|
+
"image-size": "^2.0.2",
|
|
31
33
|
"qrcode": "^1.5.4",
|
|
32
|
-
"silk-wasm": "^3.
|
|
34
|
+
"silk-wasm": "^3.7.1",
|
|
33
35
|
"tweetnacl": "^1.0.3"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
|
-
"@types/express": "5.0.
|
|
37
|
-
"@types/
|
|
38
|
-
"@types/
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"typescript": "^5.7.3"
|
|
38
|
+
"@types/express": "5.0.6",
|
|
39
|
+
"@types/node": "^24.12.4",
|
|
40
|
+
"@types/qrcode": "^1.5.6",
|
|
41
|
+
"eslint": "^9.39.4",
|
|
42
|
+
"neostandard": "^0.13.0",
|
|
43
|
+
"node-karin": "^1.15.5",
|
|
44
|
+
"tsdown": "^0.22.0",
|
|
45
|
+
"tsx": "^4.22.0",
|
|
46
|
+
"typescript": "^6.0.3"
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public",
|
|
49
50
|
"registry": "https://registry.npmjs.org"
|
|
50
51
|
},
|
|
52
|
+
"pnpm": {
|
|
53
|
+
"overrides": {
|
|
54
|
+
"yaml@>=2.0.0 <2.8.3": "^2.8.3"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
51
57
|
"karin": {
|
|
52
58
|
"main": "src/index.ts",
|
|
53
59
|
"apps": [
|