mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:40:42 +00:00
fix(discord): preserve fast-path chunk settings
This commit is contained in:
@@ -256,6 +256,26 @@ describe("deliverDiscordReply", () => {
|
||||
expect(sendDiscordTextMock.mock.calls[1]?.[1]).toBe("789");
|
||||
});
|
||||
|
||||
it("passes maxLinesPerMessage and chunkMode through the fast path", async () => {
|
||||
const fakeRest = {} as import("@buape/carbon").RequestClient;
|
||||
|
||||
await deliverDiscordReply({
|
||||
replies: [{ text: Array.from({ length: 18 }, (_, index) => `line ${index + 1}`).join("\n") }],
|
||||
target: "channel:789",
|
||||
token: "token",
|
||||
rest: fakeRest,
|
||||
runtime,
|
||||
textLimit: 2000,
|
||||
maxLinesPerMessage: 120,
|
||||
chunkMode: "newline",
|
||||
});
|
||||
|
||||
expect(sendMessageDiscordMock).not.toHaveBeenCalled();
|
||||
expect(sendDiscordTextMock).toHaveBeenCalledTimes(1);
|
||||
expect(sendDiscordTextMock.mock.calls[0]?.[5]).toBe(120);
|
||||
expect(sendDiscordTextMock.mock.calls[0]?.[8]).toBe("newline");
|
||||
});
|
||||
|
||||
it("falls back to sendMessageDiscord when rest is not provided", async () => {
|
||||
await deliverDiscordReply({
|
||||
replies: [{ text: "single chunk" }],
|
||||
|
||||
@@ -130,9 +130,11 @@ async function sendDiscordChunkWithFallback(params: {
|
||||
text: string;
|
||||
token: string;
|
||||
accountId?: string;
|
||||
maxLinesPerMessage?: number;
|
||||
rest?: RequestClient;
|
||||
replyTo?: string;
|
||||
binding?: DiscordThreadBindingLookupRecord;
|
||||
chunkMode?: ChunkMode;
|
||||
username?: string;
|
||||
avatarUrl?: string;
|
||||
/** Pre-resolved channel ID to bypass redundant resolution per chunk. */
|
||||
@@ -169,7 +171,18 @@ async function sendDiscordChunkWithFallback(params: {
|
||||
if (params.channelId && params.request && params.rest) {
|
||||
const { channelId, request, rest } = params;
|
||||
await sendWithRetry(
|
||||
() => sendDiscordText(rest, channelId, text, params.replyTo, request),
|
||||
() =>
|
||||
sendDiscordText(
|
||||
rest,
|
||||
channelId,
|
||||
text,
|
||||
params.replyTo,
|
||||
request,
|
||||
params.maxLinesPerMessage,
|
||||
undefined,
|
||||
undefined,
|
||||
params.chunkMode,
|
||||
),
|
||||
params.retryConfig,
|
||||
);
|
||||
return;
|
||||
@@ -294,8 +307,10 @@ export async function deliverDiscordReply(params: {
|
||||
token: params.token,
|
||||
rest: params.rest,
|
||||
accountId: params.accountId,
|
||||
maxLinesPerMessage: params.maxLinesPerMessage,
|
||||
replyTo,
|
||||
binding,
|
||||
chunkMode: params.chunkMode,
|
||||
username: persona.username,
|
||||
avatarUrl: persona.avatarUrl,
|
||||
channelId,
|
||||
@@ -329,8 +344,10 @@ export async function deliverDiscordReply(params: {
|
||||
token: params.token,
|
||||
rest: params.rest,
|
||||
accountId: params.accountId,
|
||||
maxLinesPerMessage: params.maxLinesPerMessage,
|
||||
replyTo: resolveReplyTo(),
|
||||
binding,
|
||||
chunkMode: params.chunkMode,
|
||||
username: persona.username,
|
||||
avatarUrl: persona.avatarUrl,
|
||||
channelId,
|
||||
|
||||
Reference in New Issue
Block a user