File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
66import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/skill-commands-runtime" ;
77import type { TelegramBotDeps } from "./bot-deps.js" ;
88import { syncTelegramMenuCommands } from "./bot-native-command-menu.js" ;
9+ import { loadTelegramSendModule } from "./send-runtime.js" ;
910
1011export type TelegramNativeCommandDeps = Pick <
1112 TelegramBotDeps ,
@@ -19,13 +20,6 @@ export type TelegramNativeCommandDeps = Pick<
1920 getPluginCommandSpecs ?: typeof getPluginCommandSpecs ;
2021} ;
2122
22- let telegramSendRuntimePromise : Promise < typeof import ( "./send.js" ) > | undefined ;
23-
24- async function loadTelegramSendRuntime ( ) {
25- telegramSendRuntimePromise ??= import ( "./send.js" ) ;
26- return await telegramSendRuntimePromise ;
27- }
28-
2923export const defaultTelegramNativeCommandDeps : TelegramNativeCommandDeps = {
3024 get getRuntimeConfig ( ) {
3125 return getRuntimeConfig ;
@@ -46,7 +40,7 @@ export const defaultTelegramNativeCommandDeps: TelegramNativeCommandDeps = {
4640 return getPluginCommandSpecs ;
4741 } ,
4842 async editMessageTelegram ( ...args ) {
49- const { editMessageTelegram } = await loadTelegramSendRuntime ( ) ;
43+ const { editMessageTelegram } = await loadTelegramSendModule ( ) ;
5044 return await editMessageTelegram ( ...args ) ;
5145 } ,
5246} ;
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ import { withTelegramStartupProbeSlot } from "./startup-probe-limiter.js";
9292import { detectTelegramLegacyStateMigrations } from "./state-migrations.js" ;
9393import { collectTelegramStatusIssues } from "./status-issues.js" ;
9494import { parseTelegramTarget } from "./targets.js" ;
95+ import { loadTelegramSendModule } from "./send-runtime.js" ;
9596import {
9697 createTelegramThreadBindingManager ,
9798 setTelegramThreadBindingIdleTimeoutBySessionKey ,
@@ -104,14 +105,8 @@ import { parseTelegramTopicConversation } from "./topic-conversation.js";
104105type TelegramSendFn = typeof import ( "./send.js" ) . sendMessageTelegram ;
105106type TelegramUpdateOffsetRuntime = typeof import ( "../update-offset-runtime-api.js" ) ;
106107
107- let telegramSendModulePromise : Promise < typeof import ( "./send.js" ) > | undefined ;
108108let telegramUpdateOffsetRuntimePromise : Promise < TelegramUpdateOffsetRuntime > | undefined ;
109109
110- async function loadTelegramSendModule ( ) {
111- telegramSendModulePromise ??= import ( "./send.js" ) ;
112- return await telegramSendModulePromise ;
113- }
114-
115110async function loadTelegramUpdateOffsetRuntime ( ) {
116111 telegramUpdateOffsetRuntimePromise ??= import ( "../update-offset-runtime-api.js" ) ;
117112 return await telegramUpdateOffsetRuntimePromise ;
Original file line number Diff line number Diff line change @@ -24,24 +24,17 @@ import { resolveTelegramInlineButtons } from "./button-types.js";
2424import { splitTelegramHtmlChunks } from "./format.js" ;
2525import { resolveTelegramInteractiveTextFallback } from "./interactive-fallback.js" ;
2626import { parseTelegramReplyToMessageId , parseTelegramThreadId } from "./outbound-params.js" ;
27+ import { loadTelegramSendModule , type TelegramSendModule } from "./send-runtime.js" ;
2728import { normalizeTelegramOutboundTarget , parseTelegramTarget } from "./targets.js" ;
2829
2930export const TELEGRAM_TEXT_CHUNK_LIMIT = 4000 ;
3031export const TELEGRAM_POLL_OPTION_LIMIT = 10 ;
3132
3233type TelegramSendFn = typeof import ( "./send.js" ) . sendMessageTelegram ;
33- type TelegramSendModule = typeof import ( "./send.js" ) ;
3434type TelegramSendOpts = Parameters < TelegramSendFn > [ 2 ] ;
3535type ResolveTelegramSendFn = ( deps ?: OutboundSendDeps ) => Promise < TelegramSendFn > ;
3636type LoadTelegramSendModuleFn = ( ) => Promise < TelegramSendModule > ;
3737
38- let telegramSendModulePromise : Promise < typeof import ( "./send.js" ) > | undefined ;
39-
40- async function loadTelegramSendModule ( ) : Promise < TelegramSendModule > {
41- telegramSendModulePromise ??= import ( "./send.js" ) ;
42- return await telegramSendModulePromise ;
43- }
44-
4538async function resolveDefaultTelegramSend ( deps ?: OutboundSendDeps ) : Promise < TelegramSendFn > {
4639 return (
4740 resolveOutboundSendDep < TelegramSendFn > ( deps , "telegram" ) ??
Original file line number Diff line number Diff line change 1+ // Telegram plugin module owns the lazy send runtime import.
2+ export type TelegramSendModule = typeof import ( "./send.js" ) ;
3+
4+ let telegramSendModulePromise : Promise < TelegramSendModule > | undefined ;
5+
6+ export async function loadTelegramSendModule ( ) : Promise < TelegramSendModule > {
7+ telegramSendModulePromise ??= import ( "./send.js" ) ;
8+ return await telegramSendModulePromise ;
9+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
2222import { resolveStateDir } from "openclaw/plugin-sdk/state-paths" ;
2323import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime" ;
2424import { getTelegramRuntime } from "./runtime.js" ;
25+ import { loadTelegramSendModule } from "./send-runtime.js" ;
2526import { resolveTelegramToken } from "./token.js" ;
2627
2728const DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS = 24 * 60 * 60 * 1000 ;
@@ -31,14 +32,8 @@ const STORE_VERSION = 1;
3132export const TELEGRAM_THREAD_BINDINGS_NAMESPACE = "telegram.thread-bindings" ;
3233export const TELEGRAM_THREAD_BINDINGS_MAX_ENTRIES = 5_000 ;
3334
34- let telegramSendModulePromise : Promise < typeof import ( "./send.js" ) > | undefined ;
3535let threadBindingStoreForTest : PluginStateSyncKeyedStore < TelegramThreadBindingRecord > | undefined ;
3636
37- async function loadTelegramSendModule ( ) {
38- telegramSendModulePromise ??= import ( "./send.js" ) ;
39- return await telegramSendModulePromise ;
40- }
41-
4237type TelegramBindingTargetKind = "subagent" | "acp" ;
4338
4439type TelegramThreadBindingRecord = {
You can’t perform that action at this time.
0 commit comments