@pontasockets/baileys 0.2.3 → 0.2.4

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
@@ -63,6 +63,8 @@ This fork introduces targeted custom patches on top of the original Baileys libr
63
63
  |---|-------|-------------|
64
64
  | `01` | 🤖 **Code Block Message** | Send syntax-highlighted code via `{ code, language }` — renders as AI bot message in WhatsApp |
65
65
  | `02` | 📊 **Table Message** | Send structured tables via `{ table: { title?, headers, rows } }` — renders as rich table in WhatsApp |
66
+ | `03` | 📝 **Rich Text Message** | Send styled text via `{ richText: '...' }` — renders as AI bot markdown text in WhatsApp |
67
+ | `04` | 🔀 **Mixed Rich Message** | Combine text + code + table in one message via `{ items: [...] }` |
66
68
  | `02` | 🪪 **Custom Message ID** | All outgoing message IDs prefixed with `PONTASOCKETS` |
67
69
  | `03` | 🐛 **LID Bug Fixes** | Full fix for participant, mentionedJid, sender, and group admin LID resolution |
68
70
  | `04` | 📦 **makeInMemoryStore Fix** | Corrected store behavior for stable session handling |
@@ -395,6 +397,99 @@ await sock.sendMessage(jid, {
395
397
 
396
398
  </details>
397
399
 
400
+ <details>
401
+ <summary><b>📝 Rich Text Message <kbd>NEW</kbd></b></summary>
402
+ <br>
403
+
404
+ > Renders as AI bot markdown-style text dalam WhatsApp (gunakan `richText`, bukan `text` — supaya tidak konflik dengan text message biasa)
405
+
406
+ ```javascript
407
+ // Simple text
408
+ await sock.sendMessage(jid, {
409
+ richText: 'Halo! Ini adalah pesan teks rich dari bot.'
410
+ }, { quoted: message })
411
+
412
+ // Markdown supported (bold, italic, code inline)
413
+ await sock.sendMessage(jid, {
414
+ richText: '*Hasil eksekusi:*\nStatus: `success`\nWaktu: _120ms_'
415
+ }, { quoted: message })
416
+ ```
417
+
418
+ </details>
419
+
420
+ <details>
421
+ <summary><b>🔀 Mixed Rich Message <kbd>NEW</kbd></b></summary>
422
+ <br>
423
+
424
+ > Gabungkan text, code block, dan table dalam urutan bebas dalam satu pesan menggunakan key `items`
425
+
426
+ **Text → Code → Text**
427
+
428
+ ```javascript
429
+ await sock.sendMessage(jid, {
430
+ items: [
431
+ { text: 'Contoh fungsi JavaScript:' },
432
+ { code: 'function greet(name) {\n return `Hello, ${name}!`\n}', language: 'javascript' },
433
+ { text: 'Panggil fungsi di atas dengan `greet("Ponta")` untuk mendapat output `Hello, Ponta!`' }
434
+ ]
435
+ }, { quoted: message })
436
+ ```
437
+
438
+ **Text → Code → Table**
439
+
440
+ ```javascript
441
+ await sock.sendMessage(jid, {
442
+ items: [
443
+ { text: 'Query yang dijalankan:' },
444
+ { code: 'SELECT id, name, score FROM users ORDER BY score DESC LIMIT 3', language: 'sql' },
445
+ { text: 'Hasil:' },
446
+ {
447
+ table: {
448
+ headers: ['id', 'name', 'score'],
449
+ rows: [
450
+ ['1', 'Ponta', '98'],
451
+ ['2', 'Yue', '87'],
452
+ ['3', 'Frieren', '75']
453
+ ]
454
+ }
455
+ }
456
+ ]
457
+ }, { quoted: message })
458
+ ```
459
+
460
+ **Full mixed**
461
+
462
+ ```javascript
463
+ await sock.sendMessage(jid, {
464
+ items: [
465
+ { text: '*Dokumentasi Command `.eval`*' },
466
+ { text: 'Syntax:' },
467
+ { code: '.eval <kode javascript>', language: 'bash' },
468
+ { text: 'Contoh penggunaan:' },
469
+ { code: 'return 1 + 1', language: 'javascript' },
470
+ { text: 'Supported types:' },
471
+ {
472
+ table: {
473
+ headers: ['Type', 'Contoh'],
474
+ rows: [
475
+ ['Expression', '2 ** 10'],
476
+ ['Statement', 'let x = 5; return x'],
477
+ ['Async', 'await fetch(url)']
478
+ ]
479
+ }
480
+ },
481
+ { text: '_Hanya owner yang bisa menggunakan command ini._' }
482
+ ]
483
+ }, { quoted: message })
484
+ ```
485
+
486
+ > **Tipe yang valid di dalam `items`:**
487
+ > - `{ text: 'string' }` — teks / markdown
488
+ > - `{ code: 'string', language: 'string' }` — code block
489
+ > - `{ table: { title?, headers?, rows } }` — tabel
490
+
491
+ </details>
492
+
398
493
  <details>
399
494
  <summary><b>🖼️ Image Message</b></summary>
400
495
  <br>
@@ -1013,4 +1108,4 @@ This project is licensed for **personal and non-commercial use only**.
1013
1108
 
1014
1109
  *Made with ♥ by PONTASOCKETS*
1015
1110
 
1016
- </div>
1111
+ </div>
@@ -409,7 +409,7 @@ const generateForwardMessageContent = (message, forceForward) => {
409
409
 
410
410
  const generateWAMessageContent = async (message, options) => {
411
411
  let m = {}
412
- if ('code' in message || 'codes' in message || 'table' in message || 'items' in message) {
412
+ if ('code' in message || 'codes' in message || 'table' in message || 'items' in message || 'richText' in message) {
413
413
  return rich_message_utils_1.prepareRichResponseMessage(message)
414
414
  } else if ('text' in message) {
415
415
  const extContent = {
@@ -238,10 +238,11 @@ const prepareRichResponseMessage = (content) => {
238
238
 
239
239
  // Normalize ke array of items
240
240
  // Support:
241
- // { code, language } — single code block
242
- // { codes: [{ code, language }, ...] } — multi code block
243
- // { table: { title?, headers?, rows } } — single table
244
- // { items: [{ code, language } | { table }] } mixed, bebas urutan
241
+ // { code, language } — single code block
242
+ // { codes: [{ code, language }, ...] } — multi code block
243
+ // { table: { title?, headers?, rows } } — single table
244
+ // { text: 'string' } single text
245
+ // { items: [{ text } | { code, language } | { table }] } — mixed, bebas urutan
245
246
  let items = []
246
247
 
247
248
  if (content.items) {
@@ -250,11 +251,28 @@ const prepareRichResponseMessage = (content) => {
250
251
  items = content.codes.map(c => ({ code: c.code, language: c.language }))
251
252
  } else if (content.table) {
252
253
  items = [{ table: content.table }]
254
+ } else if ('richText' in content) {
255
+ items = [{ text: content.richText }]
253
256
  } else {
254
257
  items = [{ code: content.code, language: content.language }]
255
258
  }
256
259
 
257
260
  const built = items.map(item => {
261
+ // ── TEXT ──────────────────────────────────────────────────────────────
262
+ if ('text' in item) {
263
+ return {
264
+ submessage: proto.AIRichResponseSubMessage.create({
265
+ messageType: RichSubMessageType.TEXT, // 2
266
+ messageText: item.text
267
+ }),
268
+ unified: {
269
+ messageType: RichSubMessageType.TEXT,
270
+ messageText: item.text
271
+ }
272
+ }
273
+ }
274
+
275
+ // ── TABLE ─────────────────────────────────────────────────────────────
258
276
  if (item.table) {
259
277
  const { title, headers, rows } = item.table
260
278
 
@@ -296,7 +314,7 @@ const prepareRichResponseMessage = (content) => {
296
314
  }
297
315
  }
298
316
 
299
- // Default: code block
317
+ // ── CODE (default) ────────────────────────────────────────────────────
300
318
  const lang = item.language || 'javascript'
301
319
  const codeBlocks = tokenizeCode(item.code, lang)
302
320
  return {
@@ -361,4 +379,4 @@ const prepareRichResponseMessage = (content) => {
361
379
 
362
380
  return message
363
381
  }
364
- exports.prepareRichResponseMessage = prepareRichResponseMessage
382
+ exports.prepareRichResponseMessage = prepareRichResponseMessage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pontasockets/baileys",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Baileys is a lightweight JavaScript library for interacting with the WhatsApp Web API using WebSocket.",
5
5
  "keywords": [
6
6
  "facebook",