diff --git a/src/telegram/bot.test.ts b/src/telegram/bot.test.ts index e9f3c2348..56a046bc3 100644 --- a/src/telegram/bot.test.ts +++ b/src/telegram/bot.test.ts @@ -148,7 +148,7 @@ describe("createTelegramBot", () => { expect(payload.ReplyToSender).toBe("Ada"); }); - it("sends replies as native replies without chaining", async () => { + it("sends replies without native reply threading", async () => { onSpy.mockReset(); sendMessageSpy.mockReset(); const replySpy = replyModule.__replySpy as unknown as ReturnType< @@ -174,7 +174,7 @@ describe("createTelegramBot", () => { expect(sendMessageSpy.mock.calls.length).toBeGreaterThan(1); for (const call of sendMessageSpy.mock.calls) { - expect(call[2]?.reply_to_message_id).toBe(101); + expect(call[2]?.reply_to_message_id).toBeUndefined(); } }); }); diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index 95e0258f7..a4032fe0b 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -199,7 +199,6 @@ export function createTelegramBot(opts: TelegramBotOptions) { token: opts.token, runtime, bot, - replyToMessageId: msg.message_id, }); } catch (err) { runtime.error?.(danger(`Telegram handler failed: ${String(err)}`)); @@ -222,10 +221,8 @@ async function deliverReplies(params: { token: string; runtime: RuntimeEnv; bot: Bot; - replyToMessageId?: number; }) { const { replies, chatId, runtime, bot } = params; - const replyTarget = params.replyToMessageId; for (const reply of replies) { if (!reply?.text && !reply?.mediaUrl && !(reply?.mediaUrls?.length ?? 0)) { runtime.error?.(danger("Telegram reply missing text/media")); @@ -236,14 +233,9 @@ async function deliverReplies(params: { : reply.mediaUrl ? [reply.mediaUrl] : []; - if (replyTarget && isVerbose()) { - logVerbose( - `telegram reply-send: chatId=${chatId} replyToMessageId=${replyTarget} kind=${mediaList.length ? "media" : "text"}`, - ); - } if (mediaList.length === 0) { for (const chunk of chunkText(reply.text || "", 4000)) { - await sendTelegramText(bot, chatId, chunk, runtime, replyTarget); + await sendTelegramText(bot, chatId, chunk, runtime); } continue; } @@ -255,18 +247,14 @@ async function deliverReplies(params: { const file = new InputFile(media.buffer, media.fileName ?? "file"); const caption = first ? (reply.text ?? undefined) : undefined; first = false; - const replyOpts = replyTarget ? { reply_to_message_id: replyTarget } : {}; if (kind === "image") { - await bot.api.sendPhoto(chatId, file, { caption, ...replyOpts }); + await bot.api.sendPhoto(chatId, file, { caption }); } else if (kind === "video") { - await bot.api.sendVideo(chatId, file, { caption, ...replyOpts }); + await bot.api.sendVideo(chatId, file, { caption }); } else if (kind === "audio") { - await bot.api.sendAudio(chatId, file, { caption, ...replyOpts }); + await bot.api.sendAudio(chatId, file, { caption }); } else { - await bot.api.sendDocument(chatId, file, { - caption, - ...replyOpts, - }); + await bot.api.sendDocument(chatId, file, { caption }); } } } @@ -363,12 +351,10 @@ async function sendTelegramText( chatId: string, text: string, runtime: RuntimeEnv, - replyToMessageId?: number, ): Promise { try { const res = await bot.api.sendMessage(chatId, text, { parse_mode: "Markdown", - reply_to_message_id: replyToMessageId, }); return res.message_id; } catch (err) { @@ -378,7 +364,6 @@ async function sendTelegramText( `telegram markdown parse failed; retrying without formatting: ${errText}`, ); const res = await bot.api.sendMessage(chatId, text, { - reply_to_message_id: replyToMessageId, }); return res.message_id; } diff --git a/src/web/inbound.ts b/src/web/inbound.ts index 80dd2dce7..8b11d3b68 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -223,10 +223,10 @@ export async function monitorWebInbox(options: { } }; const reply = async (text: string) => { - await sock.sendMessage(chatJid, { text }, { quoted: msg }); + await sock.sendMessage(chatJid, { text }); }; const sendMedia = async (payload: AnyMessageContent) => { - await sock.sendMessage(chatJid, payload, { quoted: msg }); + await sock.sendMessage(chatJid, payload); }; const timestamp = msg.messageTimestamp ? Number(msg.messageTimestamp) * 1000 diff --git a/src/web/monitor-inbox.test.ts b/src/web/monitor-inbox.test.ts index dd885375a..803f71269 100644 --- a/src/web/monitor-inbox.test.ts +++ b/src/web/monitor-inbox.test.ts @@ -112,11 +112,6 @@ describe("web monitor inbox", () => { expect(sock.sendMessage).toHaveBeenCalledWith( "999@s.whatsapp.net", { text: "pong" }, - { - quoted: expect.objectContaining({ - key: expect.objectContaining({ id: "abc" }), - }), - }, ); await listener.close(); @@ -200,11 +195,6 @@ describe("web monitor inbox", () => { expect(sock.sendMessage).toHaveBeenCalledWith( "999@s.whatsapp.net", { text: "pong" }, - { - quoted: expect.objectContaining({ - key: expect.objectContaining({ id: "abc" }), - }), - }, ); await listener.close();