@karinjs/adapter-qqbot 2.0.0 → 2.1.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 +102 -255
- package/dist/apps/cleanup.d.ts +5 -0
- package/dist/apps/cleanup.js +22 -0
- package/dist/apps/login.d.ts +1 -3
- package/dist/apps/login.js +65 -16
- package/dist/common-by1GpV0b.js +49 -0
- package/dist/{config-H7LrvlNU.js → config-DKa7596f.js} +21 -48
- package/dist/index.d.ts +490 -19
- package/dist/index.js +2118 -220
- package/dist/message-O73AeL_P.js +1739 -0
- package/dist/{onboard-BX8g8Wik.js → onboard-DPWgX39H.js} +10 -7
- package/dist/utils-BPbnNAix.js +4 -0
- package/dist/web.config.d.ts +3 -3
- package/dist/web.config.js +18 -2
- package/package.json +5 -10
- package/dist/utils-DO4gEkVN.js +0 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as writeConfig, c as log, i as getDefaultConfig, n as config } from "./config-DKa7596f.js";
|
|
2
|
+
import { a as sleep } from "./common-by1GpV0b.js";
|
|
2
3
|
import qrcode from "qrcode";
|
|
3
4
|
import axios from "node-karin/axios";
|
|
4
5
|
import crypto from "node:crypto";
|
|
@@ -128,7 +129,7 @@ const renderQr = async (url) => {
|
|
|
128
129
|
* 3. 解密返回 secret
|
|
129
130
|
*/
|
|
130
131
|
const qrRegister = async (opts = {}) => {
|
|
131
|
-
const { timeoutSeconds = DEFAULT_TIMEOUT_S, onQr } = opts;
|
|
132
|
+
const { timeoutSeconds = DEFAULT_TIMEOUT_S, printTerminal = false, onQr } = opts;
|
|
132
133
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
133
134
|
for (let refresh = 0; refresh <= MAX_REFRESHES; refresh++) {
|
|
134
135
|
let task;
|
|
@@ -141,11 +142,13 @@ const qrRegister = async (opts = {}) => {
|
|
|
141
142
|
const url = buildConnectUrl(task.taskId);
|
|
142
143
|
const { ascii, base64 } = await renderQr(url);
|
|
143
144
|
const qrDeadline = Date.now() + QR_TTL_MS;
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
if (printTerminal) {
|
|
146
|
+
if (ascii) {
|
|
147
|
+
console.log();
|
|
148
|
+
console.log(ascii);
|
|
149
|
+
}
|
|
150
|
+
console.log(` 请使用 QQ 扫码(60s 内有效),或在手机 QQ 打开:\n ${url}\n`);
|
|
147
151
|
}
|
|
148
|
-
console.log(` 请使用 QQ 扫码(60s 内有效),或在手机 QQ 打开:\n ${url}\n`);
|
|
149
152
|
if (onQr) try {
|
|
150
153
|
await onQr({
|
|
151
154
|
url,
|
|
@@ -196,7 +199,7 @@ const qrRegister = async (opts = {}) => {
|
|
|
196
199
|
}
|
|
197
200
|
if (expired) {
|
|
198
201
|
if (refresh >= MAX_REFRESHES) {
|
|
199
|
-
log("error", `[扫码登录] 二维码已过期
|
|
202
|
+
log("error", `[扫码登录] 二维码已过期 4 次,终止流程`);
|
|
200
203
|
return null;
|
|
201
204
|
}
|
|
202
205
|
log("info", `[扫码登录] 二维码 60s 内未完成扫码,正在刷新 (${refresh + 1}/${MAX_REFRESHES})`);
|
package/dist/web.config.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _$node_karin0 from "node-karin";
|
|
2
|
-
|
|
3
1
|
//#region src/web.config.d.ts
|
|
4
|
-
declare const _default:
|
|
2
|
+
declare const _default: import("node-karin").DefineConfig<{
|
|
5
3
|
qqbot: Array<{
|
|
6
4
|
name: string;
|
|
7
5
|
appId: string;
|
|
@@ -15,6 +13,8 @@ declare const _default: _$node_karin0.DefineConfig<{
|
|
|
15
13
|
guildMode: boolean;
|
|
16
14
|
regex: string[];
|
|
17
15
|
"keyboard:enable": boolean;
|
|
16
|
+
"messageCache:enable": boolean;
|
|
17
|
+
"messageCache:self": boolean;
|
|
18
18
|
"event:type": string;
|
|
19
19
|
}>;
|
|
20
20
|
}>;
|
package/dist/web.config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import "./utils-
|
|
1
|
+
import { a as writeConfig, n as config, o as pkg } from "./config-DKa7596f.js";
|
|
2
|
+
import "./utils-BPbnNAix.js";
|
|
3
3
|
import { components, defineConfig } from "node-karin";
|
|
4
4
|
|
|
5
5
|
//#region src/web.config.ts
|
|
@@ -32,6 +32,8 @@ var web_config_default = defineConfig({
|
|
|
32
32
|
guildMode: item.guildMode === 1,
|
|
33
33
|
regex: item.regex.map((r) => `${r.reg} ${r.rep}`),
|
|
34
34
|
"keyboard:enable": item.keyboard?.enable !== false,
|
|
35
|
+
"messageCache:enable": item.messageCache?.enable === true,
|
|
36
|
+
"messageCache:self": item.messageCache?.self === true,
|
|
35
37
|
"event:type": String(item.event?.type ?? 2)
|
|
36
38
|
});
|
|
37
39
|
});
|
|
@@ -104,6 +106,16 @@ var web_config_default = defineConfig({
|
|
|
104
106
|
description: "将文本中的链接自动转为 keyboard 按钮",
|
|
105
107
|
defaultSelected: true
|
|
106
108
|
}),
|
|
109
|
+
components.switch.create("messageCache:enable", {
|
|
110
|
+
label: "启用数据库缓存消息",
|
|
111
|
+
description: "用于 bot.getMsg 查询最近一天消息。开启后会将收到的消息写入本地数据库,并把接收到的富媒体保存到本地;高并发或富媒体消息量较大时不建议开启,可能快速占用磁盘空间甚至导致磁盘溢出。",
|
|
112
|
+
defaultSelected: false
|
|
113
|
+
}),
|
|
114
|
+
components.switch.create("messageCache:self", {
|
|
115
|
+
label: "缓存自己消息",
|
|
116
|
+
description: "仅在启用数据库缓存消息时生效,发送成功后缓存机器人自己的消息",
|
|
117
|
+
defaultSelected: false
|
|
118
|
+
}),
|
|
107
119
|
components.radio.group("event:type", {
|
|
108
120
|
label: "事件接收方式",
|
|
109
121
|
description: "选择 QQ 官方推送事件的方式",
|
|
@@ -158,6 +170,10 @@ var web_config_default = defineConfig({
|
|
|
158
170
|
guildMode,
|
|
159
171
|
regex,
|
|
160
172
|
keyboard: { enable: item["keyboard:enable"] !== false },
|
|
173
|
+
messageCache: {
|
|
174
|
+
enable: !!item["messageCache:enable"],
|
|
175
|
+
self: !!item["messageCache:self"]
|
|
176
|
+
},
|
|
161
177
|
event: { type: eventType }
|
|
162
178
|
};
|
|
163
179
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karinjs/adapter-qqbot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "karin adapter for QQ Official Bot (2.0)",
|
|
5
5
|
"homepage": "https://github.com/KarinJS/karin-plugin-adapter-qqbot",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@karinjs/geturls": "^1.0.2",
|
|
31
|
-
"form-data": "^4.0.
|
|
31
|
+
"form-data": "^4.0.6",
|
|
32
32
|
"image-size": "^2.0.2",
|
|
33
33
|
"qrcode": "^1.5.4",
|
|
34
34
|
"silk-wasm": "^3.7.1",
|
|
@@ -36,24 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/express": "5.0.6",
|
|
39
|
-
"@types/node": "^24.
|
|
39
|
+
"@types/node": "^24.13.2",
|
|
40
40
|
"@types/qrcode": "^1.5.6",
|
|
41
41
|
"eslint": "^9.39.4",
|
|
42
42
|
"neostandard": "^0.13.0",
|
|
43
43
|
"node-karin": "^1.15.5",
|
|
44
|
-
"tsdown": "^0.22.
|
|
45
|
-
"tsx": "^4.22.
|
|
44
|
+
"tsdown": "^0.22.3",
|
|
45
|
+
"tsx": "^4.22.4",
|
|
46
46
|
"typescript": "^6.0.3"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public",
|
|
50
50
|
"registry": "https://registry.npmjs.org"
|
|
51
51
|
},
|
|
52
|
-
"pnpm": {
|
|
53
|
-
"overrides": {
|
|
54
|
-
"yaml@>=2.0.0 <2.8.3": "^2.8.3"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
52
|
"karin": {
|
|
58
53
|
"main": "src/index.ts",
|
|
59
54
|
"apps": [
|
package/dist/utils-DO4gEkVN.js
DELETED