@nuiisweety/baileys 0.1.1 → 0.1.2

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,222 @@ 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
+ ```js
1240
+ // Rumus sederhana
1241
+ await sock.sendMessage(jid, {
1242
+ latex: {
1243
+ text: 'Berikut rumus yang kamu minta:',
1244
+ expressions: [
1245
+ {
1246
+ expression: 'E = mc^2',
1247
+ url: 'https://example.com/formula/e-mc2.png', // opsional: gambar render-nya
1248
+ width: 120,
1249
+ height: 40
1250
+ }
1251
+ ]
1252
+ },
1253
+ headerText: 'Rumus Einstein~ 🌟',
1254
+ footerText: 'E = energi, m = massa, c = kecepatan cahaya 💡'
1255
+ })
1256
+
1257
+ // Multiple expressions
1258
+ await sock.sendMessage(jid, {
1259
+ latex: {
1260
+ text: 'Rumus-rumus fisika dasar:',
1261
+ expressions: [
1262
+ { expression: 'F = ma', width: 80, height: 35 },
1263
+ { expression: 'v = u + at', width: 100, height: 35 },
1264
+ { expression: 's = ut + \\frac{1}{2}at^2', width: 160, height: 50 }
1265
+ ]
1266
+ },
1267
+ headerText: 'Hukum Newton 🍎',
1268
+ disclaimerText: 'Fisika dasar kelas 10~'
1269
+ })
1270
+ ```
1271
+
1272
+ > 💡 `expression` menggunakan sintaks LaTeX standar. `url` adalah opsional — URL gambar hasil render LaTeX (misalnya dari layanan seperti render.githubusercontent.com)~
1273
+
1274
+ ---
1275
+
1276
+ ## 🎠 Content Items (Rich)
1277
+
1278
+ > 🎬 Kirim daftar konten berupa reel/video carousel — seperti hasil rekomendasi konten AI~
1279
+
1280
+ ```js
1281
+ // Carousel reel
1282
+ await sock.sendMessage(jid, {
1283
+ contentItems: {
1284
+ contentType: 1, // 0 = DEFAULT, 1 = CAROUSEL
1285
+ items: [
1286
+ {
1287
+ kind: 'reel',
1288
+ title: 'Tutorial Coding JavaScript 🌸',
1289
+ profileIconUrl: 'https://example.com/avatar1.jpg',
1290
+ thumbnailUrl: 'https://example.com/thumb1.jpg',
1291
+ videoUrl: 'https://example.com/video1.mp4'
1292
+ },
1293
+ {
1294
+ kind: 'reel',
1295
+ title: 'Belajar React Hooks 💕',
1296
+ profileIconUrl: 'https://example.com/avatar2.jpg',
1297
+ thumbnailUrl: 'https://example.com/thumb2.jpg',
1298
+ videoUrl: 'https://example.com/video2.mp4'
1299
+ },
1300
+ {
1301
+ kind: 'reel',
1302
+ title: 'Node.js untuk Pemula 🌿',
1303
+ profileIconUrl: 'https://example.com/avatar3.jpg',
1304
+ thumbnailUrl: 'https://example.com/thumb3.jpg',
1305
+ videoUrl: 'https://example.com/video3.mp4'
1306
+ }
1307
+ ]
1308
+ },
1309
+ headerText: 'Rekomendasi video untukmu~ 🎬',
1310
+ footerText: 'Selamat belajar! 💖'
1311
+ })
1312
+ ```
1313
+
1314
+ ---
1315
+
1316
+
1101
1317
  ## 🌈 Rich Response (Gabungan)
1102
1318
 
1103
1319
  > 💞 Kirim gabungan teks, kode, dan tabel dalam satu pesan AI Rich Response~
