diff --git a/extensions/telegram/src/api-fetch.ts b/extensions/telegram/src/api-fetch.ts index 5389e7ed841..21dd8fd64e5 100644 --- a/extensions/telegram/src/api-fetch.ts +++ b/extensions/telegram/src/api-fetch.ts @@ -11,6 +11,26 @@ export function resolveTelegramChatLookupFetch(params?: { return resolveTelegramFetch(proxyFetch, { network: params?.network }); } +export async function lookupTelegramChatId(params: { + token: string; + chatId: string; + signal?: AbortSignal; + apiRoot?: string; + proxyUrl?: string; + network?: TelegramNetworkConfig; +}): Promise { + return fetchTelegramChatId({ + token: params.token, + chatId: params.chatId, + signal: params.signal, + apiRoot: params.apiRoot, + fetchImpl: resolveTelegramChatLookupFetch({ + proxyUrl: params.proxyUrl, + network: params.network, + }), + }); +} + export async function fetchTelegramChatId(params: { token: string; chatId: string; diff --git a/extensions/telegram/src/setup-core.ts b/extensions/telegram/src/setup-core.ts index 63c4ab87437..6e24563a9c9 100644 --- a/extensions/telegram/src/setup-core.ts +++ b/extensions/telegram/src/setup-core.ts @@ -11,7 +11,7 @@ import type { ChannelSetupAdapter, ChannelSetupDmPolicy } from "openclaw/plugin- import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools"; import type { TelegramNetworkConfig } from "../runtime-api.js"; import { resolveDefaultTelegramAccountId, resolveTelegramAccount } from "./accounts.js"; -import { fetchTelegramChatId, resolveTelegramChatLookupFetch } from "./api-fetch.js"; +import { lookupTelegramChatId } from "./api-fetch.js"; const channel = "telegram" as const; @@ -51,10 +51,6 @@ export async function resolveTelegramAllowFromEntries(params: { proxyUrl?: string; network?: TelegramNetworkConfig; }) { - const fetchImpl = resolveTelegramChatLookupFetch({ - proxyUrl: params.proxyUrl, - network: params.network, - }); return await Promise.all( params.entries.map(async (entry) => { const numericId = parseTelegramAllowFromId(entry); @@ -66,11 +62,12 @@ export async function resolveTelegramAllowFromEntries(params: { return { input: entry, resolved: false, id: null }; } const username = stripped.startsWith("@") ? stripped : `@${stripped}`; - const id = await fetchTelegramChatId({ + const id = await lookupTelegramChatId({ token: params.credentialValue, chatId: username, apiRoot: params.apiRoot, - fetchImpl, + proxyUrl: params.proxyUrl, + network: params.network, }); return { input: entry, resolved: Boolean(id), id }; }), diff --git a/src/commands/doctor-config-flow.ts b/src/commands/doctor-config-flow.ts index 4d426d91336..a800da83ab6 100644 --- a/src/commands/doctor-config-flow.ts +++ b/src/commands/doctor-config-flow.ts @@ -4,8 +4,8 @@ import { listTelegramAccountIds, lookupTelegramChatId, normalizeTelegramAllowFromEntry, -} from "../../extensions/telegram/api.js"; -import type { TelegramNetworkConfig } from "../config/types.telegram.js"; +} from "openclaw/plugin-sdk/telegram"; +import type { TelegramNetworkConfig } from "openclaw/plugin-sdk/telegram"; import { normalizeChatChannelId } from "../channels/registry.js"; import { formatCliCommand } from "../cli/command-format.js"; import { resolveCommandSecretRefsViaGateway } from "../cli/command-secret-gateway.js"; diff --git a/src/plugins/runtime/runtime-telegram-contract.ts b/src/plugins/runtime/runtime-telegram-contract.ts index 6700ae25429..fc0b680f51d 100644 --- a/src/plugins/runtime/runtime-telegram-contract.ts +++ b/src/plugins/runtime/runtime-telegram-contract.ts @@ -82,7 +82,7 @@ export { isNumericTelegramUserId, normalizeTelegramAllowFromEntry, } from "../../../extensions/telegram/api.js"; -export { fetchTelegramChatId } from "../../../extensions/telegram/api.js"; +export { fetchTelegramChatId, lookupTelegramChatId } from "../../../extensions/telegram/api.js"; export { resolveTelegramInlineButtonsScope, resolveTelegramTargetChatType,