@dyyxyzz/baileys-mod 6.0.44 → 6.0.46
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/lib/Socket/messages-send.js +210 -226
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -360,7 +361,8 @@ const makeMessagesSocket = (config) => {
|
|
|
360
361
|
return node;
|
|
361
362
|
}));
|
|
362
363
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
363
|
-
};
|
|
364
|
+
};
|
|
365
|
+
|
|
364
366
|
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
|
|
365
367
|
const meId = authState.creds.me.id;
|
|
366
368
|
let shouldIncludeDeviceIdentity = false;
|
|
@@ -444,15 +446,6 @@ const makeMessagesSocket = (config) => {
|
|
|
444
446
|
participantsList.push(...statusJidList)
|
|
445
447
|
}
|
|
446
448
|
|
|
447
|
-
// if (!isStatus) {
|
|
448
|
-
// const expiration = await getEphemeralGroup(jid)
|
|
449
|
-
// additionalAttributes = {
|
|
450
|
-
// ...additionalAttributes,
|
|
451
|
-
// addressing_mode: 'pn',
|
|
452
|
-
// ...expiration ? { expiration: expiration.toString() } : null
|
|
453
|
-
// }
|
|
454
|
-
// }
|
|
455
|
-
|
|
456
449
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
|
|
457
450
|
devices.push(...additionalDevices)
|
|
458
451
|
}
|
|
@@ -498,65 +491,49 @@ const makeMessagesSocket = (config) => {
|
|
|
498
491
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
499
492
|
}
|
|
500
493
|
else if (isNewsletter) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
// Message delete
|
|
508
|
-
if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
509
|
-
msgId = message.protocolMessage.key?.id
|
|
510
|
-
message = {}
|
|
511
|
-
}
|
|
494
|
+
// Message edit
|
|
495
|
+
if (message.protocolMessage?.editedMessage) {
|
|
496
|
+
msgId = message.protocolMessage.key?.id
|
|
497
|
+
message = message.protocolMessage.editedMessage
|
|
498
|
+
}
|
|
512
499
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const mediaType = getMediaType(patched)
|
|
519
|
-
|
|
520
|
-
// Set extraAttrs untuk newsletter
|
|
521
|
-
if (mediaType) {
|
|
522
|
-
extraAttrs['mediatype'] = mediaType
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (patched.pinInChatMessage || patched.keepInChatMessage ||
|
|
526
|
-
patched.reactionMessage || patched.protocolMessage?.editedMessage) {
|
|
527
|
-
extraAttrs['decrypt-fail'] = 'hide'
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (patched.interactiveResponseMessage?.nativeFlowResponseMessage) {
|
|
531
|
-
extraAttrs['native_flow_name'] = patched.interactiveResponseMessage?.nativeFlowResponseMessage.name
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (patched.interactiveMessage?.nativeFlowMessage) {
|
|
535
|
-
extraAttrs['native_flow_name'] = patched.interactiveMessage?.nativeFlowMessage?.name || 'flow'
|
|
536
|
-
}
|
|
500
|
+
// Message delete
|
|
501
|
+
if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
502
|
+
msgId = message.protocolMessage.key?.id
|
|
503
|
+
message = {}
|
|
504
|
+
}
|
|
537
505
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
506
|
+
const patched = await patchMessageBeforeSending(message, [])
|
|
507
|
+
const bytes = Utils_1.encodeNewsletterMessage(patched)
|
|
508
|
+
|
|
509
|
+
// Detect button type dan media type
|
|
510
|
+
const buttonType = getButtonType(patched)
|
|
511
|
+
const mediaType = getMediaType(patched)
|
|
512
|
+
|
|
513
|
+
// Set extraAttrs untuk newsletter
|
|
514
|
+
if (mediaType) {
|
|
515
|
+
extraAttrs['mediatype'] = mediaType
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (patched.pinInChatMessage || patched.keepInChatMessage ||
|
|
519
|
+
patched.reactionMessage || patched.protocolMessage?.editedMessage) {
|
|
520
|
+
extraAttrs['decrypt-fail'] = 'hide'
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (patched.interactiveResponseMessage?.nativeFlowResponseMessage) {
|
|
524
|
+
extraAttrs['native_flow_name'] = patched.interactiveResponseMessage?.nativeFlowResponseMessage.name
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (patched.interactiveMessage?.nativeFlowMessage) {
|
|
528
|
+
extraAttrs['native_flow_name'] = patched.interactiveMessage?.nativeFlowMessage?.name || 'flow'
|
|
529
|
+
}
|
|
548
530
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
logger.debug({ jid, buttonType }, 'adding button node to newsletter')
|
|
558
|
-
}
|
|
559
|
-
}
|
|
531
|
+
binaryNodeContent.push({
|
|
532
|
+
tag: 'plaintext',
|
|
533
|
+
attrs: extraAttrs,
|
|
534
|
+
content: bytes
|
|
535
|
+
})
|
|
536
|
+
}
|
|
560
537
|
else {
|
|
561
538
|
const { user: meUser } = WABinary_1.jidDecode(meId);
|
|
562
539
|
if (!participant) {
|
|
@@ -624,24 +601,10 @@ const makeMessagesSocket = (config) => {
|
|
|
624
601
|
},
|
|
625
602
|
content: binaryNodeContent
|
|
626
603
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const content = WABinary_1.getAdditionalNode(buttonType)
|
|
632
|
-
const filteredNode = WABinary_1.getBinaryNodeFilter(additionalNodes || [])
|
|
633
|
-
|
|
634
|
-
if (filteredNode && additionalNodes) {
|
|
635
|
-
stanza.content.push(...additionalNodes)
|
|
636
|
-
didPushAdditional = true
|
|
637
|
-
} else if (content && content.length > 0) {
|
|
638
|
-
stanza.content.push(...content)
|
|
639
|
-
didPushAdditional = true
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
logger.debug({ jid, buttonType }, 'adding button node to newsletter')
|
|
643
|
-
}
|
|
644
|
-
}
|
|
604
|
+
|
|
605
|
+
// if the participant to send to is explicitly specified (generally retry recp)
|
|
606
|
+
// ensure the message is only sent to that person
|
|
607
|
+
// if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
|
|
645
608
|
if (participant) {
|
|
646
609
|
if (WABinary_1.isJidGroup(destinationJid)) {
|
|
647
610
|
stanza.attrs.to = destinationJid;
|
|
@@ -658,6 +621,7 @@ const makeMessagesSocket = (config) => {
|
|
|
658
621
|
else {
|
|
659
622
|
stanza.attrs.to = destinationJid;
|
|
660
623
|
}
|
|
624
|
+
|
|
661
625
|
if (shouldIncludeDeviceIdentity) {
|
|
662
626
|
stanza.content.push({
|
|
663
627
|
tag: 'device-identity',
|
|
@@ -667,7 +631,7 @@ const makeMessagesSocket = (config) => {
|
|
|
667
631
|
logger.debug({ jid }, 'adding device identity');
|
|
668
632
|
}
|
|
669
633
|
|
|
670
|
-
if (AI && isPrivate) {
|
|
634
|
+
if (AI && isPrivate && !didPushAdditional) {
|
|
671
635
|
const botNode = {
|
|
672
636
|
tag: 'bot',
|
|
673
637
|
attrs: {
|
|
@@ -675,31 +639,43 @@ const makeMessagesSocket = (config) => {
|
|
|
675
639
|
}
|
|
676
640
|
}
|
|
677
641
|
|
|
678
|
-
const filteredBizBot =
|
|
642
|
+
const filteredBizBot = getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
|
|
679
643
|
|
|
680
|
-
if (filteredBizBot) {
|
|
644
|
+
if (filteredBizBot && additionalNodes) {
|
|
681
645
|
stanza.content.push(...additionalNodes)
|
|
682
646
|
didPushAdditional = true
|
|
683
647
|
}
|
|
684
|
-
|
|
685
648
|
else {
|
|
686
|
-
stanza.content.push(botNode)
|
|
649
|
+
stanza.content.push(botNode)
|
|
650
|
+
didPushAdditional = true
|
|
687
651
|
}
|
|
688
652
|
}
|
|
689
653
|
|
|
690
654
|
if(!isNewsletter && buttonType && !isStatus) {
|
|
691
|
-
|
|
692
|
-
|
|
655
|
+
const content = getAdditionalNode(buttonType)
|
|
656
|
+
const filteredNode = getBinaryNodeFilter(additionalNodes)
|
|
657
|
+
|
|
658
|
+
if (filteredNode && additionalNodes) {
|
|
659
|
+
stanza.content.push(...additionalNodes)
|
|
660
|
+
didPushAdditional = true
|
|
661
|
+
}
|
|
662
|
+
else if (content && content.length > 0 && !didPushAdditional) {
|
|
663
|
+
stanza.content.push(...content)
|
|
664
|
+
didPushAdditional = true
|
|
665
|
+
}
|
|
666
|
+
logger.debug({ jid }, 'adding business node')
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// KHUSUS NEWSLETTER: Tambah button node
|
|
670
|
+
if (isNewsletter && buttonType && !didPushAdditional) {
|
|
671
|
+
const content = getAdditionalNode(buttonType)
|
|
693
672
|
|
|
694
|
-
if (
|
|
695
|
-
didPushAdditional = true
|
|
696
|
-
stanza.content.push(...additionalNodes)
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
673
|
+
if (content && content.length > 0) {
|
|
699
674
|
stanza.content.push(...content)
|
|
675
|
+
didPushAdditional = true
|
|
676
|
+
logger.debug({ jid, buttonType }, 'adding button node to newsletter')
|
|
700
677
|
}
|
|
701
|
-
|
|
702
|
-
}
|
|
678
|
+
}
|
|
703
679
|
|
|
704
680
|
if (!didPushAdditional && additionalNodes && additionalNodes.length > 0) {
|
|
705
681
|
stanza.content.push(...additionalNodes);
|
|
@@ -725,10 +701,10 @@ const makeMessagesSocket = (config) => {
|
|
|
725
701
|
}
|
|
726
702
|
|
|
727
703
|
return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
|
|
728
|
-
// return msgId;
|
|
729
704
|
};
|
|
705
|
+
|
|
730
706
|
const getTypeMessage = (msg) => {
|
|
731
|
-
|
|
707
|
+
const message = Utils_1.normalizeMessageContent(msg)
|
|
732
708
|
if (message.reactionMessage) {
|
|
733
709
|
return 'reaction'
|
|
734
710
|
}
|
|
@@ -792,40 +768,41 @@ const makeMessagesSocket = (config) => {
|
|
|
792
768
|
}
|
|
793
769
|
|
|
794
770
|
const getButtonType = (message) => {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
771
|
+
if (message.listMessage) {
|
|
772
|
+
return 'list'
|
|
773
|
+
}
|
|
774
|
+
else if (message.buttonsMessage) {
|
|
775
|
+
return 'buttons'
|
|
776
|
+
}
|
|
777
|
+
else if (message.viewOnceMessage?.message?.interactiveMessage) {
|
|
778
|
+
return 'interactive'
|
|
779
|
+
}
|
|
780
|
+
else if (message.viewOnceMessageV2?.message?.interactiveMessage) {
|
|
781
|
+
return 'interactive'
|
|
782
|
+
}
|
|
783
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') {
|
|
784
|
+
return 'review_and_pay'
|
|
785
|
+
}
|
|
786
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_order') {
|
|
787
|
+
return 'review_order'
|
|
788
|
+
}
|
|
789
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
|
|
790
|
+
return 'payment_info'
|
|
791
|
+
}
|
|
792
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
|
|
793
|
+
return 'payment_status'
|
|
794
|
+
}
|
|
795
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
|
|
796
|
+
return 'payment_method'
|
|
797
|
+
}
|
|
798
|
+
else if (message.interactiveMessage?.nativeFlowMessage) {
|
|
799
|
+
return 'native_flow'
|
|
800
|
+
}
|
|
801
|
+
else if (message.interactiveMessage) {
|
|
802
|
+
return 'interactive'
|
|
803
|
+
}
|
|
827
804
|
}
|
|
828
|
-
|
|
805
|
+
|
|
829
806
|
const getPrivacyTokens = async (jids) => {
|
|
830
807
|
const t = Utils_1.unixTimestampSeconds().toString();
|
|
831
808
|
const result = await query({
|
|
@@ -852,9 +829,11 @@ const makeMessagesSocket = (config) => {
|
|
|
852
829
|
});
|
|
853
830
|
return result;
|
|
854
831
|
}
|
|
832
|
+
|
|
855
833
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
856
834
|
const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
|
|
857
835
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
836
|
+
|
|
858
837
|
return {
|
|
859
838
|
...sock,
|
|
860
839
|
getPrivacyTokens,
|
|
@@ -922,6 +901,7 @@ const makeMessagesSocket = (config) => {
|
|
|
922
901
|
const { filter = false, quoted } = options;
|
|
923
902
|
const getParticipantAttr = () => filter ? { participant: { jid } } : {};
|
|
924
903
|
const messageType = rahmi.detectType(content);
|
|
904
|
+
|
|
925
905
|
if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
|
|
926
906
|
typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
|
|
927
907
|
const { disappearingMessagesInChat } = content
|
|
@@ -932,108 +912,112 @@ const makeMessagesSocket = (config) => {
|
|
|
932
912
|
|
|
933
913
|
await groupToggleEphemeral(jid, value)
|
|
934
914
|
}
|
|
935
|
-
|
|
936
915
|
else {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
916
|
+
if (messageType) {
|
|
917
|
+
switch(messageType) {
|
|
918
|
+
case 'PAYMENT':
|
|
919
|
+
const paymentContent = await rahmi.handlePayment(content, quoted);
|
|
920
|
+
return await relayMessage(jid, paymentContent, {
|
|
921
|
+
messageId: Utils_1.generateMessageID(),
|
|
922
|
+
...getParticipantAttr()
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
case 'PRODUCT':
|
|
926
|
+
const productContent = await rahmi.handleProduct(content, jid, quoted);
|
|
927
|
+
const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
|
|
928
|
+
return await relayMessage(jid, productMsg.message, {
|
|
929
|
+
messageId: productMsg.key.id,
|
|
930
|
+
...getParticipantAttr()
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
case 'INTERACTIVE':
|
|
934
|
+
const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
|
|
935
|
+
const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
|
|
936
|
+
return await relayMessage(jid, interactiveMsg.message, {
|
|
937
|
+
messageId: interactiveMsg.key.id,
|
|
938
|
+
...getParticipantAttr()
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
case 'ALBUM':
|
|
942
|
+
return await rahmi.handleAlbum(content, jid, quoted)
|
|
943
|
+
|
|
944
|
+
case 'EVENT':
|
|
945
|
+
return await rahmi.handleEvent(content, jid, quoted)
|
|
946
|
+
|
|
947
|
+
case 'POLL_RESULT':
|
|
948
|
+
return await rahmi.handlePollResult(content, jid, quoted)
|
|
949
|
+
|
|
950
|
+
case 'GROUP_STORY':
|
|
951
|
+
return await rahmi.handleGroupStory(content, jid, quoted)
|
|
952
|
+
}
|
|
953
|
+
}
|
|
956
954
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
955
|
+
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
956
|
+
logger,
|
|
957
|
+
userJid,
|
|
958
|
+
quoted,
|
|
959
|
+
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
960
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
961
|
+
fetchOpts: {
|
|
962
|
+
timeout: 3000,
|
|
963
|
+
...axiosOptions || {}
|
|
964
|
+
},
|
|
965
|
+
logger,
|
|
966
|
+
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
967
|
+
}),
|
|
968
|
+
upload: async (readStream, opts) => {
|
|
969
|
+
const up = await waUploadToServer(readStream, {
|
|
970
|
+
...opts,
|
|
971
|
+
newsletter: WABinary_1.isJidNewsLetter(jid)
|
|
963
972
|
});
|
|
964
|
-
|
|
965
|
-
return await rahmi.handleAlbum(content, jid, quoted)
|
|
966
|
-
case 'EVENT':
|
|
967
|
-
return await rahmi.handleEvent(content, jid, quoted)
|
|
968
|
-
case 'POLL_RESULT':
|
|
969
|
-
return await rahmi.handlePollResult(content, jid, quoted)
|
|
970
|
-
case 'GROUP_STORY':
|
|
971
|
-
return await rahmi.handleGroupStory(content, jid, quoted)
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
975
|
-
logger,
|
|
976
|
-
userJid,
|
|
977
|
-
quoted,
|
|
978
|
-
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
979
|
-
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
980
|
-
fetchOpts: {
|
|
981
|
-
timeout: 3000,
|
|
982
|
-
...axiosOptions || {}
|
|
973
|
+
return up;
|
|
983
974
|
},
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
upload: async (readStream, opts) => {
|
|
988
|
-
const up = await waUploadToServer(readStream, {
|
|
989
|
-
...opts,
|
|
990
|
-
newsletter: WABinary_1.isJidNewsLetter(jid)
|
|
991
|
-
});
|
|
992
|
-
return up;
|
|
993
|
-
},
|
|
994
|
-
mediaCache: config.mediaCache,
|
|
995
|
-
options: config.options,
|
|
996
|
-
...options
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
1000
|
-
const isEditMsg = 'edit' in content && !!content.edit;
|
|
1001
|
-
const isAiMsg = 'ai' in content && !!content.ai;
|
|
1002
|
-
|
|
1003
|
-
const additionalAttributes = {};
|
|
1004
|
-
const additionalNodes = [];
|
|
1005
|
-
|
|
1006
|
-
if (isDeleteMsg) {
|
|
1007
|
-
const fromMe = content.delete?.fromMe;
|
|
1008
|
-
const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
|
|
1009
|
-
additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
|
|
1010
|
-
} else if (isEditMsg) {
|
|
1011
|
-
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
|
|
1012
|
-
} else if (isAiMsg) {
|
|
1013
|
-
additionalNodes.push({
|
|
1014
|
-
attrs: {
|
|
1015
|
-
biz_bot: '1'
|
|
1016
|
-
}, tag: "bot"
|
|
975
|
+
mediaCache: config.mediaCache,
|
|
976
|
+
options: config.options,
|
|
977
|
+
...options
|
|
1017
978
|
});
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
979
|
+
|
|
980
|
+
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
981
|
+
const isEditMsg = 'edit' in content && !!content.edit;
|
|
982
|
+
const isAiMsg = 'ai' in content && !!content.ai;
|
|
983
|
+
|
|
984
|
+
const additionalAttributes = {};
|
|
985
|
+
const additionalNodes = [];
|
|
986
|
+
|
|
987
|
+
if (isDeleteMsg) {
|
|
988
|
+
const fromMe = content.delete?.fromMe;
|
|
989
|
+
const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
|
|
990
|
+
additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
|
|
991
|
+
} else if (isEditMsg) {
|
|
992
|
+
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
|
|
993
|
+
} else if (isAiMsg) {
|
|
994
|
+
additionalNodes.push({
|
|
995
|
+
attrs: {
|
|
996
|
+
biz_bot: '1'
|
|
997
|
+
}, tag: "bot"
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
await relayMessage(jid, fullMsg.message, {
|
|
1002
|
+
messageId: fullMsg.key.id,
|
|
1003
|
+
cachedGroupMetadata: options.cachedGroupMetadata,
|
|
1004
|
+
additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
|
|
1005
|
+
additionalAttributes,
|
|
1006
|
+
statusJidList: options.statusJidList,
|
|
1007
|
+
AI: isAiMsg
|
|
1031
1008
|
});
|
|
1032
|
-
|
|
1033
|
-
|
|
1009
|
+
|
|
1010
|
+
if (config.emitOwnEvents) {
|
|
1011
|
+
process.nextTick(() => {
|
|
1012
|
+
processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return fullMsg;
|
|
1034
1017
|
}
|
|
1035
1018
|
}
|
|
1036
1019
|
}
|
|
1037
1020
|
};
|
|
1021
|
+
|
|
1038
1022
|
exports.makeMessagesSocket = makeMessagesSocket;
|
|
1039
1023
|
|