



























@@ -33,7 +33,11 @@ import { resolveTelegramInlineButtons, type TelegramInlineButtons } from "../but
3333import { splitTelegramCaption } from "../caption.js";
3434import { renderTelegramHtmlText } from "../format.js";
3535import { resolveTelegramInteractiveTextFallback } from "../interactive-fallback.js";
36-import { splitTelegramRichMarkdownChunks, TELEGRAM_RICH_TEXT_LIMIT } from "../rich-message.js";
36+import {
37+splitTelegramRichMessageTextChunks,
38+TELEGRAM_RICH_TEXT_LIMIT,
39+type TelegramRichTextChunk,
40+} from "../rich-message.js";
3741import { buildInlineKeyboard } from "../send.js";
3842import { resolveTelegramVoiceSend } from "../voice.js";
3943import {
@@ -71,23 +75,23 @@ type TelegramReplyQuoteForSend = {
7175entities?: unknown[];
7276};
737774-type TelegramTextChunk = {
75-text: string;
76-};
77-78-type ChunkTextFn = (markdown: string) => TelegramTextChunk[];
78+type ChunkTextFn = (markdown: string) => TelegramRichTextChunk[];
79798080function buildChunkTextResolver(params: {
8181textLimit: number;
8282chunkMode: ChunkMode;
8383tableMode?: MarkdownTableMode;
84+skipEntityDetection?: boolean;
8485}): ChunkTextFn {
8586return (markdown: string) => {
86-return splitTelegramRichMarkdownChunks(markdown, params.textLimit, params.chunkMode).map(
87-(text) => ({
88- text,
89-}),
90-);
87+return splitTelegramRichMessageTextChunks({
88+text: markdown,
89+textLimit: params.textLimit,
90+textMode: "markdown",
91+chunkMode: params.chunkMode,
92+tableMode: params.tableMode,
93+skipEntityDetection: params.skipEntityDetection,
94+});
9195};
9296}
9397@@ -156,6 +160,7 @@ async function deliverTextReply(params: {
156160replyQuoteEntities?: unknown[];
157161linkPreview?: boolean;
158162silent?: boolean;
163+tableMode?: MarkdownTableMode;
159164replyToId?: number;
160165replyToMode: ReplyToMode;
161166progress: DeliveryProgress;
@@ -183,8 +188,9 @@ async function deliverTextReply(params: {
183188replyQuotePosition: params.replyQuotePosition,
184189replyQuoteEntities: params.replyQuoteEntities,
185190thread: params.thread,
186-textMode: "markdown",
191+textMode: chunk.textMode,
187192linkPreview: params.linkPreview,
193+tableMode: params.tableMode,
188194silent: params.silent,
189195 replyMarkup,
190196},
@@ -207,6 +213,7 @@ async function sendPendingFollowUpText(params: {
207213replyMarkup?: ReturnType<typeof buildInlineKeyboard>;
208214linkPreview?: boolean;
209215silent?: boolean;
216+tableMode?: MarkdownTableMode;
210217replyToId?: number;
211218replyToMode: ReplyToMode;
212219progress: DeliveryProgress;
@@ -223,8 +230,9 @@ async function sendPendingFollowUpText(params: {
223230await sendTelegramText(params.bot, params.chatId, chunk.text, params.runtime, {
224231 replyToMessageId,
225232thread: params.thread,
226-textMode: "markdown",
233+textMode: chunk.textMode,
227234linkPreview: params.linkPreview,
235+tableMode: params.tableMode,
228236silent: params.silent,
229237 replyMarkup,
230238});
@@ -261,14 +269,15 @@ async function sendTelegramVoiceFallbackText(opts: {
261269chatId: string;
262270runtime: RuntimeEnv;
263271text: string;
264-chunkText: (markdown: string) => TelegramTextChunk[];
272+chunkText: ChunkTextFn;
265273replyToId?: number;
266274replyQuoteMessageId?: number;
267275replyQuotePosition?: number;
268276replyQuoteEntities?: unknown[];
269277thread?: TelegramThreadSpec | null;
270278linkPreview?: boolean;
271279silent?: boolean;
280+tableMode?: MarkdownTableMode;
272281replyMarkup?: ReturnType<typeof buildInlineKeyboard>;
273282replyQuoteText?: string;
274283}): Promise<number | undefined> {
@@ -286,8 +295,9 @@ async function sendTelegramVoiceFallbackText(opts: {
286295replyQuotePosition: applyQuoteForChunk ? opts.replyQuotePosition : undefined,
287296replyQuoteEntities: applyQuoteForChunk ? opts.replyQuoteEntities : undefined,
288297thread: opts.thread,
289-textMode: "markdown",
298+textMode: chunk.textMode,
290299linkPreview: opts.linkPreview,
300+tableMode: opts.tableMode,
291301silent: opts.silent,
292302replyMarkup: !appliedReplyTo ? opts.replyMarkup : undefined,
293303});
@@ -552,6 +562,7 @@ async function deliverMediaReply(params: {
552562replyMarkup: params.replyMarkup,
553563linkPreview: params.linkPreview,
554564silent: params.silent,
565+tableMode: params.tableMode,
555566replyToId: params.replyToId,
556567replyToMode: params.replyToMode,
557568progress: params.progress,
@@ -717,6 +728,7 @@ export async function deliverReplies(params: {
717728textLimit: Math.min(params.textLimit, TELEGRAM_RICH_TEXT_LIMIT),
718729chunkMode: params.chunkMode ?? "length",
719730tableMode: params.tableMode,
731+skipEntityDetection: params.linkPreview === false,
720732});
721733const candidateReplies: ReplyPayload[] = [];
722734for (const reply of params.replies) {
@@ -837,6 +849,7 @@ export async function deliverReplies(params: {
837849replyQuoteEntities: replyQuote.entities,
838850linkPreview: params.linkPreview,
839851silent: params.silent,
852+tableMode: params.tableMode,
840853 replyToId,
841854replyToMode: params.replyToMode,
842855 progress,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。