fix: preserve markdown fences when chunking
This commit is contained in:
@@ -15,7 +15,10 @@ import {
|
||||
type PartialUser,
|
||||
type User,
|
||||
} from "discord.js";
|
||||
import { chunkText, resolveTextChunkLimit } from "../auto-reply/chunk.js";
|
||||
import {
|
||||
chunkMarkdownText,
|
||||
resolveTextChunkLimit,
|
||||
} from "../auto-reply/chunk.js";
|
||||
import { hasControlCommand } from "../auto-reply/command-detection.js";
|
||||
import { formatAgentEnvelope } from "../auto-reply/envelope.js";
|
||||
import { dispatchReplyFromConfig } from "../auto-reply/reply/dispatch-from-config.js";
|
||||
@@ -1295,7 +1298,7 @@ async function deliverReplies({
|
||||
const replyToId = payload.replyToId;
|
||||
if (!text && mediaList.length === 0) continue;
|
||||
if (mediaList.length === 0) {
|
||||
for (const chunk of chunkText(text, chunkLimit)) {
|
||||
for (const chunk of chunkMarkdownText(text, chunkLimit)) {
|
||||
const replyTo = resolveDiscordReplyTarget({
|
||||
replyToMode,
|
||||
replyToId,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user