chore(deadcode): share telegram send runtime loader · openclaw/openclaw@e012f2c
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,7 @@ import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
6 | 6 | import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/skill-commands-runtime"; |
7 | 7 | import type { TelegramBotDeps } from "./bot-deps.js"; |
8 | 8 | import { syncTelegramMenuCommands } from "./bot-native-command-menu.js"; |
| 9 | +import { loadTelegramSendModule } from "./send-runtime.js"; |
9 | 10 | |
10 | 11 | export type TelegramNativeCommandDeps = Pick< |
11 | 12 | TelegramBotDeps, |
@@ -19,13 +20,6 @@ export type TelegramNativeCommandDeps = Pick<
|
19 | 20 | getPluginCommandSpecs?: typeof getPluginCommandSpecs; |
20 | 21 | }; |
21 | 22 | |
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 | | - |
29 | 23 | export const defaultTelegramNativeCommandDeps: TelegramNativeCommandDeps = { |
30 | 24 | get getRuntimeConfig() { |
31 | 25 | return getRuntimeConfig; |
@@ -46,7 +40,7 @@ export const defaultTelegramNativeCommandDeps: TelegramNativeCommandDeps = {
|
46 | 40 | return getPluginCommandSpecs; |
47 | 41 | }, |
48 | 42 | async editMessageTelegram(...args) { |
49 | | -const { editMessageTelegram } = await loadTelegramSendRuntime(); |
| 43 | +const { editMessageTelegram } = await loadTelegramSendModule(); |
50 | 44 | return await editMessageTelegram(...args); |
51 | 45 | }, |
52 | 46 | }; |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -92,6 +92,7 @@ import { withTelegramStartupProbeSlot } from "./startup-probe-limiter.js";
|
92 | 92 | import { detectTelegramLegacyStateMigrations } from "./state-migrations.js"; |
93 | 93 | import { collectTelegramStatusIssues } from "./status-issues.js"; |
94 | 94 | import { parseTelegramTarget } from "./targets.js"; |
| 95 | +import { loadTelegramSendModule } from "./send-runtime.js"; |
95 | 96 | import { |
96 | 97 | createTelegramThreadBindingManager, |
97 | 98 | setTelegramThreadBindingIdleTimeoutBySessionKey, |
@@ -104,14 +105,8 @@ import { parseTelegramTopicConversation } from "./topic-conversation.js";
|
104 | 105 | type TelegramSendFn = typeof import("./send.js").sendMessageTelegram; |
105 | 106 | type TelegramUpdateOffsetRuntime = typeof import("../update-offset-runtime-api.js"); |
106 | 107 | |
107 | | -let telegramSendModulePromise: Promise<typeof import("./send.js")> | undefined; |
108 | 108 | let telegramUpdateOffsetRuntimePromise: Promise<TelegramUpdateOffsetRuntime> | undefined; |
109 | 109 | |
110 | | -async function loadTelegramSendModule() { |
111 | | -telegramSendModulePromise ??= import("./send.js"); |
112 | | -return await telegramSendModulePromise; |
113 | | -} |
114 | | - |
115 | 110 | async function loadTelegramUpdateOffsetRuntime() { |
116 | 111 | telegramUpdateOffsetRuntimePromise ??= import("../update-offset-runtime-api.js"); |
117 | 112 | return await telegramUpdateOffsetRuntimePromise; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -24,24 +24,17 @@ import { resolveTelegramInlineButtons } from "./button-types.js";
|
24 | 24 | import { splitTelegramHtmlChunks } from "./format.js"; |
25 | 25 | import { resolveTelegramInteractiveTextFallback } from "./interactive-fallback.js"; |
26 | 26 | import { parseTelegramReplyToMessageId, parseTelegramThreadId } from "./outbound-params.js"; |
| 27 | +import { loadTelegramSendModule, type TelegramSendModule } from "./send-runtime.js"; |
27 | 28 | import { normalizeTelegramOutboundTarget, parseTelegramTarget } from "./targets.js"; |
28 | 29 | |
29 | 30 | export const TELEGRAM_TEXT_CHUNK_LIMIT = 4000; |
30 | 31 | export const TELEGRAM_POLL_OPTION_LIMIT = 10; |
31 | 32 | |
32 | 33 | type TelegramSendFn = typeof import("./send.js").sendMessageTelegram; |
33 | | -type TelegramSendModule = typeof import("./send.js"); |
34 | 34 | type TelegramSendOpts = Parameters<TelegramSendFn>[2]; |
35 | 35 | type ResolveTelegramSendFn = (deps?: OutboundSendDeps) => Promise<TelegramSendFn>; |
36 | 36 | type LoadTelegramSendModuleFn = () => Promise<TelegramSendModule>; |
37 | 37 | |
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 | | - |
45 | 38 | async function resolveDefaultTelegramSend(deps?: OutboundSendDeps): Promise<TelegramSendFn> { |
46 | 39 | return ( |
47 | 40 | 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";
|
22 | 22 | import { resolveStateDir } from "openclaw/plugin-sdk/state-paths"; |
23 | 23 | import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
24 | 24 | import { getTelegramRuntime } from "./runtime.js"; |
| 25 | +import { loadTelegramSendModule } from "./send-runtime.js"; |
25 | 26 | import { resolveTelegramToken } from "./token.js"; |
26 | 27 | |
27 | 28 | const DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS = 24 * 60 * 60 * 1000; |
@@ -31,14 +32,8 @@ const STORE_VERSION = 1;
|
31 | 32 | export const TELEGRAM_THREAD_BINDINGS_NAMESPACE = "telegram.thread-bindings"; |
32 | 33 | export const TELEGRAM_THREAD_BINDINGS_MAX_ENTRIES = 5_000; |
33 | 34 | |
34 | | -let telegramSendModulePromise: Promise<typeof import("./send.js")> | undefined; |
35 | 35 | let threadBindingStoreForTest: PluginStateSyncKeyedStore<TelegramThreadBindingRecord> | undefined; |
36 | 36 | |
37 | | -async function loadTelegramSendModule() { |
38 | | -telegramSendModulePromise ??= import("./send.js"); |
39 | | -return await telegramSendModulePromise; |
40 | | -} |
41 | | - |
42 | 37 | type TelegramBindingTargetKind = "subagent" | "acp"; |
43 | 38 | |
44 | 39 | type TelegramThreadBindingRecord = { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。