@tencent-connect/openclaw-qqbot 1.7.2 → 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.
Files changed (291) hide show
  1. package/README.md +25 -8
  2. package/README.zh.md +24 -8
  3. package/bin/qqbot-cli.js +5 -2
  4. package/dist/index.cjs +15549 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.cts +890 -0
  7. package/index.ts +56 -19
  8. package/openclaw.plugin.json +19 -3
  9. package/package.json +14 -23
  10. package/preload.cjs +17 -14
  11. package/scripts/link-sdk-core.cjs +133 -50
  12. package/scripts/upgrade-via-npm.sh +42 -11
  13. package/scripts/upgrade-via-source.sh +4 -4
  14. package/skills/qqbot-channel/SKILL.md +34 -12
  15. package/src/adapter/contract.ts +69 -0
  16. package/src/adapter/gateway.ts +61 -0
  17. package/src/adapter/index.ts +15 -0
  18. package/src/adapter/lint.ts +144 -0
  19. package/src/adapter/media.ts +112 -0
  20. package/src/adapter/pairing.ts +99 -0
  21. package/src/adapter/resolve.ts +333 -0
  22. package/src/adapter/setup.ts +55 -0
  23. package/src/adapter/webhook.ts +248 -0
  24. package/src/adapter/workspace.ts +29 -0
  25. package/src/bot-instance.ts +60 -0
  26. package/src/channel.ts +202 -413
  27. package/src/commands/bot-approve.ts +143 -0
  28. package/src/commands/bot-clear-storage.ts +114 -0
  29. package/src/commands/bot-group-always.ts +62 -0
  30. package/src/commands/bot-help.ts +40 -0
  31. package/src/commands/bot-logs.ts +248 -0
  32. package/src/commands/bot-me.ts +18 -0
  33. package/src/commands/bot-pairing.ts +57 -0
  34. package/src/commands/bot-ping.ts +33 -0
  35. package/src/commands/bot-streaming.ts +55 -0
  36. package/src/commands/bot-upgrade.ts +56 -0
  37. package/src/commands/bot-version.ts +41 -0
  38. package/src/commands/config-util.ts +96 -0
  39. package/src/commands/index.ts +49 -0
  40. package/src/config.ts +46 -19
  41. package/src/dispatch/body-assembler.ts +356 -0
  42. package/src/dispatch/ctx-builder.ts +110 -0
  43. package/src/dispatch/dispatch.ts +352 -0
  44. package/src/dispatch/envelope-builder.ts +112 -0
  45. package/src/dispatch/index.ts +2 -0
  46. package/src/{approval-handler.ts → features/approval-handler.ts} +40 -94
  47. package/src/features/approval-utils.ts +41 -0
  48. package/src/features/credential-backup.ts +82 -0
  49. package/src/features/history-store.ts +19 -0
  50. package/src/features/msgid-cache.ts +55 -0
  51. package/src/features/onboarding.ts +38 -0
  52. package/src/{proactive.ts → features/proactive.ts} +68 -49
  53. package/src/features/ref-index-store.ts +282 -0
  54. package/src/{update-checker.ts → features/update-checker.ts} +15 -35
  55. package/src/gateway/event-handlers.ts +241 -0
  56. package/src/gateway/index.ts +3 -0
  57. package/src/gateway/lifecycle.ts +221 -0
  58. package/src/gateway/middleware-setup.ts +139 -0
  59. package/src/gateway/qqbot-gateway.ts +342 -0
  60. package/src/middleware/access-control.ts +130 -0
  61. package/src/middleware/attachment.ts +314 -0
  62. package/src/middleware/policy-injector.ts +66 -0
  63. package/src/openclaw-plugin-sdk.d.ts +81 -10
  64. package/src/outbound/cron-scheduler.ts +130 -0
  65. package/src/outbound/debounce.ts +102 -0
  66. package/src/outbound/deliver-pipeline.ts +235 -0
  67. package/src/outbound/image-size.ts +123 -0
  68. package/src/outbound/index.ts +3 -0
  69. package/src/outbound/local-file-router.ts +145 -0
  70. package/src/outbound/media-send.ts +377 -0
  71. package/src/outbound/outbound-service.ts +222 -0
  72. package/src/outbound/reply-limiter.ts +128 -0
  73. package/src/outbound/sanitize.ts +32 -0
  74. package/src/outbound/streaming-controller.ts +228 -0
  75. package/src/outbound/target.ts +63 -0
  76. package/src/outbound/tts-provider.ts +84 -0
  77. package/src/request-context.ts +9 -8
  78. package/src/runtime.ts +31 -6
  79. package/src/setup/account-key.ts +41 -0
  80. package/src/setup/finalize.ts +110 -0
  81. package/src/setup/login.ts +197 -0
  82. package/src/setup/surface.ts +40 -0
  83. package/src/tools/platform.ts +149 -0
  84. package/src/tools/remind.ts +2 -0
  85. package/src/types-augment.d.ts +54 -0
  86. package/src/types.ts +51 -9
  87. package/src/utils/mention.ts +52 -0
  88. package/src/utils/pkg-version.ts +84 -47
  89. package/src/utils/platform.ts +31 -7
  90. package/src/utils/plugin-logger.ts +104 -0
  91. package/src/utils/ssrf-guard.ts +32 -2
  92. package/src/utils/stt.ts +137 -0
  93. package/src/utils/voice-text.ts +61 -0
  94. package/tsconfig.json +2 -1
  95. package/tsup.config.ts +57 -0
  96. package/dist/index.d.ts +0 -18
  97. package/dist/index.js +0 -27
  98. package/dist/src/admin-resolver.d.ts +0 -33
  99. package/dist/src/admin-resolver.js +0 -157
  100. package/dist/src/api.d.ts +0 -309
  101. package/dist/src/api.js +0 -923
  102. package/dist/src/approval-handler.d.ts +0 -47
  103. package/dist/src/approval-handler.js +0 -372
  104. package/dist/src/channel.d.ts +0 -29
  105. package/dist/src/channel.js +0 -528
  106. package/dist/src/config.d.ts +0 -60
  107. package/dist/src/config.js +0 -288
  108. package/dist/src/credential-backup.d.ts +0 -31
  109. package/dist/src/credential-backup.js +0 -66
  110. package/dist/src/deliver-debounce.d.ts +0 -74
  111. package/dist/src/deliver-debounce.js +0 -174
  112. package/dist/src/gateway.d.ts +0 -18
  113. package/dist/src/gateway.js +0 -2025
  114. package/dist/src/group-history.d.ts +0 -136
  115. package/dist/src/group-history.js +0 -226
  116. package/dist/src/image-server.d.ts +0 -87
  117. package/dist/src/image-server.js +0 -570
  118. package/dist/src/inbound-attachments.d.ts +0 -60
  119. package/dist/src/inbound-attachments.js +0 -248
  120. package/dist/src/known-users.d.ts +0 -100
  121. package/dist/src/known-users.js +0 -263
  122. package/dist/src/message-gating.d.ts +0 -53
  123. package/dist/src/message-gating.js +0 -107
  124. package/dist/src/message-queue.d.ts +0 -91
  125. package/dist/src/message-queue.js +0 -257
  126. package/dist/src/onboarding.d.ts +0 -10
  127. package/dist/src/onboarding.js +0 -203
  128. package/dist/src/outbound-deliver.d.ts +0 -48
  129. package/dist/src/outbound-deliver.js +0 -392
  130. package/dist/src/outbound.d.ts +0 -220
  131. package/dist/src/outbound.js +0 -975
  132. package/dist/src/proactive.d.ts +0 -170
  133. package/dist/src/proactive.js +0 -399
  134. package/dist/src/ref-index-store.d.ts +0 -101
  135. package/dist/src/ref-index-store.js +0 -298
  136. package/dist/src/reply-dispatcher.d.ts +0 -35
  137. package/dist/src/reply-dispatcher.js +0 -311
  138. package/dist/src/request-context.d.ts +0 -25
  139. package/dist/src/request-context.js +0 -37
  140. package/dist/src/runtime.d.ts +0 -3
  141. package/dist/src/runtime.js +0 -13
  142. package/dist/src/session-store.d.ts +0 -52
  143. package/dist/src/session-store.js +0 -254
  144. package/dist/src/slash-commands.d.ts +0 -82
  145. package/dist/src/slash-commands.js +0 -2233
  146. package/dist/src/startup-greeting.d.ts +0 -30
  147. package/dist/src/startup-greeting.js +0 -97
  148. package/dist/src/streaming.d.ts +0 -247
  149. package/dist/src/streaming.js +0 -899
  150. package/dist/src/stt.d.ts +0 -21
  151. package/dist/src/stt.js +0 -70
  152. package/dist/src/tools/channel.d.ts +0 -16
  153. package/dist/src/tools/channel.js +0 -231
  154. package/dist/src/tools/remind.d.ts +0 -2
  155. package/dist/src/tools/remind.js +0 -255
  156. package/dist/src/transport/index.d.ts +0 -10
  157. package/dist/src/transport/index.js +0 -9
  158. package/dist/src/transport/webhook-transport.d.ts +0 -67
  159. package/dist/src/transport/webhook-transport.js +0 -245
  160. package/dist/src/transport/webhook-verify.d.ts +0 -48
  161. package/dist/src/transport/webhook-verify.js +0 -98
  162. package/dist/src/types.d.ts +0 -462
  163. package/dist/src/types.js +0 -22
  164. package/dist/src/typing-keepalive.d.ts +0 -27
  165. package/dist/src/typing-keepalive.js +0 -64
  166. package/dist/src/update-checker.d.ts +0 -36
  167. package/dist/src/update-checker.js +0 -171
  168. package/dist/src/utils/audio-convert.d.ts +0 -98
  169. package/dist/src/utils/audio-convert.js +0 -783
  170. package/dist/src/utils/chunked-upload.d.ts +0 -68
  171. package/dist/src/utils/chunked-upload.js +0 -341
  172. package/dist/src/utils/file-utils.d.ts +0 -61
  173. package/dist/src/utils/file-utils.js +0 -172
  174. package/dist/src/utils/image-size.d.ts +0 -51
  175. package/dist/src/utils/image-size.js +0 -234
  176. package/dist/src/utils/media-send.d.ts +0 -158
  177. package/dist/src/utils/media-send.js +0 -502
  178. package/dist/src/utils/media-tags.d.ts +0 -14
  179. package/dist/src/utils/media-tags.js +0 -165
  180. package/dist/src/utils/payload.d.ts +0 -112
  181. package/dist/src/utils/payload.js +0 -186
  182. package/dist/src/utils/pkg-version.d.ts +0 -5
  183. package/dist/src/utils/pkg-version.js +0 -61
  184. package/dist/src/utils/platform.d.ts +0 -137
  185. package/dist/src/utils/platform.js +0 -390
  186. package/dist/src/utils/ssrf-guard.d.ts +0 -25
  187. package/dist/src/utils/ssrf-guard.js +0 -91
  188. package/dist/src/utils/text-parsing.d.ts +0 -31
  189. package/dist/src/utils/text-parsing.js +0 -74
  190. package/dist/src/utils/upload-cache.d.ts +0 -34
  191. package/dist/src/utils/upload-cache.js +0 -93
  192. package/node_modules/@eshaz/web-worker/LICENSE +0 -201
  193. package/node_modules/@eshaz/web-worker/README.md +0 -134
  194. package/node_modules/@eshaz/web-worker/browser.js +0 -17
  195. package/node_modules/@eshaz/web-worker/cjs/browser.js +0 -16
  196. package/node_modules/@eshaz/web-worker/cjs/node.js +0 -219
  197. package/node_modules/@eshaz/web-worker/index.d.ts +0 -4
  198. package/node_modules/@eshaz/web-worker/node.js +0 -223
  199. package/node_modules/@eshaz/web-worker/package.json +0 -54
  200. package/node_modules/@wasm-audio-decoders/common/index.js +0 -5
  201. package/node_modules/@wasm-audio-decoders/common/package.json +0 -36
  202. package/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +0 -231
  203. package/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +0 -129
  204. package/node_modules/@wasm-audio-decoders/common/src/puff/README +0 -67
  205. package/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +0 -31
  206. package/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +0 -863
  207. package/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +0 -35
  208. package/node_modules/@wasm-audio-decoders/common/src/utilities.js +0 -3
  209. package/node_modules/@wasm-audio-decoders/common/types.d.ts +0 -7
  210. package/node_modules/mpg123-decoder/README.md +0 -265
  211. package/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +0 -185
  212. package/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +0 -1
  213. package/node_modules/mpg123-decoder/index.js +0 -8
  214. package/node_modules/mpg123-decoder/package.json +0 -58
  215. package/node_modules/mpg123-decoder/src/EmscriptenWasm.js +0 -464
  216. package/node_modules/mpg123-decoder/src/MPEGDecoder.js +0 -200
  217. package/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +0 -21
  218. package/node_modules/mpg123-decoder/types.d.ts +0 -30
  219. package/node_modules/silk-wasm/LICENSE +0 -21
  220. package/node_modules/silk-wasm/README.md +0 -85
  221. package/node_modules/silk-wasm/lib/index.cjs +0 -16
  222. package/node_modules/silk-wasm/lib/index.d.ts +0 -70
  223. package/node_modules/silk-wasm/lib/index.mjs +0 -16
  224. package/node_modules/silk-wasm/lib/silk.wasm +0 -0
  225. package/node_modules/silk-wasm/lib/utils.d.ts +0 -4
  226. package/node_modules/silk-wasm/package.json +0 -39
  227. package/node_modules/simple-yenc/.github/FUNDING.yml +0 -1
  228. package/node_modules/simple-yenc/.prettierignore +0 -1
  229. package/node_modules/simple-yenc/LICENSE +0 -7
  230. package/node_modules/simple-yenc/README.md +0 -163
  231. package/node_modules/simple-yenc/dist/esm.js +0 -1
  232. package/node_modules/simple-yenc/dist/index.js +0 -1
  233. package/node_modules/simple-yenc/package.json +0 -50
  234. package/node_modules/simple-yenc/rollup.config.js +0 -27
  235. package/node_modules/simple-yenc/src/simple-yenc.js +0 -302
  236. package/node_modules/ws/LICENSE +0 -20
  237. package/node_modules/ws/README.md +0 -548
  238. package/node_modules/ws/browser.js +0 -8
  239. package/node_modules/ws/index.js +0 -13
  240. package/node_modules/ws/lib/buffer-util.js +0 -131
  241. package/node_modules/ws/lib/constants.js +0 -19
  242. package/node_modules/ws/lib/event-target.js +0 -292
  243. package/node_modules/ws/lib/extension.js +0 -203
  244. package/node_modules/ws/lib/limiter.js +0 -55
  245. package/node_modules/ws/lib/permessage-deflate.js +0 -528
  246. package/node_modules/ws/lib/receiver.js +0 -706
  247. package/node_modules/ws/lib/sender.js +0 -602
  248. package/node_modules/ws/lib/stream.js +0 -161
  249. package/node_modules/ws/lib/subprotocol.js +0 -62
  250. package/node_modules/ws/lib/validation.js +0 -152
  251. package/node_modules/ws/lib/websocket-server.js +0 -554
  252. package/node_modules/ws/lib/websocket.js +0 -1393
  253. package/node_modules/ws/package.json +0 -69
  254. package/node_modules/ws/wrapper.mjs +0 -8
  255. package/scripts/postinstall-link-sdk.js +0 -170
  256. package/skills/qqbot-media/SKILL.md +0 -60
  257. package/src/admin-resolver.ts +0 -181
  258. package/src/api.ts +0 -1333
  259. package/src/credential-backup.ts +0 -72
  260. package/src/deliver-debounce.ts +0 -229
  261. package/src/gateway.ts +0 -2272
  262. package/src/group-history.ts +0 -328
  263. package/src/image-server.ts +0 -675
  264. package/src/inbound-attachments.ts +0 -321
  265. package/src/known-users.ts +0 -353
  266. package/src/message-gating.ts +0 -190
  267. package/src/message-queue.ts +0 -354
  268. package/src/onboarding.ts +0 -282
  269. package/src/outbound-deliver.ts +0 -486
  270. package/src/outbound.ts +0 -1179
  271. package/src/ref-index-store.ts +0 -412
  272. package/src/reply-dispatcher.ts +0 -334
  273. package/src/session-store.ts +0 -303
  274. package/src/slash-commands.ts +0 -2431
  275. package/src/startup-greeting.ts +0 -120
  276. package/src/streaming.ts +0 -1077
  277. package/src/stt.ts +0 -86
  278. package/src/tools/channel.ts +0 -275
  279. package/src/transport/index.ts +0 -11
  280. package/src/transport/webhook-transport.ts +0 -332
  281. package/src/transport/webhook-verify.ts +0 -119
  282. package/src/typing-keepalive.ts +0 -59
  283. package/src/utils/audio-convert.ts +0 -887
  284. package/src/utils/chunked-upload.ts +0 -483
  285. package/src/utils/file-utils.ts +0 -193
  286. package/src/utils/image-size.ts +0 -266
  287. package/src/utils/media-send.ts +0 -636
  288. package/src/utils/media-tags.ts +0 -183
  289. package/src/utils/payload.ts +0 -265
  290. package/src/utils/text-parsing.ts +0 -85
  291. package/src/utils/upload-cache.ts +0 -128
