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

Function forwardedSource

quote/quote.ts:368–383  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

366
367function fwdHeaderName(fwd: any): string | undefined {
368 return fwd?.fromName || fwd?.from_name || fwd?.postAuthor || fwd?.post_author || undefined;
369}
370
371function fwdPeer(fwd: any): any | undefined {
372 return fwd?.fromId ?? fwd?.from_id ?? fwd?.savedFromPeer ?? fwd?.saved_from_peer;
373}
374
375async function forwardedSource(msg: Api.Message): Promise<{ peer?: any; entity?: any; name?: string; anonymous: boolean } | undefined> {
376 const fwd: any = (msg as any).fwdFrom || (msg as any).fwd_from;
377 if (!fwd) return undefined;
378
379 const client: any = (msg as any).client;
380 const peer = fwdPeer(fwd);
381 const headerName = fwdHeaderName(fwd);
382
383 if (peer) {
384 const entity = await getPeerEntity(client, peer);
385 return { peer, entity, name: displayName(entity) || headerName || "Forwarded", anonymous: !entity && !!headerName };
386 }

Callers 2

forwardPreviewFunction · 0.85
toQuoteMessageFunction · 0.85

Calls 4

fwdPeerFunction · 0.85
fwdHeaderNameFunction · 0.85
getPeerEntityFunction · 0.85
displayNameFunction · 0.85

Tested by

no test coverage detected