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

Function resolveForwardSenderFromHeader

yvlu/yvlu.ts:293–339  ·  view source on GitHub ↗
(
  forwardHeader: Api.MessageFwdHeader,
  client: any,
)

Source from the content-addressed store, hash-verified

291 return sender;
292 }
293 } catch (err) {
294 console.debug("[yvlu] getSender failed:", err?.message || err);
295 }
296 const entity = await getPeerEntity((msg as any).client, peer);
297 return entity;
298}
299
300function emojiStatusIdFromEntity(entity: any): string | undefined {
301 const status = entity?.emojiStatus ?? entity?.emoji_status;
302 if (!status) return undefined;
303 if (typeof status !== "object") {
304 const id = status?.value ?? status;
305 return id ? String(id) : undefined;
306 }
307 const documentId = status.documentId ?? status.document_id ?? status.customEmojiId ?? status.custom_emoji_id ?? status.id;
308 if (!documentId) return undefined;
309 return String(documentId);
310}
311
312const hashCode = (s: any) => {
313 const l = s.length;
314 let h = 0;
315 let i = 0;
316 if (l > 0) {
317 while (i < l) {
318 h = ((h << 5) - h + s.charCodeAt(i++)) | 0;
319 }
320 }
321 return h;
322};
323
324// 检测是否为 webm 格式
325function isWebmFormat(buffer: Buffer): boolean {
326 if (!buffer || buffer.length < 4) return false;
327 // WebM 魔数: 0x1A 0x45 0xDF 0xA3 (EBML header)
328 return (
329 buffer[0] === 0x1a &&
330 buffer[1] === 0x45 &&
331 buffer[2] === 0xdf &&
332 buffer[3] === 0xa3
333 );
334}
335
336// 检测是否为 TGS 格式 (gzip 压缩的 Lottie JSON)
337function isTgsFormat(buffer: Buffer): boolean {
338 if (!buffer || buffer.length < 2) return false;
339 // gzip 魔数: 0x1F 0x8B
340 return buffer[0] === 0x1f && buffer[1] === 0x8b;
341}
342

Callers 1

YvluPluginClass · 0.85

Calls 3

getPeerNumericIdFunction · 0.85
hashCodeFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected