diff --git a/extensions/telegram/src/bot-message.ts b/extensions/telegram/src/bot-message.ts index 6ab4cfbd015..6bd6e0e64a4 100644 --- a/extensions/telegram/src/bot-message.ts +++ b/extensions/telegram/src/bot-message.ts @@ -9,11 +9,22 @@ import { type TelegramMediaRef, } from "./bot-message-context.js"; import type { TelegramMessageContextOptions } from "./bot-message-context.types.js"; -import { dispatchTelegramMessage } from "./bot-message-dispatch.js"; import type { TelegramBotOptions } from "./bot.types.js"; import { buildTelegramThreadParams } from "./bot/helpers.js"; import type { TelegramContext, TelegramStreamMode } from "./bot/types.js"; +type TelegramMessageDispatchModule = Pick< + typeof import("./bot-message-dispatch.js"), + "dispatchTelegramMessage" +>; + +let telegramMessageDispatchPromise: Promise | undefined; + +async function loadTelegramMessageDispatch(): Promise { + telegramMessageDispatchPromise ??= import("./bot-message-dispatch.js"); + return await telegramMessageDispatchPromise; +} + /** Dependencies injected once when creating the message processor. */ type TelegramMessageProcessorDeps = Omit< BuildTelegramMessageContextParams, @@ -108,6 +119,7 @@ export const createTelegramMessageProcessor = (deps: TelegramMessageProcessorDep ); } try { + const { dispatchTelegramMessage } = await loadTelegramMessageDispatch(); await dispatchTelegramMessage({ context, bot, diff --git a/extensions/telegram/src/sequential-key.ts b/extensions/telegram/src/sequential-key.ts index 246fb2bfc69..14be5fda490 100644 --- a/extensions/telegram/src/sequential-key.ts +++ b/extensions/telegram/src/sequential-key.ts @@ -4,9 +4,11 @@ import { maybeResolveTextAlias, normalizeCommandBody, } from "openclaw/plugin-sdk/command-auth"; +import { + isAbortRequestText, + isBtwRequestText, +} from "openclaw/plugin-sdk/command-primitives-runtime"; import { parseExecApprovalCommandText } from "openclaw/plugin-sdk/infra-runtime"; -import { isAbortRequestText } from "openclaw/plugin-sdk/reply-runtime"; -import { isBtwRequestText } from "openclaw/plugin-sdk/reply-runtime"; import { resolveTelegramForumThreadId } from "./bot/helpers.js"; export type TelegramSequentialKeyContext = {