* feat(telegram): add silent message option (disable_notification) Add support for sending Telegram messages silently without notification sound via the `silent` parameter on the message tool. Changes: - Add `silent` boolean to message tool schema - Extract and pass `silent` through telegram plugin - Add `disable_notification: true` to Telegram API calls - Add `--silent` flag to CLI `message send` command - Add unit test for silent flag Closes #2249 AI-assisted (Claude) - fully tested with unit tests + manual Telegram testing * feat(telegram): add silent send option (#2382) (thanks @Suksham-sharma) --------- Co-authored-by: Pocket Clawd <pocket@Pockets-Mac-mini.local>
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import type { ClawdbotConfig } from "../../../config/config.js";
|
|
import { telegramMessageActions } from "./telegram.js";
|
|
|
|
const handleTelegramAction = vi.fn(async () => ({ ok: true }));
|
|
|
|
vi.mock("../../../agents/tools/telegram-actions.js", () => ({
|
|
handleTelegramAction: (...args: unknown[]) => handleTelegramAction(...args),
|
|
}));
|
|
|
|
describe("telegramMessageActions", () => {
|
|
it("allows media-only sends and passes asVoice", async () => {
|
|
handleTelegramAction.mockClear();
|
|
const cfg = { channels: { telegram: { botToken: "tok" } } } as ClawdbotConfig;
|
|
|
|
await telegramMessageActions.handleAction({
|
|
action: "send",
|
|
params: {
|
|
to: "123",
|
|
media: "https://example.com/voice.ogg",
|
|
asVoice: true,
|
|
},
|
|
cfg,
|
|
accountId: undefined,
|
|
});
|
|
|
|
expect(handleTelegramAction).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
action: "sendMessage",
|
|
to: "123",
|
|
content: "",
|
|
mediaUrl: "https://example.com/voice.ogg",
|
|
asVoice: true,
|
|
}),
|
|
cfg,
|
|
);
|
|
});
|
|
|
|
it("passes silent flag for silent sends", async () => {
|
|
handleTelegramAction.mockClear();
|
|
const cfg = { channels: { telegram: { botToken: "tok" } } } as ClawdbotConfig;
|
|
|
|
await telegramMessageActions.handleAction({
|
|
action: "send",
|
|
params: {
|
|
to: "456",
|
|
message: "Silent notification test",
|
|
silent: true,
|
|
},
|
|
cfg,
|
|
accountId: undefined,
|
|
});
|
|
|
|
expect(handleTelegramAction).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
action: "sendMessage",
|
|
to: "456",
|
|
content: "Silent notification test",
|
|
silent: true,
|
|
}),
|
|
cfg,
|
|
);
|
|
});
|
|
});
|