mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 04:29:15 +00:00
feat: added ACK events (#73)
Implements ack change detection, making it possible to know when messages have been delivered, read, etc. Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
GitHub
parent
1ebaf56617
commit
bb4ad11bfa
@@ -214,6 +214,20 @@ class Client extends EventEmitter {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
|
||||||
|
|
||||||
|
const message = new Message(this, msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when an ack event occurrs on message type.
|
||||||
|
* @event Client#message_ack
|
||||||
|
* @param {Message} message The message that was affected
|
||||||
|
* @param {number} ack The new ACK value
|
||||||
|
*/
|
||||||
|
this.emit(Events.MESSAGE_ACK, message, ack);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,6 +253,7 @@ class Client extends EventEmitter {
|
|||||||
window.Store.Msg.on('add', window.onAddMessageEvent);
|
window.Store.Msg.on('add', window.onAddMessageEvent);
|
||||||
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
||||||
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
||||||
|
window.Store.Msg.on('change:ack', window.onMessageAckEvent);
|
||||||
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
||||||
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ exports.Events = {
|
|||||||
MESSAGE_CREATE: 'message_create',
|
MESSAGE_CREATE: 'message_create',
|
||||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||||
|
MESSAGE_ACK: 'message_ack',
|
||||||
QR_RECEIVED: 'qr',
|
QR_RECEIVED: 'qr',
|
||||||
DISCONNECTED: 'disconnected',
|
DISCONNECTED: 'disconnected',
|
||||||
STATE_CHANGED: 'change_state'
|
STATE_CHANGED: 'change_state',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user