|
|
|
|
@ -3,6 +3,7 @@ import {
|
|
|
|
|
commandSpy,
|
|
|
|
|
getOnHandler,
|
|
|
|
|
getLoadConfigMock,
|
|
|
|
|
makeForumGroupMessageCtx,
|
|
|
|
|
onSpy,
|
|
|
|
|
replySpy,
|
|
|
|
|
sendMessageSpy,
|
|
|
|
|
@ -42,23 +43,7 @@ describe("createTelegramBot", () => {
|
|
|
|
|
createTelegramBot({ token: "tok" });
|
|
|
|
|
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
|
|
|
|
|
|
|
|
|
await handler({
|
|
|
|
|
message: {
|
|
|
|
|
chat: {
|
|
|
|
|
id: -1001234567890,
|
|
|
|
|
type: "supergroup",
|
|
|
|
|
title: "Forum Group",
|
|
|
|
|
is_forum: true,
|
|
|
|
|
},
|
|
|
|
|
from: { id: 12345, username: "testuser" },
|
|
|
|
|
text: "hello",
|
|
|
|
|
date: 1736380800,
|
|
|
|
|
message_id: 42,
|
|
|
|
|
message_thread_id: 99,
|
|
|
|
|
},
|
|
|
|
|
me: { username: "openclaw_bot" },
|
|
|
|
|
getFile: async () => ({ download: async () => new Uint8Array() }),
|
|
|
|
|
});
|
|
|
|
|
await handler(makeForumGroupMessageCtx({ threadId: 99 }));
|
|
|
|
|
|
|
|
|
|
expect(replySpy).toHaveBeenCalledTimes(1);
|
|
|
|
|
const payload = replySpy.mock.calls[0][0];
|
|
|
|
|
@ -85,23 +70,7 @@ describe("createTelegramBot", () => {
|
|
|
|
|
createTelegramBot({ token: "tok" });
|
|
|
|
|
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
|
|
|
|
|
|
|
|
|
await handler({
|
|
|
|
|
message: {
|
|
|
|
|
chat: {
|
|
|
|
|
id: -1001234567890,
|
|
|
|
|
type: "supergroup",
|
|
|
|
|
title: "Forum Group",
|
|
|
|
|
is_forum: true,
|
|
|
|
|
},
|
|
|
|
|
from: { id: 12345, username: "testuser" },
|
|
|
|
|
text: "hello",
|
|
|
|
|
date: 1736380800,
|
|
|
|
|
message_id: 42,
|
|
|
|
|
message_thread_id: 99,
|
|
|
|
|
},
|
|
|
|
|
me: { username: "openclaw_bot" },
|
|
|
|
|
getFile: async () => ({ download: async () => new Uint8Array() }),
|
|
|
|
|
});
|
|
|
|
|
await handler(makeForumGroupMessageCtx({ threadId: 99 }));
|
|
|
|
|
|
|
|
|
|
expect(sendMessageSpy).toHaveBeenCalledWith(
|
|
|
|
|
"-1001234567890",
|
|
|
|
|
@ -132,19 +101,7 @@ describe("createTelegramBot", () => {
|
|
|
|
|
const handler = commandSpy.mock.calls[0][1] as (ctx: Record<string, unknown>) => Promise<void>;
|
|
|
|
|
|
|
|
|
|
await handler({
|
|
|
|
|
message: {
|
|
|
|
|
chat: {
|
|
|
|
|
id: -1001234567890,
|
|
|
|
|
type: "supergroup",
|
|
|
|
|
title: "Forum Group",
|
|
|
|
|
is_forum: true,
|
|
|
|
|
},
|
|
|
|
|
from: { id: 12345, username: "testuser" },
|
|
|
|
|
text: "/status",
|
|
|
|
|
date: 1736380800,
|
|
|
|
|
message_id: 42,
|
|
|
|
|
message_thread_id: 99,
|
|
|
|
|
},
|
|
|
|
|
...makeForumGroupMessageCtx({ threadId: 99, text: "/status" }),
|
|
|
|
|
match: "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|