import type { WASocket, WAMessage } from '@whiskeysockets/baileys'; import utils from '../utils/index.js'; import { MongoStorage } from '../store/index.js'; import type { ActionSendMessage, Logger, MasterToWorkerActions, WAClientConfig, WorkerToMasterEvents } from '../types/index.js'; import { WorkerPipe } from '../pipe/WorkerPipe.js'; /** * Represents a WhatsApp client instance. */ export declare class WAClient extends WorkerPipe { /** * Unique identifier for the client. */ clientId: string; /** * WebSocket instance for WhatsApp communication. */ sock: WASocket | null; /** * Mongo store URL for persistent storage. */ mongoUrl?: string; /** * Utility functions for handling directories and other utilities. */ utils: ReturnType; /** * Logger instance for debugging and informational messages. */ readonly baseLogger: Logger; readonly logger: Logger; private storage; private version; private browser; private msgRetryCounterCache; private readonly socketConfig?; private reconnectAttempts; private presenceDebouncer; private readonly subs; /** * Creates a new WhatsApp client instance. * @param config - Configuration options for the client. */ constructor(config: WAClientConfig); private postEvent; private resolveContactIdentity; private ingestMessageIdentity; private handleLidMappingUpdate; private postContactScopedEvent; /** * Getter for the storage instance with dynamic typing. */ get store(): MongoStorage; /** * Restarts the client by resyncing app state. */ restart(): Promise; /** * Initializes the WhatsApp client and sets up event handlers. */ initialize(): Promise; /** * Subscribes to actions from the master process. */ private subscribeMasterActions; /** * Sends a message using the WhatsApp client. * @param post - The message details to send. * @returns The message information or undefined if sending fails. */ sendMessage(post: ActionSendMessage): Promise; /** * Retrieves a message by its key from the database. * @param key - The key identifying the message. * @returns The message content or undefined if not found. */ private getMessage; private handleFetchPPs; /** * Handles the 'send.message' action from the master process. * @param payload - The payload for sending the message. */ private handleSendMessage; /** * Clears the unread message count for a specific chat. * @param jid - The chat ID to clear unread messages for. */ private handleClearUnreadCount; /** * Processes events received from the WhatsApp client. * @param events - Partial map of events to handle. */ private handleEvents; private reconnectQueue; /** * Handles connection state updates. * @param update - The connection state update. */ private handleConnectionUpdate; /** * Handles credential updates. * @param update - The credential update. */ private handleCredsUpdate; /** * Handles updates to messaging history. * @param history - The messaging history update. */ private handleMessagingHistorySet; /** * Handles new or updated messages. * @param upsert - Details about the new or updated messages. */ private handleMessagesUpsert; /** * Handles new or updated messages. * @param update - Details about the new or updated messages. */ private handleMessagesUpdate; /** * Handles delete messages. * @param item - Details about deleted messages. */ private handleMessagesDelete; /** * Handles updated message receipts. * @param update - Details about updated message receipts. */ /** * Handles updated message reactions. * @param update - Details about updated message reactions. */ /** * Handles presence updates for contacts. * @param update - The presence update details. */ private handlePresenceUpdate; /** * Handles upsert events for chats. * @param upsert - The chat upsert details. */ private handleChatsUpsert; /** * Handles updates to existing chats. * @param update - The chat update details. */ private handleChatsUpdate; /** * Handles deletes to existing chats. * @param update - The chat delete details. */ private handleChatsDelete; /** * Handles upsert events for contacts. * @param upsert - The contact upsert details. */ private handleContactsUpsert; /** * Handles updates to existing contacts. * @param update - The contact update details. */ private handleContactsUpdate; /** * Handles updates to existing groups. * @param update - The group update details. */ /** * Handles updates to existing group participants. * @param update - The group participant update details. */ graceful(): Promise; /** * Destroy the WhatsApp client and cleans up resources and logout from account. */ destroy(): Promise; }