@dyyxyzz/baileys-mod 6.0.45 → 6.0.48

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.
@@ -18,76 +18,6 @@ const newsletter_1 = require("./newsletter");
18
18
  const WAUSync_1 = require("../WAUSync")
19
19
  const kikyy = require('./dugong');
20
20
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
21
-
22
- // TAMBAHAN BARU: Helper functions untuk button di newsletter
23
- const getAdditionalNode = (buttonType) => {
24
- const nodes = []
25
-
26
- switch(buttonType) {
27
- case 'list':
28
- nodes.push({
29
- tag: 'biz',
30
- attrs: {},
31
- content: [{
32
- tag: 'list_message',
33
- attrs: { v: '2' }
34
- }]
35
- })
36
- break
37
-
38
- case 'buttons':
39
- nodes.push({
40
- tag: 'biz',
41
- attrs: {},
42
- content: [{
43
- tag: 'buttons_message',
44
- attrs: { v: '2' }
45
- }]
46
- })
47
- break
48
-
49
- case 'interactive':
50
- case 'native_flow':
51
- nodes.push({
52
- tag: 'biz',
53
- attrs: {},
54
- content: [{
55
- tag: 'native_flow',
56
- attrs: { v: '3' }
57
- }]
58
- })
59
- break
60
-
61
- case 'review_and_pay':
62
- case 'review_order':
63
- case 'payment_info':
64
- case 'payment_status':
65
- case 'payment_method':
66
- nodes.push({
67
- tag: 'biz',
68
- attrs: {},
69
- content: [{
70
- tag: 'payment',
71
- attrs: { v: '2' }
72
- }]
73
- })
74
- break
75
- }
76
-
77
- return nodes
78
- }
79
-
80
- const getBinaryNodeFilter = (nodes) => {
81
- if (!nodes || !Array.isArray(nodes) || nodes.length === 0) return false
82
-
83
- return nodes.some(node =>
84
- node.tag === 'biz' ||
85
- node.tag === 'bot' ||
86
- node.tag === 'native_flow' ||
87
- node.tag === 'payment'
88
- )
89
- }
90
-
91
21
  const makeMessagesSocket = (config) => {
92
22
  const {
93
23
  logger,
@@ -361,8 +291,7 @@ const makeMessagesSocket = (config) => {
361
291
  return node;
362
292
  }));
363
293
  return { nodes, shouldIncludeDeviceIdentity };
364
- };
365
-
294
+ }; //apela
366
295
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
367
296
  const meId = authState.creds.me.id;
368
297
  let shouldIncludeDeviceIdentity = false;
@@ -446,6 +375,15 @@ const makeMessagesSocket = (config) => {
446
375
  participantsList.push(...statusJidList)
447
376
  }
448
377
 
378
+ // if (!isStatus) {
379
+ // const expiration = await getEphemeralGroup(jid)
380
+ // additionalAttributes = {
381
+ // ...additionalAttributes,
382
+ // addressing_mode: 'pn',
383
+ // ...expiration ? { expiration: expiration.toString() } : null
384
+ // }
385
+ // }
386
+
449
387
  const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
450
388
  devices.push(...additionalDevices)
451
389
  }
@@ -505,32 +443,10 @@ const makeMessagesSocket = (config) => {
505
443
 
506
444
  const patched = await patchMessageBeforeSending(message, [])
507
445
  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
- }
530
446
 
531
447
  binaryNodeContent.push({
532
448
  tag: 'plaintext',
533
- attrs: extraAttrs,
449
+ attrs: extraAttrs ? extraAttrs : {},
534
450
  content: bytes
535
451
  })
536
452
  }
@@ -601,7 +517,6 @@ const makeMessagesSocket = (config) => {
601
517
  },
602
518
  content: binaryNodeContent
603
519
  }
604
-
605
520
  // if the participant to send to is explicitly specified (generally retry recp)
606
521
  // ensure the message is only sent to that person
607
522
  // if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
