Telegram: Add reply-chain detection to bypass mention requirement (#1038)
* Telegram: add reply-chain detection to bypass mention requirement * fix: allow telegram reply-chain mention bypass (#1038) (thanks @adityashaw2) --------- Co-authored-by: Aditya Shaw <aditya@adityashaw.dev> Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -952,6 +952,39 @@ describe("createTelegramBot", () => {
|
||||
expect(replySpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("accepts group replies to the bot without explicit mention when requireMention is enabled", async () => {
|
||||
onSpy.mockReset();
|
||||
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
|
||||
replySpy.mockReset();
|
||||
loadConfig.mockReturnValue({
|
||||
channels: {
|
||||
telegram: { groups: { "*": { requireMention: true } } },
|
||||
},
|
||||
});
|
||||
|
||||
createTelegramBot({ token: "tok" });
|
||||
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
||||
|
||||
await handler({
|
||||
message: {
|
||||
chat: { id: 456, type: "group", title: "Ops Chat" },
|
||||
text: "following up",
|
||||
date: 1736380800,
|
||||
reply_to_message: {
|
||||
message_id: 42,
|
||||
text: "original reply",
|
||||
from: { id: 999, first_name: "Clawdbot" },
|
||||
},
|
||||
},
|
||||
me: { id: 999, username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
||||
const payload = replySpy.mock.calls[0][0];
|
||||
expect(payload.WasMentioned).toBe(true);
|
||||
});
|
||||
|
||||
it("honors routed group activation from session store", async () => {
|
||||
onSpy.mockReset();
|
||||
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
|
||||
|
||||
Reference in New Issue
Block a user