mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 15:13:43 +00:00
fix: newline chunking across channels
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import type { RequestClient } from "@buape/carbon";
|
||||
|
||||
import type { ChunkMode } from "../../auto-reply/chunk.js";
|
||||
import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||
import type { MarkdownTableMode } from "../../config/types.base.js";
|
||||
import { convertMarkdownTables } from "../../markdown/tables.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import { chunkDiscordText } from "../chunk.js";
|
||||
import { chunkDiscordTextWithMode } from "../chunk.js";
|
||||
import { sendMessageDiscord } from "../send.js";
|
||||
|
||||
export async function deliverDiscordReply(params: {
|
||||
@@ -18,6 +19,7 @@ export async function deliverDiscordReply(params: {
|
||||
maxLinesPerMessage?: number;
|
||||
replyToId?: string;
|
||||
tableMode?: MarkdownTableMode;
|
||||
chunkMode?: ChunkMode;
|
||||
}) {
|
||||
const chunkLimit = Math.min(params.textLimit, 2000);
|
||||
for (const payload of params.replies) {
|
||||
@@ -30,10 +32,14 @@ export async function deliverDiscordReply(params: {
|
||||
|
||||
if (mediaList.length === 0) {
|
||||
let isFirstChunk = true;
|
||||
for (const chunk of chunkDiscordText(text, {
|
||||
const mode = params.chunkMode ?? "length";
|
||||
const chunks = chunkDiscordTextWithMode(text, {
|
||||
maxChars: chunkLimit,
|
||||
maxLines: params.maxLinesPerMessage,
|
||||
})) {
|
||||
chunkMode: mode,
|
||||
});
|
||||
if (!chunks.length && text) chunks.push(text);
|
||||
for (const chunk of chunks) {
|
||||
const trimmed = chunk.trim();
|
||||
if (!trimmed) continue;
|
||||
await sendMessageDiscord(params.target, trimmed, {
|
||||
|
||||
Reference in New Issue
Block a user