MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / resolveEntityWithFallback

Function resolveEntityWithFallback

biko/biko.ts:141–161  ·  view source on GitHub ↗
(
  client: any,
  raw: string,
)

Source from the content-addressed store, hash-verified

139 if (/^-?\d+$/.test(raw)) {
140 const numeric = Number(raw);
141 if (Number.isSafeInteger(numeric)) attempts.push(numeric);
142 }
143
144 let lastError: unknown;
145 for (const attempt of attempts) {
146 try {
147 return await client.getEntity(attempt);
148 } catch (error) {
149 lastError = error;
150 }
151 }
152
153 throw lastError ?? new Error(`无法解析 ${raw}`);
154}
155
156async function resolveChatTarget(
157 client: any,
158 raw: string,
159 label: string,
160): Promise<ResolvedChat> {
161 try {
162 const entity = await resolveEntityWithFallback(client, raw);
163 return {
164 raw,

Callers 2

resolveChatTargetFunction · 0.85
resolveSourceUserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected