mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 21:19:16 +00:00
feat: Get message delivery information (close #418)
This commit is contained in:
15
index.d.ts
vendored
15
index.d.ts
vendored
@@ -433,6 +433,15 @@ declare namespace WAWebJS {
|
|||||||
UNPAIRED_IDLE = 'UNPAIRED_IDLE',
|
UNPAIRED_IDLE = 'UNPAIRED_IDLE',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MessageInfo = {
|
||||||
|
delivery: Array<{id: ContactId, t: number}>,
|
||||||
|
deliveryRemaining: number,
|
||||||
|
played: Array<{id: ContactId, t: number}>,
|
||||||
|
playedRemaining: number,
|
||||||
|
read: Array<{id: ContactId, t: number}>,
|
||||||
|
readRemaining: number
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Message on WhatsApp
|
* Represents a Message on WhatsApp
|
||||||
*
|
*
|
||||||
@@ -530,9 +539,11 @@ declare namespace WAWebJS {
|
|||||||
*/
|
*/
|
||||||
forward: (chat: Chat | string) => Promise<void>,
|
forward: (chat: Chat | string) => Promise<void>,
|
||||||
/** Star this message */
|
/** Star this message */
|
||||||
star: () => Promise<void>
|
star: () => Promise<void>,
|
||||||
/** Unstar this message */
|
/** Unstar this message */
|
||||||
unstar: () => Promise<void>
|
unstar: () => Promise<void>,
|
||||||
|
/** Get information about message delivery statuso */
|
||||||
|
getInfo: () => Promise<MessageInfo | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ID that represents a message */
|
/** ID that represents a message */
|
||||||
|
|||||||
@@ -310,6 +310,36 @@ class Message extends Base {
|
|||||||
}
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message Info
|
||||||
|
* @typedef {Object} MessageInfo
|
||||||
|
* @property {Array<{id: ContactId, t: number}>} delivery Contacts to which the message has been delivered to
|
||||||
|
* @property {number} deliveryRemaining Amount of people to whom the message has not been delivered to
|
||||||
|
* @property {Array<{id: ContactId, t: number}>} played Contacts who have listened to the voice message
|
||||||
|
* @property {number} playedRemaining Amount of people who have not listened to the message
|
||||||
|
* @property {Array<{id: ContactId, t: number}>} read Contacts who have read the message
|
||||||
|
* @property {number} readRemaining Amount of people who have not read the message
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about message delivery status. May return null if the message does not exist or is not sent by you.
|
||||||
|
* @returns {Promise<?MessageInfo>}
|
||||||
|
*/
|
||||||
|
async getInfo() {
|
||||||
|
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||||
|
const msg = window.Store.Msg.get(msgId);
|
||||||
|
if(!msg) return null;
|
||||||
|
|
||||||
|
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||||
|
}, this.id._serialized);
|
||||||
|
|
||||||
|
if(info.status) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Message;
|
module.exports = Message;
|
||||||
|
|||||||
Reference in New Issue
Block a user