supun-bailey-vip 1.0.6 → 1.0.8
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/README.md +975 -14
- package/lib/defaults.js +6 -2
- package/lib/foundation/vip-license.js +115 -0
- package/lib/index.js +25 -0
- package/lib/socket/connect-bot.js +96 -0
- package/lib/socket/messages-send.js +77 -6
- package/lib/socket/newsletter.js +57 -2
- package/lib/socket/session-manager.js +144 -0
- package/lib/socket/socket-builder.js +185 -15
- package/lib/utils/button-builder.js +141 -0
- package/lib/utils/chat-extras.js +1379 -0
- package/lib/utils/console-filter.js +39 -0
- package/lib/utils/experimental-buttons.js +27 -0
- package/lib/utils/group-cache.js +148 -0
- package/lib/utils/html-format.js +344 -0
- package/lib/utils/interactive.js +369 -0
- package/lib/utils/live-wa-version.js +99 -0
- package/lib/utils/media.js +13 -12
- package/lib/utils/message-compose.js +144 -111
- package/lib/utils/message-processing.js +18 -2
- package/lib/utils/message-store.js +24 -0
- package/lib/utils/native-flow.js +6 -13
- package/lib/utils/pairing-utils.js +103 -0
- package/lib/utils/pretty-log.js +64 -0
- package/lib/utils/replies.js +190 -0
- package/lib/utils/send-queue.js +169 -0
- package/lib/utils/sender-utils.js +120 -0
- package/lib/utils/session-backup.js +65 -0
- package/lib/utils/vip-engine.js +1089 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
</p>
|
|
31
31
|
|
|
32
32
|
**Next-generation, all-in-one WhatsApp automation library — no browser required.**
|
|
33
|
-
High performance, enterprise-grade Baileys protocol engine featuring **Pairing Code & Terminal QR**, **MessageBuilder v4.7**, **VoIP Voice/Video Calls**, **
|
|
33
|
+
High performance, enterprise-grade Baileys protocol engine featuring **Pairing Code & Terminal QR**, **MessageBuilder v4.7**, **VoIP Voice/Video Calls**, **VIP Cloud Engine**, **Meta AI Live Reasoning & Planning Replay**, **AIRich UX Primitives**, **Performance Latency Tuning**, **Multi-DB Auth**, and **WhatsApp Flows**.
|
|
34
34
|
|
|
35
35
|
<br/>
|
|
36
36
|
|
|
@@ -65,9 +65,10 @@ High performance, enterprise-grade Baileys protocol engine featuring **Pairing C
|
|
|
65
65
|
- [🤖 Meta AI Reasoning & Planning Replay](#-meta-ai-reasoning--planning-replay)
|
|
66
66
|
- [💎 AIRich UX Primitives](#-airich-ux-primitives)
|
|
67
67
|
- [🎨 MessageBuilder v4.7 (Buttons & Carousels)](#-messagebuilder-v47-buttons--carousels)
|
|
68
|
+
- [🔘 Modern Native Buttons & Interactive System](#-modern-native-buttons--interactive-system)
|
|
68
69
|
- [🔘 Telegram-Style Interactive Buttons](#-telegram-style-interactive-buttons)
|
|
69
70
|
- [📋 WhatsApp Flows & Native Flow Handlers](#-whatsapp-flows--native-flow-handlers)
|
|
70
|
-
- [☁️
|
|
71
|
+
- [☁️ VIP Cloud Engine (`sock.cloud`)](#️-vip-cloud-engine-sockcloud)
|
|
71
72
|
- [📢 Status & Stories](#-status--stories)
|
|
72
73
|
- [👥 Group Management](#-group-management)
|
|
73
74
|
- [🏘️ Communities Management](#️-communities-management)
|
|
@@ -79,6 +80,11 @@ High performance, enterprise-grade Baileys protocol engine featuring **Pairing C
|
|
|
79
80
|
- [🆔 WhatsApp MEX Username API](#-whatsapp-mex-username-api)
|
|
80
81
|
- [⚡ Performance Tuning & Modes](#-performance-tuning--modes)
|
|
81
82
|
- [💾 In-Memory Store & Reporting Info Store](#-in-memory-store--reporting-info-store)
|
|
83
|
+
- [💼 Business Features (WhatsApp Business)](#-business-features-whatsapp-business)
|
|
84
|
+
- [💬 Comprehensive Chat Features & Shortcuts](#-comprehensive-chat-features--shortcuts)
|
|
85
|
+
- [🚀 ConnectBot & Multi-Session Manager](#-connectbot--multi-session-manager)
|
|
86
|
+
- [📦 Compressed Session Backup & Restore](#-compressed-session-backup--restore)
|
|
87
|
+
- [⏱️ Send Queue & Human Typing Simulation](#-send-queue--human-typing-simulation)
|
|
82
88
|
- [🌐 Community & Support](#-community--support)
|
|
83
89
|
- [📄 License](#-license)
|
|
84
90
|
|
|
@@ -96,7 +102,7 @@ High performance, enterprise-grade Baileys protocol engine featuring **Pairing C
|
|
|
96
102
|
- **AIRich UX Primitives**: Syntax-highlighted code blocks with lexers, formatted markdown tables, and Lottie stickers.
|
|
97
103
|
- **WhatsApp Flows**: Full parser and button generator for interactive native flows and forms.
|
|
98
104
|
- **MessageBuilder v4.7**: Fluent chaining API for CTA buttons, carousels, cards, and flows.
|
|
99
|
-
- **
|
|
105
|
+
- **VIP Cloud Engine**: High-level dispatcher for albums, payments, products, interactive messages, and group stories.
|
|
100
106
|
- **VoIP Calling Engine**: Handle, accept, reject WhatsApp voice and video calls with custom stream feeders.
|
|
101
107
|
- **Multi-DB Auth**: Ready-to-use adapters for MongoDB, Redis, PostgreSQL, MySQL, SQLite, Cache-Manager, KeyedDB, and Multi-file.
|
|
102
108
|
- **Separated Clean Modules**: High cohesion socket split across Groups, Newsletters, Business, and Communities.
|
|
@@ -447,14 +453,23 @@ await sock.sendMessage(jid, {
|
|
|
447
453
|
ptt: true // set true to send as Voice Recording
|
|
448
454
|
})
|
|
449
455
|
|
|
450
|
-
// 4. Document
|
|
456
|
+
// 4. Document (Supports up to 2GB / 3GB large files!)
|
|
451
457
|
await sock.sendMessage(jid, {
|
|
452
|
-
document:
|
|
453
|
-
mimetype: 'application/
|
|
454
|
-
fileName: '
|
|
458
|
+
document: { url: './movie_or_large_archive.zip' }, // Always use stream/url for large files (>100MB up to 2GB-3GB)
|
|
459
|
+
mimetype: 'application/zip',
|
|
460
|
+
fileName: 'Archive.zip',
|
|
461
|
+
caption: '📦 Large 2GB-3GB Archive'
|
|
455
462
|
})
|
|
456
463
|
|
|
457
|
-
// 5.
|
|
464
|
+
// 5. Large Video as Document (Up to 2GB / 3GB without WhatsApp media restriction)
|
|
465
|
+
await sock.sendMessage(jid, {
|
|
466
|
+
video: { url: './movie.mp4' },
|
|
467
|
+
asDocument: true, // Automatically sends as Document to bypass WhatsApp's 16-64MB video limit
|
|
468
|
+
fileName: 'Movie_1080p.mp4',
|
|
469
|
+
caption: '🎬 Full HD Movie (2GB+)'
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
// 6. Sticker
|
|
458
473
|
await sock.sendMessage(jid, {
|
|
459
474
|
sticker: fs.readFileSync('./sticker.webp')
|
|
460
475
|
})
|
|
@@ -844,6 +859,274 @@ await sock.sendMessage(jid, {
|
|
|
844
859
|
|
|
845
860
|
---
|
|
846
861
|
|
|
862
|
+
## 🔘 Modern Native Buttons & Interactive System
|
|
863
|
+
|
|
864
|
+
`supun-bailey-vip` includes a complete professional button and interactive suite: native buttons with automatic `<biz>` node rendering, multi-action types, button disabling, event listeners, experimental buttons, and smart interactive dialogs (confirmations, pagination, submenus, permissions guard, and repeatable actions).
|
|
865
|
+
|
|
866
|
+
### 1. Sending Native Buttons (`sock.sendButtons`)
|
|
867
|
+
|
|
868
|
+
Easily send messages with quick reply, URL, call, copy code, dropdown list, and in-app webview buttons:
|
|
869
|
+
|
|
870
|
+
```javascript
|
|
871
|
+
import { experimentalButtons } from 'supun-bailey-vip'
|
|
872
|
+
|
|
873
|
+
// Send all button types in one clean call
|
|
874
|
+
await sock.sendButtons(jid, {
|
|
875
|
+
text: 'Welcome to Supun VIP Bot! Please choose an option:',
|
|
876
|
+
footer: 'Powered by supun-bailey-vip',
|
|
877
|
+
buttons: [
|
|
878
|
+
{ text: '📌 Quick Reply', id: '#menu' },
|
|
879
|
+
{ text: '🌐 Visit Website', url: 'https://supunofc.site' },
|
|
880
|
+
{ text: '📋 Copy Promo Code', copy: 'SUPUNVIP' },
|
|
881
|
+
{ text: '📞 Call Helpline', call: '+94770000000' },
|
|
882
|
+
{ text: '🚀 Open Web App', url: 'https://app.supunofc.site', useWebview: true },
|
|
883
|
+
experimentalButtons.requestLocation('📍 Share Location')
|
|
884
|
+
]
|
|
885
|
+
})
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
### 2. Button Format Modes (`buttonsFormat`)
|
|
889
|
+
|
|
890
|
+
Control whether buttons are sent as modern interactive native flow or classic fallback:
|
|
891
|
+
|
|
892
|
+
```javascript
|
|
893
|
+
// Mode 1: Modern Interactive (Default) — Renders natively on Android, iOS, and Web
|
|
894
|
+
await sock.sendButtons(jid, {
|
|
895
|
+
text: 'Modern interactive buttons',
|
|
896
|
+
buttons: [{ text: 'Click Me', id: '#click' }]
|
|
897
|
+
})
|
|
898
|
+
|
|
899
|
+
// Mode 2: Classic ButtonsMessage — Replies sent as plain text across all clients
|
|
900
|
+
await sock.sendButtons(jid, {
|
|
901
|
+
text: 'Classic format buttons',
|
|
902
|
+
buttonsFormat: 'buttons',
|
|
903
|
+
buttons: [{ text: 'Option A', id: '#a' }]
|
|
904
|
+
})
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
### 3. Listening to Button & List Responses (`onButton`, `onList`, `onReply`)
|
|
908
|
+
|
|
909
|
+
Handle button taps cleanly without manually parsing messages in `messages.upsert`:
|
|
910
|
+
|
|
911
|
+
```javascript
|
|
912
|
+
// Listen to a specific button ID (with once: true support)
|
|
913
|
+
sock.onButton('#menu', async (msg, reply) => {
|
|
914
|
+
await sock.sendMessage(msg.key.remoteJid, { text: `Hello! You tapped: ${reply.text}` }, { quoted: msg })
|
|
915
|
+
})
|
|
916
|
+
|
|
917
|
+
// Listen to list / dropdown row selections
|
|
918
|
+
sock.onList('plan_pro', async (msg, reply) => {
|
|
919
|
+
console.log('Selected row:', reply.id)
|
|
920
|
+
})
|
|
921
|
+
|
|
922
|
+
// Global reply handler for any button, list, or template response
|
|
923
|
+
sock.onReply((reply) => reply.id.startsWith('cmd_'), async (msg, reply) => {
|
|
924
|
+
console.log(`Action dispatched: ${reply.id}`)
|
|
925
|
+
})
|
|
926
|
+
|
|
927
|
+
// Wait for a user's next message / reply
|
|
928
|
+
const userReply = await sock.awaitReply(msg, { timeoutMs: 30000 })
|
|
929
|
+
if (userReply) {
|
|
930
|
+
console.log('User replied with:', userReply.message)
|
|
931
|
+
}
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
### 4. Disabling Buttons After Click (`sock.disableButtons`)
|
|
935
|
+
|
|
936
|
+
Prevent double-clicks or expired button usage by editing the message to plain text:
|
|
937
|
+
|
|
938
|
+
```javascript
|
|
939
|
+
const sent = await sock.sendButtons(jid, {
|
|
940
|
+
text: 'Select your preferred subscription:',
|
|
941
|
+
buttons: [
|
|
942
|
+
{ text: 'Monthly ($5)', id: 'sub_month' },
|
|
943
|
+
{ text: 'Yearly ($50)', id: 'sub_year' }
|
|
944
|
+
]
|
|
945
|
+
})
|
|
946
|
+
|
|
947
|
+
// Once an option is chosen, disable the buttons
|
|
948
|
+
sock.onButton(/^sub_/, async (msg, reply) => {
|
|
949
|
+
await sock.disableButtons(sent, `✅ Selected plan: ${reply.text}`)
|
|
950
|
+
})
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### 5. Multi-Card Interactive Carousels (`sock.sendCarousel`)
|
|
954
|
+
|
|
955
|
+
Send sideways-scrolling carousels with up to 10 cards, each with its own media, body, and buttons:
|
|
956
|
+
|
|
957
|
+
```javascript
|
|
958
|
+
await sock.sendCarousel(jid, {
|
|
959
|
+
text: '🔥 Featured Products for Today',
|
|
960
|
+
cards: [
|
|
961
|
+
{
|
|
962
|
+
image: { url: 'https://example.com/item1.jpg' },
|
|
963
|
+
title: 'Supun Pro Bot',
|
|
964
|
+
body: 'Full WhatsApp automation package',
|
|
965
|
+
buttons: [{ text: '🛒 Order Now', id: 'order_pro' }]
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
image: { url: 'https://example.com/item2.jpg' },
|
|
969
|
+
title: 'VoIP Plugin',
|
|
970
|
+
body: 'Real-time voice and video calling',
|
|
971
|
+
buttons: [{ text: '🌐 View Demo', url: 'https://supunofc.site' }]
|
|
972
|
+
}
|
|
973
|
+
]
|
|
974
|
+
})
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
### 6. Dropdown Lists (`sock.sendList`)
|
|
978
|
+
|
|
979
|
+
Send organized single-select dropdown menus:
|
|
980
|
+
|
|
981
|
+
```javascript
|
|
982
|
+
await sock.sendList(jid, {
|
|
983
|
+
title: 'Service Catalog',
|
|
984
|
+
text: 'Choose a department to connect with:',
|
|
985
|
+
footer: '24/7 Customer Care',
|
|
986
|
+
buttonText: 'View Departments',
|
|
987
|
+
sections: [
|
|
988
|
+
{
|
|
989
|
+
title: 'Technical Support',
|
|
990
|
+
rows: [
|
|
991
|
+
{ id: 'tech_bot', title: 'Bot Issues', description: 'Help with bot deployment' },
|
|
992
|
+
{ id: 'tech_api', title: 'API Integration', description: 'Custom webhook support' }
|
|
993
|
+
]
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
title: 'Sales & Billing',
|
|
997
|
+
rows: [
|
|
998
|
+
{ id: 'sales_vip', title: 'VIP License', description: 'Purchase VIP subscription' }
|
|
999
|
+
]
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
})
|
|
1003
|
+
|
|
1004
|
+
// Or pass a flat rows array directly without wrapping in sections:
|
|
1005
|
+
await sock.sendList(jid, {
|
|
1006
|
+
title: 'Quick Menu',
|
|
1007
|
+
text: 'Select your preferred action:',
|
|
1008
|
+
buttonText: 'Open Menu',
|
|
1009
|
+
rows: [
|
|
1010
|
+
{ id: 'row_1', title: 'Option 1', description: 'First feature description' },
|
|
1011
|
+
{ id: 'row_2', title: 'Option 2', description: 'Second feature description' },
|
|
1012
|
+
{ id: 'row_3', title: 'Option 3', description: 'Third feature description' }
|
|
1013
|
+
]
|
|
1014
|
+
})
|
|
1015
|
+
|
|
1016
|
+
// You can also mix Row Buttons inside sendButtons alongside other action buttons:
|
|
1017
|
+
await sock.sendButtons(jid, {
|
|
1018
|
+
text: 'Dashboard Menu:',
|
|
1019
|
+
buttons: [
|
|
1020
|
+
{ text: '⚡ Quick Action', id: '#quick' },
|
|
1021
|
+
{
|
|
1022
|
+
text: '📋 View All Rows',
|
|
1023
|
+
rows: [
|
|
1024
|
+
{ id: 'row_a', title: 'Row Item A', description: 'Detailed info A' },
|
|
1025
|
+
{ id: 'row_b', title: 'Row Item B', description: 'Detailed info B' }
|
|
1026
|
+
]
|
|
1027
|
+
},
|
|
1028
|
+
{ text: '🌐 Official Website', url: 'https://supunofc.site' }
|
|
1029
|
+
]
|
|
1030
|
+
})
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
### 7. Smart Interactive Dialogs (`sock.interactive`)
|
|
1034
|
+
|
|
1035
|
+
Built-in stateful helpers for confirmations, pagination, multi-level menus, and permissions:
|
|
1036
|
+
|
|
1037
|
+
```javascript
|
|
1038
|
+
// A. Confirm Dialog (Yes / No) — Returns boolean Promise & auto-disables buttons
|
|
1039
|
+
const confirmed = await sock.confirm(msg, 'Are you sure you want to clear the logs?')
|
|
1040
|
+
if (confirmed) {
|
|
1041
|
+
await sock.sendMessage(msg.key.remoteJid, { text: 'Logs cleared successfully!' })
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// B. Interactive Pagination with Auto Prev / Next
|
|
1045
|
+
const items = Array.from({ length: 25 }, (_, i) => `Item #${i + 1} - Product Details`)
|
|
1046
|
+
await sock.paginate(msg, items, {
|
|
1047
|
+
title: '📦 Inventory List',
|
|
1048
|
+
perPage: 5,
|
|
1049
|
+
prevText: '◀ Back',
|
|
1050
|
+
nextText: 'Next ▶'
|
|
1051
|
+
})
|
|
1052
|
+
|
|
1053
|
+
// C. Nested Menus with Submenus and Auto Back (Volver)
|
|
1054
|
+
await sock.menu(msg, {
|
|
1055
|
+
title: 'Main System Menu',
|
|
1056
|
+
buttonText: 'Select Option',
|
|
1057
|
+
items: [
|
|
1058
|
+
{
|
|
1059
|
+
title: 'Settings',
|
|
1060
|
+
items: [
|
|
1061
|
+
{ title: 'Change Language', run: async (tap) => console.log('Lang selected') },
|
|
1062
|
+
{ title: 'Notifications', run: async (tap) => console.log('Notif selected') }
|
|
1063
|
+
]
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
title: 'Account Info',
|
|
1067
|
+
text: 'Your account is active and verified.'
|
|
1068
|
+
}
|
|
1069
|
+
]
|
|
1070
|
+
})
|
|
1071
|
+
|
|
1072
|
+
// D. Guarded Buttons (Only target user or admins can click)
|
|
1073
|
+
await sock.sendGuardedButtons(msg, {
|
|
1074
|
+
text: 'Admin Management Panel',
|
|
1075
|
+
buttons: [{ id: 'admin_reboot', text: '⚡ Reboot Server' }],
|
|
1076
|
+
who: 'admins', // 'admins' | 'sender' | 'anyone' | (tap, msg) => boolean
|
|
1077
|
+
once: true,
|
|
1078
|
+
denied: '🚫 Only group administrators can use this button.'
|
|
1079
|
+
}, async (tap) => {
|
|
1080
|
+
console.log('Authorized admin clicked reboot:', tap.sender.number)
|
|
1081
|
+
})
|
|
1082
|
+
|
|
1083
|
+
// E. Repeatable Action Button (Refresh / Again)
|
|
1084
|
+
let count = 0
|
|
1085
|
+
await sock.sendRepeatable(msg, () => {
|
|
1086
|
+
count++
|
|
1087
|
+
return `Random Lucky Number: ${Math.floor(Math.random() * 1000)} (Generated: ${count} times)`
|
|
1088
|
+
}, { buttonText: '🔁 Generate Again', maxRepeats: 10 })
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
### 8. Experimental Native Flow Buttons (`experimentalButtons`)
|
|
1092
|
+
|
|
1093
|
+
Access newer WhatsApp native flow button types:
|
|
1094
|
+
|
|
1095
|
+
```javascript
|
|
1096
|
+
import { experimentalButtons } from 'supun-bailey-vip'
|
|
1097
|
+
|
|
1098
|
+
await sock.sendButtons(jid, {
|
|
1099
|
+
text: 'Advanced Actions:',
|
|
1100
|
+
buttons: [
|
|
1101
|
+
experimentalButtons.requestLocation('📍 Send Location'),
|
|
1102
|
+
experimentalButtons.reminder('⏰ Remind Me Later'),
|
|
1103
|
+
experimentalButtons.cancelReminder('🚫 Cancel Reminder'),
|
|
1104
|
+
experimentalButtons.address('🏠 Enter Shipping Address'),
|
|
1105
|
+
experimentalButtons.webview('🌐 Open Webview', 'https://supunofc.site'),
|
|
1106
|
+
experimentalButtons.custom('cta_call', { display_text: 'Custom Call', phone_number: '+94770000000' })
|
|
1107
|
+
]
|
|
1108
|
+
})
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
### 9. Sender & Identity Resolvers (`getSender`, `isAdmin`, `isBotAdmin`)
|
|
1112
|
+
|
|
1113
|
+
Identify users accurately across phone numbers and LIDs:
|
|
1114
|
+
|
|
1115
|
+
```javascript
|
|
1116
|
+
// Resolve who sent the message (resolves phone number, LID, name, group status)
|
|
1117
|
+
const sender = await sock.getSender(msg)
|
|
1118
|
+
console.log('Phone number:', sender.number)
|
|
1119
|
+
console.log('LID ID:', sender.id)
|
|
1120
|
+
console.log('Is Sender from me:', sender.fromMe)
|
|
1121
|
+
console.log('Is specific number:', sender.is('94770000000'))
|
|
1122
|
+
|
|
1123
|
+
// Check admin status accurately
|
|
1124
|
+
const isUserAdmin = await sock.isAdmin(groupJid, sender)
|
|
1125
|
+
const isBotAdmin = await sock.isBotAdmin(groupJid)
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
---
|
|
1129
|
+
|
|
847
1130
|
## 🔘 Telegram-Style Interactive Buttons
|
|
848
1131
|
|
|
849
1132
|
Experience Telegram-like interactive buttons inside WhatsApp using native protocol flows:
|
|
@@ -1051,12 +1334,12 @@ sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
|
1051
1334
|
|
|
1052
1335
|
---
|
|
1053
1336
|
|
|
1054
|
-
## ☁️
|
|
1337
|
+
## ☁️ VIP Cloud Engine (`sock.cloud` / `sock.vipEngine`)
|
|
1055
1338
|
|
|
1056
|
-
Access
|
|
1339
|
+
Access VIP high-level interactive handlers directly:
|
|
1057
1340
|
|
|
1058
1341
|
```javascript
|
|
1059
|
-
// 1. Native Interactive Buttons via
|
|
1342
|
+
// 1. Native Interactive Buttons via VIP Cloud Engine
|
|
1060
1343
|
await sock.cloud.handleInteractiveButtons({
|
|
1061
1344
|
title: 'Bot Dashboard',
|
|
1062
1345
|
text: 'Choose your desired service below:',
|
|
@@ -1158,6 +1441,32 @@ await sock.groupRevokeInvite(groupJid) // Revoke link
|
|
|
1158
1441
|
const requests = await sock.groupRequestParticipantsList(groupJid)
|
|
1159
1442
|
await sock.groupRequestParticipantsUpdate(groupJid, [requests[0].jid], 'approve')
|
|
1160
1443
|
|
|
1444
|
+
// Member Label / Group Tag
|
|
1445
|
+
await sock.setLabelGroup(groupJid, 'VIP Member')
|
|
1446
|
+
// or: await sock.updateMemberLabel(groupJid, 'VIP Member')
|
|
1447
|
+
|
|
1448
|
+
// Member Add Mode & Join Approval Mode
|
|
1449
|
+
await sock.groupMemberAddMode(groupJid, 'all_member_add') // or 'admin_add'
|
|
1450
|
+
await sock.groupJoinApprovalMode(groupJid, 'on') // or 'off'
|
|
1451
|
+
|
|
1452
|
+
// Chat Labels & Message Labels (Business Labels)
|
|
1453
|
+
import { LabelColor, LabelAssociationType } from 'supun-bailey-vip'
|
|
1454
|
+
|
|
1455
|
+
// Add / Remove label on a Chat or Group
|
|
1456
|
+
await sock.addChatLabel(groupJid, '1')
|
|
1457
|
+
await sock.removeChatLabel(groupJid, '1')
|
|
1458
|
+
|
|
1459
|
+
// Add / Remove label on a specific message
|
|
1460
|
+
await sock.addMessageLabel(groupJid, msg.key.id, '1')
|
|
1461
|
+
await sock.removeMessageLabel(groupJid, msg.key.id, '1')
|
|
1462
|
+
|
|
1463
|
+
// Create custom label
|
|
1464
|
+
await sock.addLabel(groupJid, {
|
|
1465
|
+
name: 'Important Clients',
|
|
1466
|
+
color: LabelColor.Color1,
|
|
1467
|
+
deleted: false
|
|
1468
|
+
})
|
|
1469
|
+
|
|
1161
1470
|
// Bulk Send to Group Members (with safety delay)
|
|
1162
1471
|
await sock.sendMessageMembers(groupJid, { text: 'Notification to all members!' }, {
|
|
1163
1472
|
delayMs: 2000,
|
|
@@ -1165,6 +1474,173 @@ await sock.sendMessageMembers(groupJid, { text: 'Notification to all members!' }
|
|
|
1165
1474
|
})
|
|
1166
1475
|
```
|
|
1167
1476
|
|
|
1477
|
+
---
|
|
1478
|
+
|
|
1479
|
+
## 🌟 VIP Advanced Engine & Handlers
|
|
1480
|
+
|
|
1481
|
+
Full support for rich menus, Instagram previews, and advanced VIP message types:
|
|
1482
|
+
|
|
1483
|
+
### 1. Rich AI Menu (`sock.richMenu`)
|
|
1484
|
+
|
|
1485
|
+
```javascript
|
|
1486
|
+
await sock.richMenu(jid, {
|
|
1487
|
+
header: {
|
|
1488
|
+
title: '🌟 Main Bot Menu',
|
|
1489
|
+
disclaimer: true,
|
|
1490
|
+
disclaimerText: 'Automated by Baileys VIP',
|
|
1491
|
+
image: { url: 'https://example.com/banner.png', inline: false }
|
|
1492
|
+
},
|
|
1493
|
+
body: {
|
|
1494
|
+
title: 'Select a category:',
|
|
1495
|
+
toast: 'Opening service...',
|
|
1496
|
+
carousel: true, // or row: true
|
|
1497
|
+
cards: [
|
|
1498
|
+
{
|
|
1499
|
+
title: '⚡ Fast Tools',
|
|
1500
|
+
toast: 'Tool chosen',
|
|
1501
|
+
buttons: ['Converter', 'Downloader']
|
|
1502
|
+
},
|
|
1503
|
+
{
|
|
1504
|
+
title: '🎮 Games & Fun',
|
|
1505
|
+
toast: 'Game chosen',
|
|
1506
|
+
buttons: ['Trivia', 'Riddle']
|
|
1507
|
+
}
|
|
1508
|
+
]
|
|
1509
|
+
},
|
|
1510
|
+
footer: {
|
|
1511
|
+
text: 'Join Official Channel',
|
|
1512
|
+
url: 'https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07'
|
|
1513
|
+
}
|
|
1514
|
+
})
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1517
|
+
### 2. Instagram Profile View Card (`sock.sendInstaView`)
|
|
1518
|
+
|
|
1519
|
+
```javascript
|
|
1520
|
+
// Sends a verified Instagram entity card with preview thumbnail & direct link
|
|
1521
|
+
await sock.sendInstaView(jid, 'supunfernando', 'https://example.com/profile.jpg')
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
### 3. Dynamic HTML App (`sock.sendHtml`)
|
|
1525
|
+
|
|
1526
|
+
```javascript
|
|
1527
|
+
await sock.sendHtml(jid, `
|
|
1528
|
+
<div style="background:#121b22; color:#fff; padding:15px; border-radius:10px;">
|
|
1529
|
+
<h2>VIP Dashboard</h2>
|
|
1530
|
+
<p>Real-time analytics and controls.</p>
|
|
1531
|
+
</div>
|
|
1532
|
+
`)
|
|
1533
|
+
```
|
|
1534
|
+
|
|
1535
|
+
### 4. Status Broadcast with Mentions (`sock.sendStatusMention`)
|
|
1536
|
+
|
|
1537
|
+
```javascript
|
|
1538
|
+
// Broadcasts to status@broadcast and notifies targeted users/groups
|
|
1539
|
+
await sock.sendStatusMention(
|
|
1540
|
+
{
|
|
1541
|
+
text: '🔥 New release 1.0.8 is live!',
|
|
1542
|
+
backgroundColor: '#8D153A',
|
|
1543
|
+
font: 2
|
|
1544
|
+
},
|
|
1545
|
+
['94712345678@s.whatsapp.net', '12036302@g.us']
|
|
1546
|
+
)
|
|
1547
|
+
```
|
|
1548
|
+
|
|
1549
|
+
### 5. Check WhatsApp & Request Pairing Codes
|
|
1550
|
+
|
|
1551
|
+
```javascript
|
|
1552
|
+
// Check ban or official WA restriction status
|
|
1553
|
+
const status = await sock.checkWhatsApp('94712345678')
|
|
1554
|
+
console.log(status) // { isBanned: false, isNeedOfficialWa: false, exists: true }
|
|
1555
|
+
|
|
1556
|
+
// Request pairing code multiple times
|
|
1557
|
+
const codes = await sock.reqPairing('94712345678', 3)
|
|
1558
|
+
console.log(codes)
|
|
1559
|
+
```
|
|
1560
|
+
|
|
1561
|
+
### 6. VIP Message Types in `sendMessage`
|
|
1562
|
+
|
|
1563
|
+
```javascript
|
|
1564
|
+
// 1. Payment Request
|
|
1565
|
+
await sock.sendMessage(jid, {
|
|
1566
|
+
requestPaymentMessage: {
|
|
1567
|
+
amount: 50000,
|
|
1568
|
+
currency: 'USD',
|
|
1569
|
+
note: 'Payment for Baileys VIP Subscription'
|
|
1570
|
+
}
|
|
1571
|
+
})
|
|
1572
|
+
|
|
1573
|
+
// 2. Interactive Product Message with Buttons
|
|
1574
|
+
await sock.sendMessage(jid, {
|
|
1575
|
+
productMessage: {
|
|
1576
|
+
title: 'VIP Software License',
|
|
1577
|
+
description: 'Lifetime access to all updates',
|
|
1578
|
+
priceAmount1000: 50000000,
|
|
1579
|
+
currencyCode: 'USD',
|
|
1580
|
+
body: 'Click below to order:',
|
|
1581
|
+
footer: 'Supun Fernando',
|
|
1582
|
+
buttons: [
|
|
1583
|
+
{
|
|
1584
|
+
name: 'cta_url',
|
|
1585
|
+
buttonParamsJson: JSON.stringify({
|
|
1586
|
+
display_text: 'Buy Now',
|
|
1587
|
+
url: 'https://supunofc.site'
|
|
1588
|
+
})
|
|
1589
|
+
}
|
|
1590
|
+
]
|
|
1591
|
+
}
|
|
1592
|
+
})
|
|
1593
|
+
|
|
1594
|
+
// 3. Interactive Message with Native Flow & Media
|
|
1595
|
+
await sock.sendMessage(jid, {
|
|
1596
|
+
interactiveMessage: {
|
|
1597
|
+
title: 'Interactive Message',
|
|
1598
|
+
footer: 'Powered by Baileys VIP',
|
|
1599
|
+
header: 'Welcome!',
|
|
1600
|
+
image: 'https://example.com/header.jpg',
|
|
1601
|
+
buttons: [
|
|
1602
|
+
{
|
|
1603
|
+
name: 'quick_reply',
|
|
1604
|
+
buttonParamsJson: JSON.stringify({
|
|
1605
|
+
display_text: 'Accept Terms',
|
|
1606
|
+
id: 'btn_terms'
|
|
1607
|
+
})
|
|
1608
|
+
}
|
|
1609
|
+
]
|
|
1610
|
+
}
|
|
1611
|
+
})
|
|
1612
|
+
|
|
1613
|
+
// 4. Album Message
|
|
1614
|
+
await sock.sendMessage(jid, {
|
|
1615
|
+
albumMessage: [
|
|
1616
|
+
{ image: fs.readFileSync('./photo1.jpg'), caption: 'Photo 1' },
|
|
1617
|
+
{ image: fs.readFileSync('./photo2.jpg'), caption: 'Photo 2' }
|
|
1618
|
+
]
|
|
1619
|
+
})
|
|
1620
|
+
|
|
1621
|
+
// 5. Event Message
|
|
1622
|
+
await sock.sendMessage(jid, {
|
|
1623
|
+
eventMessage: {
|
|
1624
|
+
name: 'VIP Developer Meetup',
|
|
1625
|
+
description: 'Monthly Q&A with Supun Fernando',
|
|
1626
|
+
startTime: Date.now() + 86400000,
|
|
1627
|
+
endTime: Date.now() + 90000000,
|
|
1628
|
+
location: { degreesLatitude: 6.9271, degreesLongitude: 79.8612, name: 'Colombo' }
|
|
1629
|
+
}
|
|
1630
|
+
})
|
|
1631
|
+
|
|
1632
|
+
// 6. Poll Result Message
|
|
1633
|
+
await sock.sendMessage(jid, {
|
|
1634
|
+
pollResultMessage: {
|
|
1635
|
+
name: 'Community Vote Result',
|
|
1636
|
+
pollVotes: [
|
|
1637
|
+
{ optionName: 'Feature A', optionVoteCount: 45 },
|
|
1638
|
+
{ optionName: 'Feature B', optionVoteCount: 120 }
|
|
1639
|
+
]
|
|
1640
|
+
}
|
|
1641
|
+
})
|
|
1642
|
+
|
|
1643
|
+
|
|
1168
1644
|
---
|
|
1169
1645
|
|
|
1170
1646
|
## 🏘️ Communities Management
|
|
@@ -1195,9 +1671,22 @@ Create and interact with WhatsApp Channels (Newsletters) with dedicated status s
|
|
|
1195
1671
|
// Create Channel
|
|
1196
1672
|
const newsletter = await sock.newsletterCreate('Tech Updates', 'Latest technology news')
|
|
1197
1673
|
|
|
1198
|
-
// Follow & Unfollow
|
|
1199
|
-
await sock.newsletterFollow(
|
|
1200
|
-
await sock.newsletterUnfollow(
|
|
1674
|
+
// Follow & Unfollow (Supports Channel Link, Invite Code, or @newsletter JID!)
|
|
1675
|
+
await sock.newsletterFollow('https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07')
|
|
1676
|
+
await sock.newsletterUnfollow('https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07')
|
|
1677
|
+
|
|
1678
|
+
// Batch Auto-Follow Channels (with anti-ban delay)
|
|
1679
|
+
await sock.newsletterAutoFollow([
|
|
1680
|
+
'https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07',
|
|
1681
|
+
'https://whatsapp.com/channel/0029VaXXXXX'
|
|
1682
|
+
], { delayMs: 2500, onProgress: ({ index, total, channel, success }) => console.log(`[${index}/${total}] Followed ${channel}: ${success}`) })
|
|
1683
|
+
|
|
1684
|
+
// Boost Channel Followers using Multi-Sessions
|
|
1685
|
+
// Pass an array of active sockets or a makeSessionManager instance:
|
|
1686
|
+
await sock.boostChannelFollowers('https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07', sessionManager, {
|
|
1687
|
+
delayMs: 3000,
|
|
1688
|
+
onProgress: (p) => console.log(`Session ${p.user} joined channel!`)
|
|
1689
|
+
})
|
|
1201
1690
|
|
|
1202
1691
|
// Mute & Unmute
|
|
1203
1692
|
await sock.newsletterMute(newsletterJid)
|
|
@@ -1205,6 +1694,13 @@ await sock.newsletterUnmute(newsletterJid)
|
|
|
1205
1694
|
|
|
1206
1695
|
// React to Channel Post
|
|
1207
1696
|
await sock.newsletterReactMessage(newsletterJid, serverId, '🔥')
|
|
1697
|
+
// Or use universal react helper:
|
|
1698
|
+
await sock.react(channelMsg, '❤️')
|
|
1699
|
+
|
|
1700
|
+
// Vote on a WhatsApp Channel Poll
|
|
1701
|
+
await sock.newsletterSendPollVote(newsletterJid, serverId, ['Option 1'])
|
|
1702
|
+
// Or use universal votePoll helper:
|
|
1703
|
+
await sock.votePoll(newsletterJid, ['Option 1'], { serverId })
|
|
1208
1704
|
|
|
1209
1705
|
// Publish Newsletter Status Story
|
|
1210
1706
|
await sock.sendNewsletterStatus(newsletterJid, {
|
|
@@ -1383,6 +1879,471 @@ sock.reportingInfoStore.add('94712345678@s.whatsapp.net', {
|
|
|
1383
1879
|
|
|
1384
1880
|
---
|
|
1385
1881
|
|
|
1882
|
+
## 💼 Business Features (WhatsApp Business)
|
|
1883
|
+
|
|
1884
|
+
`supun-bailey-vip` provides full-fledged support for WhatsApp Business APIs, including catalogs, products, order management, business profiles, quick replies, and labels.
|
|
1885
|
+
|
|
1886
|
+
### 1. Business Profile & Cover Photo
|
|
1887
|
+
```javascript
|
|
1888
|
+
// Fetch business profile of any business account
|
|
1889
|
+
const profile = await sock.getBusinessProfile('94771234567@s.whatsapp.net')
|
|
1890
|
+
console.log(profile.description, profile.email, profile.websites, profile.hours)
|
|
1891
|
+
|
|
1892
|
+
// Update your own business profile
|
|
1893
|
+
await sock.updateBusinessProfile({
|
|
1894
|
+
description: 'Premier Software & WhatsApp Bot Development',
|
|
1895
|
+
email: 'contact@supunofc.site',
|
|
1896
|
+
address: 'Colombo, Sri Lanka',
|
|
1897
|
+
websites: ['https://supunofc.site'],
|
|
1898
|
+
hours: {
|
|
1899
|
+
timezone: 'Asia/Colombo',
|
|
1900
|
+
days: [
|
|
1901
|
+
{ day: 'monday', mode: 'specific_hours', openTimeInMinutes: 540, closeTimeInMinutes: 1080 },
|
|
1902
|
+
{ day: 'tuesday', mode: 'specific_hours', openTimeInMinutes: 540, closeTimeInMinutes: 1080 }
|
|
1903
|
+
]
|
|
1904
|
+
}
|
|
1905
|
+
})
|
|
1906
|
+
|
|
1907
|
+
// Update or remove cover photo
|
|
1908
|
+
await sock.updateCoverPhoto(fs.readFileSync('./cover.jpg'))
|
|
1909
|
+
await sock.removeCoverPhoto()
|
|
1910
|
+
```
|
|
1911
|
+
|
|
1912
|
+
### 2. Catalog & Product Management
|
|
1913
|
+
```javascript
|
|
1914
|
+
// Fetch products from catalog
|
|
1915
|
+
const catalog = await sock.getCatalog({ jid: '94771234567@s.whatsapp.net', limit: 10 })
|
|
1916
|
+
console.log(catalog.products)
|
|
1917
|
+
|
|
1918
|
+
// Fetch catalog collections
|
|
1919
|
+
const collections = await sock.getCollections('94771234567@s.whatsapp.net', 10)
|
|
1920
|
+
|
|
1921
|
+
// Create a new product in your catalog
|
|
1922
|
+
const newProduct = await sock.productCreate({
|
|
1923
|
+
name: 'VIP Bot Premium License',
|
|
1924
|
+
description: 'Lifetime access to all VIP bot features',
|
|
1925
|
+
price: 1500000, // in minor currency units (e.g. cents)
|
|
1926
|
+
currency: 'LKR',
|
|
1927
|
+
retailerId: 'LIC-001',
|
|
1928
|
+
url: 'https://supunofc.site',
|
|
1929
|
+
images: [{ image: fs.readFileSync('./license.png') }]
|
|
1930
|
+
})
|
|
1931
|
+
|
|
1932
|
+
// Update existing product
|
|
1933
|
+
await sock.productUpdate(newProduct.id, {
|
|
1934
|
+
name: 'VIP Bot Premium License - 2026 Edition',
|
|
1935
|
+
price: 1200000
|
|
1936
|
+
})
|
|
1937
|
+
|
|
1938
|
+
// Delete products
|
|
1939
|
+
await sock.productDelete([newProduct.id])
|
|
1940
|
+
|
|
1941
|
+
// Fetch order details
|
|
1942
|
+
const order = await sock.getOrderDetails('ORDER_ID_123', 'TOKEN_ABC')
|
|
1943
|
+
```
|
|
1944
|
+
|
|
1945
|
+
### 3. Quick Replies & Contacts
|
|
1946
|
+
```javascript
|
|
1947
|
+
// Add or edit quick reply
|
|
1948
|
+
await sock.addOrEditQuickReply({
|
|
1949
|
+
shortcut: 'thanks',
|
|
1950
|
+
message: 'Thank you for reaching out to Supun Fernando! How can I assist you today?'
|
|
1951
|
+
})
|
|
1952
|
+
|
|
1953
|
+
// Remove quick reply
|
|
1954
|
+
await sock.removeQuickReply('QUICK_REPLY_ID')
|
|
1955
|
+
|
|
1956
|
+
// Add or remove WhatsApp contact
|
|
1957
|
+
await sock.addOrEditContact('94771234567@s.whatsapp.net', { firstName: 'Supun', lastName: 'Fernando' })
|
|
1958
|
+
await sock.removeContact('94771234567@s.whatsapp.net')
|
|
1959
|
+
```
|
|
1960
|
+
|
|
1961
|
+
### 4. Labels & Chat/Message Labels
|
|
1962
|
+
```javascript
|
|
1963
|
+
// Add a business label
|
|
1964
|
+
const label = await sock.addLabel('VIP Customers', '#00534E')
|
|
1965
|
+
|
|
1966
|
+
// Label or unlabel a chat
|
|
1967
|
+
await sock.addChatLabel('94771234567@s.whatsapp.net', label.id)
|
|
1968
|
+
await sock.removeChatLabel('94771234567@s.whatsapp.net', label.id)
|
|
1969
|
+
|
|
1970
|
+
// Label or unlabel a specific message
|
|
1971
|
+
await sock.addMessageLabel('94771234567@s.whatsapp.net', 'MSG_ID_123', label.id)
|
|
1972
|
+
await sock.removeMessageLabel('94771234567@s.whatsapp.net', 'MSG_ID_123', label.id)
|
|
1973
|
+
```
|
|
1974
|
+
|
|
1975
|
+
---
|
|
1976
|
+
|
|
1977
|
+
## 💬 Comprehensive Chat Features & Shortcuts
|
|
1978
|
+
|
|
1979
|
+
High-level convenience helpers:
|
|
1980
|
+
|
|
1981
|
+
### 1. Shortcuts (`reply`, `react`, `sendSafe`, `ask`, `tagAll`)
|
|
1982
|
+
```javascript
|
|
1983
|
+
// Fast reply with string or content
|
|
1984
|
+
await sock.reply(msg, 'Hello from Supun Bailey VIP!')
|
|
1985
|
+
await sock.reply(msg, { image: { url: 'https://example.com/pic.jpg' }, caption: 'Here is your photo!' })
|
|
1986
|
+
|
|
1987
|
+
// Emoji reactions (pass '' to remove reaction, works on DMs, Groups and Channels!)
|
|
1988
|
+
await sock.react(msg, '🦁')
|
|
1989
|
+
await sock.react(msg, '')
|
|
1990
|
+
|
|
1991
|
+
// Auto-React to Incoming Messages
|
|
1992
|
+
const reactor = sock.autoReact({
|
|
1993
|
+
emojis: ['❤️', '🔥', '👍', '🎉', '👏', '🦁', '💯', '✨'], // Pool of random emojis or single emoji
|
|
1994
|
+
delayMs: 1200, // anti-ban delay
|
|
1995
|
+
ignoreMe: true
|
|
1996
|
+
})
|
|
1997
|
+
// reactor.stop() // Call anytime to disable auto-reactions
|
|
1998
|
+
|
|
1999
|
+
// Safe send (never throws, returns status: 'sent' | 'failed' | 'unknown')
|
|
2000
|
+
const res = await sock.sendSafe(jid, 'Safe message without try/catch', {}, { timeoutMs: 15000 })
|
|
2001
|
+
if (res.status === 'sent') console.log('Delivered message ID:', res.message.key.id)
|
|
2002
|
+
|
|
2003
|
+
// Tag all group members cleanly
|
|
2004
|
+
await sock.tagAll('120363012345678901@g.us', '📢 Attention everyone!')
|
|
2005
|
+
|
|
2006
|
+
// Ask a question and wait for the same user's response
|
|
2007
|
+
const answer = await sock.ask(msg, 'What is your username?', { timeoutMs: 60000 })
|
|
2008
|
+
console.log('User answered:', answer)
|
|
2009
|
+
```
|
|
2010
|
+
|
|
2011
|
+
### 2. Media Download with Auto-Reupload
|
|
2012
|
+
```javascript
|
|
2013
|
+
// Download media from direct message or quoted message with automatic re-upload fallback
|
|
2014
|
+
const buffer = await sock.downloadMedia(msg)
|
|
2015
|
+
fs.writeFileSync('./downloaded.jpg', buffer)
|
|
2016
|
+
|
|
2017
|
+
// Download from quoted message
|
|
2018
|
+
const quotedBuffer = await sock.downloadMedia(msg, { quoted: true })
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
### 3. Native vCard Contacts & Location Pins
|
|
2022
|
+
```javascript
|
|
2023
|
+
// Send vCard 3.0 contact cards with native waid buttons
|
|
2024
|
+
await sock.sendContact(jid, {
|
|
2025
|
+
name: 'Supun Fernando',
|
|
2026
|
+
number: '+94 77 123 4567',
|
|
2027
|
+
organization: 'VIP Bot Team'
|
|
2028
|
+
})
|
|
2029
|
+
|
|
2030
|
+
// Send multiple contacts at once
|
|
2031
|
+
await sock.sendContact(jid, [
|
|
2032
|
+
{ name: 'Alice', number: '+1 234 567 8901' },
|
|
2033
|
+
{ name: 'Bob', number: '+44 7123 456789' }
|
|
2034
|
+
])
|
|
2035
|
+
|
|
2036
|
+
// Send map pin location
|
|
2037
|
+
await sock.sendLocation(jid, {
|
|
2038
|
+
latitude: 6.9271,
|
|
2039
|
+
longitude: 79.8612,
|
|
2040
|
+
name: 'Colombo',
|
|
2041
|
+
address: 'Western Province, Sri Lanka'
|
|
2042
|
+
})
|
|
2043
|
+
```
|
|
2044
|
+
|
|
2045
|
+
### 4. Albums & Long Text Splitting
|
|
2046
|
+
```javascript
|
|
2047
|
+
// Send 2 to 10 photos/videos in a grouped WhatsApp Album
|
|
2048
|
+
await sock.sendAlbum(jid, [
|
|
2049
|
+
{ image: { url: 'https://example.com/photo1.jpg' }, caption: '1️⃣ First photo' },
|
|
2050
|
+
{ image: { url: 'https://example.com/photo2.jpg' }, caption: '2️⃣ Second photo' },
|
|
2051
|
+
{ video: { url: 'https://example.com/video.mp4' }, caption: '3️⃣ Clip' }
|
|
2052
|
+
])
|
|
2053
|
+
|
|
2054
|
+
// Send long text split cleanly on paragraph/word boundaries without cutting words
|
|
2055
|
+
await sock.sendLong(jid, veryLongDocumentText, { maxLength: 3500, delayMs: 800 })
|
|
2056
|
+
```
|
|
2057
|
+
|
|
2058
|
+
### 5. Events & Scheduled Calls
|
|
2059
|
+
```javascript
|
|
2060
|
+
// Send event invitation
|
|
2061
|
+
await sock.sendEvent(jid, {
|
|
2062
|
+
name: 'VIP Developer Meetup 2026',
|
|
2063
|
+
description: 'Annual gathering of bot creators & contributors',
|
|
2064
|
+
start: new Date(Date.now() + 86400000),
|
|
2065
|
+
end: new Date(Date.now() + 86400000 + 7200000),
|
|
2066
|
+
location: 'Lotus Tower, Colombo'
|
|
2067
|
+
})
|
|
2068
|
+
|
|
2069
|
+
// Send scheduled call
|
|
2070
|
+
await sock.sendScheduledCall(jid, {
|
|
2071
|
+
title: 'Code Review & Deployment Strategy',
|
|
2072
|
+
start: new Date(Date.now() + 3600000),
|
|
2073
|
+
type: 1 // 1: Voice, 2: Video
|
|
2074
|
+
})
|
|
2075
|
+
|
|
2076
|
+
// Read channel metadata by link, invite code, or JID
|
|
2077
|
+
const channel = await sock.channelInfo('https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07')
|
|
2078
|
+
console.log('Channel title:', channel.name, 'Subscribers:', channel.subscribersCount)
|
|
2079
|
+
```
|
|
2080
|
+
|
|
2081
|
+
### 6. Interactive Polls, Quizzes & Timed Auto-Closing Polls
|
|
2082
|
+
```javascript
|
|
2083
|
+
// 1. Regular poll with live vote tracking
|
|
2084
|
+
const poll = await sock.sendPoll(jid, 'Which OS do you use?', ['Android', 'iOS', 'Linux', 'Windows'])
|
|
2085
|
+
|
|
2086
|
+
// 2. Quiz with one verified correct answer
|
|
2087
|
+
await sock.sendQuiz(jid, 'What is the capital of Sri Lanka?', ['Colombo', 'Sri Jayawardenepura Kotte', 'Kandy'], 'Sri Jayawardenepura Kotte')
|
|
2088
|
+
|
|
2089
|
+
// 3. Image Poll (photo album options + poll)
|
|
2090
|
+
await sock.sendImagePoll(jid, {
|
|
2091
|
+
name: 'Choose the best logo design:',
|
|
2092
|
+
options: [
|
|
2093
|
+
{ image: fs.readFileSync('./logo1.png'), text: 'Dark Minimalist' },
|
|
2094
|
+
{ image: fs.readFileSync('./logo2.png'), text: 'Golden Lion VIP' }
|
|
2095
|
+
]
|
|
2096
|
+
})
|
|
2097
|
+
|
|
2098
|
+
// 4. Timed Poll that closes automatically and posts formatted results
|
|
2099
|
+
await sock.sendTimedPoll(jid, 'Lunch Choice?', ['Rice & Curry', 'Kottu', 'Pizza'], {
|
|
2100
|
+
closeAfter: '10m', // or ms / Date
|
|
2101
|
+
showVoters: true,
|
|
2102
|
+
onClose: (result) => {
|
|
2103
|
+
console.log('Poll completed! Winner:', result.winners)
|
|
2104
|
+
}
|
|
2105
|
+
})
|
|
2106
|
+
|
|
2107
|
+
// 5. Cast a Vote on a Poll (Chat, Group or Channel!)
|
|
2108
|
+
await sock.votePoll(pollMsg, 'Android') // by option name
|
|
2109
|
+
await sock.votePoll(pollMsg, 0) // by 0-indexed position
|
|
2110
|
+
await sock.votePoll(pollMsg, ['Android', 'Linux']) // multiple choices
|
|
2111
|
+
|
|
2112
|
+
// 6. Channel Poll Voting
|
|
2113
|
+
await sock.votePoll(channelJid, ['Option 1'], { serverId: '123' })
|
|
2114
|
+
|
|
2115
|
+
// 7. Auto-Vote on Incoming Polls
|
|
2116
|
+
const autoVoter = sock.autoVote({
|
|
2117
|
+
choice: 0, // vote first option, or option name, or 'random', or (poll, msg) => choice
|
|
2118
|
+
delayMs: 2000, // anti-ban safety delay
|
|
2119
|
+
ignoreMe: true
|
|
2120
|
+
})
|
|
2121
|
+
// autoVoter.stop() // Call anytime to disable auto-voting
|
|
2122
|
+
|
|
2123
|
+
// Listen to live poll vote updates
|
|
2124
|
+
sock.ev.on('poll.votes', ({ pollKey, pollName, votes, voter }) => {
|
|
2125
|
+
console.log(`[Vote] ${voter} voted in "${pollName}"`)
|
|
2126
|
+
console.log('Current ranking:', votes)
|
|
2127
|
+
})
|
|
2128
|
+
|
|
2129
|
+
// Inspect tracked votes anytime
|
|
2130
|
+
const votes = sock.getPollVotes(poll.key)
|
|
2131
|
+
const quizScore = sock.getQuizResult(quizKey)
|
|
2132
|
+
```
|
|
2133
|
+
|
|
2134
|
+
### 7. In-Memory & Persistent Message Scheduler
|
|
2135
|
+
Schedule one-off or recurring messages (`at`, `after`, `every`, `cron`):
|
|
2136
|
+
```javascript
|
|
2137
|
+
// Send at a specific date/time
|
|
2138
|
+
sock.schedule.at(new Date(Date.now() + 3600000), jid, { text: 'One hour has passed!' })
|
|
2139
|
+
|
|
2140
|
+
// Send after a duration string
|
|
2141
|
+
sock.schedule.after('30m', jid, { text: 'Reminder: Check server status!' })
|
|
2142
|
+
|
|
2143
|
+
// Send every interval (e.g. every 2 hours, up to 10 times)
|
|
2144
|
+
const jobId = sock.schedule.every('2h', jid, { text: 'Periodic health heartbeat' }, { times: 10 })
|
|
2145
|
+
|
|
2146
|
+
// Send on cron schedule (Weekdays at 9:00 AM)
|
|
2147
|
+
sock.schedule.cron('0 9 * * 1-5', jid, { text: 'Good morning team!' })
|
|
2148
|
+
|
|
2149
|
+
// List waiting scheduled jobs
|
|
2150
|
+
console.log(sock.schedule.list())
|
|
2151
|
+
|
|
2152
|
+
// Cancel a scheduled job
|
|
2153
|
+
sock.schedule.cancel(jobId)
|
|
2154
|
+
```
|
|
2155
|
+
|
|
2156
|
+
### 8. Commands Router with Cooldown & Spam Protection
|
|
2157
|
+
```javascript
|
|
2158
|
+
// Register a command
|
|
2159
|
+
sock.commands.add({
|
|
2160
|
+
name: 'ping',
|
|
2161
|
+
aliases: ['p', 'speed'],
|
|
2162
|
+
cooldown: '5s',
|
|
2163
|
+
groupOnly: false,
|
|
2164
|
+
run: async (msg, { args, sender, command }) => {
|
|
2165
|
+
const start = Date.now()
|
|
2166
|
+
await sock.reply(msg, `🏓 Pong! Latency: ${Date.now() - start}ms`)
|
|
2167
|
+
}
|
|
2168
|
+
})
|
|
2169
|
+
|
|
2170
|
+
// In your message listener
|
|
2171
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
2172
|
+
for (const msg of messages) {
|
|
2173
|
+
await sock.commands.handle(msg)
|
|
2174
|
+
}
|
|
2175
|
+
})
|
|
2176
|
+
```
|
|
2177
|
+
|
|
2178
|
+
### 9. Insights, Delivery Status & Connection Health
|
|
2179
|
+
```javascript
|
|
2180
|
+
// Ping health check & memory report
|
|
2181
|
+
const health = await sock.health({ ping: true })
|
|
2182
|
+
console.log('Ping Latency:', health.latencyMs, 'ms, Heap:', health.memory.heapUsedMB, 'MB')
|
|
2183
|
+
|
|
2184
|
+
// Message counters
|
|
2185
|
+
console.log(sock.getStats())
|
|
2186
|
+
|
|
2187
|
+
// Check delivery state of sent message ('sent' | 'delivered' | 'read' | 'played' | 'failed')
|
|
2188
|
+
console.log(sock.getMessageStatus('MSG_ID_123'))
|
|
2189
|
+
|
|
2190
|
+
// Listen for delivery updates
|
|
2191
|
+
sock.ev.on('message.status', ({ key, status }) => {
|
|
2192
|
+
console.log(`Message ${key.id} status is now: ${status}`)
|
|
2193
|
+
})
|
|
2194
|
+
```
|
|
2195
|
+
|
|
2196
|
+
### 10. Auto-Mentions & HTML Formatter
|
|
2197
|
+
```javascript
|
|
2198
|
+
import { htmlToWhatsApp, buildVCard, splitText, parseMentions } from 'supun-bailey-vip'
|
|
2199
|
+
|
|
2200
|
+
// Sending text with @number automatically adds them to message mentions!
|
|
2201
|
+
await sock.sendMessage(jid, { text: 'Hello @94771234567, please check this out!' })
|
|
2202
|
+
|
|
2203
|
+
// Convert HTML markup to WhatsApp native formatting (*bold*, _italic_, ~strike~, `code`)
|
|
2204
|
+
const waFormatted = htmlToWhatsApp('<h2>Title</h2><p>Here is <b>bold</b> and <code>code</code>.</p>')
|
|
2205
|
+
await sock.sendHtmlText(jid, '<b>Important Notice:</b> Update your bot to <i>v1.1.0</i>!')
|
|
2206
|
+
```
|
|
2207
|
+
|
|
2208
|
+
---
|
|
2209
|
+
|
|
2210
|
+
## 🚀 ConnectBot & Multi-Session Manager
|
|
2211
|
+
|
|
2212
|
+
### 1. `connectBot` — One-Line Instant Starter
|
|
2213
|
+
Start a production-ready bot with pairing code, automatic session folder validation, and auto-reconnect in just a few lines:
|
|
2214
|
+
|
|
2215
|
+
```javascript
|
|
2216
|
+
import { connectBot } from 'supun-bailey-vip'
|
|
2217
|
+
|
|
2218
|
+
const bot = await connectBot({
|
|
2219
|
+
authDir: './session',
|
|
2220
|
+
number: '94771234567', // Phone number with country code for pairing code
|
|
2221
|
+
setup: (sock) => {
|
|
2222
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
2223
|
+
const msg = messages[0]
|
|
2224
|
+
if (msg.message && !msg.key.fromMe) {
|
|
2225
|
+
await sock.reply(msg, '🦁 Hello from Supun Bailey VIP Bot!')
|
|
2226
|
+
}
|
|
2227
|
+
})
|
|
2228
|
+
}
|
|
2229
|
+
})
|
|
2230
|
+
|
|
2231
|
+
// Wait until connected
|
|
2232
|
+
const sock = await bot.ready
|
|
2233
|
+
console.log('Bot is online and ready!')
|
|
2234
|
+
```
|
|
2235
|
+
|
|
2236
|
+
### 2. `makeSessionManager` — Multi-Account Runner
|
|
2237
|
+
Run dozens of independent WhatsApp accounts in a single Node.js process:
|
|
2238
|
+
|
|
2239
|
+
```javascript
|
|
2240
|
+
import { makeSessionManager } from 'supun-bailey-vip'
|
|
2241
|
+
|
|
2242
|
+
const manager = makeSessionManager({
|
|
2243
|
+
authDir: './sessions',
|
|
2244
|
+
setup: (sock, sessionId) => {
|
|
2245
|
+
console.log(`Setting up session: ${sessionId}`)
|
|
2246
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
2247
|
+
// Per-session message handler
|
|
2248
|
+
})
|
|
2249
|
+
}
|
|
2250
|
+
})
|
|
2251
|
+
|
|
2252
|
+
// Listen for pairing codes across all accounts
|
|
2253
|
+
manager.on('session.pairing-code', ({ id, code }) => {
|
|
2254
|
+
console.log(`[${id}] Pairing Code: ${code}`)
|
|
2255
|
+
})
|
|
2256
|
+
|
|
2257
|
+
// Start multiple accounts
|
|
2258
|
+
await manager.start('support-bot', { pairingNumber: '94771111111' })
|
|
2259
|
+
await manager.start('marketing-bot', { pairingNumber: '94772222222' })
|
|
2260
|
+
|
|
2261
|
+
// Access any socket
|
|
2262
|
+
const supportSock = manager.get('support-bot')
|
|
2263
|
+
```
|
|
2264
|
+
|
|
2265
|
+
---
|
|
2266
|
+
|
|
2267
|
+
## 📦 Compressed Session Backup & Restore
|
|
2268
|
+
|
|
2269
|
+
Save your bot's entire credentials folder into a single, encrypted `.gz` compressed archive for easy backups, transfers, and cloud deployment:
|
|
2270
|
+
|
|
2271
|
+
```javascript
|
|
2272
|
+
import { backupSession, restoreSession } from 'supun-bailey-vip'
|
|
2273
|
+
|
|
2274
|
+
// 1. Create a compressed backup of your session
|
|
2275
|
+
const backup = await backupSession('./session', './backups/session-backup.archive')
|
|
2276
|
+
console.log(`Saved ${backup.files} keys to backup file at ${backup.createdAt}`)
|
|
2277
|
+
|
|
2278
|
+
// 2. Restore session from archive (e.g. on a new server or container)
|
|
2279
|
+
await restoreSession('./backups/session-backup.archive', './session', { overwrite: true })
|
|
2280
|
+
console.log('Session restored successfully!')
|
|
2281
|
+
```
|
|
2282
|
+
|
|
2283
|
+
---
|
|
2284
|
+
|
|
2285
|
+
## ⏱️ Send Queue & Human Typing Simulation
|
|
2286
|
+
|
|
2287
|
+
Protect your phone numbers from WhatsApp spam bans with rate-limiting, human typing simulation, and priority message queuing:
|
|
2288
|
+
|
|
2289
|
+
```javascript
|
|
2290
|
+
import makeWASocket, { useMultiFileAuthState } from 'supun-bailey-vip'
|
|
2291
|
+
|
|
2292
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
2293
|
+
|
|
2294
|
+
const sock = makeWASocket({
|
|
2295
|
+
auth: state,
|
|
2296
|
+
sendQueue: {
|
|
2297
|
+
minDelayMs: 1000, // Minimum pause between sends
|
|
2298
|
+
maxDelayMs: 2500, // Maximum random human pause
|
|
2299
|
+
perChatIntervalMs: 1500, // Delay between messages in the same chat
|
|
2300
|
+
typing: true, // Automatically shows "composing..." typing indicator
|
|
2301
|
+
typingMsPerChar: 30, // Typing speed per character
|
|
2302
|
+
perChatLimit: { max: 15, windowMs: 60000 } // Anti-spam ceiling: max 15 msgs/min per chat
|
|
2303
|
+
}
|
|
2304
|
+
})
|
|
2305
|
+
|
|
2306
|
+
// Normal send (automatically queued with typing indicator)
|
|
2307
|
+
await sock.sendMessage(jid, { text: 'This message feels like typed by a human!' })
|
|
2308
|
+
|
|
2309
|
+
// Urgent messages (sent with higher queue priority)
|
|
2310
|
+
await sock.sendMessage(jid, { text: '🚨 URGENT ALERT' }, { priority: 'urgent' })
|
|
2311
|
+
|
|
2312
|
+
// Immediate send (bypasses queue)
|
|
2313
|
+
await sock.sendMessageNow(jid, { text: 'Sent immediately without waiting' })
|
|
2314
|
+
|
|
2315
|
+
// Queue control
|
|
2316
|
+
console.log('Waiting in queue:', sock.queue.size)
|
|
2317
|
+
sock.queue.clear()
|
|
2318
|
+
```
|
|
2319
|
+
|
|
2320
|
+
---
|
|
2321
|
+
|
|
2322
|
+
## 🛡️ Group Moderation & Signal Noise Filter
|
|
2323
|
+
|
|
2324
|
+
```javascript
|
|
2325
|
+
import { installConsoleFilter, makePrettyLogger } from 'supun-bailey-vip'
|
|
2326
|
+
|
|
2327
|
+
// 1. Mute noisy libsignal console logs
|
|
2328
|
+
installConsoleFilter()
|
|
2329
|
+
|
|
2330
|
+
// 2. Readable single-line logger
|
|
2331
|
+
const logger = makePrettyLogger({ level: 'info' })
|
|
2332
|
+
|
|
2333
|
+
// 3. Fast group moderation (handles both Phone Numbers and LIDs)
|
|
2334
|
+
const admins = await sock.getAdmins(groupJid)
|
|
2335
|
+
const isUserAdmin = await sock.isAdmin(groupJid, msg)
|
|
2336
|
+
const isBotAdmin = await sock.isBotAdmin(groupJid)
|
|
2337
|
+
|
|
2338
|
+
// Kick, Add, Promote, Demote
|
|
2339
|
+
await sock.kick(groupJid, '94771234567@s.whatsapp.net')
|
|
2340
|
+
await sock.addMembers(groupJid, '94771234567@s.whatsapp.net')
|
|
2341
|
+
await sock.promote(groupJid, '94771234567@s.whatsapp.net')
|
|
2342
|
+
await sock.demote(groupJid, '94771234567@s.whatsapp.net')
|
|
2343
|
+
```
|
|
2344
|
+
|
|
2345
|
+
---
|
|
2346
|
+
|
|
1386
2347
|
## 🌐 Community & Support
|
|
1387
2348
|
|
|
1388
2349
|
<div align="center">
|