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

Function downloadEntityAvatar

quote/quote.ts:559–579  ·  view source on GitHub ↗
(client: any, entity: any)

Source from the content-addressed store, hash-verified

557async function forwardedSource(msg: Api.Message): Promise<{ peer?: any; entity?: any; name?: string; anonymous: boolean } | undefined> {
558 const fwd: any = (msg as any).fwdFrom || (msg as any).fwd_from;
559 if (!fwd) return undefined;
560
561 const client: any = (msg as any).client;
562 const peer = fwdPeer(fwd);
563 const headerName = fwdHeaderName(fwd);
564
565 if (peer) {
566 const rawEntity = await getPeerEntity(client, peer);
567 const entity = await ensureFullEntity(client, rawEntity);
568 return { peer, entity, name: displayName(entity) || headerName || "Forwarded", anonymous: !entity && !!headerName };
569 }
570
571 if (headerName) return { name: headerName, anonymous: true };
572 return { anonymous: true };
573}
574
575function stableEntityKey(entity: any): string | undefined {
576 const raw = entity?.id ?? entity?.userId ?? entity?.channelId ?? entity?.chatId ?? entity?.accessHash ?? entity;
577 if (!raw) return undefined;
578 try { return typeof raw === "bigint" ? raw.toString() : JSON.stringify(raw, (_, v) => typeof v === "bigint" ? v.toString() : v); } catch (_) { return String(raw); }
579}
580
581async function getPeerEntity(client: any, peer: any): Promise<any | undefined> {
582 if (!client || !peer) return undefined;

Callers 3

downloadSenderAvatarFunction · 0.85
forwardPreviewFunction · 0.85
toQuoteMessageFunction · 0.85

Calls 5

stableEntityKeyFunction · 0.85
tryDownloadFunction · 0.85
normalizeAvatarBufferFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected