fix: preserve markdown fences when chunking

This commit is contained in:
Peter Steinberger
2026-01-06 20:19:56 +01:00
parent afc42c7547
commit 67bda21811
13 changed files with 378 additions and 108 deletions

View File

@@ -12,7 +12,7 @@ import type {
RESTPostAPIGuildScheduledEventJSONBody,
} from "discord-api-types/v10";
import { chunkText } from "../auto-reply/chunk.js";
import { chunkMarkdownText } from "../auto-reply/chunk.js";
import { loadConfig } from "../config/config.js";
import {
normalizePollDurationHours,
@@ -360,7 +360,7 @@ async function sendDiscordText(
})) as { id: string; channel_id: string };
return res;
}
const chunks = chunkText(text, DISCORD_TEXT_LIMIT);
const chunks = chunkMarkdownText(text, DISCORD_TEXT_LIMIT);
let last: { id: string; channel_id: string } | null = null;
let isFirst = true;
for (const chunk of chunks) {