Class: MessageCollector
Collects messages on a chat.
Will automatically stop if the chat ('chatDelete'
) is deleted.
Extends
Constructors
new MessageCollector()
new MessageCollector(
sessionId
,instanceId
,chat
,filter
,options
,openWaEventEmitter
):MessageCollector
Parameters
• sessionId: string
The id of the session
• instanceId: string
The id of the current instance of the session (see: client.getInstanceId)
• chat: ChatId
• filter
The filter to be applied to this collector
• options: CollectorOptions
= {}
The options to be applied to this collector
• openWaEventEmitter: EventEmitter2
The EventEmitter2 that fires all open-wa events. In local instances of the library, this is the global ev
object.
Returns
Emits
MessageCollector#Message
Overrides
Properties
_idletimeout
protected
_idletimeout:Timeout
Inherited from
_timeout
protected
_timeout:Timeout
Inherited from
chat
chat:
ChatId
collected
collected:
Collection
<string
,any
>
Inherited from
ended
ended:
boolean
Inherited from
ev
ev:
EventEmitter2
filter()
filter: (...
args
) =>boolean
|Promise
<boolean
>
Parameters
• ...args: any
[]
Returns
boolean
| Promise
<boolean
>
Inherited from
instanceId
instanceId:
string
options
options:
CollectorOptions
Inherited from
received
received:
number
sessionId
sessionId:
string
captureRejectionSymbol
readonly
static
captureRejectionSymbol: typeofcaptureRejectionSymbol
Inherited from
Collector
.captureRejectionSymbol
captureRejections
static
captureRejections:boolean
Sets or gets the default captureRejection value for all emitters.
Inherited from
defaultMaxListeners
static
defaultMaxListeners:number
Inherited from
errorMonitor
readonly
static
errorMonitor: typeoferrorMonitor
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Inherited from
Accessors
next
get
next():Promise
<any
>
Returns a promise that resolves with the next collected element; rejects with collected elements if the collector finishes without receiving a next element
Returns
Promise
<any
>
Inherited from
Methods
[asyncIterator]()
[asyncIterator]():
any
Allows collectors to be consumed with for-await-of loops
Returns
any
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
Inherited from
addListener()
addListener(
eventName
,listener
):this
Alias for emitter.on(eventName, listener)
.
Parameters
• eventName: string
| symbol
• listener
Returns
this
Since
v0.1.26
Inherited from
checkEnd()
checkEnd():
void
Checks whether the collector should end, and if so, ends it.
Returns
void
Inherited from
clearImmediate()
clearImmediate(
immediate
):void
Clears an immediate.