[+] New message_create event that is fired on all message creations.

A new property "fromMe" has also been added to messages.

Close #8
This commit is contained in:
Pedro Lopez
2019-09-08 03:48:19 -04:00
parent cde0034d93
commit 18199d8120
4 changed files with 14 additions and 2 deletions

View File

@@ -107,8 +107,11 @@ class Client extends EventEmitter {
// Register events
await page.exposeFunction('onAddMessageEvent', msg => {
const message = new Message(this, msg);
this.emit(Events.MESSAGE_CREATE, message);
if (msg.id.fromMe || !msg.isNewMsg) return;
this.emit(Events.MESSAGE_CREATE, new Message(this, msg));
this.emit(Events.MESSAGE_RECEIVED, message);
});
await page.exposeFunction('onConnectionChangedEvent', (conn, connected) => {