fix(telegram): stream replies in-place without duplicate final sends

This commit is contained in:
Ayaan Zaidi
2026-02-15 20:09:10 +05:30
committed by Ayaan Zaidi
parent 8b2a5672be
commit a69e82765f
17 changed files with 575 additions and 210 deletions

View File

@@ -696,6 +696,8 @@ type TelegramEditOpts = {
api?: Bot["api"];
retry?: RetryConfig;
textMode?: "markdown" | "html";
/** Controls whether link previews are shown in the edited message. */
linkPreview?: boolean;
/** Inline keyboard buttons (reply markup). Pass empty array to remove buttons. */
buttons?: Array<Array<{ text: string; callback_data: string }>>;
/** Optional config injection to avoid global loadConfig() (improves testability). */
@@ -752,6 +754,9 @@ export async function editMessageTelegram(
const editParams: Record<string, unknown> = {
parse_mode: "HTML",
};
if (opts.linkPreview === false) {
editParams.link_preview_options = { is_disabled: true };
}
if (replyMarkup !== undefined) {
editParams.reply_markup = replyMarkup;
}
@@ -767,6 +772,9 @@ export async function editMessageTelegram(
console.warn(`telegram HTML parse failed, retrying as plain text: ${errText}`);
}
const plainParams: Record<string, unknown> = {};
if (opts.linkPreview === false) {
plainParams.link_preview_options = { is_disabled: true };
}
if (replyMarkup !== undefined) {
plainParams.reply_markup = replyMarkup;
}