import { Buffer } from 'node:buffer'; import { Readable } from 'node:stream'; import type { WasmWhatsAppClient } from 'whatsapp-rust-bridge'; import { proto } from 'whatsapp-rust-bridge/proto-types'; import { type MediaType } from '../Defaults/index.js'; import type { AnyMediaMessageContent, AnyMessageContent, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, WAMessage, WAMessageContent } from '../Types/index.js'; import type { ILogger } from './logger.js'; import { type MediaDownloadOptions } from './messages-media.js'; type ExtractByKey = T extends Record ? T : never; /** * Uses a regex to test whether the string contains a URL, and returns the URL if it does. * @param text eg. hello https://google.com * @returns the URL, eg. https://google.com */ export declare const extractUrlFromText: (text: string) => string | undefined; export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions["getUrlInfo"], logger: MessageGenerationOptions["logger"]) => Promise; export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MessageContentGenerationOptions) => Promise; export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message; /** * Generate forwarded message content like WA does * @param message the message to forward * @param options.forceForward will show the message as forwarded even if it is from you */ export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage; export declare const hasNonNullishProperty: (message: AnyMessageContent, key: K) => message is ExtractByKey; export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise; export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => WAMessage; export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise; /** Get the key to access the true type of content */ export declare const getContentType: (content: proto.IMessage | undefined) => keyof proto.IMessage | undefined; /** * Normalizes ephemeral, view once messages to regular message content * Eg. image messages in ephemeral messages, in view once messages etc. * @param content * @returns */ export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined; /** * Extract the true message content from a message * Eg. extracts the inner message from a disappearing message/view once message */ export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined; export type DownloadMediaMessageContext = { reuploadRequest: (msg: WAMessage) => Promise; logger: ILogger; /** Bridge client for media download — handles CDN failover, auth refresh, * HMAC-SHA256 verification, and AES-256-CBC decryption internally. */ waClient: Pick; }; /** * Downloads the given message. Throws an error if it's not a media message. * * Uses the Rust bridge for download — provides CDN failover, automatic auth * refresh on 401/404, HMAC-SHA256 integrity verification, and AES-256-CBC * decryption. Requires `ctx.waClient` (the bridge client). */ export declare const downloadMediaMessage: (message: WAMessage, type: Type, options: MediaDownloadOptions, ctx: DownloadMediaMessageContext) => Promise : Readable>; export declare const _registerActiveBridgeClient: (client: WasmWhatsAppClient, logger?: ILogger) => void; /** * Upstream-Baileys-compatible standalone media download. Builds a synthetic * `WAMessage` from the supplied media subcontent (image/video/audio/etc fields) * and routes it through {@link downloadMediaMessage}, so CDN failover, auth * refresh, HMAC verification, and AES-256-CBC decryption all happen inside the * Rust bridge — same code path as `sock.downloadMedia`. * * The bridge client is required. Pass it explicitly via `opts.client` for * multi-account hosts; otherwise the helper falls back to the most-recently * created bridge client (registered automatically by `makeWASocket`). */ export declare const downloadContentFromMessage: (mediaContent: { directPath?: string | null; mediaKey?: Uint8Array | null; fileSha256?: Uint8Array | null; fileEncSha256?: Uint8Array | null; fileLength?: number | Long | null; url?: string | null; }, type: MediaType, opts?: MediaDownloadOptions & { client?: WasmWhatsAppClient; logger?: ILogger; }) => Promise; type Long = { low: number; high: number; unsigned: boolean; }; type VoteAggregation = { name: string; voters: string[]; }; /** * Aggregate votes from a poll message. * * Takes a poll creation message and its accumulated poll updates (from * `messages.update` events) and returns the vote tally per option. * * `pollUpdates` should contain pre-decrypted votes where `vote.selectedOptions` * are the SHA-256 hashes of the voted option names. * * @example * ```ts * sock.ev.on('messages.update', event => { * for (const { key, update } of event) { * if (update.pollUpdates) { * const pollMsg = await getMessageFromStore(key) * const votes = getAggregateVotesInPollMessage({ * message: pollMsg.message, * pollUpdates: pollMsg.pollUpdates * }) * console.log(votes) // [{ name: 'Yes', voters: ['jid1'] }, ...] * } * } * }) * ``` */ export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick, meId?: string): VoteAggregation[]; export {}; //# sourceMappingURL=messages.d.ts.map