@zetagoaurum-socket/wasocket 2.1.8 → 2.2.0
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 +47 -37
- package/lib/Utils/link-preview.js +5 -2
- package/package.json +1 -1
|
@@ -17,7 +17,6 @@ const WABinary_1 = require("../WABinary");
|
|
|
17
17
|
const newsletter_1 = require("./newsletter");
|
|
18
18
|
const WAUSync_1 = require("../WAUSync")
|
|
19
19
|
const kikyy = require('./dugong');
|
|
20
|
-
const { ContactManager } = require("../Utils/auto-contact");
|
|
21
20
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
22
21
|
const makeMessagesSocket = (config) => {
|
|
23
22
|
const {
|
|
@@ -321,25 +320,23 @@ const makeMessagesSocket = (config) => {
|
|
|
321
320
|
const extraAttrs = {}
|
|
322
321
|
const messages = Utils_1.normalizeMessageContent(message)
|
|
323
322
|
|
|
324
|
-
// [AI BADGE
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const buttonType = getButtonType(messages);
|
|
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);
|
|
343
340
|
if (participant) {
|
|
344
341
|
// when the retry request is not for a group
|
|
345
342
|
// only send to the specific device that asked for a retry
|
|
@@ -566,8 +563,9 @@ const makeMessagesSocket = (config) => {
|
|
|
566
563
|
logger.debug({ jid }, 'adding device identity');
|
|
567
564
|
}
|
|
568
565
|
|
|
569
|
-
|
|
570
|
-
|
|
566
|
+
// [AI BADGE LOGIC v2.1.9]
|
|
567
|
+
// 2. For PRIVATE CHATS: Use biz_bot (standard method, works fine)
|
|
568
|
+
if (AI && isPrivate) {
|
|
571
569
|
const botNode = {
|
|
572
570
|
tag: 'bot',
|
|
573
571
|
attrs: {
|
|
@@ -586,7 +584,6 @@ const makeMessagesSocket = (config) => {
|
|
|
586
584
|
stanza.content.push(botNode)
|
|
587
585
|
}
|
|
588
586
|
}
|
|
589
|
-
*/
|
|
590
587
|
|
|
591
588
|
if(!isNewsletter && buttonType && !isStatus) {
|
|
592
589
|
const content = WABinary_1.getAdditionalNode(buttonType)
|
|
@@ -816,9 +813,8 @@ const makeMessagesSocket = (config) => {
|
|
|
816
813
|
sendMessage: async (jid, content, options = {}) => {
|
|
817
814
|
const userJid = authState.creds.me.id;
|
|
818
815
|
|
|
819
|
-
// Auto Safe Contact
|
|
820
|
-
ContactManager.checkAndSave(jid, { user: authState.creds.me });
|
|
821
|
-
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 });
|
|
822
818
|
const { filter = false, quoted } = options;
|
|
823
819
|
const getParticipantAttr = () => filter ? { participant: { jid } } : {};
|
|
824
820
|
const messageType = rahmi.detectType(content);
|
|
@@ -844,7 +840,7 @@ const makeMessagesSocket = (config) => {
|
|
|
844
840
|
return await relayMessage(jid, paymentContent, {
|
|
845
841
|
messageId: Utils_1.generateMessageID(),
|
|
846
842
|
...getParticipantAttr(),
|
|
847
|
-
AI: true
|
|
843
|
+
AI: true // Default to true via relayMessage logic which now handles the split
|
|
848
844
|
});
|
|
849
845
|
|
|
850
846
|
case 'PRODUCT':
|
|
@@ -853,7 +849,7 @@ const makeMessagesSocket = (config) => {
|
|
|
853
849
|
return await relayMessage(jid, productMsg.message, {
|
|
854
850
|
messageId: productMsg.key.id,
|
|
855
851
|
...getParticipantAttr(),
|
|
856
|
-
AI: true
|
|
852
|
+
AI: true // Default to true via relayMessage logic which now handles the split
|
|
857
853
|
});
|
|
858
854
|
|
|
859
855
|
case 'INTERACTIVE':
|
|
@@ -862,7 +858,7 @@ const makeMessagesSocket = (config) => {
|
|
|
862
858
|
return await relayMessage(jid, interactiveMsg.message, {
|
|
863
859
|
messageId: interactiveMsg.key.id,
|
|
864
860
|
...getParticipantAttr(),
|
|
865
|
-
AI: true
|
|
861
|
+
AI: true // Default to true via relayMessage logic which now handles the split
|
|
866
862
|
});
|
|
867
863
|
case 'ALBUM':
|
|
868
864
|
return await rahmi.handleAlbum(content, jid, quoted)
|
|
@@ -901,10 +897,10 @@ const makeMessagesSocket = (config) => {
|
|
|
901
897
|
|
|
902
898
|
|
|
903
899
|
|
|
900
|
+
|
|
904
901
|
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
905
902
|
const isEditMsg = 'edit' in content && !!content.edit;
|
|
906
|
-
|
|
907
|
-
const isAiMsg = 'ai' in content && !!content.ai;
|
|
903
|
+
const isAiMsg = 'ai' in content && !!content.ai;
|
|
908
904
|
|
|
909
905
|
const additionalAttributes = {};
|
|
910
906
|
const additionalNodes = [];
|
|
@@ -916,11 +912,25 @@ const makeMessagesSocket = (config) => {
|
|
|
916
912
|
} else if (isEditMsg) {
|
|
917
913
|
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
|
|
918
914
|
} else if (isAiMsg) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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
|
+
}
|
|
924
934
|
}
|
|
925
935
|
|
|
926
936
|
await relayMessage(jid, fullMsg.message, {
|
|
@@ -929,7 +939,7 @@ const makeMessagesSocket = (config) => {
|
|
|
929
939
|
additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
|
|
930
940
|
additionalAttributes,
|
|
931
941
|
statusJidList: options.statusJidList,
|
|
932
|
-
AI: true //
|
|
942
|
+
AI: true // Default to true via relayMessage logic which now handles the split
|
|
933
943
|
});
|
|
934
944
|
|
|
935
945
|
if (config.emitOwnEvents) {
|
|
@@ -49,7 +49,8 @@ const getUrlInfo = async (text, opts = {
|
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
|
|
52
|
+
},
|
|
53
|
+
// headers: opts.fetchOpts // [FIX] Do not pass fetchOpts as headers, this causes 400 Bad Request
|
|
53
54
|
});
|
|
54
55
|
if (info && 'title' in info && info.title) {
|
|
55
56
|
const [image] = info.images;
|
|
@@ -86,7 +87,9 @@ const getUrlInfo = async (text, opts = {
|
|
|
86
87
|
}
|
|
87
88
|
catch (error) {
|
|
88
89
|
if (!error.message.includes('receive a valid')) {
|
|
89
|
-
|
|
90
|
+
// [FIX] Log error but do not crash/throw for link preview failures
|
|
91
|
+
(_a = opts.logger) === null || _a === void 0 ? void 0 : _a.debug({ err: error.stack, url: text }, 'error in fetching link preview');
|
|
92
|
+
// throw error; // Safe to ignore link preview errors
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
};
|