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

Function getEntityWithRetry

dme/dme.ts:435–450  ·  view source on GitHub ↗

* 带重试机制的实体获取函数

(
  client: TelegramClient,
  entityId: string,
  retryCount: number = 0
)

Source from the content-addressed store, hash-verified

433 try {
434 return await client.getEntity(entityId);
435 } catch (error: any) {
436 if (retryCount < 2) {
437 console.log(`[DME] 获取实体失败,第 ${retryCount + 1} 次重试:`, error.message);
438 await sleep(1000 * (retryCount + 1));
439 return getEntityWithRetry(client, entityId, retryCount + 1);
440 }
441 throw error;
442 }
443}
444
445/**
446 * 通用实体解析器 - 增强版本
447 */
448async function resolveChatEntity(client: TelegramClient, chatId: string): Promise<any> {
449 console.log(`[DME] 开始解析聊天实体: ${chatId}`);
450
451 // 策略1: 优先使用主仓库共享的 accessHash 感知解析器,覆盖折叠/归档等缓存未预热场景
452 try {
453 const entity = await getEntityWithHash(client, chatId);

Callers 1

resolveChatEntityFunction · 0.85

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected