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

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

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