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

Function waitForStableFile

quote/quote.ts:589–612  ·  view source on GitHub ↗
(filePath: string, timeoutMs = 8000)

Source from the content-addressed store, hash-verified

587 const key = JSON.stringify(peer, (_, v) => typeof v === "bigint" ? v.toString() : v);
588 if (entityCache.has(key)) return entityCache.get(key);
589 try {
590 const entity = await withTimeout(client.getEntity(peer), QUOTE_RPC_TIMEOUT_MS, "getPeerEntity.getEntity");
591 entityCache.set(key, entity);
592 return entity;
593 } catch (_) {
594 entityCache.set(key, undefined);
595 return undefined;
596 }
597}
598
599async function ensureFullEntity(client: any, entity: any): Promise<any> {
600 if (!entity || !client) return entity;
601 if (entity.id && entity.emojiStatus === undefined && entity.emoji_status === undefined) {
602 try {
603 const full = await withTimeout(client.getEntity(entity), QUOTE_RPC_TIMEOUT_MS, "ensureFullEntity");
604 return full || entity;
605 } catch { return entity; }
606 }
607 return entity;
608}
609
610async function senderEntity(msg: Api.Message): Promise<any | undefined> {
611 const peer = (msg as any).senderId ?? (msg as any).fromId;
612 const key = peer ? `sender:${stableEntityKey(peer)}` : undefined;
613 if (key && entityCache.has(key)) return entityCache.get(key);
614 try {
615 const sender = await withTimeout((msg as any).getSender?.(), QUOTE_RPC_TIMEOUT_MS, "senderEntity.getSender");

Callers 1

downloadMediaToBufferFunction · 0.85

Calls 1

sleepMsFunction · 0.85

Tested by

no test coverage detected