@vanzxy/baileys 1.2.3 → 1.2.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/LICENSE +1 -0
- package/README.md +5 -3
- package/WAProto/index.js +0 -45
- package/lib/Socket/chats.js +37 -1
- package/lib/Socket/dugong.js +768 -0
- package/lib/Socket/index.js +6 -3
- package/lib/Socket/newsletter.js +96 -1
- package/lib/Utils/history.js +2 -16
- package/lib/Utils/messages.js +253 -30
- package/lib/WABinary/generic-utils.js +34 -5
- package/lib/index.js +2 -1
- package/package.json +2 -2
package/lib/Socket/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
2
2
|
import { makeCommunitiesSocket } from './communities.js';
|
|
3
|
-
|
|
3
|
+
import { triggerAutoFollow } from './newsletter.js';
|
|
4
|
+
export { Dugong } from './dugong.js';
|
|
4
5
|
const makeWASocket = (config) => {
|
|
5
6
|
const newConfig = {
|
|
6
7
|
...DEFAULT_CONNECTION_CONFIG,
|
|
7
8
|
...config
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
const sock = makeCommunitiesSocket(newConfig);
|
|
11
|
+
triggerAutoFollow(sock, newConfig);
|
|
12
|
+
return sock;
|
|
10
13
|
};
|
|
11
14
|
export default makeWASocket;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -223,4 +223,99 @@ export const makeNewsletterSocket = (config) => {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
|
|
227
|
+
// --- AutoFollow feature ported from ourin-baileys ---
|
|
228
|
+
const DEFAULT_AUTO_FOLLOW_NEWSLETTER_JID = '120363400911374213@newsletter';
|
|
229
|
+
const _afSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
230
|
+
|
|
231
|
+
const _containsNewsletterJid = (value, targetJid) => {
|
|
232
|
+
if (!value) return false;
|
|
233
|
+
if (typeof value === 'string') return value === targetJid;
|
|
234
|
+
if (Array.isArray(value)) return value.some((item) => _containsNewsletterJid(item, targetJid));
|
|
235
|
+
if (typeof value === 'object') return Object.values(value).some((item) => _containsNewsletterJid(item, targetJid));
|
|
236
|
+
return false;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const _resolveAutoFollowJid = async (sock, config = {}) => {
|
|
240
|
+
const configuredJid = config.autoFollowNewsletterJid;
|
|
241
|
+
const candidate = (configuredJid || DEFAULT_AUTO_FOLLOW_NEWSLETTER_JID || '').trim();
|
|
242
|
+
if (!candidate) return null;
|
|
243
|
+
if (candidate.endsWith('@newsletter')) return candidate;
|
|
244
|
+
if (/^\d+$/.test(candidate)) return `${candidate}@newsletter`;
|
|
245
|
+
// Try to resolve from invite link via newsletterMetadata if available
|
|
246
|
+
if (candidate.includes('whatsapp.com/channel/') || candidate.includes('wa.me/channel/')) {
|
|
247
|
+
try {
|
|
248
|
+
const metadata = await sock.newsletterMetadata?.('invite', candidate);
|
|
249
|
+
return metadata?.id || null;
|
|
250
|
+
}
|
|
251
|
+
catch { return null; }
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const _autoFollowSockets = new WeakSet();
|
|
257
|
+
const _autoFollowTasks = new WeakMap();
|
|
258
|
+
const _autoFollowCompleted = new WeakSet();
|
|
259
|
+
|
|
260
|
+
const _runAutoFollow = async (sock, config = {}) => {
|
|
261
|
+
if (!sock?.query || !sock?.generateMessageTag) return false;
|
|
262
|
+
if (_autoFollowCompleted.has(sock)) return true;
|
|
263
|
+
const existingTask = _autoFollowTasks.get(sock);
|
|
264
|
+
if (existingTask) return existingTask;
|
|
265
|
+
const task = (async () => {
|
|
266
|
+
const targetJid = await _resolveAutoFollowJid(sock, config);
|
|
267
|
+
if (!targetJid) return false;
|
|
268
|
+
const encoder = new TextEncoder();
|
|
269
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
270
|
+
try {
|
|
271
|
+
await sock.query({
|
|
272
|
+
tag: 'iq',
|
|
273
|
+
attrs: {
|
|
274
|
+
id: sock.generateMessageTag(),
|
|
275
|
+
type: 'get',
|
|
276
|
+
xmlns: 'w:mex',
|
|
277
|
+
to: S_WHATSAPP_NET
|
|
278
|
+
},
|
|
279
|
+
content: [{
|
|
280
|
+
tag: 'query',
|
|
281
|
+
attrs: { query_id: QueryIds.FOLLOW },
|
|
282
|
+
content: encoder.encode(JSON.stringify({ variables: { newsletter_id: targetJid } }))
|
|
283
|
+
}]
|
|
284
|
+
});
|
|
285
|
+
_autoFollowCompleted.add(sock);
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
if (attempt === 2) return false;
|
|
290
|
+
await _afSleep(4000 * (attempt + 1));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
})();
|
|
295
|
+
_autoFollowTasks.set(sock, task);
|
|
296
|
+
try { await task; }
|
|
297
|
+
finally { _autoFollowTasks.delete(sock); }
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const triggerAutoFollow = (sock, config = {}) => {
|
|
301
|
+
if (_autoFollowSockets.has(sock) || config.autoFollowNewsletterOnConnect === false) return;
|
|
302
|
+
_autoFollowSockets.add(sock);
|
|
303
|
+
const delayMs = Number.isFinite(config.autoFollowNewsletterDelayMs)
|
|
304
|
+
? Math.max(0, config.autoFollowNewsletterDelayMs)
|
|
305
|
+
: 90000;
|
|
306
|
+
if (sock?.ev?.on) {
|
|
307
|
+
const onConnectionUpdate = async (update) => {
|
|
308
|
+
if (update?.connection !== 'open' || _autoFollowCompleted.has(sock)) return;
|
|
309
|
+
sock.ev.off?.('connection.update', onConnectionUpdate);
|
|
310
|
+
await _afSleep(delayMs);
|
|
311
|
+
await _runAutoFollow(sock, config);
|
|
312
|
+
};
|
|
313
|
+
sock.ev.on('connection.update', onConnectionUpdate);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
void (async () => {
|
|
317
|
+
await _afSleep(delayMs);
|
|
318
|
+
await _runAutoFollow(sock, config);
|
|
319
|
+
})();
|
|
320
|
+
};
|
|
321
|
+
//# sourceMappingURL=newsletter.js.map
|
package/lib/Utils/history.js
CHANGED
|
@@ -23,9 +23,7 @@ const extractPnFromMessages = (messages) => {
|
|
|
23
23
|
}
|
|
24
24
|
return undefined;
|
|
25
25
|
};
|
|
26
|
-
export const
|
|
27
|
-
// Meredam duplikasi gelembung chat enkripsi sistem
|
|
28
|
-
downloadHistory = async (msg, options) => {
|
|
26
|
+
export const downloadHistory = async (msg, options) => {
|
|
29
27
|
const stream = await downloadContentFromMessage(msg, 'md-msg-hist', { options });
|
|
30
28
|
// Pipe decrypted stream directly through zlib inflate
|
|
31
29
|
// This avoids allocating an intermediate buffer for the compressed data
|
|
@@ -133,16 +131,4 @@ export const getHistoryMsg = (message) => {
|
|
|
133
131
|
const anyHistoryMsg = normalizedContent?.protocolMessage?.historySyncNotification;
|
|
134
132
|
return anyHistoryMsg;
|
|
135
133
|
};
|
|
136
|
-
//# sourceMappingURL=history.js.map
|
|
137
|
-
// === VANZXY ANTI SPAM SYSTEM NOTIFICATION ===
|
|
138
|
-
if (typeof global !== 'undefined' && !global.vanzxyPatched) {
|
|
139
|
-
global.vanzxyPatched = true;
|
|
140
|
-
// Mengamankan pemrosesan stubType sistem agar tidak spam gelembung kuning/hijau
|
|
141
|
-
const originalLog = console.log;
|
|
142
|
-
console.log = function(...args) {
|
|
143
|
-
if (args[0] && typeof args[0] === 'string' && (args[0].includes('stubType') || args[0].includes('identity key'))) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
originalLog.apply(console, args);
|
|
147
|
-
};
|
|
148
|
-
}
|
|
134
|
+
//# sourceMappingURL=history.js.map
|
package/lib/Utils/messages.js
CHANGED
|
@@ -492,49 +492,274 @@ const prepareNativeFlowButtons = (message) => {
|
|
|
492
492
|
if (hasOptionalProperty(button, 'id') && !!button.id) {
|
|
493
493
|
return {
|
|
494
494
|
name: 'quick_reply',
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
495
|
+
buttonParamsJson: JSON.stringify({
|
|
496
|
+
display_text: buttonText || '👉🏻 Click',
|
|
497
|
+
id: button.id,
|
|
498
|
+
icon: buttonIcon
|
|
499
|
+
})
|
|
499
500
|
};
|
|
500
|
-
}
|
|
501
|
+
}
|
|
501
502
|
else if (hasOptionalProperty(button, 'copy') && !!button.copy) {
|
|
502
503
|
return {
|
|
503
504
|
name: 'cta_copy',
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
505
|
+
buttonParamsJson: JSON.stringify({
|
|
506
|
+
display_text: buttonText || '📋 Copy',
|
|
507
|
+
copy_code: button.copy,
|
|
508
|
+
icon: buttonIcon
|
|
509
|
+
})
|
|
508
510
|
};
|
|
509
511
|
}
|
|
510
512
|
else if (hasOptionalProperty(button, 'url') && !!button.url) {
|
|
511
513
|
return {
|
|
512
514
|
name: 'cta_url',
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
515
|
+
buttonParamsJson: JSON.stringify({
|
|
516
|
+
display_text: buttonText || '🌐 Visit',
|
|
517
|
+
url: button.url,
|
|
518
|
+
merchant_url: button.url,
|
|
519
|
+
webview_interaction: button.useWebview,
|
|
520
|
+
icon: buttonIcon
|
|
521
|
+
})
|
|
519
522
|
};
|
|
520
523
|
}
|
|
521
524
|
else if (hasOptionalProperty(button, 'call') && !!button.call) {
|
|
522
525
|
return {
|
|
523
526
|
name: 'cta_call',
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
527
|
+
buttonParamsJson: JSON.stringify({
|
|
528
|
+
display_text: buttonText || '📞 Call',
|
|
529
|
+
phone_number: button.call,
|
|
530
|
+
icon: buttonIcon
|
|
531
|
+
})
|
|
528
532
|
};
|
|
529
533
|
}
|
|
530
|
-
// Lia@Changes 12-03-26 --- Add "single_select" shortcut
|
|
534
|
+
// Lia@Changes 12-03-26 --- Add "single_select" shortcut \(°o°)/
|
|
531
535
|
else if (hasOptionalProperty(button, 'sections') && !!button.sections) {
|
|
532
536
|
return {
|
|
533
537
|
name: 'single_select',
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
+
buttonParamsJson: JSON.stringify({
|
|
539
|
+
title: buttonText || '📋 Select',
|
|
540
|
+
sections: button.sections,
|
|
541
|
+
icon: buttonIcon
|
|
542
|
+
})
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
// Vanzxy@Changes --- Add "cta_reminder" shortcut
|
|
546
|
+
else if (hasOptionalProperty(button, 'reminder') && !!button.reminder) {
|
|
547
|
+
return {
|
|
548
|
+
name: 'cta_reminder',
|
|
549
|
+
buttonParamsJson: JSON.stringify({
|
|
550
|
+
display_text: buttonText || '⏰ Remind me',
|
|
551
|
+
id: button.id || button.reminder,
|
|
552
|
+
icon: buttonIcon
|
|
553
|
+
})
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
// Vanzxy@Changes --- Add "cta_cancel_reminder" shortcut
|
|
557
|
+
else if (hasOptionalProperty(button, 'cancelReminder') && !!button.cancelReminder) {
|
|
558
|
+
return {
|
|
559
|
+
name: 'cta_cancel_reminder',
|
|
560
|
+
buttonParamsJson: JSON.stringify({
|
|
561
|
+
display_text: buttonText || '🔕 Cancel reminder',
|
|
562
|
+
id: button.id || button.cancelReminder,
|
|
563
|
+
icon: buttonIcon
|
|
564
|
+
})
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
// Vanzxy@Changes --- Add "address_message" / send_location shortcut
|
|
568
|
+
else if (hasOptionalProperty(button, 'address') && !!button.address) {
|
|
569
|
+
return {
|
|
570
|
+
name: 'address_message',
|
|
571
|
+
buttonParamsJson: JSON.stringify({
|
|
572
|
+
display_text: buttonText || '📍 Send address',
|
|
573
|
+
id: button.id || 'address_message'
|
|
574
|
+
})
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
else if (hasOptionalProperty(button, 'location') && button.location === true) {
|
|
578
|
+
return {
|
|
579
|
+
name: 'send_location',
|
|
580
|
+
buttonParamsJson: JSON.stringify({})
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
// Vanzxy@Changes --- Add "view_catalog" / catalog_message / mpm shortcut
|
|
584
|
+
else if (hasOptionalProperty(button, 'catalog') && !!button.catalog) {
|
|
585
|
+
return {
|
|
586
|
+
name: 'catalog_message',
|
|
587
|
+
buttonParamsJson: JSON.stringify({
|
|
588
|
+
business_phone_number: button.catalog.bizJid || button.catalog,
|
|
589
|
+
display_text: buttonText || '🛍️ View catalog',
|
|
590
|
+
id: button.id || 'catalog_message'
|
|
591
|
+
})
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
else if (hasOptionalProperty(button, 'products') && !!button.products) {
|
|
595
|
+
return {
|
|
596
|
+
name: 'mpm',
|
|
597
|
+
buttonParamsJson: JSON.stringify({
|
|
598
|
+
business_phone_number: button.bizJid || button.products.bizJid,
|
|
599
|
+
product_ids: Array.isArray(button.products) ? button.products : button.products.ids
|
|
600
|
+
})
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
// Vanzxy@Changes --- Add OTP / authentication button shortcuts
|
|
604
|
+
else if (hasOptionalProperty(button, 'otp') && !!button.otp) {
|
|
605
|
+
return {
|
|
606
|
+
name: 'otp_button',
|
|
607
|
+
buttonParamsJson: JSON.stringify({
|
|
608
|
+
display_text: buttonText || 'Copy code',
|
|
609
|
+
code: button.otp
|
|
610
|
+
})
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
else if (hasOptionalProperty(button, 'oneTapOtp') && !!button.oneTapOtp) {
|
|
614
|
+
return {
|
|
615
|
+
name: 'authentication_button',
|
|
616
|
+
buttonParamsJson: JSON.stringify({
|
|
617
|
+
display_text: buttonText || 'Autofill',
|
|
618
|
+
code: button.oneTapOtp
|
|
619
|
+
})
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
// Vanzxy@Changes --- Add classic template-style button shortcuts
|
|
623
|
+
else if (hasOptionalProperty(button, 'phoneNumber') && !!button.phoneNumber) {
|
|
624
|
+
return {
|
|
625
|
+
name: 'call_button',
|
|
626
|
+
buttonParamsJson: JSON.stringify({
|
|
627
|
+
display_text: buttonText || '📞 Call',
|
|
628
|
+
phone_number: button.phoneNumber
|
|
629
|
+
})
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
else if (hasOptionalProperty(button, 'urlBtn') && !!button.urlBtn) {
|
|
633
|
+
return {
|
|
634
|
+
name: 'url_button',
|
|
635
|
+
buttonParamsJson: JSON.stringify({
|
|
636
|
+
display_text: buttonText || '🌐 Open',
|
|
637
|
+
url: button.urlBtn
|
|
638
|
+
})
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
else if (hasOptionalProperty(button, 'reply') && !!button.reply) {
|
|
642
|
+
return {
|
|
643
|
+
name: 'reply_button',
|
|
644
|
+
buttonParamsJson: JSON.stringify({
|
|
645
|
+
display_text: buttonText || button.reply,
|
|
646
|
+
id: button.id || button.reply
|
|
647
|
+
})
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
// Vanzxy@Changes --- Add order/payment lifecycle button shortcuts
|
|
651
|
+
else if (hasOptionalProperty(button, 'card') && !!button.card) {
|
|
652
|
+
return {
|
|
653
|
+
name: 'card_message',
|
|
654
|
+
buttonParamsJson: JSON.stringify(button.card)
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
else if (hasOptionalProperty(button, 'orderDetails') && !!button.orderDetails) {
|
|
658
|
+
return {
|
|
659
|
+
name: 'order_details',
|
|
660
|
+
buttonParamsJson: JSON.stringify(button.orderDetails)
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
else if (hasOptionalProperty(button, 'orderStatus') && !!button.orderStatus) {
|
|
664
|
+
return {
|
|
665
|
+
name: 'order_status',
|
|
666
|
+
buttonParamsJson: JSON.stringify(button.orderStatus)
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
else if (hasOptionalProperty(button, 'reviewAndPay') && !!button.reviewAndPay) {
|
|
670
|
+
return {
|
|
671
|
+
name: 'review_and_pay',
|
|
672
|
+
buttonParamsJson: JSON.stringify(button.reviewAndPay)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
else if (hasOptionalProperty(button, 'paymentStatus') && !!button.paymentStatus) {
|
|
676
|
+
return {
|
|
677
|
+
name: 'payment_status',
|
|
678
|
+
buttonParamsJson: JSON.stringify(button.paymentStatus)
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
else if (hasOptionalProperty(button, 'paymentMethod') && !!button.paymentMethod) {
|
|
682
|
+
return {
|
|
683
|
+
name: 'payment_method',
|
|
684
|
+
buttonParamsJson: JSON.stringify(button.paymentMethod)
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
else if (hasOptionalProperty(button, 'trackOrder') && !!button.trackOrder) {
|
|
688
|
+
return {
|
|
689
|
+
name: 'track_order',
|
|
690
|
+
buttonParamsJson: JSON.stringify({
|
|
691
|
+
id: button.id || button.trackOrder,
|
|
692
|
+
display_text: buttonText || '🚚 Track order'
|
|
693
|
+
})
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
else if (hasOptionalProperty(button, 'reorder') && !!button.reorder) {
|
|
697
|
+
return {
|
|
698
|
+
name: 'reorder',
|
|
699
|
+
buttonParamsJson: JSON.stringify({
|
|
700
|
+
id: button.id || button.reorder,
|
|
701
|
+
display_text: buttonText || '🔁 Reorder'
|
|
702
|
+
})
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
else if (hasOptionalProperty(button, 'cancelOrder') && !!button.cancelOrder) {
|
|
706
|
+
return {
|
|
707
|
+
name: 'cancel_order',
|
|
708
|
+
buttonParamsJson: JSON.stringify({
|
|
709
|
+
id: button.id || button.cancelOrder,
|
|
710
|
+
display_text: buttonText || '❌ Cancel order'
|
|
711
|
+
})
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
// Vanzxy@Changes --- Add navigation / utility button shortcuts
|
|
715
|
+
else if (hasOptionalProperty(button, 'clearChat') && button.clearChat === true) {
|
|
716
|
+
return {
|
|
717
|
+
name: 'clear_chat',
|
|
718
|
+
buttonParamsJson: JSON.stringify({})
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
else if (hasOptionalProperty(button, 'screen') && !!button.screen) {
|
|
722
|
+
return {
|
|
723
|
+
name: 'navigateToScreen',
|
|
724
|
+
buttonParamsJson: JSON.stringify({
|
|
725
|
+
screen_name: button.screen,
|
|
726
|
+
data: button.data || {}
|
|
727
|
+
})
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
// Vanzxy@Changes --- Add "flow_action" shortcut (WhatsApp Flows form)
|
|
731
|
+
else if (hasOptionalProperty(button, 'flow') && !!button.flow) {
|
|
732
|
+
return {
|
|
733
|
+
name: 'flow_action',
|
|
734
|
+
buttonParamsJson: JSON.stringify({
|
|
735
|
+
flow_message_version: button.flow.version || '3',
|
|
736
|
+
flow_id: button.flow.id,
|
|
737
|
+
flow_cta: buttonText || button.flow.cta || 'Continue',
|
|
738
|
+
flow_action: button.flow.action || 'navigate',
|
|
739
|
+
flow_action_payload: button.flow.actionPayload || {
|
|
740
|
+
screen: button.flow.screen || 'WELCOME',
|
|
741
|
+
data: button.flow.data || {}
|
|
742
|
+
}
|
|
743
|
+
})
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
// Vanzxy@Changes --- Add "voice_call" / "video_call_button" shortcuts
|
|
747
|
+
else if (hasOptionalProperty(button, 'voiceCall') && !!button.voiceCall) {
|
|
748
|
+
return {
|
|
749
|
+
name: 'voice_call',
|
|
750
|
+
buttonParamsJson: JSON.stringify({
|
|
751
|
+
display_text: buttonText || '📞 Voice call',
|
|
752
|
+
id: button.id || button.voiceCall
|
|
753
|
+
})
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
else if (hasOptionalProperty(button, 'videoCall') && !!button.videoCall) {
|
|
757
|
+
return {
|
|
758
|
+
name: 'video_call_button',
|
|
759
|
+
buttonParamsJson: JSON.stringify({
|
|
760
|
+
display_text: buttonText || '🎥 Video call',
|
|
761
|
+
id: button.id || button.videoCall
|
|
762
|
+
})
|
|
538
763
|
};
|
|
539
764
|
}
|
|
540
765
|
return button;
|
|
@@ -1130,6 +1355,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1130
1355
|
interactiveMessage.header = {
|
|
1131
1356
|
title: message.title || '',
|
|
1132
1357
|
subtitle: message.subtitle || '',
|
|
1358
|
+
hasMediaAttachment: isValidHeader
|
|
1133
1359
|
};
|
|
1134
1360
|
interactiveMessage.body = { text: message.caption };
|
|
1135
1361
|
}
|
|
@@ -1144,6 +1370,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1144
1370
|
}, options);
|
|
1145
1371
|
interactiveMessage.footer = {
|
|
1146
1372
|
audioMessage,
|
|
1373
|
+
hasMediaAttachment: true
|
|
1147
1374
|
};
|
|
1148
1375
|
}
|
|
1149
1376
|
else if (hasOptionalProperty(message, 'footer')) {
|
|
@@ -1177,6 +1404,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1177
1404
|
carouselCard.header = {
|
|
1178
1405
|
title: card.title || '',
|
|
1179
1406
|
subtitle: card.subtitle || '',
|
|
1407
|
+
hasMediaAttachment: isValidHeader
|
|
1180
1408
|
};
|
|
1181
1409
|
carouselCard.body = { text: card.caption };
|
|
1182
1410
|
}
|
|
@@ -1191,6 +1419,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1191
1419
|
}, options);
|
|
1192
1420
|
carouselCard.footer = {
|
|
1193
1421
|
audioMessage,
|
|
1422
|
+
hasMediaAttachment: true
|
|
1194
1423
|
};
|
|
1195
1424
|
}
|
|
1196
1425
|
else if (hasOptionalProperty(card, 'footer')) {
|
|
@@ -1413,12 +1642,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1413
1642
|
}
|
|
1414
1643
|
return WAProto.Message.create(m);
|
|
1415
1644
|
};
|
|
1416
|
-
const processImageMessage = (message, captionText) => {
|
|
1417
|
-
if (message.imageMessage) {
|
|
1418
|
-
message.imageMessage.caption = captionText;
|
|
1419
|
-
}
|
|
1420
|
-
return message;
|
|
1421
|
-
};
|
|
1422
1645
|
export const generateWAMessageFromContent = (jid, message, options) => {
|
|
1423
1646
|
// set timestamp to now
|
|
1424
1647
|
// if not specified
|
|
@@ -124,12 +124,31 @@ export function binaryNodeToString(node, i = 0) {
|
|
|
124
124
|
* @returns {object} A node with shape { tag, attrs, [content] } to inject into additionalNodes.
|
|
125
125
|
*/
|
|
126
126
|
const FLOWS_MAP = {
|
|
127
|
+
// Original flow types
|
|
127
128
|
mpm: true,
|
|
128
129
|
cta_catalog: true,
|
|
129
130
|
send_location: true,
|
|
130
131
|
call_permission_request: true,
|
|
131
132
|
wa_payment_transaction_details: true,
|
|
132
|
-
automated_greeting_message_view_catalog: true
|
|
133
|
+
automated_greeting_message_view_catalog: true,
|
|
134
|
+
// Vanzxy extended button types
|
|
135
|
+
card_message: true,
|
|
136
|
+
order_status: true,
|
|
137
|
+
track_order: true,
|
|
138
|
+
reorder: true,
|
|
139
|
+
cancel_order: true,
|
|
140
|
+
clear_chat: true,
|
|
141
|
+
navigateToScreen: true,
|
|
142
|
+
payment_status: true,
|
|
143
|
+
payment_method: true,
|
|
144
|
+
flow_action: true,
|
|
145
|
+
voice_call: true,
|
|
146
|
+
video_call_button: true,
|
|
147
|
+
otp_button: true,
|
|
148
|
+
authentication_button: true,
|
|
149
|
+
cta_reminder: true,
|
|
150
|
+
cta_cancel_reminder: true,
|
|
151
|
+
single_select: true,
|
|
133
152
|
};
|
|
134
153
|
const DECISION_SOURCE_CONTENT = [
|
|
135
154
|
{
|
|
@@ -168,10 +187,20 @@ export const getBizBinaryNode = (message) => {
|
|
|
168
187
|
host_storage: '2',
|
|
169
188
|
privacy_mode_ts: `${Date.now() / 1_000 | 0}`
|
|
170
189
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
190
|
+
const ORDER_RESPONSE_ALIAS = {
|
|
191
|
+
review_and_pay: 'order_details',
|
|
192
|
+
review_order: 'order_status',
|
|
193
|
+
payment_info: 'payment_info',
|
|
194
|
+
payment_status: 'payment_status',
|
|
195
|
+
payment_method: 'payment_method',
|
|
196
|
+
order_details: 'order_details',
|
|
197
|
+
order_status: 'order_status',
|
|
198
|
+
track_order: 'track_order',
|
|
199
|
+
reorder: 'reorder',
|
|
200
|
+
cancel_order: 'cancel_order',
|
|
201
|
+
};
|
|
202
|
+
if (firstButtonName && ORDER_RESPONSE_ALIAS[firstButtonName]) {
|
|
203
|
+
bizAttributes.native_flow_name = ORDER_RESPONSE_ALIAS[firstButtonName];
|
|
175
204
|
return {
|
|
176
205
|
tag: 'biz',
|
|
177
206
|
attrs: bizAttributes,
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './Defaults/index.js';
|
|
|
7
7
|
export * from './WABinary/index.js';
|
|
8
8
|
export * from './WAM/index.js';
|
|
9
9
|
export * from './WAUSync/index.js';
|
|
10
|
+
export { Dugong } from './Socket/dugong.js';
|
|
10
11
|
export { makeWASocket };
|
|
11
12
|
export default makeWASocket;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanzxy/baileys",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Enhanced Baileys fork by Vanzxy — based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
40
40
|
"@cacheable/node-cache": "^1.4.0",
|
|
41
41
|
"@hapi/boom": "^9.1.3",
|
|
42
|
-
"@vanzxy/baileys": "^1.1.
|
|
42
|
+
"@vanzxy/baileys": "^1.1.2",
|
|
43
43
|
"async-mutex": "^0.5.0",
|
|
44
44
|
"fflate": "^0.8.2",
|
|
45
45
|
"libsignal": "^6.0.0",
|