@@ -37,15 +37,14 @@ import {
3737 resolveCommandArgMenu ,
3838} from "openclaw/plugin-sdk/reply-runtime" ;
3939import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime" ;
40- import { dispatchReplyWithBufferedBlockDispatcher } from "openclaw/plugin-sdk/reply-runtime" ;
41- import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/reply-runtime" ;
4240import { resolveAgentRoute } from "openclaw/plugin-sdk/routing" ;
4341import { resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing" ;
4442import { danger , logVerbose } from "openclaw/plugin-sdk/runtime-env" ;
4543import { getChildLogger } from "openclaw/plugin-sdk/runtime-env" ;
4644import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env" ;
4745import { withTelegramApiErrorLogging } from "./api-logging.js" ;
4846import { isSenderAllowed , normalizeDmAllowFromWithStore } from "./bot-access.js" ;
47+ import { defaultTelegramBotDeps , type TelegramBotDeps } from "./bot-deps.js" ;
4948import type { TelegramMediaRef } from "./bot-message-context.js" ;
5049import {
5150 buildCappedTelegramMenuCommands ,
@@ -77,19 +76,6 @@ import { resolveTelegramGroupPromptSettings } from "./group-config-helpers.js";
7776import { buildInlineKeyboard } from "./send.js" ;
7877
7978const EMPTY_RESPONSE_FALLBACK = "No response generated. Please try again." ;
80- const DEFAULT_BOT_NATIVE_COMMANDS_RUNTIME = {
81- dispatchReplyWithBufferedBlockDispatcher,
82- listSkillCommandsForAgents,
83- } ;
84- let botNativeCommandsRuntimeForTest :
85- | Partial < typeof DEFAULT_BOT_NATIVE_COMMANDS_RUNTIME >
86- | undefined ;
87-
88- export function setBotNativeCommandsRuntimeForTest (
89- runtime ?: Partial < typeof DEFAULT_BOT_NATIVE_COMMANDS_RUNTIME > ,
90- ) : void {
91- botNativeCommandsRuntimeForTest = runtime ;
92- }
9379
9480type TelegramNativeCommandContext = Context & { match ?: string } ;
9581
@@ -114,6 +100,7 @@ export type RegisterTelegramHandlerParams = {
114100 telegramTransport ?: TelegramTransport ;
115101 runtime : RuntimeEnv ;
116102 telegramCfg : TelegramAccountConfig ;
103+ telegramDeps ?: TelegramBotDeps ;
117104 allowFrom ?: Array < string | number > ;
118105 groupAllowFrom ?: Array < string | number > ;
119106 resolveGroupPolicy : ( chatId : string | number ) => ChannelGroupPolicy ;
@@ -155,6 +142,7 @@ export type RegisterTelegramNativeCommandsParams = {
155142 messageThreadId ?: number ,
156143 ) => { groupConfig ?: TelegramGroupConfig ; topicConfig ?: TelegramTopicConfig } ;
157144 shouldSkipUpdate : ( ctx : TelegramUpdateKeyContext ) => boolean ;
145+ telegramDeps ?: TelegramBotDeps ;
158146 opts : { token : string } ;
159147} ;
160148
@@ -377,12 +365,9 @@ export const registerTelegramNativeCommands = ({
377365 resolveGroupPolicy,
378366 resolveTelegramGroupConfig,
379367 shouldSkipUpdate,
368+ telegramDeps = defaultTelegramBotDeps ,
380369 opts,
381370} : RegisterTelegramNativeCommandsParams ) => {
382- const botNativeCommandsRuntime = {
383- ...DEFAULT_BOT_NATIVE_COMMANDS_RUNTIME ,
384- ...botNativeCommandsRuntimeForTest ,
385- } ;
386371 const silentErrorReplies = telegramCfg . silentErrorReplies === true ;
387372 const boundRoute =
388373 nativeEnabled && nativeSkillsEnabled
@@ -395,7 +380,7 @@ export const registerTelegramNativeCommands = ({
395380 }
396381 const skillCommands =
397382 nativeEnabled && nativeSkillsEnabled && boundRoute
398- ? botNativeCommandsRuntime . listSkillCommandsForAgents ( {
383+ ? telegramDeps . listSkillCommandsForAgents ( {
399384 cfg,
400385 agentIds : [ boundRoute . agentId ] ,
401386 } )
@@ -776,7 +761,7 @@ export const registerTelegramNativeCommands = ({
776761 accountId : route . accountId ,
777762 } ) ;
778763
779- await botNativeCommandsRuntime . dispatchReplyWithBufferedBlockDispatcher ( {
764+ await telegramDeps . dispatchReplyWithBufferedBlockDispatcher ( {
780765 ctx : ctxPayload ,
781766 cfg,
782767 dispatcherOptions : {
0 commit comments