@@ -1122,6 +1338,121 @@ await sock.sendMessage(jid, {
1122
1338
 
1123
1339
  ---
1124
1340
 
1341
+ ---
1342
+
1343
+ ---
1344
+
1345
+ ## 📥 Terima & Decode Rich Message
1346
+
1347
+ > 🔍 Parse pesan rich yang masuk (dari bot lain atau diri sendiri) menjadi objek yang mudah dipakai~
1348
+
1349
+ ```js
1350
+ const { normalizeMessageContent, parseRichMessage } = require('@nuiisweety/baileys')
1351
+
1352
+ sock.ev.on('messages.upsert', async ({ messages }) => {
1353
+ for (const msg of messages) {
1354
+ // unwrap botForwardedMessage -> dapat richResponseMessage di dalamnya
1355
+ const inner = normalizeMessageContent(msg.message)
1356
+ const parsed = parseRichMessage(inner?.richResponseMessage)
1357
+
1358
+ if (!parsed) continue
1359
+
1360
+ console.log('Rich message diterima! 🌸')
1361
+ console.log('Total bagian:', parsed.submessages.length)
1362
+
1363
+ for (const sub of parsed.submessages) {
1364
+ switch (sub.type) {
1365
+ case 'text':
1366
+ console.log('📝 Teks:', sub.text)
1367
+ break
1368
+
1369
+ case 'code':
1370
+ console.log('💻 Kode (' + sub.language + '):')
1371
+ console.log(sub.raw) // ← source code mentah tanpa highlight
1372
+ break
1373
+
1374
+ case 'table':
1375
+ console.log('📊 Tabel:', sub.title)
1376
+ for (const row of sub.rows) {
1377
+ console.log(row.isHeading ? '[Header]' : '[Row]', row.items)
1378
+ }
1379
+ break
1380
+
1381
+ case 'gridImage':
1382
+ console.log('🖼️ Grid Image:', sub.gridImageUrl)
1383
+ console.log('Thumbnails:', sub.imageUrls.length)
1384
+ break
1385
+
1386
+ case 'inlineImage':
1387
+ console.log('🖼️ Inline Image:', sub.imageUrl)
1388
+ console.log('Teks:', sub.imageText)
1389
+ break
1390
+
1391
+ case 'dynamic':
1392
+ console.log('🎞️ Dynamic (GIF/Image):', sub.url)
1393
+ console.log('Type:', sub.dynamicType === 2 ? 'GIF' : 'Image')
1394
+ break
1395
+
1396
+ case 'map':
1397
+ console.log('🗺️ Map:', sub.centerLatitude, sub.centerLongitude)
1398
+ for (const ann of sub.annotations) {
1399
+ console.log(' -', ann.title, ':', ann.body)
1400
+ }
1401
+ break
1402
+
1403
+ case 'latex':
1404
+ console.log('🧮 LaTeX:', sub.text)
1405
+ for (const expr of sub.expressions) {
1406
+ console.log(' -', expr.expression)
1407
+ }
1408
+ break
1409
+
1410
+ case 'contentItems':
1411
+ console.log('🎠 Content Items (' + sub.contentType + '):')
1412
+ for (const item of sub.items) {
1413
+ if (item.kind === 'reel') {
1414
+ console.log(' -', item.title, '→', item.videoUrl)
1415
+ }
1416
+ }
1417
+ break
1418
+ }
1419
+ }
1420
+ }
1421
+ })
1422
+ ```
1423
+
1424
+ > 💡 `parseRichMessage` bisa terima `null` atau `undefined` dengan aman — return `null` kalau tidak ada rich message~
1425
+
1426
+ ---
1427
+
1428
+ ## 📋 Bahasa yang Didukung
1429
+
1430
+ > 🌸 Daftar lengkap bahasa pemrograman yang memiliki keyword highlighting untuk Code Block~
1431
+
1432
+ | Bahasa | Key yang valid |
1433
+ |--------|----------------|
1434
+ | JavaScript | `javascript`, `js` |
1435
+ | TypeScript | `typescript`, `ts` |
1436
+ | Python | `python`, `py` |
1437
+ | Go | `go`, `golang` |
1438
+ | C++ | `cpp`, `c++` |
1439
+ | Rust | `rust`, `rs` |
1440
+ | Java | `java` |
1441
+ | PHP | `php` |
1442
+ | Ruby | `ruby`, `rb` |
1443
+ | Kotlin | `kotlin`, `kt` |
1444
+ | Swift | `swift` |
1445
+ | C | `c` |
1446
+ | SQL / MySQL / PostgreSQL | `sql`, `mysql`, `postgresql`, `sqlite` |
1447
+ | Bash / Shell | `bash`, `sh`, `shell` |
1448
+ | HTML | `html` |
1449
+ | CSS | `css` |
1450
+ | JSON | `json` |
1451
+ | YAML | `yaml`, `yml` |
1452
+
1453
+ > 💡 Bahasa lain yang tidak ada di daftar akan tetap dikirim sebagai code block, hanya saja tanpa syntax highlighting~
1454
+
1455
+
1125
1456
  ## 📩 List Reply
1126
1457
 
1127
1458
  > 🌷 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