@nuiisweety/baileys 0.1.13 → 0.1.15

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.bak CHANGED
@@ -77,11 +77,7 @@
77
77
  [List Message](#list-message) ·
78
78
  [Template Buttons](#template-buttons) ·
79
79
  [Native Flow](#native-flow) ·
80
- [Carousel](#carousel) ·
81
- [Shop Message](#shop-message) ·
82
- [Collection Message](#collection-message) ·
83
- [Order Status Message](#order-status-message) ·
84
- [Product List Message](#product-list-message)
80
+ [Carousel](#carousel)
85
81
 
86
82
  🤖 **Rich Message (AI)** —
87
83
  [Text](#addtext) ·
@@ -690,8 +686,27 @@ await sock.sendMessage(groupJid, {
690
686
  caption: 'Keterangan'
691
687
  }
692
688
  })
689
+
690
+ // Audio
691
+ await sock.sendMessage(groupJid, {
692
+ groupStatusMessage: {
693
+ audio: { url: 'https://example.com/audio.mp3' },
694
+ mimetype: 'audio/mpeg'
695
+ }
696
+ })
697
+
698
+ // Audio Voice Note (PTT)
699
+ await sock.sendMessage(groupJid, {
700
+ groupStatusMessage: {
701
+ audio: fs.readFileSync('voice.ogg'),
702
+ mimetype: 'audio/ogg; codecs=opus',
703
+ ptt: true
704
+ }
705
+ })
693
706
  ```
694
707
 
708
+ > **Catatan perilaku audio:** Saat audio dikirim sebagai group status (`groupStatusMessageV2`), pesan dikirim dengan `type="text"` dan tanpa `mediatype` attribute — ini adalah perilaku yang sama dengan Baileys upstream. Berbeda dengan media lain (gambar/video) yang dikirim dengan `type="media"`.
709
+
695
710
  </details>
696
711
 
697
712
  ---
@@ -875,13 +890,32 @@ await sock.sendMessage(jid, {
875
890
  <details>
876
891
  <summary>🎭 Group Status Wrap</summary>
877
892
 
893
+ Wrapper `groupStatus: true` membungkus pesan apapun ke dalam `groupStatusMessageV2` secara otomatis.
894
+
878
895
  ```js
896
+ // Teks
879
897
  await sock.sendMessage(jid, {
880
898
  text: 'Status di grup ini',
881
899
  groupStatus: true
882
900
  })
901
+
902
+ // Gambar
903
+ await sock.sendMessage(jid, {
904
+ image: { url: 'https://example.com/image.jpg' },
905
+ caption: 'Keterangan',
906
+ groupStatus: true
907
+ })
908
+
909
+ // Audio
910
+ await sock.sendMessage(jid, {
911
+ audio: { url: 'https://example.com/audio.mp3' },
912
+ mimetype: 'audio/mpeg',
913
+ groupStatus: true
914
+ })
883
915
  ```
884
916
 
917
+ > **Catatan audio:** Pesan audio yang dibungkus `groupStatus: true` dikirim dengan `type="text"` dan tanpa `mediatype` (perilaku Baileys upstream). Ini hanya berlaku untuk audio — gambar dan video tetap dikirim sebagai `type="media"`.
918
+
885
919
  </details>
886
920
 
887
921
  ---
@@ -1263,118 +1297,7 @@ await sock.sendMessage(jid, {
1263
1297
  })
1264
1298
  ```
1265
1299
 
1266
- > **Tipe tombol ditentukan otomatis** dari field yang ada:
1267
- >
1268
- > | Field pada button | Native Flow yang dihasilkan |
1269
- > |---|---|
1270
- > | `id` | `quick_reply` |
1271
- > | `url` | `cta_url` |
1272
- > | `copy` | `cta_copy` |
1273
- > | `call` | `cta_call` |
1274
- > | `sections` | `single_select` |
1275
- > | `catalog` | `cta_catalog` |
1276
- > | `reminder: true` | `cta_reminder` |
1277
- > | `cancelReminder: true` | `cta_cancel_reminder` |
1278
- > | `address: true` | `address_message` |
1279
- > | `location: true` | `send_location` |
1280
- > | `webview` | `open_webview` |
1281
- > | `productId` | `mpm` |
1282
- > | `transactionId` | `wa_payment_transaction_details` |
1283
- > | `catalogProduct` | `automated_greeting_message_view_catalog` |
1284
- > | `flow` | `galaxy_message` (WA Flow) |
1285
- >
1286
- > Bisa juga pakai `name` + `paramsJson` langsung untuk kontrol penuh. `text` atau `buttonText` keduanya diterima. Field `icon` opsional (string uppercase, e.g. `'CHECK'`, `'LINK'`).
1287
-
1288
- ```js
1289
- // Catalog button — buka katalog bisnis
1290
- await sock.sendMessage(jid, {
1291
- text: 'Lihat produk kami',
1292
- nativeFlow: [
1293
- { catalog: '628xxx', text: 'Buka Katalog' }
1294
- ]
1295
- })
1296
-
1297
- // Reminder button
1298
- await sock.sendMessage(jid, {
1299
- text: 'Ingatkan saya',
1300
- nativeFlow: [
1301
- { reminder: true, text: 'Set Pengingat' },
1302
- { cancelReminder: true, text: 'Batalkan Pengingat' }
1303
- ]
1304
- })
1305
-
1306
- // Address & Location button
1307
- await sock.sendMessage(jid, {
1308
- text: 'Butuh info lokasi',
1309
- nativeFlow: [
1310
- { address: true, text: 'Bagikan Alamat' },
1311
- { location: true, text: 'Kirim Lokasi' }
1312
- ]
1313
- })
1314
-
1315
- // Open Webview button
1316
- await sock.sendMessage(jid, {
1317
- text: 'Buka halaman web',
1318
- nativeFlow: [
1319
- { webview: 'https://example.com', text: 'Buka', inAppWebview: true }
1320
- ]
1321
- })
1322
-
1323
- // MPM — Multi-product message button
1324
- await sock.sendMessage(jid, {
1325
- text: 'Produk pilihan',
1326
- nativeFlow: [
1327
- { productId: '8816262248471474', text: 'Lihat Produk' }
1328
- ]
1329
- })
1330
-
1331
- // Payment transaction details button
1332
- await sock.sendMessage(jid, {
1333
- text: 'Detail pembayaran',
1334
- nativeFlow: [
1335
- { transactionId: '12345848', text: 'Lihat Detail' }
1336
- ]
1337
- })
1338
-
1339
- // Automated greeting catalog button
1340
- await sock.sendMessage(jid, {
1341
- text: 'Halo! Cek katalog kami',
1342
- nativeFlow: [
1343
- {
1344
- catalogProduct: { bizPhone: '628xxx', productId: '12345' },
1345
- text: 'Lihat Katalog'
1346
- }
1347
- ]
1348
- })
1349
-
1350
- // WA Flow (galaxy_message)
1351
- await sock.sendMessage(jid, {
1352
- text: 'Isi formulir pendaftaran',
1353
- nativeFlow: [
1354
- {
1355
- flow: {
1356
- mode: 'published',
1357
- flowId: '1307913409923914',
1358
- flowToken: '1:1307913409923914:293680f87029f5a13d1ec5e35e718af3',
1359
- flowCta: 'Daftar Sekarang',
1360
- flowAction: 'navigate',
1361
- flowActionPayload: {
1362
- screen: 'QUESTION_ONE',
1363
- params: { user_id: '123456789' }
1364
- },
1365
- flowMetadata: {
1366
- flow_json_version: '201',
1367
- data_api_protocol: 'v2',
1368
- flow_name: 'Lead Qualification',
1369
- data_api_version: 'v2',
1370
- categories: ['Lead Generation']
1371
- }
1372
- },
1373
- text: 'Buka Flow'
1374
- }
1375
- ]
1376
- })
1377
- ```
1300
+ > **Tipe tombol ditentukan otomatis** dari field yang ada: `id` → quick_reply · `url` → cta_url · `copy` → cta_copy · `call` → cta_call · `sections` → single_select. Bisa juga pakai `name` + `paramsJson` langsung untuk kontrol penuh. `text` atau `buttonText` keduanya diterima. Field `icon` opsional (string uppercase, e.g. `'CHECK'`, `'LINK'`).
1378
1301
 
1379
1302
  </details>
1380
1303
 
@@ -1413,172 +1336,6 @@ await sock.sendMessage(jid, {
1413
1336
 
1414
1337
  ---
1415
1338
 
1416
- <details>
1417
- <summary>🏪 Shop Message</summary>
1418
-
1419
- Menampilkan storefront toko bisnis WhatsApp. Bisa dengan header teks, gambar, video, dokumen, lokasi, atau produk.
1420
-
1421
- ```js
1422
- // Teks biasa
1423
- await sock.sendMessage(jid, {
1424
- text: 'Kunjungi toko kami!',
1425
- title: 'Toko Kami',
1426
- subtitle: 'Produk terbaik',
1427
- footer: 'Belanja sekarang',
1428
- shop: {
1429
- surface: 1, // 1 | 2 | 3 | 4
1430
- id: 'https://example.com'
1431
- }
1432
- })
1433
-
1434
- // Dengan gambar
1435
- await sock.sendMessage(jid, {
1436
- image: { url: 'https://example.com/banner.jpg' },
1437
- caption: 'Promo spesial hari ini!',
1438
- title: 'Toko Kami',
1439
- subtitle: 'Diskon 50%',
1440
- footer: 'Tap untuk belanja',
1441
- hasMediaAttachment: true,
1442
- shop: {
1443
- surface: 1,
1444
- id: 'https://example.com'
1445
- }
1446
- })
1447
-
1448
- // Dengan video
1449
- await sock.sendMessage(jid, {
1450
- video: { url: 'https://example.com/promo.mp4' },
1451
- caption: 'Tonton promo kami!',
1452
- title: 'Promo Bulan Ini',
1453
- footer: 'Belanja sekarang',
1454
- hasMediaAttachment: true,
1455
- shop: { surface: 2, id: 'https://example.com' }
1456
- })
1457
- ```
1458
-
1459
- </details>
1460
-
1461
- ---
1462
-
1463
- <details>
1464
- <summary>📦 Collection Message</summary>
1465
-
1466
- Menampilkan koleksi produk dari bisnis WhatsApp.
1467
-
1468
- ```js
1469
- // Teks biasa
1470
- await sock.sendMessage(jid, {
1471
- text: 'Koleksi terbaru kami',
1472
- title: 'Koleksi Musim Ini',
1473
- subtitle: 'Pilihan terbaik',
1474
- footer: 'Lihat semua',
1475
- collection: {
1476
- bizJid: '628xxx@s.whatsapp.net',
1477
- id: 'collection-id-123',
1478
- version: 1
1479
- }
1480
- })
1481
-
1482
- // Dengan gambar
1483
- await sock.sendMessage(jid, {
1484
- image: { url: 'https://example.com/collection.jpg' },
1485
- caption: 'Temukan koleksi terbaru!',
1486
- title: 'Koleksi Baru',
1487
- subtitle: 'Limited edition',
1488
- footer: 'Stok terbatas!',
1489
- hasMediaAttachment: true,
1490
- collection: {
1491
- bizJid: '628xxx@s.whatsapp.net',
1492
- id: 'collection-id-456',
1493
- version: 1
1494
- }
1495
- })
1496
- ```
1497
-
1498
- </details>
1499
-
1500
- ---
1501
-
1502
- <details>
1503
- <summary>📦 Order Status Message</summary>
1504
-
1505
- Mengirim kartu status pesanan dengan tampilan native WhatsApp (menggunakan `order_status` native flow, dibungkus view once).
1506
-
1507
- ```js
1508
- await sock.sendMessage(jid, {
1509
- orderStatus: {
1510
- image: 'path/to/image.jpg', // string path, URL, atau Buffer — wajib
1511
- title: 'Status Pesananmu', // judul header
1512
- text: 'Pesananmu sedang diproses.',
1513
- footer: 'Terima kasih sudah belanja!',
1514
- referenceId: 'ORDER-001', // ID referensi pesanan
1515
- status: 'PROCESSING', // PROCESSING | COMPLETED | CANCELLED | dst
1516
- subtotalValue: 50000, // subtotal dalam satuan terkecil
1517
- subtotalOffset: 100, // pembagi (100 = dalam rupiah)
1518
- taxValue: 5000,
1519
- taxOffset: 100,
1520
- currency: 'IDR'
1521
- }
1522
- })
1523
-
1524
- // Status pesanan selesai
1525
- await sock.sendMessage(jid, {
1526
- orderStatus: {
1527
- image: { url: 'https://example.com/order.jpg' },
1528
- title: 'Pesanan Selesai! 🎉',
1529
- text: 'Pesananmu telah dikirim.',
1530
- referenceId: 'ORDER-789',
1531
- status: 'COMPLETED',
1532
- subtotalValue: 150000,
1533
- subtotalOffset: 100,
1534
- taxValue: 0,
1535
- taxOffset: 100,
1536
- currency: 'IDR'
1537
- }
1538
- }, { quoted: m })
1539
- ```
1540
-
1541
- > ⚠️ `image` wajib diisi — `orderStatus` selalu dibungkus dalam viewOnceMessage.
1542
-
1543
- </details>
1544
-
1545
- ---
1546
-
1547
- <details>
1548
- <summary>🛒 Product List Message</summary>
1549
-
1550
- Menampilkan list produk bisnis (hanya berfungsi di private chat).
1551
-
1552
- ```js
1553
- await sock.sendMessage(jid, {
1554
- text: 'Pilih produk yang kamu inginkan',
1555
- title: 'Produk Pilihan',
1556
- buttonText: 'Lihat Daftar Produk',
1557
- footer: 'Stok terbatas!',
1558
- businessOwnerJid: '628xxx@s.whatsapp.net',
1559
- thumbnail: { url: 'https://example.com/thumbnail.jpg' }, // opsional
1560
- productList: [
1561
- {
1562
- title: 'Kategori Makanan',
1563
- products: [
1564
- { productId: '111222333' },
1565
- { productId: '444555666' }
1566
- ]
1567
- },
1568
- {
1569
- title: 'Kategori Minuman',
1570
- products: [
1571
- { productId: '777888999' }
1572
- ]
1573
- }
1574
- ]
1575
- })
1576
- ```
1577
-
1578
- </details>
1579
-
1580
- ---
1581
-
1582
1339
  <details>
1583
1340
  <summary>🏷️ Status Mention</summary>
1584
1341
 
@@ -471,7 +471,8 @@ export const makeMessagesSocket = (config) => {
471
471
  }
472
472
  await authState.keys.transaction(async () => {
473
473
  const normalizedMsg = normalizeMessageContent(message);
474
- const mediaType = getMediaType(normalizedMsg || message);
474
+ const isGroupStatusAudio = !!(message?.groupStatusMessageV2?.message?.audioMessage);
475
+ const mediaType = isGroupStatusAudio ? undefined : getMediaType(normalizedMsg || message);
475
476
  if (mediaType) {
476
477
  extraAttrs['mediatype'] = mediaType;
477
478
  }
@@ -912,7 +913,9 @@ export const makeMessagesSocket = (config) => {
912
913
  if (normalizedMessage.eventMessage) {
913
914
  return 'event';
914
915
  }
915
- if (getMediaType(normalizedMessage) !== '') {
916
+ // Audio wrapped in groupStatusMessageV2 → type "text" (Baileys behavior)
917
+ const isGroupStatusAudio = !!(message?.groupStatusMessageV2?.message?.audioMessage);
918
+ if (!isGroupStatusAudio && getMediaType(normalizedMessage) !== '') {
916
919
  return 'media';
917
920
  }
918
921
  return 'text';