fix: add per-channel markdown table conversion (#1495) (thanks @odysseus0)
This commit is contained in:
@@ -4,6 +4,7 @@ import { resolveChannelMediaMaxBytes } from "../../channels/plugins/media-limits
|
||||
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
||||
import type { ChannelOutboundAdapter } from "../../channels/plugins/types.js";
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import { resolveMarkdownTableMode } from "../../config/markdown-tables.js";
|
||||
import type { sendMessageDiscord } from "../../discord/send.js";
|
||||
import type { sendMessageIMessage } from "../../imessage/send.js";
|
||||
import { markdownToSignalTextChunks, type SignalTextStyleRange } from "../../signal/format.js";
|
||||
@@ -192,6 +193,9 @@ export async function deliverOutboundPayloads(params: {
|
||||
})
|
||||
: undefined;
|
||||
const isSignalChannel = channel === "signal";
|
||||
const signalTableMode = isSignalChannel
|
||||
? resolveMarkdownTableMode({ cfg, channel: "signal", accountId })
|
||||
: "code";
|
||||
const signalMaxBytes = isSignalChannel
|
||||
? resolveChannelMediaMaxBytes({
|
||||
cfg,
|
||||
@@ -231,8 +235,10 @@ export async function deliverOutboundPayloads(params: {
|
||||
throwIfAborted(abortSignal);
|
||||
let signalChunks =
|
||||
textLimit === undefined
|
||||
? markdownToSignalTextChunks(text, Number.POSITIVE_INFINITY)
|
||||
: markdownToSignalTextChunks(text, textLimit);
|
||||
? markdownToSignalTextChunks(text, Number.POSITIVE_INFINITY, {
|
||||
tableMode: signalTableMode,
|
||||
})
|
||||
: markdownToSignalTextChunks(text, textLimit, { tableMode: signalTableMode });
|
||||
if (signalChunks.length === 0 && text) {
|
||||
signalChunks = [{ text, styles: [] }];
|
||||
}
|
||||
@@ -244,7 +250,9 @@ export async function deliverOutboundPayloads(params: {
|
||||
|
||||
const sendSignalMedia = async (caption: string, mediaUrl: string) => {
|
||||
throwIfAborted(abortSignal);
|
||||
const formatted = markdownToSignalTextChunks(caption, Number.POSITIVE_INFINITY)[0] ?? {
|
||||
const formatted = markdownToSignalTextChunks(caption, Number.POSITIVE_INFINITY, {
|
||||
tableMode: signalTableMode,
|
||||
})[0] ?? {
|
||||
text: caption,
|
||||
styles: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user