@zetagoaurum-socket/wasocket 2.1.7 → 2.1.9

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.
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeMessagesSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
+ const crypto = require("crypto"); // Added for supportPayload messageSecret
8
9
  const node_cache_1 = __importDefault(require("node-cache"));
9
10
  const WAProto_1 = require("../../WAProto");
10
11
  const Defaults_1 = require("../Defaults");
@@ -16,7 +17,6 @@ const WABinary_1 = require("../WABinary");
16
17
  const newsletter_1 = require("./newsletter");
17
18
  const WAUSync_1 = require("../WAUSync")
18
19
  const kikyy = require('./dugong');
19
- const { ContactManager } = require("../Utils/auto-contact");
20
20
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
21
21
  const makeMessagesSocket = (config) => {
22
22
  const {
@@ -319,7 +319,24 @@ const makeMessagesSocket = (config) => {
319
319
  };
320
320
  const extraAttrs = {}
321
321
  const messages = Utils_1.normalizeMessageContent(message)
322
- const buttonType = getButtonType(messages);
322
+
323
+ // [AI BADGE LOGIC v2.1.9]
324
+ // 1. For GROUPS: Use supportPayload (safest, no drop)
325
+ if (AI && !isPrivate && !isStatus && !isNewsletter) {
326
+ const msgType = Object.keys(messages)[0];
327
+ if (msgType) {
328
+ messages[msgType].contextInfo = messages[msgType].contextInfo || {};
329
+ messages[msgType].contextInfo.messageSecret = messages[msgType].contextInfo.messageSecret || crypto.randomBytes(32);
330
+ messages[msgType].contextInfo.supportPayload = JSON.stringify({
331
+ version: 1,
332
+ is_ai_message: true,
333
+ should_show_system_message: true,
334
+ ticket_id: crypto.randomBytes(16).toString('hex')
335
+ });
336
+ }
337
+ }
338
+
339
+ const buttonType = getButtonType(messages);
323
340
  if (participant) {
324
341
  // when the retry request is not for a group
325
342
  // only send to the specific device that asked for a retry
@@ -546,7 +563,9 @@ const makeMessagesSocket = (config) => {
546
563
  logger.debug({ jid }, 'adding device identity');
547
564
  }
548
565
 
549
- if (AI) {
566
+ // [AI BADGE LOGIC v2.1.9]
567
+ // 2. For PRIVATE CHATS: Use biz_bot (standard method, works fine)
568
+ if (AI && isPrivate) {
550
569
  const botNode = {
551
570
  tag: 'bot',
552
571
  attrs: {
@@ -794,9 +813,8 @@ const makeMessagesSocket = (config) => {
794
813
  sendMessage: async (jid, content, options = {}) => {
795
814
  const userJid = authState.creds.me.id;
796
815
 
797
- // Auto Safe Contact
798
- ContactManager.checkAndSave(jid, { user: authState.creds.me });
799
- delete options.ephemeralExpiration
816
+ // Auto Safe Contact (Moved from sendMessage to relayMessage or handled by caller, but keeping here for now)
817
+ // ContactManager.checkAndSave(jid, { user: authState.creds.me });
800
818
  const { filter = false, quoted } = options;
801
819
  const getParticipantAttr = () => filter ? { participant: { jid } } : {};
802
820
  const messageType = rahmi.detectType(content);
@@ -822,7 +840,7 @@ const makeMessagesSocket = (config) => {
822
840
  return await relayMessage(jid, paymentContent, {
823
841
  messageId: Utils_1.generateMessageID(),
824
842
  ...getParticipantAttr(),
825
- AI: true
843
+ AI: true // Default to true via relayMessage logic which now handles the split
826
844
  });
827
845
 
828
846
  case 'PRODUCT':
@@ -831,7 +849,7 @@ const makeMessagesSocket = (config) => {
831
849
  return await relayMessage(jid, productMsg.message, {
832
850
  messageId: productMsg.key.id,
833
851
  ...getParticipantAttr(),
834
- AI: true
852
+ AI: true // Default to true via relayMessage logic which now handles the split
835
853
  });
836
854
 
837
855
  case 'INTERACTIVE':
@@ -840,7 +858,7 @@ const makeMessagesSocket = (config) => {
840
858
  return await relayMessage(jid, interactiveMsg.message, {
841
859
  messageId: interactiveMsg.key.id,
842
860
  ...getParticipantAttr(),
843
- AI: true
861
+ AI: true // Default to true via relayMessage logic which now handles the split
844
862
  });
845
863
  case 'ALBUM':
846
864
  return await rahmi.handleAlbum(content, jid, quoted)
@@ -879,10 +897,10 @@ const makeMessagesSocket = (config) => {
879
897
 
880
898
 
881
899
 
900
+
882
901
  const isDeleteMsg = 'delete' in content && !!content.delete;
883
902
  const isEditMsg = 'edit' in content && !!content.edit;
884
- // FORCE AI BADGES FOR ALL MESSAGES
885
- const isAiMsg = 'ai' in content && !!content.ai;
903
+ const isAiMsg = 'ai' in content && !!content.ai;
886
904
 
887
905
  const additionalAttributes = {};
888
906
  const additionalNodes = [];
@@ -894,11 +912,25 @@ const makeMessagesSocket = (config) => {
894
912
  } else if (isEditMsg) {
895
913
  additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
896
914
  } else if (isAiMsg) {
897
- additionalNodes.push({
898
- attrs: {
899
- biz_bot: '1'
900
- }, tag: "bot"
901
- });
915
+ if (WABinary_1.isJidGroup(jid)) {
916
+ additionalNodes.push({
917
+ attrs: {},
918
+ tag: 'bot',
919
+ content: [
920
+ {
921
+ attrs: {},
922
+ tag: 'support_payload',
923
+ content: Dugong_1.DugongMessage.fromObject(content.ai).toBuffer()
924
+ }
925
+ ]
926
+ });
927
+ } else {
928
+ additionalNodes.push({
929
+ attrs: {
930
+ biz_bot: '1'
931
+ }, tag: "bot"
932
+ });
933
+ }
902
934
  }
903
935
 
904
936
  await relayMessage(jid, fullMsg.message, {
@@ -907,7 +939,7 @@ const makeMessagesSocket = (config) => {
907
939
  additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
908
940
  additionalAttributes,
909
941
  statusJidList: options.statusJidList,
910
- AI: true // Ensure relayMessage knows it's AI
942
+ AI: true // Default to true via relayMessage logic which now handles the split
911
943
  });
912
944
 
913
945
  if (config.emitOwnEvents) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zetagoaurum-socket/wasocket",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "WhatsApp API Modification ZetaGo",
5
5
  "keywords": [
6
6
  "whatsapp",