fix(telegram): inject media loader through bot deps

This commit is contained in:
Vincent Koc
2026-03-22 21:29:33 -07:00
parent df3f9bb555
commit 6eafa2ec87
3 changed files with 8 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import { readChannelAllowFromStore } from "openclaw/plugin-sdk/conversation-runt
import { upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
import { enqueueSystemEvent } from "openclaw/plugin-sdk/infra-runtime";
import { dispatchReplyWithBufferedBlockDispatcher } from "openclaw/plugin-sdk/reply-runtime";
import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
import { wasSentByBot } from "./sent-message-cache.js";
export type TelegramBotDeps = {
@@ -16,6 +17,7 @@ export type TelegramBotDeps = {
upsertChannelPairingRequest: typeof upsertChannelPairingRequest;
enqueueSystemEvent: typeof enqueueSystemEvent;
dispatchReplyWithBufferedBlockDispatcher: typeof dispatchReplyWithBufferedBlockDispatcher;
loadWebMedia: typeof loadWebMedia;
buildModelsProviderData: typeof buildModelsProviderData;
listSkillCommandsForAgents: typeof listSkillCommandsForAgents;
wasSentByBot: typeof wasSentByBot;
@@ -40,6 +42,9 @@ export const defaultTelegramBotDeps: TelegramBotDeps = {
get dispatchReplyWithBufferedBlockDispatcher() {
return dispatchReplyWithBufferedBlockDispatcher;
},
get loadWebMedia() {
return loadWebMedia;
},
get buildModelsProviderData() {
return buildModelsProviderData;
},

View File

@@ -481,6 +481,7 @@ export const dispatchTelegramMessage = async ({
replies: [payload],
onVoiceRecording: sendRecordVoice,
silent: silentErrorReplies && payload.isError === true,
mediaLoader: telegramDeps.loadWebMedia,
});
if (result.delivered) {
deliveryState.markDelivered();
@@ -867,6 +868,7 @@ export const dispatchTelegramMessage = async ({
replies: [{ text: fallbackText }],
...deliveryBaseOptions,
silent: silentErrorReplies && (dispatchError != null || hadErrorReplyFailureOrSkip),
mediaLoader: telegramDeps.loadWebMedia,
});
sentFallback = result.delivered;
}

View File

@@ -406,6 +406,7 @@ export const telegramBotDepsForTest: TelegramBotDeps = {
upsertChannelPairingRequest as TelegramBotDeps["upsertChannelPairingRequest"],
enqueueSystemEvent: enqueueSystemEventSpy as TelegramBotDeps["enqueueSystemEvent"],
dispatchReplyWithBufferedBlockDispatcher,
loadWebMedia: loadWebMedia as TelegramBotDeps["loadWebMedia"],
buildModelsProviderData: buildModelsProviderData as TelegramBotDeps["buildModelsProviderData"],
listSkillCommandsForAgents:
listSkillCommandsForAgents as TelegramBotDeps["listSkillCommandsForAgents"],