import { EventEmitter } from "node:events"; import { vi } from "vitest";
type BaileysExports = typeofimport("@whiskeysockets/baileys");
type FetchLatestBaileysVersionFn = BaileysExports["fetchLatestBaileysVersion"];
type MakeCacheableSignalKeyStoreFn = BaileysExports["makeCacheableSignalKeyStore"];
type MakeWASocketFn = BaileysExports["makeWASocket"];
type UseMultiFileAuthStateFn = BaileysExports["useMultiFileAuthState"];
type DownloadMediaMessageFn = BaileysExports["downloadMediaMessage"];
type ExtractMessageContentFn = BaileysExports["extractMessageContent"];
type GetContentTypeFn = BaileysExports["getContentType"];
type NormalizeMessageContentFn = BaileysExports["normalizeMessageContent"];
type IsJidGroupFn = BaileysExports["isJidGroup"];
type MessageContentInput = Parameters<NormalizeMessageContentFn>[0];
type MessageContentOutput = ReturnType<NormalizeMessageContentFn>;
type MessageContentType = ReturnType<GetContentTypeFn>;
export function mockNormalizeMessageContent(message: MessageContentInput): MessageContentOutput {
let current = message as unknown; while (current && typeof current === "object") {
let unwrapped = false; for (const key of MESSAGE_WRAPPER_KEYS) { const candidate = (current as MessageLike)[key]; if (
candidate && typeof candidate === "object" && "message" in (candidate as MessageLike) &&
(candidate as { message?: unknown }).message
) {
current = (candidate as { message: unknown }).message;
unwrapped = true; break;
}
} if (!unwrapped) { break;
}
} return current as MessageContentOutput;
}
export function mockGetContentType(message: MessageContentInput): MessageContentType { const normalized = mockNormalizeMessageContent(message); if (!normalized || typeof normalized !== "object") { return undefined;
} for (const key of MESSAGE_CONTENT_KEYS) { if ((normalized as MessageLike)[key] != null) { return key as MessageContentType;
}
} return undefined;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.