diff --git a/src/auto-reply/reply/route-reply.test.ts b/src/auto-reply/reply/route-reply.test.ts index 9571e292f..8debc7b67 100644 --- a/src/auto-reply/reply/route-reply.test.ts +++ b/src/auto-reply/reply/route-reply.test.ts @@ -1,8 +1,14 @@ import { describe, expect, it, vi } from "vitest"; +import type { ClawdbotConfig } from "../../config/config.js"; + const mocks = vi.hoisted(() => ({ sendMessageDiscord: vi.fn(async () => ({ messageId: "m1", channelId: "c1" })), sendMessageIMessage: vi.fn(async () => ({ messageId: "ok" })), + sendMessageMSTeams: vi.fn(async () => ({ + messageId: "m1", + conversationId: "c1", + })), sendMessageSignal: vi.fn(async () => ({ messageId: "t1" })), sendMessageSlack: vi.fn(async () => ({ messageId: "m1", channelId: "c1" })), sendMessageTelegram: vi.fn(async () => ({ messageId: "m1", chatId: "c1" })), @@ -15,6 +21,9 @@ vi.mock("../../discord/send.js", () => ({ vi.mock("../../imessage/send.js", () => ({ sendMessageIMessage: mocks.sendMessageIMessage, })); +vi.mock("../../msteams/send.js", () => ({ + sendMessageMSTeams: mocks.sendMessageMSTeams, +})); vi.mock("../../signal/send.js", () => ({ sendMessageSignal: mocks.sendMessageSignal, })); @@ -143,4 +152,25 @@ describe("routeReply", () => { expect.objectContaining({ accountId: "acc-1", verbose: false }), ); }); + + it("routes MS Teams via proactive sender", async () => { + mocks.sendMessageMSTeams.mockClear(); + const cfg = { + msteams: { + enabled: true, + }, + } as unknown as ClawdbotConfig; + await routeReply({ + payload: { text: "hi" }, + channel: "msteams", + to: "conversation:19:abc@thread.tacv2", + cfg, + }); + expect(mocks.sendMessageMSTeams).toHaveBeenCalledWith({ + cfg, + to: "conversation:19:abc@thread.tacv2", + text: "hi", + mediaUrl: undefined, + }); + }); }); diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index 80d99028d..ac0550aeb 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -153,8 +153,12 @@ export function createTelegramBot(opts: TelegramBotOptions) { }, }; const fetchImpl = resolveTelegramFetch(opts.proxyFetch); + const isBun = "Bun" in globalThis || Boolean(process?.versions?.bun); + const shouldProvideFetch = Boolean(opts.proxyFetch) || isBun; const client: ApiClientOptions | undefined = fetchImpl - ? { fetch: fetchImpl as unknown as ApiClientOptions["fetch"] } + ? shouldProvideFetch + ? { fetch: fetchImpl as unknown as ApiClientOptions["fetch"] } + : undefined : undefined; const bot = new Bot(opts.token, client ? { client } : undefined);