fix: Message.getInfo (#2574)
* module fixed + improved modules retrieving * wait for msg data to be updated * added random sleep value between 1100-1200 ms * added check for msg is sent by current user * node 13 compatible * docs fixed * msg.fromMe fixed * timestamp calculation fixed * window.injectToFunction clarifications
This commit is contained in:
parent
7737a0d701
commit
7ff9c9807b
1 changed files with 25 additions and 20 deletions
|
|
@ -534,15 +534,20 @@ class Message extends Base {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Get information about message delivery status. May return null if the message does not exist or is not sent by you.
|
||||
* 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;
|
||||
if (!msg || !msg.id.fromMe) return null;
|
||||
|
||||
return await window.Store.MessageInfo.sendQueryMsgInfo(msg.id);
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(async () => {
|
||||
resolve(await window.Store.getMsgInfo(msg.id));
|
||||
}, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
|
||||
});
|
||||
}, this.id._serialized);
|
||||
|
||||
return info;
|
||||
|
|
|
|||
Loading…
Reference in a new issue