@vinzsocket/baileys 3.2.0 → 3.2.5

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 CHANGED
@@ -37,6 +37,10 @@ Library ini memungkinkan kamu berinteraksi langsung dengan **WhatsApp Web Multi-
37
37
  - Reaction, Mention, Quoted Message
38
38
  - View Once, Edit Message, Revoke Message
39
39
  - Location, Contact, Poll
40
+ - **List Message** (flat & nested multi-section)
41
+ - **Interactive Message** — semua Native Flow V7 button shape
42
+ - Album, Event, Product, Request Payment
43
+ - Group Status V2 (group story)
40
44
 
41
45
  ### 👥 Group Management
42
46
  - Create Group
@@ -64,4 +68,317 @@ Library ini memungkinkan kamu berinteraksi langsung dengan **WhatsApp Web Multi-
64
68
  ## 📦 Installation
65
69
 
66
70
  ```bash
67
- npm install @vinzsocket/baileys
71
+ npm install @vinzsocket/baileys
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 🔔 Changelog v3.1.9
77
+
78
+ - fix(process-message): only drop self-only protocolMessages from non-self senders
79
+ - feat(dugong): tambah **nested list** (`nestedListMessage`) — list yang isinya ada list lagi
80
+ - feat(dugong): export semua **Native Flow V7 button builder** (`nfButtonUrl`, `nfButtonCall`, `nfButtonCopy`, `nfButtonReminder`, `nfButtonCancelReminder`, `nfButtonAddress`, `nfButtonLocation`, `nfButtonQuickReply`, `nfButtonSingleSelect`, `nfButtonReviewPay`, `nfButtonReviewOrder`, `nfButtonMPM`)
81
+ - feat(messages-send): wire `NESTED_LIST` case ke `sendMessage()` dengan proper `additionalNodes`
82
+
83
+ ---
84
+
85
+ ## 📨 Mengirim Pesan Interaktif
86
+
87
+ Semua interactive message dikirim lewat `conn.sendMessage()`. Untuk bot yang pakai `simple.js`, gunakan wrapper `conn.sendInteractive()` / `conn.sendList()` / `conn.sendNestedList()` sesuai kebutuhan.
88
+
89
+ ### Legacy List Message (sendList)
90
+
91
+ ```js
92
+ await conn.sendMessage(jid, {
93
+ listMessage: {
94
+ title: 'Pilih menu',
95
+ description: 'Footer pesan',
96
+ buttonText: '📋 Buka Menu',
97
+ listType: 1,
98
+ sections: [
99
+ {
100
+ title: '🎮 Kategori',
101
+ rows: [
102
+ { rowId: 'rpg_shop', title: '🏪 Shop', description: 'Beli item' },
103
+ { rowId: 'rpg_inv', title: '🎒 Inventory', description: 'Lihat inventory' }
104
+ ]
105
+ }
106
+ ]
107
+ }
108
+ })
109
+ ```
110
+
111
+ ---
112
+
113
+ ### Nested List (list dalam list)
114
+
115
+ Gunakan `nestedListMessage`. Rows yang punya field `rows` sendiri akan otomatis di-flatten jadi section baru.
116
+
117
+ ```js
118
+ await conn.sendMessage(jid, {
119
+ nestedListMessage: {
120
+ title: '🛒 Pilih Kategori & Item',
121
+ buttonText: '📋 Buka Menu',
122
+ footer: 'Harps-MD Shop',
123
+ sections: [
124
+ {
125
+ title: '⚔️ Senjata',
126
+ rows: [
127
+ // flat row biasa
128
+ { rowId: 'wpn_sword', title: '🗡️ Pedang', description: '50 ATK' },
129
+ // nested row → dijadikan section baru
130
+ {
131
+ title: '🏹 Senjata Jarak Jauh',
132
+ rows: [
133
+ { rowId: 'wpn_bow', title: '🏹 Busur', description: '35 ATK' },
134
+ { rowId: 'wpn_crossbow', title: '🔫 Crossbow', description: '45 ATK' }
135
+ ]
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ title: '🛡️ Armor',
141
+ rows: [
142
+ { rowId: 'arm_light', title: '👕 Light Armor', description: '20 DEF' },
143
+ { rowId: 'arm_heavy', title: '🛡️ Heavy Armor', description: '50 DEF' }
144
+ ]
145
+ }
146
+ ]
147
+ }
148
+ })
149
+ ```
150
+
151
+ Hasil di WhatsApp: section *"⚔️ Senjata"* lalu section baru *"🏹 Senjata Jarak Jauh"* lalu *"🛡️ Armor"*.
152
+
153
+ ---
154
+
155
+ ## ⚡ Native Flow V7 Button Builders
156
+
157
+ Import langsung dari library:
158
+
159
+ ```js
160
+ import {
161
+ nfButtonUrl,
162
+ nfButtonCall,
163
+ nfButtonCopy,
164
+ nfButtonReminder,
165
+ nfButtonCancelReminder,
166
+ nfButtonAddress,
167
+ nfButtonLocation,
168
+ nfButtonQuickReply,
169
+ nfButtonSingleSelect,
170
+ nfButtonReviewPay,
171
+ nfButtonReviewOrder,
172
+ nfButtonMPM
173
+ } from '@vinzsocket/baileys/lib/Socket/dugong.js'
174
+ ```
175
+
176
+ ### Semua Button Type
177
+
178
+ | Builder | `name` (proto) | Fungsi |
179
+ |---|---|---|
180
+ | `nfButtonUrl` | `cta_url` | Buka URL di browser |
181
+ | `nfButtonCall` | `cta_call` | Langsung telepon |
182
+ | `nfButtonCopy` | `cta_copy` | Salin teks/kode OTP |
183
+ | `nfButtonReminder` | `cta_reminder` | Set reminder di kalender |
184
+ | `nfButtonCancelReminder` | `cta_cancel_reminder` | Batalkan reminder |
185
+ | `nfButtonAddress` | `address_message` | Isi & kirim alamat |
186
+ | `nfButtonLocation` | `send_location` | Kirim lokasi GPS |
187
+ | `nfButtonQuickReply` | `quick_reply` | Balas cepat dengan payload |
188
+ | `nfButtonSingleSelect` | `single_select` | Dropdown / bottom sheet pilihan |
189
+ | `nfButtonReviewPay` | `review_and_pay` | Review & bayar order |
190
+ | `nfButtonReviewOrder` | `review_order` | Review order saja |
191
+ | `nfButtonMPM` | `mpm` | Tampilkan katalog produk |
192
+
193
+ ---
194
+
195
+ ### Contoh: Tombol URL + Copy + Quick Reply
196
+
197
+ ```js
198
+ import { nfButtonUrl, nfButtonCopy, nfButtonQuickReply } from '@vinzsocket/baileys/lib/Socket/dugong.js'
199
+
200
+ await conn.sendMessage(jid, {
201
+ interactiveMessage: {
202
+ title: '✅ Verifikasi Akun',
203
+ footer: 'Harps-MD',
204
+ buttons: [
205
+ nfButtonUrl({
206
+ displayText: '🌐 Buka Website',
207
+ url: 'https://example.com'
208
+ }),
209
+ nfButtonCopy({
210
+ displayText: '📋 Salin Kode',
211
+ copyCode: 'ABC123'
212
+ }),
213
+ nfButtonQuickReply({
214
+ id: 'confirm_yes',
215
+ displayText: '✅ Konfirmasi'
216
+ })
217
+ ]
218
+ }
219
+ })
220
+ ```
221
+
222
+ ---
223
+
224
+ ### Contoh: Tombol Single-Select (Dropdown Bottom Sheet)
225
+
226
+ ```js
227
+ import { nfButtonSingleSelect } from '@vinzsocket/baileys/lib/Socket/dugong.js'
228
+
229
+ await conn.sendMessage(jid, {
230
+ interactiveMessage: {
231
+ title: '⚙️ Pilih Difficulty',
232
+ footer: 'RPG Game',
233
+ buttons: [
234
+ nfButtonSingleSelect({
235
+ displayText: '🎯 Pilih Level',
236
+ sections: [
237
+ {
238
+ title: '🟢 Mudah',
239
+ rows: [
240
+ { id: 'diff_easy', title: 'Easy', description: 'Untuk pemula' },
241
+ { id: 'diff_normal', title: 'Normal', description: 'Standar' }
242
+ ]
243
+ },
244
+ {
245
+ title: '🔴 Susah',
246
+ rows: [
247
+ { id: 'diff_hard', title: 'Hard', description: 'Untuk pro' },
248
+ { id: 'diff_insane', title: 'Insane', description: 'GG' }
249
+ ]
250
+ }
251
+ ]
252
+ })
253
+ ]
254
+ }
255
+ })
256
+ ```
257
+
258
+ ---
259
+
260
+ ### Contoh: Interactive + Gambar
261
+
262
+ ```js
263
+ await conn.sendMessage(jid, {
264
+ interactiveMessage: {
265
+ title: '🎮 RPG Shop',
266
+ footer: 'Pilih item yang mau dibeli',
267
+ image: { url: 'https://example.com/shop.jpg' },
268
+ buttons: [
269
+ nfButtonQuickReply({ id: 'buy_sword', displayText: '🗡️ Beli Pedang' }),
270
+ nfButtonQuickReply({ id: 'buy_shield', displayText: '🛡️ Beli Tameng' }),
271
+ nfButtonUrl({ displayText: '📖 Lihat Katalog', url: 'https://example.com/catalog' })
272
+ ]
273
+ }
274
+ })
275
+ ```
276
+
277
+ ---
278
+
279
+ ## 🧩 buildNestedListMessage (standalone)
280
+
281
+ Kalau mau build raw proto payload tanpa `sendMessage`:
282
+
283
+ ```js
284
+ import { buildNestedListMessage } from '@vinzsocket/baileys/lib/Socket/dugong.js'
285
+
286
+ const payload = buildNestedListMessage({
287
+ title: 'Menu Utama',
288
+ buttonText: '📋 Buka',
289
+ footer: 'Bot Footer',
290
+ sections: [
291
+ {
292
+ title: 'Kategori 1',
293
+ rows: [
294
+ { rowId: 'a', title: 'Item A' },
295
+ {
296
+ title: 'Sub-kategori',
297
+ rows: [
298
+ { rowId: 'b1', title: 'Item B1' },
299
+ { rowId: 'b2', title: 'Item B2' }
300
+ ]
301
+ }
302
+ ]
303
+ }
304
+ ]
305
+ })
306
+ // payload → { listMessage: { title, description, buttonText, listType, sections } }
307
+ ```
308
+
309
+ ---
310
+
311
+ ## ⚠️ Catatan Penting: Interactive Message Rendering
312
+
313
+ WhatsApp butuh binary node hint tambahan agar interactive/button/list message **render** di client. Harps-Baileys sudah otomatis inject ini lewat `buildInteractiveAdditionalNodes()` di `messages-send.js`. **Jangan relay manual** tanpa `additionalNodes`.
314
+
315
+ Kalau pakai `relayMessage` langsung:
316
+
317
+ ```js
318
+ import { buildInteractiveAdditionalNodes } from '@vinzsocket/baileys/lib/Utils/messages.js'
319
+
320
+ await relayMessage(jid, msg.message, {
321
+ messageId: msg.key.id,
322
+ additionalNodes: buildInteractiveAdditionalNodes(jid, msg.message)
323
+ })
324
+ ```
325
+
326
+ Node yang di-inject:
327
+ - **List message** → `<biz><list type="product_list" v="2"/></biz>`
328
+ - **Interactive/button/template/product** → `<biz><interactive type="native_flow" v="1"><native_flow name="mixed" v="9"/></interactive></biz>`
329
+ - **1:1 chat (bukan grup)** → tambahan `<bot biz_bot="1"/>`
330
+
331
+ ---
332
+
333
+ ## 🔌 Quick Start
334
+
335
+ ```js
336
+ import makeWASocket, { useMultiFileAuthState } from '@vinzsocket/baileys'
337
+
338
+ const { state, saveCreds } = await useMultiFileAuthState('./auth')
339
+
340
+ const conn = makeWASocket({
341
+ auth: state,
342
+ printQRInTerminal: true
343
+ })
344
+
345
+ conn.ev.on('creds.update', saveCreds)
346
+
347
+ conn.ev.on('messages.upsert', async ({ messages }) => {
348
+ const msg = messages[0]
349
+ if (!msg.message) return
350
+ const text = msg.message.conversation || msg.message.extendedTextMessage?.text || ''
351
+ const from = msg.key.remoteJid
352
+
353
+ if (text === '!menu') {
354
+ await conn.sendMessage(from, {
355
+ nestedListMessage: {
356
+ title: '📋 Main Menu',
357
+ buttonText: 'Buka Menu',
358
+ footer: 'Harps-MD Bot',
359
+ sections: [
360
+ {
361
+ title: '🎮 Game',
362
+ rows: [
363
+ { rowId: 'rpg', title: '⚔️ RPG', description: 'Main RPG' },
364
+ {
365
+ title: '🏆 Kompetitif',
366
+ rows: [
367
+ { rowId: 'pvp', title: '⚔️ PvP' },
368
+ { rowId: 'rank', title: '📊 Ranking' }
369
+ ]
370
+ }
371
+ ]
372
+ }
373
+ ]
374
+ }
375
+ }, { quoted: msg })
376
+ }
377
+ })
378
+ ```
379
+
380
+ ---
381
+
382
+ ## 📄 License
383
+
384
+ MIT — © Alvin-B2T
@@ -24,6 +24,154 @@ export interface ExtendedMessageUtils {
24
24
  generateMessageID: () => string;
25
25
  }
26
26
 
27
+ // ─── Native Flow V7 Button Types ─────────────────────────────────────────────
28
+
29
+ export interface NFButtonUrlOptions {
30
+ id?: string;
31
+ displayText: string;
32
+ url: string;
33
+ merchantUrl?: string;
34
+ }
35
+ export interface NFButtonCallOptions {
36
+ id?: string;
37
+ displayText: string;
38
+ phoneNumber: string;
39
+ }
40
+ export interface NFButtonCopyOptions {
41
+ id?: string;
42
+ displayText: string;
43
+ copyCode: string;
44
+ }
45
+ export interface NFButtonReminderOptions {
46
+ id?: string;
47
+ displayText: string;
48
+ title: string;
49
+ notes: string;
50
+ startTime: number;
51
+ endTime: number;
52
+ timezone?: string;
53
+ }
54
+ export interface NFButtonCancelReminderOptions {
55
+ id?: string;
56
+ displayText: string;
57
+ reminderKey: string;
58
+ }
59
+ export interface NFButtonAddressOptions {
60
+ id?: string;
61
+ displayText: string;
62
+ label?: string;
63
+ }
64
+ export interface NFButtonLocationOptions {
65
+ id?: string;
66
+ displayText: string;
67
+ }
68
+ export interface NFButtonQuickReplyOptions {
69
+ id?: string;
70
+ displayText: string;
71
+ payload?: string;
72
+ }
73
+ export interface NFButtonSingleSelectRow {
74
+ id: string;
75
+ title: string;
76
+ description?: string;
77
+ }
78
+ export interface NFButtonSingleSelectSection {
79
+ title?: string;
80
+ highlight_label?: string;
81
+ rows: NFButtonSingleSelectRow[];
82
+ }
83
+ export interface NFButtonSingleSelectOptions {
84
+ id?: string;
85
+ displayText: string;
86
+ sections: NFButtonSingleSelectSection[];
87
+ }
88
+ export interface NFButtonReviewPayOptions {
89
+ id?: string;
90
+ currency?: string;
91
+ totalAmount1000: number;
92
+ subtotal?: any;
93
+ tax?: any;
94
+ items?: any[];
95
+ merchant?: any;
96
+ }
97
+ export interface NFButtonReviewOrderOptions {
98
+ id?: string;
99
+ referenceId: string;
100
+ type?: string;
101
+ orderId: string;
102
+ }
103
+ export interface NFButtonMPMSection {
104
+ title?: string;
105
+ productItems: Array<{ productId: string } | { product_id: string }>;
106
+ }
107
+ export interface NFButtonMPMOptions {
108
+ id?: string;
109
+ sections: NFButtonMPMSection[];
110
+ }
111
+
112
+ /** Buka URL */
113
+ export declare function nfButtonUrl(opts: NFButtonUrlOptions): proto.Message.InteractiveMessage.INativeFlowButton;
114
+ /** Telepon */
115
+ export declare function nfButtonCall(opts: NFButtonCallOptions): proto.Message.InteractiveMessage.INativeFlowButton;
116
+ /** Salin teks/kode */
117
+ export declare function nfButtonCopy(opts: NFButtonCopyOptions): proto.Message.InteractiveMessage.INativeFlowButton;
118
+ /** Set reminder */
119
+ export declare function nfButtonReminder(opts: NFButtonReminderOptions): proto.Message.InteractiveMessage.INativeFlowButton;
120
+ /** Batalkan reminder */
121
+ export declare function nfButtonCancelReminder(opts: NFButtonCancelReminderOptions): proto.Message.InteractiveMessage.INativeFlowButton;
122
+ /** Isi alamat */
123
+ export declare function nfButtonAddress(opts: NFButtonAddressOptions): proto.Message.InteractiveMessage.INativeFlowButton;
124
+ /** Kirim lokasi */
125
+ export declare function nfButtonLocation(opts: NFButtonLocationOptions): proto.Message.InteractiveMessage.INativeFlowButton;
126
+ /** Quick reply dengan payload */
127
+ export declare function nfButtonQuickReply(opts: NFButtonQuickReplyOptions): proto.Message.InteractiveMessage.INativeFlowButton;
128
+ /** Dropdown single-select (bottom sheet) */
129
+ export declare function nfButtonSingleSelect(opts: NFButtonSingleSelectOptions): proto.Message.InteractiveMessage.INativeFlowButton;
130
+ /** Review & bayar */
131
+ export declare function nfButtonReviewPay(opts: NFButtonReviewPayOptions): proto.Message.InteractiveMessage.INativeFlowButton;
132
+ /** Review order */
133
+ export declare function nfButtonReviewOrder(opts: NFButtonReviewOrderOptions): proto.Message.InteractiveMessage.INativeFlowButton;
134
+ /** Multi-Product Message (katalog) */
135
+ export declare function nfButtonMPM(opts: NFButtonMPMOptions): proto.Message.InteractiveMessage.INativeFlowButton;
136
+
137
+ // ─── Nested List ──────────────────────────────────────────────────────────────
138
+
139
+ export interface FlatListRow {
140
+ rowId?: string;
141
+ id?: string;
142
+ title: string;
143
+ description?: string;
144
+ }
145
+
146
+ export interface NestedListRow {
147
+ title: string;
148
+ rows: FlatListRow[];
149
+ }
150
+
151
+ export type ListRow = FlatListRow | NestedListRow;
152
+
153
+ export interface ListSection {
154
+ title?: string;
155
+ rows: ListRow[];
156
+ }
157
+
158
+ export interface NestedListMessageOptions {
159
+ title: string;
160
+ buttonText: string;
161
+ footer?: string;
162
+ sections: ListSection[];
163
+ }
164
+
165
+ /**
166
+ * Build raw `listMessage` proto payload dengan dukungan nested section.
167
+ * Rows yang punya sub-rows di-flatten jadi section tersendiri.
168
+ */
169
+ export declare function buildNestedListMessage(opts: NestedListMessageOptions): {
170
+ listMessage: proto.Message.IListMessage;
171
+ };
172
+
173
+ // ─── Message Interfaces ───────────────────────────────────────────────────────
174
+
27
175
  export interface StickerMessage {
28
176
  url: string;
29
177
  fileSha256: Buffer | string;
@@ -162,10 +310,19 @@ export interface ExtendedMessageContent {
162
310
  eventMessage?: EventMessage;
163
311
  pollResultMessage?: PollResultMessage;
164
312
  groupStatusMessage?: GroupStatusMessage;
313
+ nestedListMessage?: NestedListMessageOptions;
165
314
  sender?: string;
166
315
  }
167
316
 
168
- export type ExtendedMessageType = 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY';
317
+ export type ExtendedMessageType =
318
+ | 'PAYMENT'
319
+ | 'PRODUCT'
320
+ | 'INTERACTIVE'
321
+ | 'ALBUM'
322
+ | 'EVENT'
323
+ | 'POLL_RESULT'
324
+ | 'GROUP_STORY'
325
+ | 'NESTED_LIST';
169
326
 
170
327
  export declare class ExtendedMessageBuilder {
171
328
  utils: ExtendedMessageUtils;
@@ -177,28 +334,20 @@ export declare class ExtendedMessageBuilder {
177
334
  getContentType: (msg: any) => string;
178
335
  };
179
336
 
180
- constructor(utils: ExtendedMessageUtils, waUploadToServer: WAMediaUploadFunction, relayMessageFn: (jid: string, content: any, options?: any) => Promise<any>);
337
+ constructor(
338
+ utils: ExtendedMessageUtils,
339
+ waUploadToServer: WAMediaUploadFunction,
340
+ relayMessageFn: (jid: string, content: any, options?: any) => Promise<any>
341
+ );
181
342
 
182
343
  detectType(content: ExtendedMessageContent): ExtendedMessageType | null;
183
-
184
- handlePayment(content: { requestPaymentMessage: PaymentMessage }, quoted?: proto.IWebMessageInfo | null): Promise<{
185
- requestPaymentMessage: proto.Message.RequestPaymentMessage;
186
- }>;
187
-
188
- handleProduct(content: { productMessage: ProductMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<{
189
- viewOnceMessage: { message: { interactiveMessage: any } };
190
- }>;
191
-
192
- handleInteractive(content: { interactiveMessage: InteractiveMessage }, jid: string, quoted?: proto.IWebMessageInfo | null, options?: { mentions?: string[] }): Promise<{
193
- interactiveMessage: any;
194
- }>;
195
-
344
+ handlePayment(content: { requestPaymentMessage: PaymentMessage }, quoted?: proto.IWebMessageInfo | null): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
345
+ handleProduct(content: { productMessage: ProductMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<{ viewOnceMessage: { message: { interactiveMessage: any } } }>;
346
+ handleInteractive(content: { interactiveMessage: InteractiveMessage }, jid: string, quoted?: proto.IWebMessageInfo | null, options?: { mentions?: string[] }): Promise<{ interactiveMessage: any }>;
347
+ handleNestedList(content: { nestedListMessage: NestedListMessageOptions }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
196
348
  handleAlbum(content: { albumMessage: AlbumItem[] }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
197
-
198
349
  handleEvent(content: { eventMessage: EventMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
199
-
200
350
  handlePollResult(content: { pollResultMessage: PollResultMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
201
-
202
351
  handleGroupStory(content: { groupStatusMessage: GroupStatusMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
203
352
  }
204
353
 
@@ -1,12 +1,253 @@
1
1
  // dugong.js — extended message builders
2
2
  // Handles: Request Payment, Product, Interactive (buttons/native flow/external ad reply/
3
- // document+thumbnail), Album, Event, Poll Result, Group Status V2 (group story).
3
+ // document+thumbnail), Album, Event, Poll Result, Group Status V2 (group story),
4
+ // List Message (legacy flat + nested multi-section), Nested Section List.
4
5
  // Ported from baileys-lily (Socket/dugong.js), adapted to ESM for Harps-Baileys.
6
+ // v7 native-flow button shapes fully supported: cta_url, cta_call, cta_copy, cta_reminder,
7
+ // cta_cancel_reminder, address_message, send_location, quick_reply, single_select,
8
+ // review_and_pay, review_order, mpm (Multi-Product Message).
5
9
 
6
10
  import { randomBytes } from 'crypto';
7
11
  import { proto } from '../../WAProto/index.js';
8
12
  import { normalizeMentions } from '../Utils/mention.js';
9
13
 
14
+ // ─── Native Flow Button Builders (V7) ────────────────────────────────────────
15
+ /**
16
+ * Semua builder di bawah ini menghasilkan objek yang langsung dipakai di
17
+ * interactiveMessage.nativeFlowMessage.buttons[]
18
+ * atau di conn.sendInteractive({ buttons: [...] })
19
+ */
20
+
21
+ /** Tombol buka URL */
22
+ export const nfButtonUrl = ({ id = '', displayText, url, merchantUrl = url }) => ({
23
+ name: 'cta_url',
24
+ buttonParamsJson: JSON.stringify({
25
+ display_text: displayText,
26
+ url,
27
+ merchant_url: merchantUrl
28
+ }),
29
+ ...(id ? { id } : {})
30
+ });
31
+
32
+ /** Tombol telepon */
33
+ export const nfButtonCall = ({ id = '', displayText, phoneNumber }) => ({
34
+ name: 'cta_call',
35
+ buttonParamsJson: JSON.stringify({
36
+ display_text: displayText,
37
+ phone_number: phoneNumber
38
+ }),
39
+ ...(id ? { id } : {})
40
+ });
41
+
42
+ /** Tombol salin teks / kode */
43
+ export const nfButtonCopy = ({ id = '', displayText, copyCode }) => ({
44
+ name: 'cta_copy',
45
+ buttonParamsJson: JSON.stringify({
46
+ display_text: displayText,
47
+ copy_code: copyCode
48
+ }),
49
+ ...(id ? { id } : {})
50
+ });
51
+
52
+ /** Tombol set reminder */
53
+ export const nfButtonReminder = ({ id = '', displayText, title, notes, startTime, endTime, timezone = 'Asia/Jakarta' }) => ({
54
+ name: 'cta_reminder',
55
+ buttonParamsJson: JSON.stringify({
56
+ display_text: displayText,
57
+ title,
58
+ notes,
59
+ start_timestamp: startTime,
60
+ end_timestamp: endTime,
61
+ timezone
62
+ }),
63
+ ...(id ? { id } : {})
64
+ });
65
+
66
+ /** Tombol batalkan reminder */
67
+ export const nfButtonCancelReminder = ({ id = '', displayText, reminderKey }) => ({
68
+ name: 'cta_cancel_reminder',
69
+ buttonParamsJson: JSON.stringify({
70
+ display_text: displayText,
71
+ reminder_key: reminderKey
72
+ }),
73
+ ...(id ? { id } : {})
74
+ });
75
+
76
+ /** Tombol isi alamat */
77
+ export const nfButtonAddress = ({ id = '', displayText, label = '' }) => ({
78
+ name: 'address_message',
79
+ buttonParamsJson: JSON.stringify({
80
+ display_text: displayText,
81
+ label
82
+ }),
83
+ ...(id ? { id } : {})
84
+ });
85
+
86
+ /** Tombol kirim lokasi */
87
+ export const nfButtonLocation = ({ id = '', displayText }) => ({
88
+ name: 'send_location',
89
+ buttonParamsJson: JSON.stringify({
90
+ display_text: displayText
91
+ }),
92
+ ...(id ? { id } : {})
93
+ });
94
+
95
+ /** Tombol quick reply (balas cepat dengan payload custom) */
96
+ export const nfButtonQuickReply = ({ id = '', displayText, payload = '' }) => ({
97
+ name: 'quick_reply',
98
+ buttonParamsJson: JSON.stringify({
99
+ display_text: displayText,
100
+ id: id || payload
101
+ }),
102
+ ...(id ? { id } : {})
103
+ });
104
+
105
+ /**
106
+ * Tombol dropdown single-select (bottom sheet list pilihan)
107
+ * @param {Object} opts
108
+ * @param {string} opts.displayText - label tombol
109
+ * @param {Array} opts.sections - array section, format:
110
+ * [{ title: 'Section Title', highlight_label: '', rows: [{ id, title, description? }] }]
111
+ */
112
+ export const nfButtonSingleSelect = ({ id = '', displayText, sections = [] }) => ({
113
+ name: 'single_select',
114
+ buttonParamsJson: JSON.stringify({
115
+ title: displayText,
116
+ sections: sections.map(sec => ({
117
+ title: sec.title || '',
118
+ highlight_label: sec.highlight_label || '',
119
+ rows: (sec.rows || []).map(r => ({
120
+ id: r.id,
121
+ title: r.title,
122
+ ...(r.description ? { description: r.description } : {})
123
+ }))
124
+ }))
125
+ }),
126
+ ...(id ? { id } : {})
127
+ });
128
+
129
+ /** Tombol review & bayar */
130
+ export const nfButtonReviewPay = ({ id = '', currency = 'IDR', totalAmount1000, subtotal, tax, items = [], merchant = {} }) => ({
131
+ name: 'review_and_pay',
132
+ buttonParamsJson: JSON.stringify({
133
+ currency,
134
+ total_amount: { value: totalAmount1000, offset: 1000 },
135
+ subtotal,
136
+ tax,
137
+ items,
138
+ order: {
139
+ status: 'pending',
140
+ items
141
+ },
142
+ merchant
143
+ }),
144
+ ...(id ? { id } : {})
145
+ });
146
+
147
+ /** Tombol review order */
148
+ export const nfButtonReviewOrder = ({ id = '', referenceId, type = 'ORDER', orderId }) => ({
149
+ name: 'review_order',
150
+ buttonParamsJson: JSON.stringify({
151
+ reference_id: referenceId,
152
+ type,
153
+ order_id: orderId
154
+ }),
155
+ ...(id ? { id } : {})
156
+ });
157
+
158
+ /**
159
+ * Multi-Product Message (MPM) button — tampilkan katalog produk
160
+ * @param {Object} opts
161
+ * @param {Array} opts.sections - [{ title, productItems: [{ productId }] }]
162
+ */
163
+ export const nfButtonMPM = ({ id = '', sections = [] }) => ({
164
+ name: 'mpm',
165
+ buttonParamsJson: JSON.stringify({
166
+ sections: sections.map(sec => ({
167
+ title: sec.title || '',
168
+ product_items: (sec.productItems || []).map(p => ({ product_id: p.productId || p.product_id }))
169
+ }))
170
+ }),
171
+ ...(id ? { id } : {})
172
+ });
173
+
174
+ // ─── Nested Section List ──────────────────────────────────────────────────────
175
+ /**
176
+ * Build legacy `listMessage` payload — kompatibel dengan semua WhatsApp client.
177
+ *
178
+ * Mendukung DUA mode:
179
+ * 1. **Flat (sendList lama)** — sections berisi rows langsung.
180
+ * 2. **Nested** — rows punya field `rows` sendiri (sub-list / list dalam list).
181
+ * Nested rows di-flatten ke satu section baru ber-title = row.title induk.
182
+ *
183
+ * @param {Object} opts
184
+ * @param {string} opts.title - judul pesan
185
+ * @param {string} opts.buttonText - label tombol buka list
186
+ * @param {string} [opts.footer] - footer pesan
187
+ * @param {Array} opts.sections - array section:
188
+ * {
189
+ * title: 'Section Title',
190
+ * rows: [
191
+ * // flat row:
192
+ * { rowId, title, description? },
193
+ * // nested row (list dalam list):
194
+ * { rowId?, title: 'Parent Label', rows: [{ rowId, title, description? }] }
195
+ * ]
196
+ * }
197
+ *
198
+ * @returns {Object} raw proto listMessage payload
199
+ */
200
+ export const buildNestedListMessage = ({ title, buttonText, footer = '', sections = [] }) => {
201
+ const flattenedSections = [];
202
+
203
+ for (const section of sections) {
204
+ const topRows = [];
205
+ const nestedSections = [];
206
+
207
+ for (const row of (section.rows || [])) {
208
+ if (Array.isArray(row.rows) && row.rows.length > 0) {
209
+ // Nested row → jadikan section baru dengan title = row.title
210
+ nestedSections.push({
211
+ title: row.title || '',
212
+ rows: row.rows.map(r => ({
213
+ rowId: r.rowId || r.id || '',
214
+ title: r.title || '',
215
+ description: r.description || ''
216
+ }))
217
+ });
218
+ } else {
219
+ topRows.push({
220
+ rowId: row.rowId || row.id || '',
221
+ title: row.title || '',
222
+ description: row.description || ''
223
+ });
224
+ }
225
+ }
226
+
227
+ if (topRows.length > 0) {
228
+ flattenedSections.push({
229
+ title: section.title || '',
230
+ rows: topRows
231
+ });
232
+ }
233
+
234
+ for (const ns of nestedSections) {
235
+ flattenedSections.push(ns);
236
+ }
237
+ }
238
+
239
+ return {
240
+ listMessage: {
241
+ title,
242
+ description: footer,
243
+ buttonText,
244
+ listType: 1, // SINGLE_SELECT
245
+ sections: flattenedSections
246
+ }
247
+ };
248
+ };
249
+
250
+ // ─── ExtendedMessageBuilder ───────────────────────────────────────────────────
10
251
  export class ExtendedMessageBuilder {
11
252
  constructor(utils, waUploadToServer, relayMessageFn) {
12
253
  this.utils = utils;
@@ -28,6 +269,7 @@ export class ExtendedMessageBuilder {
28
269
  if (content.eventMessage) return 'EVENT';
29
270
  if (content.pollResultMessage) return 'POLL_RESULT';
30
271
  if (content.groupStatusMessage) return 'GROUP_STORY';
272
+ if (content.nestedListMessage) return 'NESTED_LIST';
31
273
  return null;
32
274
  }
33
275
 
@@ -141,6 +383,7 @@ export class ExtendedMessageBuilder {
141
383
  /**
142
384
  * Interactive Message — button, copy code, native flow, bottom sheet,
143
385
  * limited time offer, document+thumbnail, external ad reply.
386
+ * Semua V7 native-flow button shape didukung via helper exports di atas.
144
387
  */
145
388
  async handleInteractive(content, jid, quoted, options = {}) {
146
389
  const {
@@ -198,7 +441,7 @@ export class ExtendedMessageBuilder {
198
441
  footer: { text: footer || '' }
199
442
  };
200
443
 
201
- // Buttons / nativeFlowMessage (button, copy code, native flow, bottom sheet, limited time offer)
444
+ // Buttons / nativeFlowMessage
202
445
  if (buttons && buttons.length > 0) {
203
446
  interactiveMessage.nativeFlowMessage = { buttons };
204
447
  if (nativeFlowMessage) {
@@ -234,7 +477,6 @@ export class ExtendedMessageBuilder {
234
477
  };
235
478
 
236
479
  if (externalAdReply) {
237
- // External Ad Reply — pesan dengan thumbnail eksternal
238
480
  finalContextInfo.externalAdReply = {
239
481
  title: externalAdReply.title || '',
240
482
  body: externalAdReply.body || '',
@@ -259,6 +501,43 @@ export class ExtendedMessageBuilder {
259
501
  return { interactiveMessage };
260
502
  }
261
503
 
504
+ /**
505
+ * Nested List Message — list yang isinya ada list lagi.
506
+ * Flat sections biasa juga tetap jalan.
507
+ *
508
+ * content.nestedListMessage = {
509
+ * title, buttonText, footer?,
510
+ * sections: [
511
+ * { title: 'Kategori A', rows: [
512
+ * { rowId: 'a1', title: 'Item A1', description: '...' },
513
+ * // nested:
514
+ * { title: 'Sub-Kategori', rows: [
515
+ * { rowId: 'b1', title: 'Item B1' },
516
+ * { rowId: 'b2', title: 'Item B2' }
517
+ * ]}
518
+ * ]}
519
+ * ]
520
+ * }
521
+ */
522
+ async handleNestedList(content, jid, quoted) {
523
+ const opts = content.nestedListMessage;
524
+ const payload = buildNestedListMessage(opts);
525
+
526
+ const msg = await this.utils.generateWAMessageFromContent(jid, {
527
+ viewOnceMessage: {
528
+ message: {
529
+ messageContextInfo: {
530
+ deviceListMetadata: {},
531
+ deviceListMetadataVersion: 2
532
+ },
533
+ ...payload
534
+ }
535
+ }
536
+ }, { quoted });
537
+
538
+ return msg;
539
+ }
540
+
262
541
  /** Album Message — kirim banyak foto/video sekaligus */
263
542
  async handleAlbum(content, jid, quoted) {
264
543
  const array = content.albumMessage;
@@ -1108,6 +1108,13 @@ export const makeMessagesSocket = (config) => {
1108
1108
  return await extendedMessages.handlePollResult(content, jid, quoted);
1109
1109
  case 'GROUP_STORY':
1110
1110
  return await extendedMessages.handleGroupStory(content, jid, quoted);
1111
+ case 'NESTED_LIST': {
1112
+ const nestedMsg = await extendedMessages.handleNestedList(content, jid, quoted);
1113
+ return await relayMessage(jid, nestedMsg.message, {
1114
+ messageId: nestedMsg.key.id,
1115
+ additionalNodes: buildInteractiveAdditionalNodes(jid, nestedMsg.message)
1116
+ });
1117
+ }
1111
1118
  }
1112
1119
  }
1113
1120
  const fullMsg = await generateWAMessage(jid, content, {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@vinzsocket/baileys",
3
3
  "type": "module",
4
- "version": "3.2.0",
4
+ "version": "3.2.5",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation"
9
9
  ],
10
- "homepage": "https://github.com/Kevin-b2t/VinzSocket/",
10
+ "homepage": "https://github.com/VinzSocket/Baileys/",
11
11
  "repository": {
12
- "url": "git@github.com:Kevin-b2t/VinzSocket.git"
12
+ "url": "git@github.com:VinzSocket/Baileys.git"
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Alvin-B2T",
@@ -136,4 +136,4 @@
136
136
  "engines": {
137
137
  "node": ">=20.0.0"
138
138
  }
139
- }
139
+ }