@pney/whatsapp-web 1.34.4-node20 → 1.34.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example.js +7 -0
- package/index.d.ts +21 -37
- package/package.json +2 -3
- package/src/Client.js +305 -258
- package/src/authStrategies/RemoteAuth.js +49 -41
- package/src/structures/Channel.js +11 -9
- package/src/structures/Chat.js +8 -2
- package/src/structures/ClientInfo.js +1 -1
- package/src/structures/Contact.js +14 -7
- package/src/structures/GroupChat.js +27 -29
- package/src/structures/Message.js +46 -34
- package/src/util/Injected/Utils.js +309 -149
- package/src/util/InterfaceController.js +18 -18
- package/src/util/Puppeteer.js +2 -2
- package/src/util/Injected/AuthStore/LegacyAuthStore.js +0 -22
- package/src/util/Injected/LegacyStore.js +0 -146
|
@@ -311,7 +311,7 @@ class Message extends Base {
|
|
|
311
311
|
*/
|
|
312
312
|
async reload() {
|
|
313
313
|
const newData = await this.client.pupPage.evaluate(async (msgId) => {
|
|
314
|
-
const msg = window.
|
|
314
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
315
315
|
if (!msg) return null;
|
|
316
316
|
return window.WWebJS.getMessageModel(msg);
|
|
317
317
|
}, this.id._serialized);
|
|
@@ -356,7 +356,7 @@ class Message extends Base {
|
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
358
|
* Returns groups mentioned in this message
|
|
359
|
-
* @returns {Promise<GroupChat
|
|
359
|
+
* @returns {Promise<Array<GroupChat>>}
|
|
360
360
|
*/
|
|
361
361
|
async getGroupMentions() {
|
|
362
362
|
return await Promise.all(this.groupMentions.map(async (m) => await this.client.getChatById(m.groupJid._serialized)));
|
|
@@ -370,8 +370,8 @@ class Message extends Base {
|
|
|
370
370
|
if (!this.hasQuotedMsg) return undefined;
|
|
371
371
|
|
|
372
372
|
const quotedMsg = await this.client.pupPage.evaluate(async (msgId) => {
|
|
373
|
-
const msg = window.
|
|
374
|
-
const quotedMsg = window.
|
|
373
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
374
|
+
const quotedMsg = window.require('WAWebQuotedMsgModelUtils').getQuotedMsgObj(msg);
|
|
375
375
|
return window.WWebJS.getMessageModel(quotedMsg);
|
|
376
376
|
}, this.id._serialized);
|
|
377
377
|
|
|
@@ -410,9 +410,9 @@ class Message extends Base {
|
|
|
410
410
|
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
|
411
411
|
if (!messageId) return null;
|
|
412
412
|
const msg =
|
|
413
|
-
window.
|
|
413
|
+
(window.require('WAWebCollections')).Msg.get(messageId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([messageId]))?.messages?.[0];
|
|
414
414
|
if(!msg) return null;
|
|
415
|
-
await window.
|
|
415
|
+
await (window.require('WAWebSendReactionMsgAction'))(msg, reaction);
|
|
416
416
|
}, this.id._serialized, reaction);
|
|
417
417
|
}
|
|
418
418
|
|
|
@@ -448,7 +448,13 @@ class Message extends Base {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
|
451
|
+
<<<<<<< HEAD
|
|
451
452
|
const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
453
|
+
=======
|
|
454
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
455
|
+
|
|
456
|
+
// REUPLOADING mediaStage means the media is expired and the download button is spinning, cannot be downloaded now
|
|
457
|
+
>>>>>>> 883d7e4eda036fe461e21df88db65ae16ea7241c
|
|
452
458
|
if (!msg || !msg.mediaData || msg.mediaData.mediaStage === 'REUPLOADING') {
|
|
453
459
|
return null;
|
|
454
460
|
}
|
|
@@ -470,7 +476,11 @@ class Message extends Base {
|
|
|
470
476
|
addAnnotations: function() { return this; },
|
|
471
477
|
addPoint: function() { return this; }
|
|
472
478
|
};
|
|
479
|
+
<<<<<<< HEAD
|
|
473
480
|
const decryptedMedia = await window.Store.DownloadManager.downloadAndMaybeDecrypt({
|
|
481
|
+
=======
|
|
482
|
+
const decryptedMedia = await (window.require('WAWebDownloadManager').downloadManager).downloadAndMaybeDecrypt({
|
|
483
|
+
>>>>>>> 883d7e4eda036fe461e21df88db65ae16ea7241c
|
|
474
484
|
directPath: msg.directPath,
|
|
475
485
|
encFilehash: msg.encFilehash,
|
|
476
486
|
filehash: msg.filehash,
|
|
@@ -506,21 +516,23 @@ class Message extends Base {
|
|
|
506
516
|
*/
|
|
507
517
|
async delete(everyone, clearMedia = true) {
|
|
508
518
|
await this.client.pupPage.evaluate(async (msgId, everyone, clearMedia) => {
|
|
509
|
-
const msg = window.
|
|
510
|
-
const chat = window.
|
|
519
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
520
|
+
const chat = (window.require('WAWebCollections')).Chat.get(msg.id.remote) || (await (window.require('WAWebCollections')).Chat.find(msg.id.remote));
|
|
511
521
|
|
|
512
522
|
const canRevoke =
|
|
513
|
-
window.
|
|
523
|
+
window.require('WAWebMsgActionCapability').canSenderRevokeMsg(msg) || window.require('WAWebMsgActionCapability').canAdminRevokeMsg(msg);
|
|
514
524
|
|
|
525
|
+
const { Cmd } = window.require('WAWebCmd');
|
|
526
|
+
|
|
515
527
|
if (everyone && canRevoke) {
|
|
516
|
-
return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
|
|
517
|
-
?
|
|
518
|
-
:
|
|
528
|
+
return window.WWebJS.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
|
|
529
|
+
? Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: clearMedia })
|
|
530
|
+
: Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
|
519
531
|
}
|
|
520
532
|
|
|
521
|
-
return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
|
|
522
|
-
?
|
|
523
|
-
:
|
|
533
|
+
return window.WWebJS.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
|
|
534
|
+
? Cmd.sendDeleteMsgs(chat, { list: [msg], type: 'message' }, clearMedia)
|
|
535
|
+
: Cmd.sendDeleteMsgs(chat, [msg], clearMedia);
|
|
524
536
|
}, this.id._serialized, everyone, clearMedia);
|
|
525
537
|
}
|
|
526
538
|
|
|
@@ -529,10 +541,10 @@ class Message extends Base {
|
|
|
529
541
|
*/
|
|
530
542
|
async star() {
|
|
531
543
|
await this.client.pupPage.evaluate(async (msgId) => {
|
|
532
|
-
const msg = window.
|
|
533
|
-
if (window.
|
|
534
|
-
let chat = await window.
|
|
535
|
-
return window.
|
|
544
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
545
|
+
if (window.require('WAWebMsgActionCapability').canStarMsg(msg)) {
|
|
546
|
+
let chat = await (window.require('WAWebCollections')).Chat.find(msg.id.remote);
|
|
547
|
+
return (window.require('WAWebCmd').Cmd).sendStarMsgs(chat, [msg], false);
|
|
536
548
|
}
|
|
537
549
|
}, this.id._serialized);
|
|
538
550
|
}
|
|
@@ -542,10 +554,10 @@ class Message extends Base {
|
|
|
542
554
|
*/
|
|
543
555
|
async unstar() {
|
|
544
556
|
await this.client.pupPage.evaluate(async (msgId) => {
|
|
545
|
-
const msg = window.
|
|
546
|
-
if (window.
|
|
547
|
-
let chat = await window.
|
|
548
|
-
return window.
|
|
557
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
558
|
+
if (window.require('WAWebMsgActionCapability').canStarMsg(msg)) {
|
|
559
|
+
let chat = await (window.require('WAWebCollections')).Chat.find(msg.id.remote);
|
|
560
|
+
return (window.require('WAWebCmd').Cmd).sendUnstarMsgs(chat, [msg], false);
|
|
549
561
|
}
|
|
550
562
|
}, this.id._serialized);
|
|
551
563
|
}
|
|
@@ -589,12 +601,12 @@ class Message extends Base {
|
|
|
589
601
|
*/
|
|
590
602
|
async getInfo() {
|
|
591
603
|
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
|
592
|
-
const msg = window.
|
|
604
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
593
605
|
if (!msg || !msg.id.fromMe) return null;
|
|
594
606
|
|
|
595
607
|
return new Promise((resolve) => {
|
|
596
608
|
setTimeout(async () => {
|
|
597
|
-
resolve(await window.
|
|
609
|
+
resolve(await (window.require('WAWebApiMessageInfoStore').queryMsgInfo)(msg.id));
|
|
598
610
|
}, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
|
|
599
611
|
});
|
|
600
612
|
}, this.id._serialized);
|
|
@@ -623,7 +635,7 @@ class Message extends Base {
|
|
|
623
635
|
async getPayment() {
|
|
624
636
|
if (this.type === MessageTypes.PAYMENT) {
|
|
625
637
|
const msg = await this.client.pupPage.evaluate(async (msgId) => {
|
|
626
|
-
const msg = window.
|
|
638
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
627
639
|
if(!msg) return null;
|
|
628
640
|
return msg.serialize();
|
|
629
641
|
}, this.id._serialized);
|
|
@@ -652,7 +664,7 @@ class Message extends Base {
|
|
|
652
664
|
}
|
|
653
665
|
|
|
654
666
|
const reactions = await this.client.pupPage.evaluate(async (msgId) => {
|
|
655
|
-
const msgReactions = await window.
|
|
667
|
+
const msgReactions = await (window.require('WAWebCollections')).Reactions.find(msgId);
|
|
656
668
|
if (!msgReactions || !msgReactions.reactions.length) return null;
|
|
657
669
|
return msgReactions.reactions.serialize();
|
|
658
670
|
}, this.id._serialized);
|
|
@@ -698,10 +710,10 @@ class Message extends Base {
|
|
|
698
710
|
return null;
|
|
699
711
|
}
|
|
700
712
|
const messageEdit = await this.client.pupPage.evaluate(async (msgId, message, options) => {
|
|
701
|
-
const msg = window.
|
|
713
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
702
714
|
if (!msg) return null;
|
|
703
715
|
|
|
704
|
-
let canEdit = window.
|
|
716
|
+
let canEdit = window.require('WAWebMsgActionCapability').canEditText(msg) || window.require('WAWebMsgActionCapability').canEditCaption(msg);
|
|
705
717
|
if (canEdit) {
|
|
706
718
|
const msgEdit = await window.WWebJS.editMessage(msg, message, options);
|
|
707
719
|
return msgEdit.serialize();
|
|
@@ -726,7 +738,7 @@ class Message extends Base {
|
|
|
726
738
|
}
|
|
727
739
|
|
|
728
740
|
const edittedEventMsg = await this.client.pupPage.evaluate(async (msgId, editedEventObject) => {
|
|
729
|
-
const msg = window.
|
|
741
|
+
const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
730
742
|
if (!msg) return null;
|
|
731
743
|
|
|
732
744
|
const { name, startTimeTs, eventSendOptions } = editedEventObject;
|
|
@@ -740,8 +752,8 @@ class Message extends Base {
|
|
|
740
752
|
isEventCanceled: eventSendOptions.isEventCanceled,
|
|
741
753
|
};
|
|
742
754
|
|
|
743
|
-
await window.
|
|
744
|
-
const editedMsg = window.
|
|
755
|
+
await (window.require('WAWebSendEventEditMsgAction')).sendEventEditMessage(eventOptions, msg);
|
|
756
|
+
const editedMsg = (window.require('WAWebCollections')).Msg.get(msg.id._serialized);
|
|
745
757
|
return editedMsg?.serialize();
|
|
746
758
|
}, this.id._serialized, editedEventObject);
|
|
747
759
|
|
|
@@ -768,7 +780,7 @@ class Message extends Base {
|
|
|
768
780
|
if (!Array.isArray(votes)) votes = [votes];
|
|
769
781
|
let localIdSet = new Set();
|
|
770
782
|
const msg =
|
|
771
|
-
window.
|
|
783
|
+
(window.require('WAWebCollections')).Msg.get(messageId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([messageId]))?.messages?.[0];
|
|
772
784
|
if (!msg) return null;
|
|
773
785
|
|
|
774
786
|
msg.pollOptions.forEach(a => {
|
|
@@ -777,7 +789,7 @@ class Message extends Base {
|
|
|
777
789
|
}
|
|
778
790
|
});
|
|
779
791
|
|
|
780
|
-
await window.
|
|
792
|
+
await (window.require('WAWebPollsSendVoteMsgAction')).sendVote(msg, localIdSet);
|
|
781
793
|
}, this.id._serialized, selectedOptions);
|
|
782
794
|
}
|
|
783
795
|
}
|