UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 3.45 kB
import{o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs";import{n as normalizeAccountId,r as normalizeOptionalAccountId,t as DEFAULT_ACCOUNT_ID}from"./account-id-3yqrEsRn.mjs";import{a as resolveNormalizedAccountEntry}from"./account-lookup-DXbrh7Os.mjs";import{t as mergeAccountConfig}from"./channel-account-config-DFPObbzi.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs";import{i as hasConfiguredAccountValue,o as resolveListedDefaultAccountId,t as createAccountListHelpers}from"./account-helpers-Brjsp5C9.mjs";import"./account-core-DVwDDMZR.mjs";import{r as resolveDefaultAgentBoundAccountId}from"./bindings-B5mteQei.mjs";import"./routing-BMFcTEzQ.mjs";import{t as listAgentIdsCompatibility}from"./agent-scope-runtime-DKb8jQZx.mjs"; //!extensions/telegram/src/account-config.ts function resolveTelegramAccountConfig(e,t){const n=normalizeAccountId(t);return resolveNormalizedAccountEntry(e.channels?.telegram?.accounts,n,normalizeAccountId)}function mergeTelegramAccountConfig(e,t){const n=e.channels?.telegram;const r=Object.keys(n?.accounts??{}).length>1;return mergeAccountConfig({channelConfig:n,accountConfig:resolveTelegramAccountConfig(e,t),omitKeys:[`defaultAccount`],inheritEmptyKeys:{capabilities:`array`,...r?{}:{groups:`object`}},preserveRootAllowFrom:true})}function resolveTelegramLegacyWebhookListener(e){if(!e)return;return{port:e.port,host:e.host??`127.0.0.1`}} //!extensions/telegram/src/account-selection.ts function resolveTelegramBindingAccountId(e){if(!e||typeof e!==`object`)return null;const t=e;if(normalizeLowercaseStringOrEmpty(t.match?.channel)!==`telegram`)return null;const n=typeof t.match?.accountId===`string`?t.match.accountId:``;if(!n.trim()||n.trim()===`*`)return null;return normalizeAccountId(n)}function hasTelegramAccountConfig(e,t){const n=normalizeAccountId(t);if(resolveTelegramAccountConfig(e,n))return true;const r=e.channels?.telegram;if(n!=="default"&&(Object.keys(r?.accounts??{}).length>0||!e.bindings?.some(e=>resolveTelegramBindingAccountId(e)===n)))return false;return hasConfiguredAccountValue(r?.botToken)||hasConfiguredAccountValue(r?.tokenFile)||n==="default"&&hasConfiguredAccountValue(process.env.TELEGRAM_BOT_TOKEN)}const{listAccountIds:listTelegramAccountIds}=createAccountListHelpers(`telegram`,{normalizeAccountId,additionalAccountIds:e=>[...new Set((e.bindings??[]).map(resolveTelegramBindingAccountId).filter(e=>e!==null))].toSorted((e,t)=>e.localeCompare(t)),hasImplicitDefaultAccount:e=>hasTelegramAccountConfig(e,DEFAULT_ACCOUNT_ID)});function resolveDefaultTelegramAccountSelection(e){const t=e.agents?.ownership===`explicit`&&listAgentIdsCompatibility(e).length!==1?null:resolveDefaultAgentBoundAccountId(e,`telegram`);if(t)return{accountId:t,shouldWarnMissingDefault:false};const n=listTelegramAccountIds(e);const r=normalizeOptionalAccountId(e.channels?.telegram?.defaultAccount)??void 0;const i=r?n.includes(r):false;const a=resolveListedDefaultAccountId({accountIds:n,configuredDefaultAccountId:r});return{accountId:a,shouldWarnMissingDefault:a===n[0]&&!i&&!n.includes(`default`)&&n.length>1}}function resolveDefaultTelegramAccountId(e){return resolveDefaultTelegramAccountSelection(e).accountId}export{mergeTelegramAccountConfig as a,resolveDefaultTelegramAccountSelection as i,listTelegramAccountIds as n,resolveTelegramAccountConfig as o,resolveDefaultTelegramAccountId as r,resolveTelegramLegacyWebhookListener as s,hasTelegramAccountConfig as t};