* refactor: move Telegram channel implementation to extensions/telegram/src/ Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin files) from src/telegram/ and src/channels/plugins/*/telegram.ts to extensions/telegram/src/. Leave thin re-export shims at original locations so cross-cutting src/ imports continue to resolve. - Fix all relative import paths in moved files (../X/ -> ../../../src/X/) - Fix vi.mock paths in 60 test files - Fix inline typeof import() expressions - Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS - Update write-plugin-sdk-entry-dts.ts for new rootDir structure - Move channel plugin files with correct path remapping * fix: support keyed telegram send deps * fix: sync telegram extension copies with latest main * fix: correct import paths and remove misplaced files in telegram extension * fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
import { vi } from "vitest";
|
|
import {
|
|
buildTelegramMessageContext,
|
|
type BuildTelegramMessageContextParams,
|
|
type TelegramMediaRef,
|
|
} from "./bot-message-context.js";
|
|
|
|
export const baseTelegramMessageContextConfig = {
|
|
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
|
|
channels: { telegram: {} },
|
|
messages: { groupChat: { mentionPatterns: [] } },
|
|
} as never;
|
|
|
|
type BuildTelegramMessageContextForTestParams = {
|
|
message: Record<string, unknown>;
|
|
allMedia?: TelegramMediaRef[];
|
|
options?: BuildTelegramMessageContextParams["options"];
|
|
cfg?: Record<string, unknown>;
|
|
accountId?: string;
|
|
resolveGroupActivation?: BuildTelegramMessageContextParams["resolveGroupActivation"];
|
|
resolveGroupRequireMention?: BuildTelegramMessageContextParams["resolveGroupRequireMention"];
|
|
resolveTelegramGroupConfig?: BuildTelegramMessageContextParams["resolveTelegramGroupConfig"];
|
|
};
|
|
|
|
export async function buildTelegramMessageContextForTest(
|
|
params: BuildTelegramMessageContextForTestParams,
|
|
): Promise<Awaited<ReturnType<typeof buildTelegramMessageContext>>> {
|
|
return await buildTelegramMessageContext({
|
|
primaryCtx: {
|
|
message: {
|
|
message_id: 1,
|
|
date: 1_700_000_000,
|
|
text: "hello",
|
|
from: { id: 42, first_name: "Alice" },
|
|
...params.message,
|
|
},
|
|
me: { id: 7, username: "bot" },
|
|
} as never,
|
|
allMedia: params.allMedia ?? [],
|
|
storeAllowFrom: [],
|
|
options: params.options ?? {},
|
|
bot: {
|
|
api: {
|
|
sendChatAction: vi.fn(),
|
|
setMessageReaction: vi.fn(),
|
|
},
|
|
} as never,
|
|
cfg: (params.cfg ?? baseTelegramMessageContextConfig) as never,
|
|
account: { accountId: params.accountId ?? "default" } as never,
|
|
historyLimit: 0,
|
|
groupHistories: new Map(),
|
|
dmPolicy: "open",
|
|
allowFrom: [],
|
|
groupAllowFrom: [],
|
|
ackReactionScope: "off",
|
|
logger: { info: vi.fn() },
|
|
resolveGroupActivation: params.resolveGroupActivation ?? (() => undefined),
|
|
resolveGroupRequireMention: params.resolveGroupRequireMention ?? (() => false),
|
|
resolveTelegramGroupConfig:
|
|
params.resolveTelegramGroupConfig ??
|
|
(() => ({
|
|
groupConfig: { requireMention: false },
|
|
topicConfig: undefined,
|
|
})),
|
|
sendChatActionHandler: { sendChatAction: vi.fn() } as never,
|
|
});
|
|
}
|