@@ -621,7 +536,6 @@ const makeMessagesSocket = (config) => {
621
536
  else {
622
537
  stanza.attrs.to = destinationJid;
623
538
  }
624
-
625
539
  if (shouldIncludeDeviceIdentity) {
626
540
  stanza.content.push({
627
541
  tag: 'device-identity',
@@ -631,7 +545,7 @@ const makeMessagesSocket = (config) => {
631
545
  logger.debug({ jid }, 'adding device identity');
632
546
  }
633
547
 
634
- if (AI && isPrivate && !didPushAdditional) {
548
+ if (AI && isPrivate) {
635
549
  const botNode = {
636
550
  tag: 'bot',
637
551
  attrs: {
@@ -639,43 +553,31 @@ const makeMessagesSocket = (config) => {
639
553
  }
640
554
  }
641
555
 
642
- const filteredBizBot = getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
556
+ const filteredBizBot = WABinary_1.getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
643
557
 
644
- if (filteredBizBot && additionalNodes) {
558
+ if (filteredBizBot) {
645
559
  stanza.content.push(...additionalNodes)
646
560
  didPushAdditional = true
647
561
  }
562
+
648
563
  else {
649
- stanza.content.push(botNode)
650
- didPushAdditional = true
564
+ stanza.content.push(botNode)
651
565
  }
652
566
  }
653
567
 
654
- if(!isNewsletter && buttonType && !isStatus && !didPushAdditional) {
655
- const content = getAdditionalNode(buttonType)
656
- const filteredNode = getBinaryNodeFilter(additionalNodes)
568
+ if(!isNewsletter && buttonType && !isStatus) {
569
+ const content = WABinary_1.getAdditionalNode(buttonType)
570
+ const filteredNode = WABinary_1.getBinaryNodeFilter(additionalNodes)
657
571
 
658
- if (filteredNode && additionalNodes) {
659
- stanza.content.push(...additionalNodes)
572
+ if (filteredNode) {
660
573
  didPushAdditional = true
574
+ stanza.content.push(...additionalNodes)
661
575
  }
662
- else if (content && content.length > 0) {
576
+ else {
663
577
  stanza.content.push(...content)
664
- didPushAdditional = true
665
578
  }
666
579
  logger.debug({ jid }, 'adding business node')
667
- }
668
-
669
- // KHUSUS NEWSLETTER: Tambah button node
670
- if (isNewsletter && buttonType && !didPushAdditional) {
671
- const content = getAdditionalNode(buttonType)
672
-
673
- if (content && content.length > 0) {
674
- stanza.content.push(...content)
675
- didPushAdditional = true
676
- logger.debug({ jid, buttonType }, 'adding button node to newsletter')
677
- }
678
- }
580
+ }
679
581
 
680
582
  if (!didPushAdditional && additionalNodes && additionalNodes.length > 0) {
681
583
  stanza.content.push(...additionalNodes);
@@ -701,10 +603,10 @@ const makeMessagesSocket = (config) => {
701
603
  }
702
604
 
703
605
  return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
606
+ // return msgId;
704
607
  };
705
-
706
608
  const getTypeMessage = (msg) => {
707
- const message = Utils_1.normalizeMessageContent(msg)
609
+ const message = Utils_1.normalizeMessageContent(msg)
708
610
  if (message.reactionMessage) {
709
611
  return 'reaction'
710
612
  }
@@ -774,12 +676,6 @@ const makeMessagesSocket = (config) => {
774
676
  else if (message.buttonsMessage) {
775
677
  return 'buttons'
776
678
  }
777
- else if (message.viewOnceMessage?.message?.interactiveMessage) {
778
- return 'interactive'
779
- }
780
- else if (message.viewOnceMessageV2?.message?.interactiveMessage) {
781
- return 'interactive'
782
- }
783
679
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') {
784
680
  return 'review_and_pay'
785
681
  }
@@ -795,14 +691,13 @@ const makeMessagesSocket = (config) => {
795
691
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
796
692
  return 'payment_method'
797
693
  }
694
+ else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
695
+ return 'interactive'
696
+ }
798
697
  else if (message.interactiveMessage?.nativeFlowMessage) {
799
698
  return 'native_flow'
800
699
  }
801
- else if (message.interactiveMessage) {
802
- return 'interactive'
803
- }
804
700
  }
805
-
806
701
  const getPrivacyTokens = async (jids) => {
807
702
  const t = Utils_1.unixTimestampSeconds().toString();
808
703
  const result = await query({
@@ -829,11 +724,9 @@ const makeMessagesSocket = (config) => {
829
724
  });
830
725
  return result;
831
726
  }
832
-
833
727
  const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
834
728
  const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
835
729
  const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
836
-
837
730
  return {
838
731
  ...sock,
839
732
  getPrivacyTokens,
@@ -901,7 +794,6 @@ const makeMessagesSocket = (config) => {
901
794
  const { filter = false, quoted } = options;
902
795
  const getParticipantAttr = () => filter ? { participant: { jid } } : {};
903
796
  const messageType = rahmi.detectType(content);
904
-
905
797
  if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
906
798
  typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
907
799
  const { disappearingMessagesInChat } = content
@@ -912,112 +804,107 @@ const makeMessagesSocket = (config) => {
912
804
 
913
805
  await groupToggleEphemeral(jid, value)
914
806
  }
807
+
915
808
  else {
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
- }
954
-
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)
809
+ let mediaHandle
810
+
811
+
812
+ if (messageType) {
813
+ switch(messageType) {
814
+ case 'PAYMENT':
815
+ const paymentContent = await rahmi.handlePayment(content, quoted);
816
+ return await relayMessage(jid, paymentContent, {
817
+ messageId: Utils_1.generateMessageID(),
818
+ ...getParticipantAttr()
972
819
  });
973
- return up;
974
- },
975
- mediaCache: config.mediaCache,
976
- options: config.options,
977
- ...options
978
- });
979
820
 
980
- const isDeleteMsg = 'delete' in content && !!content.delete;
981
- const isEditMsg = 'edit' in content && !!content.edit;
982
- const isAiMsg = 'ai' in content && !!content.ai;
821
+ case 'PRODUCT':
822
+ const productContent = await rahmi.handleProduct(content, jid, quoted);
823
+ const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
824
+ return await relayMessage(jid, productMsg.message, {
825
+ messageId: productMsg.key.id,
826
+ ...getParticipantAttr()
827
+ });
983
828
 
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
- });
829
+ case 'INTERACTIVE':
830
+ const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
831
+ const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
832
+ return await relayMessage(jid, interactiveMsg.message, {
833
+ messageId: interactiveMsg.key.id,
834
+ ...getParticipantAttr()
835
+ });
836
+ case 'ALBUM':
837
+ return await rahmi.handleAlbum(content, jid, quoted)
838
+ case 'EVENT':
839
+ return await rahmi.handleEvent(content, jid, quoted)
840
+ case 'POLL_RESULT':
841
+ return await rahmi.handlePollResult(content, jid, quoted)
842
+ case 'GROUP_STORY':
843
+ return await rahmi.handleGroupStory(content, jid, quoted)
999
844
  }
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
1008
- });
1009
-
1010
- if (config.emitOwnEvents) {
1011
- process.nextTick(() => {
1012
- processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
845
+ }
846
+ const fullMsg = await Utils_1.generateWAMessage(jid, content, {
847
+ logger,
848
+ userJid,
849
+ quoted,
850
+ getUrlInfo: text => link_preview_1.getUrlInfo(text, {
851
+ thumbnailWidth: linkPreviewImageThumbnailWidth,
852
+ fetchOpts: {
853
+ timeout: 3000,
854
+ ...axiosOptions || {}
855
+ },
856
+ logger,
857
+ uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
858
+ }),
859
+ upload: async (readStream, opts) => {
860
+ const up = await waUploadToServer(readStream, {
861
+ ...opts,
862
+ newsletter: WABinary_1.isJidNewsLetter(jid)
1013
863
  });
1014
- }
1015
-
1016
- return fullMsg;
864
+ return up;
865
+ },
866
+ mediaCache: config.mediaCache,
867
+ options: config.options,
868
+ ...options
869
+ });
870
+
871
+ const isDeleteMsg = 'delete' in content && !!content.delete;
872
+ const isEditMsg = 'edit' in content && !!content.edit;
873
+ const isAiMsg = 'ai' in content && !!content.ai;
874
+
875
+ const additionalAttributes = {};
876
+ const additionalNodes = [];
877
+
878
+ if (isDeleteMsg) {
879
+ const fromMe = content.delete?.fromMe;
880
+ const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
881
+ additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
882
+ } else if (isEditMsg) {
883
+ additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
884
+ } else if (isAiMsg) {
885
+ additionalNodes.push({
886
+ attrs: {
887
+ biz_bot: '1'
888
+ }, tag: "bot"
889
+ });
890
+ }
891
+
892
+ await relayMessage(jid, fullMsg.message, {
893
+ messageId: fullMsg.key.id,
894
+ cachedGroupMetadata: options.cachedGroupMetadata,
895
+ additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
896
+ additionalAttributes,
897
+ statusJidList: options.statusJidList
898
+ });
899
+
900
+ if (config.emitOwnEvents) {
901
+ process.nextTick(() => {
902
+ processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
903
+ });
904
+ }
905
+ return fullMsg;
1017
906
  }
1018
907
  }
1019
908
  }
1020
909
  };
1021
-
1022
910
  exports.makeMessagesSocket = makeMessagesSocket;
1023
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyyxyzz/baileys-mod",
3
- "version": "6.0.45",
3
+ "version": "6.0.48",
4
4
  "description": "WhatsApp API Modification",
5
5
  "keywords": [
6
6
  "whatsapp",