@ryantest/openclaw-qqbot 0.0.1

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.
Files changed (197) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +483 -0
  3. package/README.zh.md +478 -0
  4. package/bin/qqbot-cli.js +243 -0
  5. package/clawdbot.plugin.json +16 -0
  6. package/dist/index.d.ts +17 -0
  7. package/dist/index.js +26 -0
  8. package/dist/src/admin-resolver.d.ts +27 -0
  9. package/dist/src/admin-resolver.js +122 -0
  10. package/dist/src/api.d.ts +156 -0
  11. package/dist/src/api.js +599 -0
  12. package/dist/src/channel.d.ts +11 -0
  13. package/dist/src/channel.js +354 -0
  14. package/dist/src/config.d.ts +25 -0
  15. package/dist/src/config.js +161 -0
  16. package/dist/src/credential-backup.d.ts +31 -0
  17. package/dist/src/credential-backup.js +66 -0
  18. package/dist/src/gateway.d.ts +18 -0
  19. package/dist/src/gateway.js +1265 -0
  20. package/dist/src/image-server.d.ts +68 -0
  21. package/dist/src/image-server.js +462 -0
  22. package/dist/src/inbound-attachments.d.ts +58 -0
  23. package/dist/src/inbound-attachments.js +234 -0
  24. package/dist/src/known-users.d.ts +100 -0
  25. package/dist/src/known-users.js +263 -0
  26. package/dist/src/message-queue.d.ts +50 -0
  27. package/dist/src/message-queue.js +115 -0
  28. package/dist/src/onboarding.d.ts +10 -0
  29. package/dist/src/onboarding.js +203 -0
  30. package/dist/src/outbound-deliver.d.ts +48 -0
  31. package/dist/src/outbound-deliver.js +462 -0
  32. package/dist/src/outbound.d.ts +203 -0
  33. package/dist/src/outbound.js +1102 -0
  34. package/dist/src/proactive.d.ts +170 -0
  35. package/dist/src/proactive.js +399 -0
  36. package/dist/src/ref-index-store.d.ts +70 -0
  37. package/dist/src/ref-index-store.js +273 -0
  38. package/dist/src/reply-dispatcher.d.ts +35 -0
  39. package/dist/src/reply-dispatcher.js +311 -0
  40. package/dist/src/runtime.d.ts +3 -0
  41. package/dist/src/runtime.js +10 -0
  42. package/dist/src/session-store.d.ts +52 -0
  43. package/dist/src/session-store.js +254 -0
  44. package/dist/src/slash-commands.d.ts +71 -0
  45. package/dist/src/slash-commands.js +1179 -0
  46. package/dist/src/startup-greeting.d.ts +30 -0
  47. package/dist/src/startup-greeting.js +78 -0
  48. package/dist/src/stt.d.ts +21 -0
  49. package/dist/src/stt.js +70 -0
  50. package/dist/src/tools/channel.d.ts +16 -0
  51. package/dist/src/tools/channel.js +234 -0
  52. package/dist/src/tools/remind.d.ts +2 -0
  53. package/dist/src/tools/remind.js +247 -0
  54. package/dist/src/types.d.ts +175 -0
  55. package/dist/src/types.js +1 -0
  56. package/dist/src/typing-keepalive.d.ts +27 -0
  57. package/dist/src/typing-keepalive.js +64 -0
  58. package/dist/src/update-checker.d.ts +34 -0
  59. package/dist/src/update-checker.js +166 -0
  60. package/dist/src/user-messages.d.ts +8 -0
  61. package/dist/src/user-messages.js +8 -0
  62. package/dist/src/utils/audio-convert.d.ts +89 -0
  63. package/dist/src/utils/audio-convert.js +704 -0
  64. package/dist/src/utils/file-utils.d.ts +55 -0
  65. package/dist/src/utils/file-utils.js +150 -0
  66. package/dist/src/utils/image-size.d.ts +51 -0
  67. package/dist/src/utils/image-size.js +234 -0
  68. package/dist/src/utils/media-tags.d.ts +14 -0
  69. package/dist/src/utils/media-tags.js +164 -0
  70. package/dist/src/utils/payload.d.ts +112 -0
  71. package/dist/src/utils/payload.js +186 -0
  72. package/dist/src/utils/platform.d.ts +137 -0
  73. package/dist/src/utils/platform.js +390 -0
  74. package/dist/src/utils/text-parsing.d.ts +32 -0
  75. package/dist/src/utils/text-parsing.js +80 -0
  76. package/dist/src/utils/upload-cache.d.ts +34 -0
  77. package/dist/src/utils/upload-cache.js +93 -0
  78. package/index.ts +31 -0
  79. package/moltbot.plugin.json +16 -0
  80. package/node_modules/@eshaz/web-worker/LICENSE +201 -0
  81. package/node_modules/@eshaz/web-worker/README.md +134 -0
  82. package/node_modules/@eshaz/web-worker/browser.js +17 -0
  83. package/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
  84. package/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
  85. package/node_modules/@eshaz/web-worker/index.d.ts +4 -0
  86. package/node_modules/@eshaz/web-worker/node.js +223 -0
  87. package/node_modules/@eshaz/web-worker/package.json +54 -0
  88. package/node_modules/@wasm-audio-decoders/common/index.js +5 -0
  89. package/node_modules/@wasm-audio-decoders/common/package.json +36 -0
  90. package/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
  91. package/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
  92. package/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
  93. package/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
  94. package/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
  95. package/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
  96. package/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
  97. package/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
  98. package/node_modules/mpg123-decoder/README.md +265 -0
  99. package/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
  100. package/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
  101. package/node_modules/mpg123-decoder/index.js +8 -0
  102. package/node_modules/mpg123-decoder/package.json +58 -0
  103. package/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
  104. package/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
  105. package/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
  106. package/node_modules/mpg123-decoder/types.d.ts +30 -0
  107. package/node_modules/silk-wasm/LICENSE +21 -0
  108. package/node_modules/silk-wasm/README.md +85 -0
  109. package/node_modules/silk-wasm/lib/index.cjs +16 -0
  110. package/node_modules/silk-wasm/lib/index.d.ts +70 -0
  111. package/node_modules/silk-wasm/lib/index.mjs +16 -0
  112. package/node_modules/silk-wasm/lib/silk.wasm +0 -0
  113. package/node_modules/silk-wasm/lib/utils.d.ts +4 -0
  114. package/node_modules/silk-wasm/package.json +39 -0
  115. package/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
  116. package/node_modules/simple-yenc/.prettierignore +1 -0
  117. package/node_modules/simple-yenc/LICENSE +7 -0
  118. package/node_modules/simple-yenc/README.md +163 -0
  119. package/node_modules/simple-yenc/dist/esm.js +1 -0
  120. package/node_modules/simple-yenc/dist/index.js +1 -0
  121. package/node_modules/simple-yenc/package.json +50 -0
  122. package/node_modules/simple-yenc/rollup.config.js +27 -0
  123. package/node_modules/simple-yenc/src/simple-yenc.js +302 -0
  124. package/node_modules/ws/LICENSE +20 -0
  125. package/node_modules/ws/README.md +548 -0
  126. package/node_modules/ws/browser.js +8 -0
  127. package/node_modules/ws/index.js +13 -0
  128. package/node_modules/ws/lib/buffer-util.js +131 -0
  129. package/node_modules/ws/lib/constants.js +19 -0
  130. package/node_modules/ws/lib/event-target.js +292 -0
  131. package/node_modules/ws/lib/extension.js +203 -0
  132. package/node_modules/ws/lib/limiter.js +55 -0
  133. package/node_modules/ws/lib/permessage-deflate.js +528 -0
  134. package/node_modules/ws/lib/receiver.js +706 -0
  135. package/node_modules/ws/lib/sender.js +602 -0
  136. package/node_modules/ws/lib/stream.js +161 -0
  137. package/node_modules/ws/lib/subprotocol.js +62 -0
  138. package/node_modules/ws/lib/validation.js +152 -0
  139. package/node_modules/ws/lib/websocket-server.js +554 -0
  140. package/node_modules/ws/lib/websocket.js +1393 -0
  141. package/node_modules/ws/package.json +69 -0
  142. package/node_modules/ws/wrapper.mjs +8 -0
  143. package/openclaw.plugin.json +16 -0
  144. package/package.json +76 -0
  145. package/scripts/cleanup-legacy-plugins.sh +124 -0
  146. package/scripts/proactive-api-server.ts +369 -0
  147. package/scripts/send-proactive.ts +293 -0
  148. package/scripts/set-markdown.sh +156 -0
  149. package/scripts/test-sendmedia.ts +116 -0
  150. package/scripts/upgrade-via-alt-pkg.sh +307 -0
  151. package/scripts/upgrade-via-npm.ps1 +296 -0
  152. package/scripts/upgrade-via-npm.sh +301 -0
  153. package/scripts/upgrade-via-source.sh +774 -0
  154. package/skills/qqbot-channel/SKILL.md +263 -0
  155. package/skills/qqbot-channel/references/api_references.md +521 -0
  156. package/skills/qqbot-media/SKILL.md +56 -0
  157. package/skills/qqbot-remind/SKILL.md +149 -0
  158. package/src/admin-resolver.ts +140 -0
  159. package/src/api.ts +819 -0
  160. package/src/bot-logs-2026-03-21T11-21-47(2).txt +46 -0
  161. package/src/channel.ts +381 -0
  162. package/src/config.ts +187 -0
  163. package/src/credential-backup.ts +72 -0
  164. package/src/gateway.log +43 -0
  165. package/src/gateway.ts +1404 -0
  166. package/src/image-server.ts +539 -0
  167. package/src/inbound-attachments.ts +304 -0
  168. package/src/known-users.ts +353 -0
  169. package/src/message-queue.ts +169 -0
  170. package/src/onboarding.ts +274 -0
  171. package/src/openclaw-2026-03-21.log +3729 -0
  172. package/src/openclaw-plugin-sdk.d.ts +522 -0
  173. package/src/outbound-deliver.ts +552 -0
  174. package/src/outbound.ts +1266 -0
  175. package/src/proactive.ts +530 -0
  176. package/src/ref-index-store.ts +357 -0
  177. package/src/reply-dispatcher.ts +334 -0
  178. package/src/runtime.ts +14 -0
  179. package/src/session-store.ts +303 -0
  180. package/src/slash-commands.ts +1305 -0
  181. package/src/startup-greeting.ts +98 -0
  182. package/src/stt.ts +86 -0
  183. package/src/tools/channel.ts +281 -0
  184. package/src/tools/remind.ts +296 -0
  185. package/src/types.ts +183 -0
  186. package/src/typing-keepalive.ts +59 -0
  187. package/src/update-checker.ts +179 -0
  188. package/src/user-messages.ts +7 -0
  189. package/src/utils/audio-convert.ts +803 -0
  190. package/src/utils/file-utils.ts +167 -0
  191. package/src/utils/image-size.ts +266 -0
  192. package/src/utils/media-tags.ts +182 -0
  193. package/src/utils/payload.ts +265 -0
  194. package/src/utils/platform.ts +435 -0
  195. package/src/utils/text-parsing.ts +82 -0
  196. package/src/utils/upload-cache.ts +128 -0
  197. package/tsconfig.json +16 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * 版本检查器
3
+ *
4
+ * - triggerUpdateCheck(): gateway 启动时调用,后台预热缓存
5
+ * - getUpdateInfo(): 每次实时查询 npm registry,返回最新结果
6
+ *
7
+ * 使用 HTTPS 直接请求 npm registry API(不依赖 npm CLI),
8
+ * 支持多 registry fallback:npmjs.org → npmmirror.com,解决国内网络问题。
9
+ */
10
+
11
+ import { createRequire } from "node:module";
12
+ import https from "node:https";
13
+
14
+ const require = createRequire(import.meta.url);
15
+
16
+ const PKG_NAME = "@tencent-connect/openclaw-qqbot";
17
+ const ENCODED_PKG = encodeURIComponent(PKG_NAME);
18
+
19
+ const REGISTRIES = [
20
+ `https://registry.npmjs.org/${ENCODED_PKG}`,
21
+ `https://registry.npmmirror.com/${ENCODED_PKG}`,
22
+ ];
23
+
24
+ let CURRENT_VERSION = "unknown";
25
+ try {
26
+ const pkg = require("../package.json");
27
+ CURRENT_VERSION = pkg.version ?? "unknown";
28
+ } catch {
29
+ // fallback
30
+ }
31
+
32
+ export interface UpdateInfo {
33
+ current: string;
34
+ /** 最佳升级目标(prerelease 用户优先 alpha,稳定版用户取 latest) */
35
+ latest: string | null;
36
+ /** 稳定版 dist-tag */
37
+ stable: string | null;
38
+ /** alpha dist-tag */
39
+ alpha: string | null;
40
+ hasUpdate: boolean;
41
+ checkedAt: number;
42
+ error?: string;
43
+ }
44
+
45
+ let _log: { info: (msg: string) => void; error: (msg: string) => void; debug?: (msg: string) => void } | undefined;
46
+
47
+ function fetchJson(url: string, timeoutMs: number): Promise<any> {
48
+ return new Promise((resolve, reject) => {
49
+ const req = https.get(url, { timeout: timeoutMs, headers: { Accept: "application/json" } }, (res) => {
50
+ if (res.statusCode !== 200) {
51
+ res.resume();
52
+ reject(new Error(`HTTP ${res.statusCode} from ${url}`));
53
+ return;
54
+ }
55
+ let data = "";
56
+ res.on("data", (chunk: string) => { data += chunk; });
57
+ res.on("end", () => {
58
+ try { resolve(JSON.parse(data)); } catch (e) { reject(e); }
59
+ });
60
+ });
61
+ req.on("error", reject);
62
+ req.on("timeout", () => { req.destroy(); reject(new Error(`timeout fetching ${url}`)); });
63
+ });
64
+ }
65
+
66
+ async function fetchDistTags(): Promise<Record<string, string>> {
67
+ for (const url of REGISTRIES) {
68
+ try {
69
+ const json = await fetchJson(url, 10_000);
70
+ const tags = json["dist-tags"];
71
+ if (tags && typeof tags === "object") return tags;
72
+ } catch (e: any) {
73
+ _log?.debug?.(`[qqbot:update-checker] ${url} failed: ${e.message}`);
74
+ }
75
+ }
76
+ throw new Error("all registries failed");
77
+ }
78
+
79
+ function buildUpdateInfo(tags: Record<string, string>): UpdateInfo {
80
+ const currentIsPrerelease = CURRENT_VERSION.includes("-");
81
+ const stableTag = tags.latest || null;
82
+ const alphaTag = tags.alpha || null;
83
+
84
+ // 严格隔离:alpha 只跟 alpha 比,正式版只跟正式版比,不交叉
85
+ const compareTarget = currentIsPrerelease ? alphaTag : stableTag;
86
+
87
+ const hasUpdate = typeof compareTarget === "string"
88
+ && compareTarget !== CURRENT_VERSION
89
+ && compareVersions(compareTarget, CURRENT_VERSION) > 0;
90
+
91
+ return {
92
+ current: CURRENT_VERSION,
93
+ latest: compareTarget,
94
+ stable: stableTag,
95
+ alpha: alphaTag,
96
+ hasUpdate,
97
+ checkedAt: Date.now(),
98
+ };
99
+ }
100
+
101
+ /** gateway 启动时调用,保存 log 引用 */
102
+ export function triggerUpdateCheck(log?: {
103
+ info: (msg: string) => void;
104
+ error: (msg: string) => void;
105
+ debug?: (msg: string) => void;
106
+ }): void {
107
+ if (log) _log = log;
108
+ // 预热:fire-and-forget
109
+ getUpdateInfo().then((info) => {
110
+ if (info.hasUpdate) {
111
+ _log?.info?.(`[qqbot:update-checker] new version available: ${info.latest} (current: ${CURRENT_VERSION})`);
112
+ }
113
+ }).catch(() => {});
114
+ }
115
+
116
+ /** 每次实时查询 npm registry */
117
+ export async function getUpdateInfo(): Promise<UpdateInfo> {
118
+ try {
119
+ const tags = await fetchDistTags();
120
+ return buildUpdateInfo(tags);
121
+ } catch (err: any) {
122
+ _log?.debug?.(`[qqbot:update-checker] check failed: ${err.message}`);
123
+ return { current: CURRENT_VERSION, latest: null, stable: null, alpha: null, hasUpdate: false, checkedAt: Date.now(), error: err.message };
124
+ }
125
+ }
126
+
127
+ /**
128
+ * 检查指定版本是否存在于 npm registry
129
+ * 用于 /bot-upgrade --version 的前置校验
130
+ */
131
+ export async function checkVersionExists(version: string): Promise<boolean> {
132
+ for (const baseUrl of REGISTRIES) {
133
+ try {
134
+ const url = `${baseUrl}/${version}`;
135
+ const json = await fetchJson(url, 10_000);
136
+ if (json && json.version === version) return true;
137
+ } catch {
138
+ // try next registry
139
+ }
140
+ }
141
+ return false;
142
+ }
143
+
144
+ function compareVersions(a: string, b: string): number {
145
+ const parse = (v: string) => {
146
+ const clean = v.replace(/^v/, "");
147
+ const [main, pre] = clean.split("-", 2);
148
+ return { parts: main.split(".").map(Number), pre: pre || null };
149
+ };
150
+ const pa = parse(a);
151
+ const pb = parse(b);
152
+ // 先比主版本号
153
+ for (let i = 0; i < 3; i++) {
154
+ const diff = (pa.parts[i] || 0) - (pb.parts[i] || 0);
155
+ if (diff !== 0) return diff;
156
+ }
157
+ // 主版本号相同:正式版 > prerelease
158
+ if (!pa.pre && pb.pre) return 1;
159
+ if (pa.pre && !pb.pre) return -1;
160
+ if (!pa.pre && !pb.pre) return 0;
161
+ // 都是 prerelease:按段逐一比较(alpha.1 vs alpha.2)
162
+ const aParts = pa.pre!.split(".");
163
+ const bParts = pb.pre!.split(".");
164
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
165
+ const aP = aParts[i] ?? "";
166
+ const bP = bParts[i] ?? "";
167
+ const aNum = Number(aP);
168
+ const bNum = Number(bP);
169
+ // 都是数字则按数字比较
170
+ if (!isNaN(aNum) && !isNaN(bNum)) {
171
+ if (aNum !== bNum) return aNum - bNum;
172
+ } else {
173
+ // 字符串比较
174
+ if (aP < bP) return -1;
175
+ if (aP > bP) return 1;
176
+ }
177
+ }
178
+ return 0;
179
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 用户面向的提示文案 — 已清空
3
+ *
4
+ * 设计原则(对齐飞书插件):
5
+ * QQBot 插件层不生成额外的用户提示信息。
6
+ * 所有运行时错误仅写日志,不面向用户展示。
7
+ */