@nuiisweety/baileys 0.1.1 → 0.1.3

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
@@ -45,7 +45,7 @@
45
45
  [Buttons](#-buttons)  ·  [List Message](#-list-message)  ·  [Template Buttons](#️-template-buttons)  ·  [Native Flow](#-native-flow)  ·  [Carousel](#-carousel)
46
46
 
47
47
  **🌟 Rich Message (AI)**
48
- [Code Block](#-code-block)  ·  [Links](#-links-rich)  ·  [Table](#-table-rich)  ·  [Rich Response (Gabungan)](#-rich-response-gabungan)
48
+ [Code Block](#-code-block)  ·  [Links](#-links-rich)  ·  [Table](#-table-rich)  ·  [Grid Image](#%EF%B8%8F-grid-image-rich)  ·  [Inline Image](#%EF%B8%8F-inline-image-rich)  ·  [Dynamic / GIF](#-dynamic--gif-rich)  ·  [Map](#%EF%B8%8F-map-rich)  ·  [LaTeX](#-latex-rich)  ·  [Content Items](#-content-items-rich)  ·  [Rich Response (Gabungan)](#-rich-response-gabungan)  ·  [Terima & Decode](#-terima--decode-rich-message)  ·  [Bahasa Kode](#-bahasa-yang-didukung)
49
49
 
50
50
  **🍃 Lainnya**
51
51
  [List Reply](#-list-reply)  ·  [Sticker Pack](#-sticker-pack)  ·  [External Ad Reply](#-external-ad-reply)  ·  [Request Payment](#-request-payment)  ·  [Invoice](#-invoice)  ·  [Order](#-order)  ·  [Disappearing Messages](#-disappearing-messages)  ·  [Raw Message](#-raw-message)
@@ -1098,6 +1098,252 @@ await sock.sendMessage(jid, {
1098
1098
 
1099
1099
  ---
1100
1100
 
1101
+ ## 🖼️ Grid Image (Rich)
1102
+
1103
+ > 🌸 Kirim grid gambar — satu gambar utama dengan beberapa thumbnail, tampil sebagai AI Rich Response~
1104
+
1105
+ ```js
1106
+ await sock.sendMessage(jid, {
1107
+ gridImage: {
1108
+ gridImageUrl: {
1109
+ imagePreviewUrl: 'https://example.com/thumb.jpg',
1110
+ imageHighResUrl: 'https://example.com/image.jpg',
1111
+ sourceUrl: 'https://example.com'
1112
+ },
1113
+ imageUrls: [
1114
+ {
1115
+ imagePreviewUrl: 'https://example.com/t1.jpg',
1116
+ imageHighResUrl: 'https://example.com/i1.jpg',
1117
+ sourceUrl: 'https://example.com/1'
1118
+ },
1119
+ {
1120
+ imagePreviewUrl: 'https://example.com/t2.jpg',
1121
+ imageHighResUrl: 'https://example.com/i2.jpg',
1122
+ sourceUrl: 'https://example.com/2'
1123
+ }
1124
+ ]
1125
+ },
1126
+ headerText: 'Hasil pencarian gambar 🌸',
1127
+ footerText: 'Sumber: Internet 🌐'
1128
+ })
1129
+ ```
1130
+
1131
+ > 💡 `imageUrls` adalah array gambar pendukung di bawah gambar utama~
1132
+
1133
+ ---
1134
+
1135
+ ## 🖼️ Inline Image (Rich)
1136
+
1137
+ > ✨ Kirim gambar yang muncul inline di dalam teks — seperti ilustrasi di dalam respons AI~
1138
+
1139
+ ```js
1140
+ await sock.sendMessage(jid, {
1141
+ inlineImage: {
1142
+ imageUrl: {
1143
+ imagePreviewUrl: 'https://example.com/preview.jpg',
1144
+ imageHighResUrl: 'https://example.com/hires.jpg',
1145
+ sourceUrl: 'https://example.com'
1146
+ },
1147
+ imageText: 'Ilustrasi diagram arsitektur 💡',
1148
+ alignment: 0, // 0 = leading, 1 = trailing, 2 = center
1149
+ tapLinkUrl: 'https://example.com/detail'
1150
+ },
1151
+ headerText: 'Berikut ilustrasinya~ 🌷',
1152
+ footerText: 'Tap gambar untuk detail 🔍'
1153
+ })
1154
+ ```
1155
+
1156
+ ---
1157
+
1158
+ ## 🎞️ Dynamic / GIF (Rich)
1159
+
1160
+ > 💫 Kirim animasi atau GIF sebagai bagian dari AI Rich Response~
1161
+
1162
+ ```js
1163
+ // GIF animasi
1164
+ await sock.sendMessage(jid, {
1165
+ dynamic: {
1166
+ url: 'https://example.com/animation.gif',
1167
+ type: 2, // 1 = IMAGE, 2 = GIF
1168
+ version: 1,
1169
+ loopCount: 0 // 0 = loop selamanya
1170
+ },
1171
+ headerText: 'Animasi untuk kamu 💕',
1172
+ footerText: 'Cantik kan~ 🌸'
1173
+ })
1174
+
1175
+ // Gambar statis via dynamic
1176
+ await sock.sendMessage(jid, {
1177
+ dynamic: {
1178
+ url: 'https://example.com/image.png',
1179
+ type: 1, // IMAGE
1180
+ version: 1,
1181
+ loopCount: 1
1182
+ },
1183
+ headerText: 'Gambar ini untukmu 🎀'
1184
+ })
1185
+ ```
1186
+
1187
+ ---
1188
+
1189
+ ## 🗺️ Map (Rich)
1190
+
1191
+ > 🌍 Kirim peta interaktif dengan annotation lokasi — tampil sebagai AI Rich Response~
1192
+
1193
+ ```js
1194
+ // Peta sederhana
1195
+ await sock.sendMessage(jid, {
1196
+ map: {
1197
+ centerLatitude: -6.2088,
1198
+ centerLongitude: 106.8456,
1199
+ latitudeDelta: 0.05,
1200
+ longitudeDelta: 0.05,
1201
+ showInfoList: true,
1202
+ annotations: [
1203
+ {
1204
+ number: 1,
1205
+ latitude: -6.2088,
1206
+ longitude: 106.8456,
1207
+ title: 'Jakarta Pusat 🌆',
1208
+ body: 'Ibu kota Indonesia'
1209
+ }
1210
+ ]
1211
+ },
1212
+ headerText: 'Lokasi yang kamu cari~ 🗺️',
1213
+ footerText: 'Tap peta untuk navigasi 🧭'
1214
+ })
1215
+
1216
+ // Peta multi-lokasi
1217
+ await sock.sendMessage(jid, {
1218
+ map: {
1219
+ centerLatitude: -7.2575,
1220
+ centerLongitude: 112.7521,
1221
+ latitudeDelta: 0.1,
1222
+ longitudeDelta: 0.1,
1223
+ showInfoList: true,
1224
+ annotations: [
1225
+ { number: 1, latitude: -7.2575, longitude: 112.7521, title: 'Surabaya 🏙️', body: 'Kota Pahlawan' },
1226
+ { number: 2, latitude: -7.9797, longitude: 112.6304, title: 'Malang 🌿', body: 'Kota Bunga' }
1227
+ ]
1228
+ },
1229
+ headerText: 'Kota-kota di Jawa Timur~ 🌺'
1230
+ })
1231
+ ```
1232
+
1233
+ ---
1234
+
1235
+ ## 🧮 LaTeX (Rich)
1236
+
1237
+ > ✏️ Kirim rumus matematika dalam format LaTeX — tampil dengan render formula yang indah~
1238
+
1239
+ > ⚠️ **Catatan penting:**
1240
+ > - `url` di setiap expression **wajib ada** agar WA client bisa menampilkan gambar LaTeX. Jika tidak diisi, library akan **auto-generate** URL dari [latex.codecogs.com](https://latex.codecogs.com).
1241
+ > - Gunakan `latex: {...}` langsung (flat) — **bukan** dibungkus dalam `richResponse: [{ latex: {...} }]`.
1242
+ > - `headerText`, `footerText`, `disclaimerText` tetap bisa dipakai bersama `latex`.
1243
+
1244
+ ```js
1245
+ // ✅ Rumus sederhana — url auto-generate jika tidak diisi
1246
+ await sock.sendMessage(jid, {
1247
+ latex: {
1248
+ text: 'Berikut rumus yang kamu minta:',
1249
+ expressions: [
1250
+ {
1251
+ expression: 'E = mc^2',
1252
+ // url auto-generate dari codecogs kalau tidak diisi~
1253
+ width: 120,
1254
+ height: 40
1255
+ }
1256
+ ]
1257
+ },
1258
+ headerText: 'Rumus Einstein~ 🌟',
1259
+ footerText: 'E = energi, m = massa, c = kecepatan cahaya 💡'
1260
+ })
1261
+
1262
+ // ✅ Multiple expressions
1263
+ await sock.sendMessage(jid, {
1264
+ latex: {
1265
+ text: 'Rumus-rumus fisika dasar:',
1266
+ expressions: [
1267
+ { expression: 'F = ma', width: 80, height: 35 },
1268
+ { expression: 'v = u + at', width: 100, height: 35 },
1269
+ { expression: 's = ut + \\frac{1}{2}at^2', width: 160, height: 50 }
1270
+ ]
1271
+ },
1272
+ headerText: 'Hukum Newton 🍎',
1273
+ disclaimerText: 'Fisika dasar kelas 10~'
1274
+ })
1275
+
1276
+ // ✅ Dengan url custom (jika kamu punya server render sendiri)
1277
+ await sock.sendMessage(jid, {
1278
+ latex: {
1279
+ text: 'Energi massa Einstein:',
1280
+ expressions: [
1281
+ {
1282
+ expression: 'E = mc^2',
1283
+ url: 'https://latex.codecogs.com/png.image?\dpi{150}\bg{white}E%20%3D%20mc%5E2',
1284
+ width: 120,
1285
+ height: 40
1286
+ }
1287
+ ]
1288
+ },
1289
+ headerText: 'Fisika Modern ⚛️'
1290
+ })
1291
+ ```
1292
+
1293
+ > 💡 `expression` menggunakan sintaks LaTeX standar. `url` akan **otomatis di-generate** dari codecogs jika tidak diisi — jadi kamu tidak perlu khawatir soal ini~
1294
+
1295
+ > ❌ **Jangan pakai cara ini** (akan kosong/error):
1296
+ > ```js
1297
+ > // SALAH — latex tidak boleh dibungkus richResponse array untuk flat usage
1298
+ > await sock.sendMessage(jid, {
1299
+ > richResponse: [{ latex: { text: '...', expressions: [...] } }],
1300
+ > headerText: 'Judul' // ← headerText diabaikan di mode array lama
1301
+ > })
1302
+ > ```
1303
+
1304
+ ---
1305
+
1306
+ ## 🎠 Content Items (Rich)
1307
+
1308
+ > 🎬 Kirim daftar konten berupa reel/video carousel — seperti hasil rekomendasi konten AI~
1309
+
1310
+ ```js
1311
+ // Carousel reel
1312
+ await sock.sendMessage(jid, {
1313
+ contentItems: {
1314
+ contentType: 1, // 0 = DEFAULT, 1 = CAROUSEL
1315
+ items: [
1316
+ {
1317
+ kind: 'reel',
1318
+ title: 'Tutorial Coding JavaScript 🌸',
1319
+ profileIconUrl: 'https://example.com/avatar1.jpg',
1320
+ thumbnailUrl: 'https://example.com/thumb1.jpg',
1321
+ videoUrl: 'https://example.com/video1.mp4'
1322
+ },
1323
+ {
1324
+ kind: 'reel',
1325
+ title: 'Belajar React Hooks 💕',
1326
+ profileIconUrl: 'https://example.com/avatar2.jpg',
1327
+ thumbnailUrl: 'https://example.com/thumb2.jpg',
1328
+ videoUrl: 'https://example.com/video2.mp4'
1329
+ },
1330
+ {
1331
+ kind: 'reel',
1332
+ title: 'Node.js untuk Pemula 🌿',
1333
+ profileIconUrl: 'https://example.com/avatar3.jpg',
1334
+ thumbnailUrl: 'https://example.com/thumb3.jpg',
1335
+ videoUrl: 'https://example.com/video3.mp4'
1336
+ }
1337
+ ]
1338
+ },
1339
+ headerText: 'Rekomendasi video untukmu~ 🎬',
1340
+ footerText: 'Selamat belajar! 💖'
1341
+ })
1342
+ ```
1343
+
1344
+ ---
1345
+
1346
+
1101
1347
  ## 🌈 Rich Response (Gabungan)
1102
1348
 
1103
1349
  > 💞 Kirim gabungan teks, kode, dan tabel dalam satu pesan AI Rich Response~
@@ -1122,6 +1368,121 @@ await sock.sendMessage(jid, {
1122
1368
 
1123
1369
  ---
1124
1370
 
1371
+ ---
1372
+
1373
+ ---
1374
+
1375
+ ## 📥 Terima & Decode Rich Message
1376
+
1377
+ > 🔍 Parse pesan rich yang masuk (dari bot lain atau diri sendiri) menjadi objek yang mudah dipakai~
1378
+
1379
+ ```js
1380
+ const { normalizeMessageContent, parseRichMessage } = require('@nuiisweety/baileys')
1381
+
1382
+ sock.ev.on('messages.upsert', async ({ messages }) => {
1383
+ for (const msg of messages) {
1384
+ // unwrap botForwardedMessage -> dapat richResponseMessage di dalamnya
1385
+ const inner = normalizeMessageContent(msg.message)
1386
+ const parsed = parseRichMessage(inner?.richResponseMessage)
1387
+
1388
+ if (!parsed) continue
1389
+
1390
+ console.log('Rich message diterima! 🌸')
1391
+ console.log('Total bagian:', parsed.submessages.length)
1392
+
1393
+ for (const sub of parsed.submessages) {
1394
+ switch (sub.type) {
1395
+ case 'text':
1396
+ console.log('📝 Teks:', sub.text)
1397
+ break
1398
+
1399
+ case 'code':
1400
+ console.log('💻 Kode (' + sub.language + '):')
1401
+ console.log(sub.raw) // ← source code mentah tanpa highlight
1402
+ break
1403
+
1404
+ case 'table':
1405
+ console.log('📊 Tabel:', sub.title)
1406
+ for (const row of sub.rows) {
1407
+ console.log(row.isHeading ? '[Header]' : '[Row]', row.items)
1408
+ }
1409
+ break
1410
+
1411
+ case 'gridImage':
1412
+ console.log('🖼️ Grid Image:', sub.gridImageUrl)
1413
+ console.log('Thumbnails:', sub.imageUrls.length)
1414
+ break
1415
+
1416
+ case 'inlineImage':
1417
+ console.log('🖼️ Inline Image:', sub.imageUrl)
1418
+ console.log('Teks:', sub.imageText)
1419
+ break
1420
+
1421
+ case 'dynamic':
1422
+ console.log('🎞️ Dynamic (GIF/Image):', sub.url)
1423
+ console.log('Type:', sub.dynamicType === 2 ? 'GIF' : 'Image')
1424
+ break
1425
+
1426
+ case 'map':
1427
+ console.log('🗺️ Map:', sub.centerLatitude, sub.centerLongitude)
1428
+ for (const ann of sub.annotations) {
1429
+ console.log(' -', ann.title, ':', ann.body)
1430
+ }
1431
+ break
1432
+
1433
+ case 'latex':
1434
+ console.log('🧮 LaTeX:', sub.text)
1435
+ for (const expr of sub.expressions) {
1436
+ console.log(' -', expr.expression)
1437
+ }
1438
+ break
1439
+
1440
+ case 'contentItems':
1441
+ console.log('🎠 Content Items (' + sub.contentType + '):')
1442
+ for (const item of sub.items) {
1443
+ if (item.kind === 'reel') {
1444
+ console.log(' -', item.title, '→', item.videoUrl)
1445
+ }
1446
+ }
1447
+ break
1448
+ }
1449
+ }
1450
+ }
1451
+ })
1452
+ ```
1453
+
1454
+ > 💡 `parseRichMessage` bisa terima `null` atau `undefined` dengan aman — return `null` kalau tidak ada rich message~
1455
+
1456
+ ---
1457
+
1458
+ ## 📋 Bahasa yang Didukung
1459
+
1460
+ > 🌸 Daftar lengkap bahasa pemrograman yang memiliki keyword highlighting untuk Code Block~
1461
+
1462
+ | Bahasa | Key yang valid |
1463
+ |--------|----------------|
1464
+ | JavaScript | `javascript`, `js` |
1465
+ | TypeScript | `typescript`, `ts` |
1466
+ | Python | `python`, `py` |
1467
+ | Go | `go`, `golang` |
1468
+ | C++ | `cpp`, `c++` |
1469
+ | Rust | `rust`, `rs` |
1470
+ | Java | `java` |
1471
+ | PHP | `php` |
1472
+ | Ruby | `ruby`, `rb` |
1473
+ | Kotlin | `kotlin`, `kt` |
1474
+ | Swift | `swift` |
1475
+ | C | `c` |
1476
+ | SQL / MySQL / PostgreSQL | `sql`, `mysql`, `postgresql`, `sqlite` |
1477
+ | Bash / Shell | `bash`, `sh`, `shell` |
1478
+ | HTML | `html` |
1479
+ | CSS | `css` |
1480
+ | JSON | `json` |
1481
+ | YAML | `yaml`, `yml` |
1482
+
1483
+ > 💡 Bahasa lain yang tidak ada di daftar akan tetap dikirim sebagai code block, hanya saja tanpa syntax highlighting~
1484
+
1485
+
1125
1486
  ## 📩 List Reply
1126
1487
 
1127
1488
  > 🌷 Simulasi balasan dari list message (ketika user memilih item dari daftar)~
package/README.md.bak CHANGED
@@ -1,4 +1,4 @@
1
- <h1 align="center">🌸 @nuiisweety/baileys 🌸</h1>
1
+ <h1 align="center">✨@nuiisweety/baileys</h1>
2
2
 
3
3
  <div align="center">
4
4
  <img src="https://raw.githubusercontent.com/NuiiS4TORU/-nuisockets/refs/heads/main/nuiisweety.png" width="100%"/>
@@ -129,7 +129,7 @@ if (!sock.authState.creds.registered) {
129
129
 
130
130
  **🎀 Custom pairing code (8 karakter):**
131
131
  ```js
132
- const code = await sock.requestPairingCode('628123456789', 'ABCD1234')
132
+ const code = await sock.requestPairingCode('628123456789', 'NUYY2822')
133
133
  ```
134
134
 
135
135
  ---
@@ -20,4 +20,4 @@ export var RichSubMessageType;
20
20
  RichSubMessageType[RichSubMessageType["LATEX"] = 8] = "LATEX";
21
21
  RichSubMessageType[RichSubMessageType["CONTENT_ITEMS"] = 9] = "CONTENT_ITEMS";
22
22
  })(RichSubMessageType || (RichSubMessageType = {}));
23
- //# sourceMappingURL=RichType.js.map
23
+ //# sourceMappingURL=RichType.js.map
@@ -0,0 +1,23 @@
1
+ export var CodeHighlightType;
2
+ (function (CodeHighlightType) {
3
+ CodeHighlightType[CodeHighlightType["DEFAULT"] = 0] = "DEFAULT";
4
+ CodeHighlightType[CodeHighlightType["KEYWORD"] = 1] = "KEYWORD";
5
+ CodeHighlightType[CodeHighlightType["METHOD"] = 2] = "METHOD";
6
+ CodeHighlightType[CodeHighlightType["STRING"] = 3] = "STRING";
7
+ CodeHighlightType[CodeHighlightType["NUMBER"] = 4] = "NUMBER";
8
+ CodeHighlightType[CodeHighlightType["COMMENT"] = 5] = "COMMENT";
9
+ })(CodeHighlightType || (CodeHighlightType = {}));
10
+ export var RichSubMessageType;
11
+ (function (RichSubMessageType) {
12
+ RichSubMessageType[RichSubMessageType["UNKNOWN"] = 0] = "UNKNOWN";
13
+ RichSubMessageType[RichSubMessageType["GRID_IMAGE"] = 1] = "GRID_IMAGE";
14
+ RichSubMessageType[RichSubMessageType["TEXT"] = 2] = "TEXT";
15
+ RichSubMessageType[RichSubMessageType["INLINE_IMAGE"] = 3] = "INLINE_IMAGE";
16
+ RichSubMessageType[RichSubMessageType["TABLE"] = 4] = "TABLE";
17
+ RichSubMessageType[RichSubMessageType["CODE"] = 5] = "CODE";
18
+ RichSubMessageType[RichSubMessageType["DYNAMIC"] = 6] = "DYNAMIC";
19
+ RichSubMessageType[RichSubMessageType["MAP"] = 7] = "MAP";
20
+ RichSubMessageType[RichSubMessageType["LATEX"] = 8] = "LATEX";
21
+ RichSubMessageType[RichSubMessageType["CONTENT_ITEMS"] = 9] = "CONTENT_ITEMS";
22
+ })(RichSubMessageType || (RichSubMessageType = {}));
23
+ //# sourceMappingURL=RichType.js.map
@@ -561,7 +561,13 @@ export const generateWAMessageContent = async (message, options) => {
561
561
  else if (hasNonNullishProperty(message, 'code') ||
562
562
  hasNonNullishProperty(message, 'links') ||
563
563
  hasNonNullishProperty(message, 'table') ||
564
- hasNonNullishProperty(message, 'richResponse')) {
564
+ hasNonNullishProperty(message, 'richResponse') ||
565
+ hasNonNullishProperty(message, 'latex') ||
566
+ hasNonNullishProperty(message, 'gridImage') ||
567
+ hasNonNullishProperty(message, 'inlineImage') ||
568
+ hasNonNullishProperty(message, 'dynamic') ||
569
+ hasNonNullishProperty(message, 'map') ||
570
+ hasNonNullishProperty(message, 'contentItems')) {
565
571
  m = prepareRichResponseMessage(message);
566
572
  }
567
573
  else if (hasNonNullishProperty(message, 'text')) {