chore(qqbot): inline legacy text chunk helper · openclaw/openclaw@404446f
steipete
·
2026-05-01
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,23 @@ import {
|
23 | 23 | } from "./engine/messaging/target-parser.js"; |
24 | 24 | import type { ResolvedQQBotAccount } from "./types.js"; |
25 | 25 | |
| 26 | +/** Maximum text length for a single QQ Bot message. */ |
| 27 | +export const TEXT_CHUNK_LIMIT = 5000; |
| 28 | + |
| 29 | +/** |
| 30 | + * Naive text chunking fallback. |
| 31 | + * |
| 32 | + * The outbound pipeline normally uses `runtime.channel.text.chunkMarkdownText`; |
| 33 | + * this remains exported for callers that need the legacy channel helper. |
| 34 | + */ |
| 35 | +export function chunkText(text: string, limit: number = TEXT_CHUNK_LIMIT): string[] { |
| 36 | +const chunks: string[] = []; |
| 37 | +for (let i = 0; i < text.length; i += limit) { |
| 38 | +chunks.push(text.slice(i, i + limit)); |
| 39 | +} |
| 40 | +return chunks.length > 0 ? chunks : [text]; |
| 41 | +} |
| 42 | + |
26 | 43 | // Shared promise so concurrent multi-account startups serialize the dynamic |
27 | 44 | // import of the gateway module, avoiding an ESM circular-dependency race. |
28 | 45 | let _gatewayModulePromise: Promise<typeof import("./bridge/gateway.js")> | undefined; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。