* 带重试机制的实体获取函数
( client: TelegramClient, entityId: string, retryCount: number = 0 )
| 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 | */ |
| 448 | async 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); |
no test coverage detected