@@ -1,48 +0,0 @@
1
- /**
2
- * 出站消息投递模块
3
- *
4
- * 从 gateway deliver 回调中提取的两大发送管线:
5
- * 1. parseAndSendMediaTags — 解析 <qqimg/qqvoice/qqvideo/qqfile/qqmedia> 标签并按顺序发送
6
- * 2. sendPlainReply — 处理不含媒体标签的普通回复(markdown 图片/纯文本+图片)
7
- */
8
- import type { ResolvedQQBotAccount } from "./types.js";
9
- export interface DeliverEventContext {
10
- type: "c2c" | "guild" | "dm" | "group";
11
- senderId: string;
12
- messageId: string;
13
- channelId?: string;
14
- groupOpenid?: string;
15
- msgIdx?: string;
16
- }
17
- export interface DeliverAccountContext {
18
- account: ResolvedQQBotAccount;
19
- qualifiedTarget: string;
20
- log?: {
21
- info: (msg: string) => void;
22
- error: (msg: string) => void;
23
- debug?: (msg: string) => void;
24
- };
25
- }
26
- /** token 重试包装 */
27
- export type SendWithRetryFn = <T>(sendFn: (token: string) => Promise<T>) => Promise<T>;
28
- /** 一次性消费引用 ref */
29
- export type ConsumeQuoteRefFn = () => string | undefined;
30
- /**
31
- * 解析回复文本中的媒体标签并按顺序发送。
32
- *
33
- * @returns true 如果检测到媒体标签并已处理;false 表示无媒体标签,调用方继续走普通文本管线
34
- */
35
- export declare function parseAndSendMediaTags(replyText: string, event: DeliverEventContext, actx: DeliverAccountContext, sendWithRetry: SendWithRetryFn, consumeQuoteRef: ConsumeQuoteRefFn): Promise<{
36
- handled: boolean;
37
- normalizedText: string;
38
- }>;
39
- export interface PlainReplyPayload {
40
- text?: string;
41
- mediaUrls?: string[];
42
- mediaUrl?: string;
43
- }
44
- /**
45
- * 发送不含媒体标签的普通回复。
46
- * 处理 markdown 图片嵌入、Base64 富媒体、纯文本分块、本地媒体自动路由。
47
- */
48
- export declare function sendPlainReply(payload: PlainReplyPayload, replyText: string, event: DeliverEventContext, actx: DeliverAccountContext, sendWithRetry: SendWithRetryFn, consumeQuoteRef: ConsumeQuoteRefFn, toolMediaUrls: string[]): Promise<void>;
@@ -1,392 +0,0 @@
1
- /**
2
- * 出站消息投递模块
3
- *
4
- * 从 gateway deliver 回调中提取的两大发送管线:
5
- * 1. parseAndSendMediaTags — 解析 <qqimg/qqvoice/qqvideo/qqfile/qqmedia> 标签并按顺序发送
6
- * 2. sendPlainReply — 处理不含媒体标签的普通回复(markdown 图片/纯文本+图片)
7
- */
8
- import { sendC2CMessage, sendGroupMessage, sendChannelMessage, sendC2CImageMessage, sendGroupImageMessage, } from "./api.js";
9
- import { sendPhoto, sendMedia as sendMediaAuto, DEFAULT_MEDIA_SEND_ERROR, resolveUserFacingMediaError, } from "./outbound.js";
10
- import { chunkText, TEXT_CHUNK_LIMIT } from "./channel.js";
11
- import { getQQBotRuntime } from "./runtime.js";
12
- import { getImageSize, formatQQBotMarkdownImage, hasQQBotImageSize } from "./utils/image-size.js";
13
- import { parseMediaTagsToSendQueue, executeSendQueue } from "./utils/media-send.js";
14
- import { isLocalPath as isLocalFilePath } from "./utils/platform.js";
15
- import { filterInternalMarkers } from "./utils/text-parsing.js";
16
- // ============ 1. 媒体标签解析 + 发送 ============
17
- /**
18
- * 解析回复文本中的媒体标签并按顺序发送。
19
- *
20
- * @returns true 如果检测到媒体标签并已处理;false 表示无媒体标签,调用方继续走普通文本管线
21
- */
22
- export async function parseAndSendMediaTags(replyText, event, actx, sendWithRetry, consumeQuoteRef) {
23
- const { account, log } = actx;
24
- const prefix = `[qqbot:${account.accountId}]`;
25
- // 使用 media-send.ts 的统一解析器(内含 normalizeMediaTags + 路径编码修复)
26
- const { hasMediaTags: hasMedia, sendQueue } = parseMediaTagsToSendQueue(replyText, log);
27
- if (!hasMedia || sendQueue.length === 0) {
28
- return { handled: false, normalizedText: replyText };
29
- }
30
- log?.info(`${prefix} Send queue: ${sendQueue.map(item => item.type).join(" -> ")}`);
31
- // 构建统一的媒体发送上下文
32
- const mediaTarget = {
33
- targetType: event.type === "c2c" ? "c2c" : event.type === "group" ? "group" : "channel",
34
- targetId: event.type === "c2c" ? event.senderId : event.type === "group" ? event.groupOpenid : event.channelId,
35
- account,
36
- replyToId: event.messageId,
37
- logPrefix: prefix,
38
- };
39
- const mediaSendCtx = {
40
- mediaTarget,
41
- qualifiedTarget: actx.qualifiedTarget,
42
- account,
43
- replyToId: event.messageId,
44
- log,
45
- };
46
- // 使用 media-send.ts 的统一执行器
47
- await executeSendQueue(sendQueue, mediaSendCtx, {
48
- onSendText: async (textContent) => {
49
- await sendTextChunks(filterInternalMarkers(textContent), event, actx, sendWithRetry, consumeQuoteRef);
50
- },
51
- });
52
- return { handled: true, normalizedText: replyText };
53
- }
54
- /**
55
- * 发送不含媒体标签的普通回复。
56
- * 处理 markdown 图片嵌入、Base64 富媒体、纯文本分块、本地媒体自动路由。
57
- */
58
- export async function sendPlainReply(payload, replyText, event, actx, sendWithRetry, consumeQuoteRef, toolMediaUrls) {
59
- const { account, qualifiedTarget, log } = actx;
60
- const prefix = `[qqbot:${account.accountId}]`;
61
- // 预去重:把 payload 自带的媒体 URL 从 toolMediaUrls 中移除,
62
- // 防止同一个文件既被 payload.mediaUrl/mediaUrls 发送,又被 toolMediaUrls 重复发送
63
- if (toolMediaUrls.length > 0) {
64
- const payloadUrls = new Set();
65
- if (payload.mediaUrl)
66
- payloadUrls.add(payload.mediaUrl);
67
- if (payload.mediaUrls)
68
- for (const u of payload.mediaUrls)
69
- payloadUrls.add(u);
70
- if (payloadUrls.size > 0) {
71
- const before = toolMediaUrls.length;
72
- const filtered = toolMediaUrls.filter(url => !payloadUrls.has(url));
73
- if (filtered.length < before) {
74
- log?.info(`${prefix} Pre-dedup: removed ${before - filtered.length} payload media URL(s) from toolMediaUrls`);
75
- toolMediaUrls.length = 0;
76
- toolMediaUrls.push(...filtered);
77
- }
78
- }
79
- }
80
- const collectedImageUrls = [];
81
- const localMediaToSend = [];
82
- const collectImageUrl = (url) => {
83
- if (!url)
84
- return false;
85
- const isHttpUrl = url.startsWith("http://") || url.startsWith("https://");
86
- const isDataUrl = url.startsWith("data:image/");
87
- if (isHttpUrl || isDataUrl) {
88
- if (!collectedImageUrls.includes(url)) {
89
- collectedImageUrls.push(url);
90
- log?.info(`${prefix} Collected ${isDataUrl ? "Base64" : "media URL"}: ${isDataUrl ? `(length: ${url.length})` : url.slice(0, 80) + "..."}`);
91
- }
92
- return true;
93
- }
94
- if (isLocalFilePath(url)) {
95
- if (!localMediaToSend.includes(url)) {
96
- localMediaToSend.push(url);
97
- log?.info(`${prefix} Collected local media for auto-routing: ${url}`);
98
- }
99
- return true;
100
- }
101
- return false;
102
- };
103
- if (payload.mediaUrls?.length) {
104
- for (const url of payload.mediaUrls)
105
- collectImageUrl(url);
106
- }
107
- if (payload.mediaUrl)
108
- collectImageUrl(payload.mediaUrl);
109
- // 提取 markdown 图片
110
- const mdImageRegex = /!\[([^\]]*)\]\(([^)]+)\)/gi;
111
- const mdMatches = [...replyText.matchAll(mdImageRegex)];
112
- for (const m of mdMatches) {
113
- const url = m[2]?.trim();
114
- if (url && !collectedImageUrls.includes(url)) {
115
- if (url.startsWith("http://") || url.startsWith("https://")) {
116
- collectedImageUrls.push(url);
117
- log?.info(`${prefix} Extracted HTTP image from markdown: ${url.slice(0, 80)}...`);
118
- }
119
- else if (isLocalFilePath(url)) {
120
- if (!localMediaToSend.includes(url)) {
121
- localMediaToSend.push(url);
122
- log?.info(`${prefix} Collected local media from markdown for auto-routing: ${url}`);
123
- }
124
- }
125
- }
126
- }
127
- // 提取裸 URL 图片
128
- const bareUrlRegex = /(?<![(\["'])(https?:\/\/[^\s)"'<>]+\.(?:png|jpg|jpeg|gif|webp)(?:\?[^\s"'<>]*)?)/gi;
129
- const bareUrlMatches = [...replyText.matchAll(bareUrlRegex)];
130
- for (const m of bareUrlMatches) {
131
- const url = m[1];
132
- if (url && !collectedImageUrls.includes(url)) {
133
- collectedImageUrls.push(url);
134
- log?.info(`${prefix} Extracted bare image URL: ${url.slice(0, 80)}...`);
135
- }
136
- }
137
- const useMarkdown = account.markdownSupport === true;
138
- log?.info(`${prefix} Markdown mode: ${useMarkdown}, images: ${collectedImageUrls.length}`);
139
- let textWithoutImages = filterInternalMarkers(replyText);
140
- if (useMarkdown) {
141
- await sendMarkdownReply(textWithoutImages, collectedImageUrls, mdMatches, bareUrlMatches, event, actx, sendWithRetry, consumeQuoteRef);
142
- }
143
- else {
144
- await sendPlainTextReply(textWithoutImages, collectedImageUrls, mdMatches, bareUrlMatches, event, actx, sendWithRetry, consumeQuoteRef);
145
- }
146
- // 发送本地媒体(由 payload.mediaUrl 或 markdown 本地路径触发)
147
- if (localMediaToSend.length > 0) {
148
- log?.info(`${prefix} Sending ${localMediaToSend.length} local media via sendMedia auto-routing`);
149
- for (const mediaPath of localMediaToSend) {
150
- try {
151
- const result = await sendMediaAuto({
152
- to: qualifiedTarget, text: "", mediaUrl: mediaPath,
153
- accountId: account.accountId, replyToId: event.messageId, account,
154
- });
155
- if (result.error) {
156
- log?.error(`${prefix} sendMedia(auto) error for ${mediaPath}: ${result.error}`);
157
- await sendTextChunks(resolveUserFacingMediaError(result), event, actx, sendWithRetry, consumeQuoteRef);
158
- }
159
- else {
160
- log?.info(`${prefix} Sent local media: ${mediaPath}`);
161
- }
162
- }
163
- catch (err) {
164
- log?.error(`${prefix} sendMedia(auto) failed for ${mediaPath}: ${err}`);
165
- await sendTextChunks(DEFAULT_MEDIA_SEND_ERROR, event, actx, sendWithRetry, consumeQuoteRef);
166
- }
167
- }
168
- }
169
- // 转发 tool 阶段收集的媒体(去重:跳过已在 localMediaToSend 或 collectedImageUrls 中发送过的路径)
170
- if (toolMediaUrls.length > 0) {
171
- const alreadySent = new Set([...localMediaToSend, ...collectedImageUrls]);
172
- const dedupedToolMedia = toolMediaUrls.filter(url => !alreadySent.has(url));
173
- if (dedupedToolMedia.length < toolMediaUrls.length) {
174
- log?.info(`${prefix} Deduped tool media: ${toolMediaUrls.length} → ${dedupedToolMedia.length} (skipped ${toolMediaUrls.length - dedupedToolMedia.length} already sent via localMedia/collectedImages)`);
175
- }
176
- if (dedupedToolMedia.length > 0) {
177
- log?.info(`${prefix} Forwarding ${dedupedToolMedia.length} tool-collected media URL(s) after block deliver`);
178
- for (const mediaUrl of dedupedToolMedia) {
179
- try {
180
- const result = await sendMediaAuto({
181
- to: qualifiedTarget, text: "", mediaUrl,
182
- accountId: account.accountId, replyToId: event.messageId, account,
183
- });
184
- if (result.error) {
185
- log?.error(`${prefix} Tool media forward error: ${result.error}`);
186
- await sendTextChunks(resolveUserFacingMediaError(result), event, actx, sendWithRetry, consumeQuoteRef);
187
- }
188
- else {
189
- log?.info(`${prefix} Forwarded tool media: ${mediaUrl.slice(0, 80)}...`);
190
- }
191
- }
192
- catch (err) {
193
- log?.error(`${prefix} Tool media forward failed: ${err}`);
194
- await sendTextChunks(DEFAULT_MEDIA_SEND_ERROR, event, actx, sendWithRetry, consumeQuoteRef);
195
- }
196
- }
197
- }
198
- toolMediaUrls.length = 0;
199
- }
200
- }
201
- // ============ 内部辅助函数 ============
202
- /** 发送文本分块(共用逻辑) */
203
- async function sendTextChunks(text, event, actx, sendWithRetry, consumeQuoteRef) {
204
- const { account, log } = actx;
205
- const prefix = `[qqbot:${account.accountId}]`;
206
- const chunks = getQQBotRuntime().channel.text.chunkMarkdownText(text, TEXT_CHUNK_LIMIT);
207
- for (const chunk of chunks) {
208
- try {
209
- await sendWithRetry(async (token) => {
210
- const ref = consumeQuoteRef();
211
- if (event.type === "c2c") {
212
- return await sendC2CMessage(token, event.senderId, chunk, event.messageId, ref);
213
- }
214
- else if (event.type === "group" && event.groupOpenid) {
215
- return await sendGroupMessage(token, event.groupOpenid, chunk, event.messageId);
216
- }
217
- else if (event.channelId) {
218
- return await sendChannelMessage(token, event.channelId, chunk, event.messageId);
219
- }
220
- });
221
- log?.info(`${prefix} Sent text chunk (${chunk.length}/${text.length} chars): ${chunk.slice(0, 50)}...`);
222
- }
223
- catch (err) {
224
- log?.error(`${prefix} Failed to send text chunk: ${err}`);
225
- }
226
- }
227
- }
228
- /** Markdown 模式发送 */
229
- async function sendMarkdownReply(textWithoutImages, imageUrls, mdMatches, bareUrlMatches, event, actx, sendWithRetry, consumeQuoteRef) {
230
- const { account, log } = actx;
231
- const prefix = `[qqbot:${account.accountId}]`;
232
- // 分离图片:公网 URL vs Base64
233
- const httpImageUrls = [];
234
- const base64ImageUrls = [];
235
- for (const url of imageUrls) {
236
- if (url.startsWith("data:image/"))
237
- base64ImageUrls.push(url);
238
- else if (url.startsWith("http://") || url.startsWith("https://"))
239
- httpImageUrls.push(url);
240
- }
241
- log?.info(`${prefix} Image classification: httpUrls=${httpImageUrls.length}, base64=${base64ImageUrls.length}`);
242
- // 发送 Base64 图片
243
- if (base64ImageUrls.length > 0) {
244
- log?.info(`${prefix} Sending ${base64ImageUrls.length} image(s) via Rich Media API...`);
245
- for (const imageUrl of base64ImageUrls) {
246
- try {
247
- await sendWithRetry(async (token) => {
248
- if (event.type === "c2c") {
249
- await sendC2CImageMessage(token, event.senderId, imageUrl, event.messageId);
250
- }
251
- else if (event.type === "group" && event.groupOpenid) {
252
- await sendGroupImageMessage(token, event.groupOpenid, imageUrl, event.messageId);
253
- }
254
- else if (event.channelId) {
255
- log?.info(`${prefix} Channel does not support rich media, skipping Base64 image`);
256
- }
257
- });
258
- log?.info(`${prefix} Sent Base64 image via Rich Media API (size: ${imageUrl.length} chars)`);
259
- }
260
- catch (imgErr) {
261
- log?.error(`${prefix} Failed to send Base64 image via Rich Media API: ${imgErr}`);
262
- }
263
- }
264
- }
265
- // 处理公网 URL 图片
266
- const existingMdUrls = new Set(mdMatches.map((m) => m[2]));
267
- const imagesToAppend = [];
268
- for (const url of httpImageUrls) {
269
- if (!existingMdUrls.has(url)) {
270
- try {
271
- const size = await getImageSize(url);
272
- imagesToAppend.push(formatQQBotMarkdownImage(url, size));
273
- log?.info(`${prefix} Formatted HTTP image: ${size ? `${size.width}x${size.height}` : "default size"} - ${url.slice(0, 60)}...`);
274
- }
275
- catch (err) {
276
- log?.info(`${prefix} Failed to get image size, using default: ${err}`);
277
- imagesToAppend.push(formatQQBotMarkdownImage(url, null));
278
- }
279
- }
280
- }
281
- // 补充已有 markdown 图片的尺寸信息
282
- let result = textWithoutImages;
283
- for (const m of mdMatches) {
284
- const fullMatch = m[0];
285
- const imgUrl = m[2];
286
- const isHttpUrl = imgUrl.startsWith("http://") || imgUrl.startsWith("https://");
287
- if (isHttpUrl && !hasQQBotImageSize(fullMatch)) {
288
- try {
289
- const size = await getImageSize(imgUrl);
290
- result = result.replace(fullMatch, formatQQBotMarkdownImage(imgUrl, size));
291
- log?.info(`${prefix} Updated image with size: ${size ? `${size.width}x${size.height}` : "default"} - ${imgUrl.slice(0, 60)}...`);
292
- }
293
- catch (err) {
294
- log?.info(`${prefix} Failed to get image size for existing md, using default: ${err}`);
295
- result = result.replace(fullMatch, formatQQBotMarkdownImage(imgUrl, null));
296
- }
297
- }
298
- }
299
- // 移除裸 URL 图片
300
- for (const m of bareUrlMatches) {
301
- result = result.replace(m[0], "").trim();
302
- }
303
- // 追加图片
304
- if (imagesToAppend.length > 0) {
305
- result = result.trim();
306
- result = result ? result + "\n\n" + imagesToAppend.join("\n") : imagesToAppend.join("\n");
307
- }
308
- // 发送 markdown 文本
309
- if (result.trim()) {
310
- const mdChunks = chunkText(result, TEXT_CHUNK_LIMIT);
311
- for (const chunk of mdChunks) {
312
- try {
313
- await sendWithRetry(async (token) => {
314
- const ref = consumeQuoteRef();
315
- if (event.type === "c2c") {
316
- return await sendC2CMessage(token, event.senderId, chunk, event.messageId, ref);
317
- }
318
- else if (event.type === "group" && event.groupOpenid) {
319
- return await sendGroupMessage(token, event.groupOpenid, chunk, event.messageId);
320
- }
321
- else if (event.channelId) {
322
- return await sendChannelMessage(token, event.channelId, chunk, event.messageId);
323
- }
324
- });
325
- log?.info(`${prefix} Sent markdown chunk (${chunk.length}/${result.length} chars) with ${httpImageUrls.length} HTTP images (${event.type})`);
326
- }
327
- catch (err) {
328
- log?.error(`${prefix} Failed to send markdown message chunk: ${err}`);
329
- }
330
- }
331
- }
332
- }
333
- /** 普通文本模式发送 */
334
- async function sendPlainTextReply(textWithoutImages, imageUrls, mdMatches, bareUrlMatches, event, actx, sendWithRetry, consumeQuoteRef) {
335
- const { account, log } = actx;
336
- const prefix = `[qqbot:${account.accountId}]`;
337
- const imgMediaTarget = {
338
- targetType: event.type === "c2c" ? "c2c" : event.type === "group" ? "group" : "channel",
339
- targetId: event.type === "c2c" ? event.senderId : event.type === "group" ? event.groupOpenid : event.channelId,
340
- account,
341
- replyToId: event.messageId,
342
- logPrefix: prefix,
343
- };
344
- let result = textWithoutImages;
345
- for (const m of mdMatches)
346
- result = result.replace(m[0], "").trim();
347
- for (const m of bareUrlMatches)
348
- result = result.replace(m[0], "").trim();
349
- // 群聊 URL 点号过滤
350
- if (result && event.type !== "c2c") {
351
- result = result.replace(/([a-zA-Z0-9])\.([a-zA-Z0-9])/g, "$1_$2");
352
- }
353
- try {
354
- for (const imageUrl of imageUrls) {
355
- try {
356
- const imgResult = await sendPhoto(imgMediaTarget, imageUrl);
357
- if (imgResult.error) {
358
- log?.error(`${prefix} Failed to send image: ${imgResult.error}`);
359
- await sendTextChunks(resolveUserFacingMediaError(imgResult), event, actx, sendWithRetry, consumeQuoteRef);
360
- }
361
- else {
362
- log?.info(`${prefix} Sent image via sendPhoto: ${imageUrl.slice(0, 80)}...`);
363
- }
364
- }
365
- catch (imgErr) {
366
- log?.error(`${prefix} Failed to send image: ${imgErr}`);
367
- await sendTextChunks(DEFAULT_MEDIA_SEND_ERROR, event, actx, sendWithRetry, consumeQuoteRef);
368
- }
369
- }
370
- if (result.trim()) {
371
- const plainChunks = chunkText(result, TEXT_CHUNK_LIMIT);
372
- for (const chunk of plainChunks) {
373
- await sendWithRetry(async (token) => {
374
- const ref = consumeQuoteRef();
375
- if (event.type === "c2c") {
376
- return await sendC2CMessage(token, event.senderId, chunk, event.messageId, ref);
377
- }
378
- else if (event.type === "group" && event.groupOpenid) {
379
- return await sendGroupMessage(token, event.groupOpenid, chunk, event.messageId);
380
- }
381
- else if (event.channelId) {
382
- return await sendChannelMessage(token, event.channelId, chunk, event.messageId);
383
- }
384
- });
385
- log?.info(`${prefix} Sent text chunk (${chunk.length}/${result.length} chars) (${event.type})`);
386
- }
387
- }
388
- }
389
- catch (err) {
390
- log?.error(`${prefix} Send failed: ${err}`);
391
- }
392
- }
@@ -1,220 +0,0 @@
1
- /**
2
- * QQ Bot 消息发送模块
3
- */
4
- import type { ResolvedQQBotAccount } from "./types.js";
5
- /** 限流检查结果 */
6
- export interface ReplyLimitResult {
7
- /** 是否允许被动回复 */
8
- allowed: boolean;
9
- /** 剩余被动回复次数 */
10
- remaining: number;
11
- /** 是否需要降级为主动消息(超期或超过次数) */
12
- shouldFallbackToProactive: boolean;
13
- /** 降级原因 */
14
- fallbackReason?: "expired" | "limit_exceeded";
15
- /** 提示消息 */
16
- message?: string;
17
- }
18
- /**
19
- * 检查是否可以回复该消息(限流检查)
20
- * @param messageId 消息ID
21
- * @returns ReplyLimitResult 限流检查结果
22
- */
23
- export declare function checkMessageReplyLimit(messageId: string): ReplyLimitResult;
24
- /**
25
- * 记录一次消息回复
26
- * @param messageId 消息ID
27
- */
28
- export declare function recordMessageReply(messageId: string): void;
29
- /**
30
- * 获取消息回复统计信息
31
- */
32
- export declare function getMessageReplyStats(): {
33
- trackedMessages: number;
34
- totalReplies: number;
35
- };
36
- /**
37
- * 获取消息回复限制配置(供外部查询)
38
- */
39
- export declare function getMessageReplyConfig(): {
40
- limit: number;
41
- ttlMs: number;
42
- ttlHours: number;
43
- };
44
- export interface OutboundContext {
45
- to: string;
46
- text: string;
47
- accountId?: string | null;
48
- replyToId?: string | null;
49
- account: ResolvedQQBotAccount;
50
- }
51
- export interface MediaOutboundContext extends OutboundContext {
52
- mediaUrl: string;
53
- /** 可选的 MIME 类型,优先于扩展名判断媒体类型 */
54
- mimeType?: string;
55
- }
56
- export declare const OUTBOUND_ERROR_CODES: {
57
- readonly FILE_TOO_LARGE: "file_too_large";
58
- readonly UPLOAD_DAILY_LIMIT_EXCEEDED: "upload_daily_limit_exceeded";
59
- };
60
- export declare const DEFAULT_MEDIA_SEND_ERROR = "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
61
- export type OutboundErrorCode = typeof OUTBOUND_ERROR_CODES[keyof typeof OUTBOUND_ERROR_CODES];
62
- export interface OutboundResult {
63
- channel: string;
64
- messageId?: string;
65
- timestamp?: string | number;
66
- error?: string;
67
- /** 稳定错误码,供上层按类型处理,避免依赖 error 文案 */
68
- errorCode?: OutboundErrorCode;
69
- /** QQ 开放平台业务错误码(如 upload_prepare 的 40093002) */
70
- qqBizCode?: number;
71
- /** 出站消息的引用索引(ext_info.ref_idx),供引用消息缓存使用 */
72
- refIdx?: string;
73
- }
74
- /**
75
- * 将媒体发送结果映射为可展示给用户的文案。
76
- * 只对明确标记为可直接展示的错误码透传原文,其余统一走通用兜底。
77
- */
78
- export declare function resolveUserFacingMediaError(result: Pick<OutboundResult, "error" | "errorCode" | "qqBizCode">): string;
79
- /** 媒体发送的目标上下文(从 deliver 回调或 sendText 中提取) */
80
- export interface MediaTargetContext {
81
- /** 目标类型 */
82
- targetType: "c2c" | "group" | "channel";
83
- /** 目标 ID */
84
- targetId: string;
85
- /** QQ Bot 账户配置 */
86
- account: ResolvedQQBotAccount;
87
- /** 被动回复消息 ID(可选) */
88
- replyToId?: string;
89
- /** 日志前缀(可选,用于区分调用来源) */
90
- logPrefix?: string;
91
- }
92
- /**
93
- * sendPhoto — 发送图片消息
94
- *
95
- * 支持三种来源:
96
- * - 本地文件路径 → 分片上传
97
- * - 公网 HTTP/HTTPS URL → 下载到本地 → 分片上传(失败发文本链接兜底)
98
- * - Base64 Data URL → 直传 QQ API
99
- */
100
- export declare function sendPhoto(ctx: MediaTargetContext, imagePath: string,
101
- /** 原始来源 URL(仅 fallback 路径使用,记录到引用索引) */
102
- sourceUrl?: string): Promise<OutboundResult>;
103
- /**
104
- * sendVoice — 发送语音消息
105
- *
106
- * 支持本地音频文件和公网 URL:
107
- * - urlDirectUpload=true + 公网URL:先直传平台,失败后下载到本地再转码重试
108
- * - urlDirectUpload=false + 公网URL:直接下载到本地再转码发送
109
- * - 本地文件:自动转换为 SILK 格式后上传
110
- *
111
- * 支持 transcodeEnabled 配置:禁用时非原生格式 fallback 到文件发送。
112
- */
113
- export declare function sendVoice(ctx: MediaTargetContext, voicePath: string,
114
- /** 直传格式列表(跳过 SILK 转换),可选 */
115
- directUploadFormats?: string[],
116
- /** 是否启用转码(默认 true),false 时非原生格式直接返回错误 */
117
- transcodeEnabled?: boolean): Promise<OutboundResult>;
118
- /**
119
- * sendVideoMsg — 发送视频消息
120
- *
121
- * 支持公网 URL(urlDirectUpload 控制直传或下载,失败自动 fallback)和本地文件路径。
122
- */
123
- export declare function sendVideoMsg(ctx: MediaTargetContext, videoPath: string): Promise<OutboundResult>;
124
- /**
125
- * sendDocument — 发送文件消息
126
- *
127
- * 支持本地文件路径和公网 URL(urlDirectUpload 控制直传或下载,失败自动 fallback)。
128
- */
129
- export declare function sendDocument(ctx: MediaTargetContext, filePath: string): Promise<OutboundResult>;
130
- /**
131
- * 发送文本消息
132
- * - 有 replyToId: 被动回复,1小时内最多回复4次
133
- * - 无 replyToId: 主动发送,有配额限制(每月4条/用户/群)
134
- *
135
- * 注意:
136
- * 1. 主动消息(无 replyToId)必须有消息内容,不支持流式发送
137
- * 2. 当被动回复不可用(超期或超过次数)时,自动降级为主动消息
138
- * 3. 支持 <qqimg>路径</qqimg> 或 <qqimg>路径</img> 格式发送图片
139
- */
140
- export declare function sendText(ctx: OutboundContext): Promise<OutboundResult>;
141
- /**
142
- * 主动发送消息(不需要 replyToId,有配额限制:每月 4 条/用户/群)
143
- *
144
- * @param account - 账户配置
145
- * @param to - 目标地址,格式:openid(单聊)或 group:xxx(群聊)
146
- * @param text - 消息内容
147
- */
148
- export declare function sendProactiveMessage(account: ResolvedQQBotAccount, to: string, text: string): Promise<OutboundResult>;
149
- /**
150
- * 发送富媒体消息(图片)
151
- *
152
- * 支持以下 mediaUrl 格式:
153
- * - 公网 URL: https://example.com/image.png
154
- * - Base64 Data URL: data:image/png;base64,xxxxx
155
- * - 本地文件路径: /path/to/image.png(自动读取并转换为 Base64)
156
- *
157
- * @param ctx - 发送上下文,包含 mediaUrl
158
- * @returns 发送结果
159
- *
160
- * @example
161
- * ```typescript
162
- * // 发送网络图片
163
- * const result = await sendMedia({
164
- * to: "group:xxx",
165
- * text: "这是图片说明",
166
- * mediaUrl: "https://example.com/image.png",
167
- * account,
168
- * replyToId: msgId,
169
- * });
170
- *
171
- * // 发送 Base64 图片
172
- * const result = await sendMedia({
173
- * to: "group:xxx",
174
- * text: "这是图片说明",
175
- * mediaUrl: "data:image/png;base64,iVBORw0KGgo...",
176
- * account,
177
- * replyToId: msgId,
178
- * });
179
- *
180
- * // 发送本地文件(自动读取并转换为 Base64)
181
- * const result = await sendMedia({
182
- * to: "group:xxx",
183
- * text: "这是图片说明",
184
- * mediaUrl: "/tmp/generated-chart.png",
185
- * account,
186
- * replyToId: msgId,
187
- * });
188
- * ```
189
- */
190
- export declare function sendMedia(ctx: MediaOutboundContext): Promise<OutboundResult>;
191
- /**
192
- * 发送 Cron 触发的消息
193
- *
194
- * 当 OpenClaw cron 任务触发时,消息内容可能是:
195
- * 1. QQBOT_CRON:{base64} 格式的结构化载荷 - 解码后根据 targetType 和 targetAddress 发送
196
- * 2. 普通文本 - 直接发送到指定目标
197
- *
198
- * @param account - 账户配置
199
- * @param to - 目标地址(作为后备,如果载荷中没有指定)
200
- * @param message - 消息内容(可能是 QQBOT_CRON: 格式或普通文本)
201
- * @returns 发送结果
202
- *
203
- * @example
204
- * ```typescript
205
- * // 处理结构化载荷
206
- * const result = await sendCronMessage(
207
- * account,
208
- * "user_openid", // 后备地址
209
- * "QQBOT_CRON:eyJ0eXBlIjoiY3Jvbl9yZW1pbmRlciIs..." // Base64 编码的载荷
210
- * );
211
- *
212
- * // 处理普通文本
213
- * const result = await sendCronMessage(
214
- * account,
215
- * "user_openid",
216
- * "这是一条普通的提醒消息"
217
- * );
218
- * ```
219
- */
220
- export declare function sendCronMessage(account: ResolvedQQBotAccount, to: string, message: string): Promise<OutboundResult>;