perf: slim telegram bot imports

This commit is contained in:
Peter Steinberger
2026-04-24 09:12:28 +01:00
parent 028b6c9b13
commit 447105a278
2 changed files with 17 additions and 3 deletions

View File

@@ -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<TelegramMessageDispatchModule> | undefined;
async function loadTelegramMessageDispatch(): Promise<TelegramMessageDispatchModule> {
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,

View File

@@ -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 = {