wa-automate-socket-client
Version:
Easily connect to remote instances of the EASY API
78 lines (77 loc) • 3.1 kB
TypeScript
import { EventEmitter2 } from 'eventemitter2';
import { SimpleListener, Chat, ChatId, Message, MessageId } from '@open-wa/wa-automate-types-only';
import { Collector, CollectorOptions } from './Collector';
/**
* @typedef {CollectorOptions} MessageCollectorOptions
* @property {number} max The maximum amount of messages to collect
* @property {number} maxProcessed The maximum amount of messages to process
*/
/**
* Collects messages on a chat.
* Will automatically stop if the chat (`'chatDelete'`) is deleted.
* @extends {Collector}
*/
export declare class MessageCollector extends Collector {
chat: ChatId;
received: number;
sessionId: string;
instanceId: string;
ev: EventEmitter2;
/**
* @param {string} sessionId The id of the session
* @param {string} instanceId The id of the current instance of the session (see: client.getInstanceId)
* @param {ChatId} chatId The chat
* @param {CollectorFilter} filter The filter to be applied to this collector
* @param {MessageCollectorOptions} options The options to be applied to this collector
* @param {EventEmitter2} openWaEventEmitter The EventEmitter2 that fires all open-wa events. In local instances of the library, this is the global `ev` object.
* @emits MessageCollector#Message
*/
constructor(sessionId: string, instanceId: string, chat: ChatId, filter: (...args: any[]) => boolean | Promise<boolean>, options: CollectorOptions, openWaEventEmitter: EventEmitter2);
/**
* Handles a message for possible collection.
* @param {Message} message The message that could be collected
* @returns {?Snowflake}
* @private
*/
collect(message: Message): MessageId;
/**
* Handles a message for possible disposal.
* @param {Message} message The message that could be disposed of
* @returns {?Snowflake}
*/
dispose(message: Message): MessageId | null;
/**
* Checks after un/collection to see if the collector is done.
* @returns {?string}
* @private
*/
endReason(): string | null;
/**
* Handles checking if the chat has been deleted, and if so, stops the collector with the reason 'chatDelete'.
* @private
* @param {Chat} chat The chat that was deleted
* @returns {void}
*/
_handleChatDeletion(chat: Chat): void;
/**
* Handles checking if the chat has been deleted, and if so, stops the collector with the reason 'chatDelete'.
* @private
* @param {Chat} chat The group chat that the host account was removed from
* @returns {void}
*/
_handleGroupRemoval(chat: Chat): void;
/**
*
* NOT RELATED TO WA
*
* Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
* @private
* @param {Guild} guild The guild that was deleted
* @returns {void}
*/
_handleGuildDeletion(guild: string): void;
eventSignature(event: SimpleListener): string;
wrapHandler(handler: (data: any) => any): ({ data }: {
data: any;
}) => any;
}