fix: add per-channel markdown table conversion (#1495) (thanks @odysseus0)

This commit is contained in:
Peter Steinberger
2026-01-23 17:56:50 +00:00
parent 37e5f077b8
commit b77e730657
64 changed files with 837 additions and 186 deletions

View File

@@ -1,7 +1,9 @@
import type { RequestClient } from "@buape/carbon";
import { Routes } from "discord-api-types/v10";
import { loadConfig } from "../config/config.js";
import { resolveMarkdownTableMode } from "../config/markdown-tables.js";
import { recordChannelActivity } from "../infra/channel-activity.js";
import { convertMarkdownTables } from "../markdown/tables.js";
import type { RetryConfig } from "../infra/retry.js";
import type { PollInput } from "../polls.js";
import { resolveDiscordAccount } from "./accounts.js";
@@ -38,6 +40,12 @@ export async function sendMessageDiscord(
cfg,
accountId: opts.accountId,
});
const tableMode = resolveMarkdownTableMode({
cfg,
channel: "discord",
accountId: accountInfo.accountId,
});
const textWithTables = convertMarkdownTables(text ?? "", tableMode);
const { token, rest, request } = createDiscordClient(opts, cfg);
const recipient = parseRecipient(to);
const { channelId } = await resolveChannelId(rest, recipient, request);
@@ -47,7 +55,7 @@ export async function sendMessageDiscord(
result = await sendDiscordMedia(
rest,
channelId,
text,
textWithTables,
opts.mediaUrl,
opts.replyTo,
request,
@@ -58,7 +66,7 @@ export async function sendMessageDiscord(
result = await sendDiscordText(
rest,
channelId,
text,
textWithTables,
opts.replyTo,
request,
accountInfo.config.maxLinesPerMessage,