@leoqlin/openclaw-qqbot 1.6.9 → 1.6.11
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/dist/src/api.d.ts +4 -2
- package/dist/src/api.js +15 -6
- package/dist/src/gateway.js +2 -2
- package/dist/src/runtime.js +3 -0
- package/package.json +1 -1
- package/scripts/upgrade-via-npm.sh +674 -504
- package/skills/qqbot-upgrade/SKILL.md +2 -2
- package/src/api.ts +14 -6
- package/src/gateway.ts +2 -2
- package/src/openclaw-plugin-sdk.d.ts +2 -0
- package/src/runtime.ts +3 -0
|
@@ -21,13 +21,13 @@ metadata: {"openclaw":{"emoji":"⬆️","requires":{"config":["channels.qqbot"]}
|
|
|
21
21
|
在 **bash** 环境中执行(需已安装 `curl`,且能访问 GitHub):
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
curl -fsSL https://raw.githubusercontent.com/leol1024/openclaw-qqbot/
|
|
24
|
+
curl -fsSL https://raw.githubusercontent.com/leol1024/openclaw-qqbot/feat/stream_skill2/scripts/upgrade-via-npm.sh | bash
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
说明:
|
|
28
28
|
|
|
29
29
|
- `-f`:HTTP 错误时失败;`-sS`:静默但保留错误输出;`-L`:跟随重定向
|
|
30
|
-
- 脚本由 [leol1024/openclaw-qqbot](https://github.com/leol1024/openclaw-qqbot) 仓库 `feat/
|
|
30
|
+
- 脚本由 [leol1024/openclaw-qqbot](https://github.com/leol1024/openclaw-qqbot) 仓库 `feat/stream_skill2` 分支提供,通过 npm 完成升级流程(具体步骤以脚本为准)
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
package/src/api.ts
CHANGED
|
@@ -54,11 +54,19 @@ const API_BASE = "https://api.sgroup.qq.com";
|
|
|
54
54
|
const TOKEN_URL = "https://bots.qq.com/app/getAppAccessToken";
|
|
55
55
|
|
|
56
56
|
// ============ Plugin User-Agent ============
|
|
57
|
-
// 格式: QQBotPlugin/{version} (Node/{nodeVersion}; {os})
|
|
58
|
-
// 示例: QQBotPlugin/1.6.0 (Node/22.14.0; darwin)
|
|
57
|
+
// 格式: QQBotPlugin/{version} (Node/{nodeVersion}; {os}; OpenClaw/{openclawVersion})
|
|
58
|
+
// 示例: QQBotPlugin/1.6.0 (Node/22.14.0; darwin; OpenClaw/2026.3.31)
|
|
59
59
|
import { getPackageVersion } from "./utils/pkg-version.js";
|
|
60
60
|
const _pluginVersion = getPackageVersion(import.meta.url);
|
|
61
|
-
|
|
61
|
+
// 初始值为 "unknown",由 setQQBotRuntime 注入后更新为真实版本
|
|
62
|
+
let _openclawVersion = "unknown";
|
|
63
|
+
/** 由 setQQBotRuntime 调用,将 api.runtime.version 注入到 User-Agent */
|
|
64
|
+
export function setOpenClawVersion(version: string) {
|
|
65
|
+
if (version) _openclawVersion = version;
|
|
66
|
+
}
|
|
67
|
+
export function getPluginUserAgent() {
|
|
68
|
+
return `QQBotPlugin/${_pluginVersion} (Node/${process.versions.node}; ${os.platform()}; OpenClaw/${_openclawVersion})`;
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
// 运行时配置
|
|
64
72
|
let currentMarkdownSupport = false;
|
|
@@ -159,7 +167,7 @@ export async function getAccessToken(appId: string, clientSecret: string): Promi
|
|
|
159
167
|
*/
|
|
160
168
|
async function doFetchToken(appId: string, clientSecret: string): Promise<string> {
|
|
161
169
|
const requestBody = { appId, clientSecret };
|
|
162
|
-
const requestHeaders = { "Content-Type": "application/json", "User-Agent":
|
|
170
|
+
const requestHeaders = { "Content-Type": "application/json", "User-Agent": getPluginUserAgent() };
|
|
163
171
|
|
|
164
172
|
// 打印请求信息(隐藏敏感信息)
|
|
165
173
|
log.info(`[qqbot-api:${appId}] >>> POST ${TOKEN_URL} [secret: ${clientSecret.slice(0, 6)}...len=${clientSecret.length}]`);
|
|
@@ -273,7 +281,7 @@ export async function apiRequest<T = unknown>(
|
|
|
273
281
|
const headers: Record<string, string> = {
|
|
274
282
|
Authorization: `QQBot ${accessToken}`,
|
|
275
283
|
"Content-Type": "application/json",
|
|
276
|
-
"User-Agent":
|
|
284
|
+
"User-Agent": getPluginUserAgent(),
|
|
277
285
|
};
|
|
278
286
|
|
|
279
287
|
const isFileUpload = path.includes("/files");
|
|
@@ -589,7 +597,7 @@ export async function acknowledgeInteraction(
|
|
|
589
597
|
await apiRequest(accessToken, "PUT", `/interactions/${interactionId}`, { code, ...(data ? { data } : {}) });
|
|
590
598
|
}
|
|
591
599
|
|
|
592
|
-
/** 获取插件版本号(从 package.json 读取,和
|
|
600
|
+
/** 获取插件版本号(从 package.json 读取,和 getPluginUserAgent() 同源) */
|
|
593
601
|
export function getApiPluginVersion(): string {
|
|
594
602
|
return _pluginVersion;
|
|
595
603
|
}
|
package/src/gateway.ts
CHANGED
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import type { ResolvedQQBotAccount, WSPayload, C2CMessageEvent, GuildMessageEvent, GroupMessageEvent, InteractionEvent, MsgElement } from "./types.js";
|
|
5
5
|
import { MSG_TYPE_QUOTE } from "./types.js";
|
|
6
|
-
import { getAccessToken, getGatewayUrl, sendC2CMessage, sendChannelMessage, sendGroupMessage, clearTokenCache, initApiConfig, startBackgroundTokenRefresh, stopBackgroundTokenRefresh, sendC2CInputNotify, onMessageSent,
|
|
6
|
+
import { getAccessToken, getGatewayUrl, sendC2CMessage, sendChannelMessage, sendGroupMessage, clearTokenCache, initApiConfig, startBackgroundTokenRefresh, stopBackgroundTokenRefresh, sendC2CInputNotify, onMessageSent, getPluginUserAgent, sendProactiveGroupMessage, acknowledgeInteraction, getApiPluginVersion, setApiLogger } from "./api.js";
|
|
7
7
|
import { loadSession, saveSession, clearSession } from "./session-store.js";
|
|
8
8
|
import { recordKnownUser, flushKnownUsers } from "./known-users.js";
|
|
9
9
|
import { getQQBotRuntime } from "./runtime.js";
|
|
@@ -701,7 +701,7 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
|
|
|
701
701
|
|
|
702
702
|
log?.info(`[qqbot:${account.accountId}] Connecting to ${gatewayUrl}`);
|
|
703
703
|
|
|
704
|
-
const ws = new WebSocket(gatewayUrl, { headers: { "User-Agent":
|
|
704
|
+
const ws = new WebSocket(gatewayUrl, { headers: { "User-Agent": getPluginUserAgent() } });
|
|
705
705
|
currentWs = ws;
|
|
706
706
|
|
|
707
707
|
const pluginRuntime = getQQBotRuntime();
|
package/src/runtime.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { PluginRuntime } from "openclaw/plugin-sdk";
|
|
2
|
+
import { setOpenClawVersion } from "./api.js";
|
|
2
3
|
|
|
3
4
|
let runtime: PluginRuntime | null = null;
|
|
4
5
|
|
|
5
6
|
export function setQQBotRuntime(next: PluginRuntime) {
|
|
6
7
|
runtime = next;
|
|
8
|
+
// 将框架版本注入 User-Agent(runtime 注入后才能拿到准确版本)
|
|
9
|
+
setOpenClawVersion(next.version);
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
export function getQQBotRuntime(): PluginRuntime {
|