fix(telegram): preserve inbound quote context and avoid QUOTE_TEXT_INVALID

This commit is contained in:
Denis Rybnikov
2026-02-08 23:48:14 +01:00
committed by Ayaan Zaidi
parent 727a390d13
commit a4b38ce886
4 changed files with 60 additions and 26 deletions

View File

@@ -967,6 +967,42 @@ describe("createTelegramBot", () => {
expect(payload.ReplyToSender).toBe("unknown sender");
});
it("uses external_reply quote text for partial replies", async () => {
onSpy.mockReset();
sendMessageSpy.mockReset();
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
replySpy.mockReset();
createTelegramBot({ token: "tok" });
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: {
chat: { id: 7, type: "private" },
text: "Sure, see below",
date: 1736380800,
external_reply: {
message_id: 9002,
text: "Can you summarize this?",
from: { first_name: "Ada" },
quote: {
text: "summarize this",
},
},
},
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
expect(replySpy).toHaveBeenCalledTimes(1);
const payload = replySpy.mock.calls[0][0];
expect(payload.Body).toContain("[Quoting Ada id:9002]");
expect(payload.Body).toContain('"summarize this"');
expect(payload.ReplyToId).toBe("9002");
expect(payload.ReplyToBody).toBe("summarize this");
expect(payload.ReplyToSender).toBe("Ada");
});
it("sends replies without native reply threading", async () => {
onSpy.mockReset();
sendMessageSpy.mockReset();