@nexustechpro/baileys 2.1.2 → 2.1.6

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
@@ -1,16 +1,47 @@
1
1
  <div align="center">
2
2
 
3
- ![NexusTechPro Banner](https://files.catbox.moe/gzkpf8.jpg)
3
+ <p>
4
+ <!-- Banner -->
5
+ <img src="https://files.catbox.moe/gzkpf8.jpg" alt="NexusTechPro Banner" />
6
+ </p>
4
7
 
5
8
  # @nexustechpro/baileys
6
9
 
10
+ <p>
11
+ <img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%">
12
+ </p>
13
+
14
+
7
15
  **Advanced WhatsApp Web API — Built on WhiskeySockets/Baileys**
8
16
 
9
- [![NPM Version](https://img.shields.io/npm/v/@nexustechpro/baileys?color=success&logo=npm&style=flat-square)](https://www.npmjs.com/package/@nexustechpro/baileys)
10
- [![Downloads](https://img.shields.io/npm/dt/@nexustechpro/baileys?color=blue&logo=npm&style=flat-square)](https://www.npmjs.com/package/@nexustechpro/baileys)
11
- [![License](https://img.shields.io/npm/l/@nexustechpro/baileys?color=yellow&style=flat-square)](https://github.com/nexustechpro2/baileys/blob/main/LICENSE)
12
- [![Node Version](https://img.shields.io/node/v/@nexustechpro/baileys?style=flat-square)](https://nodejs.org)
13
- [![Socket Badge](https://socket.dev/api/badge/npm/package/@nexustechpro/baileys)](https://socket.dev/npm/package/@nexustechpro/baileys)
17
+ <p>
18
+ <!-- NPM Version -->
19
+ <a href="https://www.npmjs.com/package/@nexustechpro/baileys">
20
+ <img src="https://img.shields.io/npm/v/@nexustechpro/baileys?color=success&logo=npm&style=flat-square" alt="NPM Version" />
21
+ </a>
22
+ <!-- Downloads -->
23
+ <a href="https://www.npmjs.com/package/@nexustechpro/baileys">
24
+ <img src="https://img.shields.io/npm/dt/@nexustechpro/baileys?color=blue&logo=npm&style=flat-square" alt="Downloads" />
25
+ </a>
26
+ <!-- License -->
27
+ <a href="https://github.com/nexustechpro2/baileys/blob/main/LICENSE">
28
+ <img src="https://img.shields.io/npm/l/@nexustechpro/baileys?color=yellow&style=flat-square" alt="License" />
29
+ </a>
30
+ <!-- Node Version -->
31
+ <a href="https://nodejs.org">
32
+ <img src="https://img.shields.io/node/v/@nexustechpro/baileys?style=flat-square" alt="Node Version" />
33
+ </a>
34
+ <!-- Socket Badge -->
35
+ <a href="https://socket.dev/npm/package/@nexustechpro/baileys">
36
+ <img src="https://socket.dev/api/badge/npm/package/@nexustechpro/baileys" alt="Socket Badge" />
37
+ </a>
38
+ </p>
39
+ <p>
40
+ <!-- WhatsApp Channel -->
41
+ <a href="https://www.whatsapp.com/channel/0029VbBK53XBvvslYeZlBe0V">
42
+ <img src="https://img.shields.io/badge/Join-WhatsApp%20Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
43
+ </a>
44
+ </p>
14
45
 
15
46
  *Modern, feature-rich, and developer-friendly WhatsApp automation library*
16
47
 
@@ -26,11 +57,15 @@
26
57
  - [Browser Options](#-browser-options)
27
58
  - [Socket Configuration](#-socket-configuration)
28
59
  - [Session Management](#-session-management)
60
+ - [File-based](#file-based-default)
61
+ - [Keyv-based (MongoDB, Redis, PostgreSQL, SQLite...)](#keyv-based-production)
62
+ - [Per-type routing](#per-type-routing-advanced)
29
63
  - [Sending Messages](#-sending-messages)
30
64
  - [Text Messages](#text-messages)
31
65
  - [Media Messages](#media-messages)
32
66
  - [Buttons & Interactive](#buttons--interactive-messages)
33
67
  - [Extended Types](#extended-message-types)
68
+ - [AI Rich Messages](#ai-rich-messages)
34
69
  - [Status & Stories](#personal-status--story-statusbroadcast)
35
70
  - [Sticker Pack](#sticker-pack)
36
71
  - [Shorthand Wrappers](#shorthand-wrappers)
@@ -283,21 +318,124 @@ const sock = makeWASocket({
283
318
  getMessage: async (key) => store.loadMessage(key.remoteJid, key.id),
284
319
  })
285
320
  ```
286
-
287
321
  ---
288
322
 
289
323
  ## šŸ’¾ Session Management
290
324
 
325
+ Two adapters are available. They do **not** share an identical return shape — see the differences noted below each.
326
+
327
+ ### File-based (default)
328
+
329
+ Atomic writes, sha256 checksum integrity, per-file mutex locking, corrupt file recovery, and legacy file upgrade. Best for single-instance bots or local development.
330
+
291
331
  ```javascript
292
332
  import { useMultiFileAuthState } from '@nexustechpro/baileys'
293
333
 
294
- const { state, saveCreds } = await useMultiFileAuthState('auth_session')
295
- const sock = makeWASocket({ auth: state })
334
+ const { state, saveCreds, getStats } = await useMultiFileAuthState('auth_session', {
335
+ preKeyRetention: 150, // how many recent prekeys to keep (default: 150)
336
+ cleanupThreshold: 50, // new prekeys before a cleanup runs (default: 50)
337
+ logger, // optional — logs checksum mismatches and cleanup events
338
+ })
296
339
 
340
+ const sock = makeWASocket({ auth: state })
297
341
  sock.ev.on('creds.update', saveCreds)
342
+
343
+ // Diagnostics
344
+ const stats = await getStats()
345
+ // { totalFiles: 42, preKeyCount: 150, nextPreKeyId: 3200, lastCleanupAt: '2026-07-05T...' }
346
+ ```
347
+
348
+ To fully log out and delete a session's files, remove the session folder directly (e.g. `fs.rm(folder, { recursive: true, force: true })`) — there is no `clearSession`/`close` method on this adapter.
349
+
350
+ ### Keyv-based (production)
351
+
352
+ Universal adapter for any database backend via [Keyv](https://github.com/jaredwray/keyv). Pass a connection string — the matching backend driver is resolved and imported automatically, no manual adapter imports needed.
353
+
354
+ Storage format matches `useMultiFileAuthState` exactly: every value is wrapped as `{ data, __checksum }` with a sha256 integrity check, so corruption is detected and self-healed the same way on both adapters. Reads also auto-detect and repair values that were written by an older/buggy version of this adapter (including arbitrarily nested `{ value: { value: ... } }` wrapping) — no manual data-fixing needed if you're upgrading from an earlier release.
355
+
356
+ The first argument is the **session ID** — equivalent to the folder name in `useMultiFileAuthState`. It's used as the Keyv namespace, so multiple bots can safely share one backend. The second argument is a connection string, a pre-built `Keyv` instance, or a raw `KeyvStoreAdapter`:
357
+
358
+ ```javascript
359
+ import { useKeyvAuthState } from '@nexustechpro/baileys'
360
+
361
+ // ── Redis ─────────────────────────────────────────────────────────────────────
362
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'redis://localhost:6379')
363
+
364
+ // ── PostgreSQL / Supabase / Neon ──────────────────────────────────────────────
365
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'postgresql://user:pass@localhost/db')
366
+
367
+ // ── MongoDB ───────────────────────────────────────────────────────────────────
368
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'mongodb://localhost/baileys')
369
+
370
+ // ── MySQL / PlanetScale ───────────────────────────────────────────────────────
371
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'mysql://user:pass@localhost/db')
372
+
373
+ // ── SQLite (local, zero-config) ───────────────────────────────────────────────
374
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'sqlite://auth.db')
375
+
376
+ // ── etcd ──────────────────────────────────────────────────────────────────────
377
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'etcd://localhost:2379')
378
+
379
+ // ── Memcache ──────────────────────────────────────────────────────────────────
380
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'memcache://localhost:11211')
381
+
382
+ // ── In-memory (testing / ephemeral — data lost on restart) ───────────────────
383
+ const { state, saveCreds } = await useKeyvAuthState('test')
384
+ ```
385
+
386
+ Supported connection string protocols: `redis:`/`rediss:`, `mongodb:`/`mongodb+srv:`, `postgres:`/`postgresql:`, `mysql:`, `sqlite:`, `etcd:`, `memcache:`/`memcached:`. All matching driver packages (`@keyv/redis`, `@keyv/mongo`, `@keyv/postgres`, `@keyv/mysql`, `@keyv/sqlite`, `@keyv/etcd`, `@keyv/memcache`) ship as regular dependencies of this package — nothing extra to install.
387
+
388
+ For backends without a connection string (e.g. DynamoDB), or to reuse one connection across multiple `useKeyvAuthState` calls yourself, pass a pre-built adapter or `Keyv` instance instead of a string:
389
+
390
+ ```javascript
391
+ import { useKeyvAuthState } from '@nexustechpro/baileys'
392
+ import KeyvMongo from '@keyv/mongo'
393
+
394
+ const backend = new KeyvMongo('mongodb://localhost/baileys') // build once, share across sessions
395
+ const { state, saveCreds } = await useKeyvAuthState('bot1', backend)
298
396
  ```
299
397
 
300
- > šŸ’” For production, store credentials in a database (MongoDB, Redis, PostgreSQL) rather than the filesystem. The `useMultiFileAuthState` helper is for development only.
398
+ Same connection string passed as a plain string is automatically cached and reused across every `useKeyvAuthState` call in the process — you don't need to build the instance yourself just to avoid opening duplicate connections, but you can if you want the reference for other purposes.
399
+
400
+ By default, Mongo/Postgres/MySQL/SQLite store everything in a collection/table named `keyv` (each adapter's own default). Set `collectionName` to use your own name instead — it's mapped to whatever each backend actually calls it (`collection` for Mongo, `table` for Postgres/MySQL/SQLite):
401
+
402
+ ```javascript
403
+ const { state, saveCreds } = await useKeyvAuthState('bot1', 'mongodb://localhost/baileys', {
404
+ collectionName: 'baileys_auth', // instead of the default "keyv" collection
405
+ })
406
+ ```
407
+
408
+ > Per-type backend routing (e.g. prekeys on SQLite, sessions on Postgres) is not currently supported — one `useKeyvAuthState` call uses one backend for every key type.
409
+
410
+ #### Clearing a session (logout)
411
+
412
+ ```javascript
413
+ const { state, saveCreds, clearSession } = await useKeyvAuthState('bot1', 'redis://localhost:6379')
414
+
415
+ // on logout / when you want to wipe this session's auth entirely:
416
+ await clearSession()
417
+ ```
418
+
419
+ `clearSession()` wipes every key belonging to that `sessionId` — creds, prekeys, sessions, sender keys, everything — using each backend's native namespace-scoped bulk delete (a real `deleteMany`/`DELETE WHERE`/`SCAN`+delete under the hood, not a per-key loop). It only affects this session; other sessions sharing the same backend are untouched. There's no equivalent method on `useMultiFileAuthState` — delete the session folder instead.
420
+
421
+ #### Options
422
+
423
+ | Option | Type | Default | Description |
424
+ |--------|------|---------|-------------|
425
+ | `preKeyRetention` | `number` | `150` | Number of recent prekeys to keep |
426
+ | `cleanupThreshold` | `number` | `50` | New prekeys generated before cleanup runs |
427
+ | `logger` | `object` | `undefined` | Logger with `.info` / `.warn` methods |
428
+ | `collectionName` | `string` | adapter's own default (`"keyv"`) | Custom collection/table name — Keyv-based adapter only, ignored for connection-string-less (in-memory) and pre-built adapter/`Keyv` instances |
429
+
430
+ #### Return values
431
+
432
+ | | `useMultiFileAuthState` | `useKeyvAuthState` |
433
+ |---|---|---|
434
+ | `state` | āœ… | āœ… |
435
+ | `saveCreds` | āœ… | āœ… |
436
+ | `getStats` | āœ… | āŒ |
437
+ | `clearSession` | āŒ (delete the folder instead) | āœ… |
438
+ | `close` | āŒ | āœ… (drops local listeners; safe to call, does not disconnect a shared backend) |
301
439
 
302
440
  ---
303
441
 
@@ -1033,6 +1171,318 @@ await sock.stickerPackMessage(jid, {
1033
1171
 
1034
1172
  ---
1035
1173
 
1174
+ ---
1175
+
1176
+ #### AI Rich Messages
1177
+
1178
+
1179
+ All types can be sent two ways:
1180
+ - **`sock.sendMessage`** with an `aiRich` content key
1181
+ - **Shorthand methods** like `sock.sendCodeBlock`, `sock.sendTable`, etc.
1182
+
1183
+ ---
1184
+
1185
+ ##### Code Block
1186
+
1187
+ ```javascript
1188
+ // via sendMessage
1189
+ await sock.sendMessage(jid, {
1190
+ aiRich: {
1191
+ language: 'javascript',
1192
+ code: `async function fetchUser(id) {
1193
+ const res = await fetch(\`/api/users/\${id}\`)
1194
+ if (!res.ok) throw new Error('Not found')
1195
+ return res.json()
1196
+ }`,
1197
+ header: '**Fetch User Example**',
1198
+ footer: '_Requires Node 18+_'
1199
+ }
1200
+ }, { quoted: message })
1201
+
1202
+ // via shorthand (sendCodeBlock / sendCodeBlockV2)
1203
+ await sock.sendCodeBlock(jid, code, quoted, {
1204
+ language: 'javascript',
1205
+ title: 'Example Code',
1206
+ footer: 'Powered by NexusTechPro'
1207
+ })
1208
+
1209
+ await sock.sendCodeBlockV2(jid, code, quoted, {
1210
+ language: 'go',
1211
+ title: 'Go Example',
1212
+ text: 'Here is a Go snippet:',
1213
+ footer: 'Powered by NexusTechPro'
1214
+ })
1215
+ ```
1216
+
1217
+ **Supported languages:** Any of the 190+ languages supported by PrismJS — `javascript`, `typescript`, `python`, `rust`, `go`, `java`, `cpp`, `kotlin`, `swift`, `bash`, `sql`, `dockerfile`, `solidity`, `graphql`, and many more.
1218
+
1219
+ ---
1220
+
1221
+ ##### Table
1222
+
1223
+ ```javascript
1224
+ // via sendMessage
1225
+ await sock.sendMessage(jid, {
1226
+ aiRich: {
1227
+ table: [
1228
+ 'Java vs JavaScript', // title
1229
+ ['Feature', 'Java', 'JavaScript'], // headers
1230
+ ['Type', 'Compiled', 'Interpreted'],
1231
+ ['Typing', 'Static', 'Dynamic'],
1232
+ ['Main Use', 'Enterprise', 'Web']
1233
+ ],
1234
+ header: '**Comparison**',
1235
+ footer: 'Hope this helps!'
1236
+ }
1237
+ }, { quoted: message })
1238
+
1239
+ // via shorthand (sendTable)
1240
+ await sock.sendTable(
1241
+ jid,
1242
+ 'Java vs JavaScript',
1243
+ ['Feature', 'Java', 'JavaScript'],
1244
+ [
1245
+ ['Type', 'Compiled', 'Interpreted'],
1246
+ ['Typing', 'Static', 'Dynamic'],
1247
+ ['Main Use', 'Enterprise', 'Web']
1248
+ ],
1249
+ quoted,
1250
+ { headerText: 'Comparison:', footer: 'Hope this helps!' }
1251
+ )
1252
+
1253
+ // via shorthand (sendTableV2) — pipe-delimited string format
1254
+ await sock.sendTableV2(
1255
+ jid,
1256
+ [
1257
+ 'Java vs JavaScript',
1258
+ 'Feature | Java | JavaScript',
1259
+ 'Type | Compiled | Interpreted;;Typing | Static | Dynamic;;Main Use | Enterprise | Web'
1260
+ ],
1261
+ quoted,
1262
+ { headerText: 'Comparison:', text: 'Here is a table:', footer: 'Hope this helps!' }
1263
+ )
1264
+
1265
+ // sendList — two-column key/value style
1266
+ await sock.sendList(
1267
+ jid,
1268
+ 'Bot Info',
1269
+ [['Name', 'NexusBot'], ['Version', '2.1.3'], ['Developer', 'THE_TECH_PRO']],
1270
+ quoted,
1271
+ { footer: 'Ā© NexusTechPro' }
1272
+ )
1273
+ ```
1274
+
1275
+ ---
1276
+
1277
+ ##### Text
1278
+
1279
+ ```javascript
1280
+ // via sendMessage
1281
+ await sock.sendMessage(jid, {
1282
+ aiRich: {
1283
+ text: '## Hello\n\nThis supports **markdown**:\n\n- Bold\n- Lists\n- Headers',
1284
+ footer: '_Powered by NexusTechPro_'
1285
+ }
1286
+ }, { quoted: message })
1287
+
1288
+ // multiple text blocks
1289
+ await sock.sendMessage(jid, {
1290
+ aiRich: {
1291
+ texts: ['## Title', 'First paragraph', 'Second paragraph'],
1292
+ footer: '_NexusTechPro_'
1293
+ }
1294
+ }, { quoted: message })
1295
+ ```
1296
+
1297
+ ---
1298
+
1299
+ ##### Links & Search Sources
1300
+
1301
+ ```javascript
1302
+ // via sendMessage (with inline {{IE_N}} placeholders)
1303
+ await sock.sendMessage(jid, {
1304
+ aiRich: {
1305
+ text: 'Upload complete:\nāœ… Freeimage — {{IE_0}}view here{{/IE_0}}\nāœ… Yardsansh — {{IE_1}}view here{{/IE_1}}',
1306
+ sources: [
1307
+ { url: 'https://freeimage.host', displayName: 'Freeimage', subtitle: 'freeimage.host' },
1308
+ { url: 'https://yardsansh.com', displayName: 'Yardsansh', subtitle: 'yardsansh.com' }
1309
+ ],
1310
+ footer: '✨ Done!'
1311
+ }
1312
+ }, { quoted: message })
1313
+
1314
+ // via sendLink shorthand (bare URL array)
1315
+ await sock.sendLink(
1316
+ jid,
1317
+ 'Results:\nšŸ”— {{IE_0}}link one{{/IE_0}}\nšŸ”— {{IE_1}}link two{{/IE_1}}',
1318
+ ['https://example.com/1', 'https://example.com/2'],
1319
+ quoted,
1320
+ { headerText: 'šŸ“ Upload Results', footer: '✨ Done!' }
1321
+ )
1322
+
1323
+ // via sendLinkV2 shorthand (rich source objects with search engine)
1324
+ await sock.sendLinkV2(
1325
+ jid,
1326
+ 'Search results:\n- {{IE_0}}Official docs{{/IE_0}}\n- {{IE_1}}GitHub repo{{/IE_1}}',
1327
+ [
1328
+ { url: 'https://www.npmjs.com/package/@nexustechpro/baileys', displayName: 'Official docs', subtitle: 'npmjs.com' },
1329
+ { url: 'https://github.com/nexustechpro2/baileys', displayName: 'GitHub repo', subtitle: 'github.com' }
1330
+ ],
1331
+ quoted,
1332
+ { headerText: '@nexustechpro/baileys', footer: 'Reference links', searchEngine: 'MAME' }
1333
+ )
1334
+ ```
1335
+
1336
+ ---
1337
+
1338
+ ##### Images
1339
+
1340
+ ```javascript
1341
+ await sock.sendMessage(jid, {
1342
+ aiRich: {
1343
+ text: 'Here are some results:',
1344
+ images: [
1345
+ { url: 'https://example.com/img1.jpg', sourceUrl: 'https://example.com' },
1346
+ { url: 'https://example.com/img2.jpg', sourceUrl: 'https://example.com' }
1347
+ ],
1348
+ footer: '_2 images found_'
1349
+ }
1350
+ }, { quoted: message })
1351
+ ```
1352
+
1353
+ ---
1354
+
1355
+ ##### Reels
1356
+
1357
+ ```javascript
1358
+ await sock.sendMessage(jid, {
1359
+ aiRich: {
1360
+ text: 'Top reels for you:',
1361
+ reels: [
1362
+ {
1363
+ title: 'Creator Name',
1364
+ creator: 'Creator Name',
1365
+ videoUrl: 'https://example.com/reel1.mp4',
1366
+ thumbnailUrl: 'https://example.com/thumb1.jpg',
1367
+ profileIconUrl: 'https://example.com/avatar.jpg',
1368
+ view_count: 12000,
1369
+ likes_count: 800,
1370
+ is_verified: true,
1371
+ reel_source: 'IG'
1372
+ }
1373
+ ]
1374
+ }
1375
+ }, { quoted: message })
1376
+ ```
1377
+
1378
+ ---
1379
+
1380
+ ##### Multiple Codes
1381
+
1382
+ ```javascript
1383
+ await sock.sendMessage(jid, {
1384
+ aiRich: {
1385
+ texts: ['## Sorting Algorithms', 'Two implementations:'],
1386
+ codes: [
1387
+ { language: 'javascript', code: `const bubble = arr => { /* ... */ }` },
1388
+ { language: 'python', code: `def quicksort(arr):\n # ...` }
1389
+ ],
1390
+ footer: '_O(n²) vs O(n log n)_'
1391
+ }
1392
+ }, { quoted: message })
1393
+ ```
1394
+
1395
+ ---
1396
+
1397
+ ##### Composite (mix everything in one message)
1398
+
1399
+ ```javascript
1400
+ await sock.sendMessage(jid, {
1401
+ aiRich: {
1402
+ parts: [
1403
+ { type: 'text', content: '## String Reversal' },
1404
+ { type: 'code', language: 'javascript', content: `const reverse = s => s.split('').reverse().join('')` },
1405
+ { type: 'text', content: 'Performance:' },
1406
+ { type: 'table', table: ['Benchmarks', ['Method', 'Ops/sec'], ['split.reverse.join', '1.2M'], ['manual loop', '2.1M']] },
1407
+ { type: 'sources', sources: [{ url: 'https://jsperf.app', displayName: 'JSPerf', subtitle: 'jsperf.app' }] }
1408
+ ],
1409
+ footer: '_NexusTechPro_'
1410
+ }
1411
+ }, { quoted: message })
1412
+
1413
+ // via sendRichMessage shorthand
1414
+ await sock.sendRichMessage(jid, {
1415
+ text: 'Hello from sendRichMessage!',
1416
+ code: 'console.log("works!")',
1417
+ language: 'javascript',
1418
+ footer: '_NexusTechPro_'
1419
+ }, quoted)
1420
+ ```
1421
+
1422
+ ---
1423
+
1424
+ ##### LaTeX
1425
+
1426
+ ```javascript
1427
+ await sock.sendMessage(jid, {
1428
+ aiRich: {
1429
+ latexText: 'The quadratic formula:',
1430
+ latex: [
1431
+ { latexExpression: 'x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}', url: '', width: 0, height: 0 }
1432
+ ],
1433
+ footer: '_Math rendering_'
1434
+ }
1435
+ }, { quoted: message })
1436
+
1437
+ // via shorthand
1438
+ await sock.sendLatex(jid, [
1439
+ { latexExpression: 'E = mc^2', url: '', width: 0, height: 0 }
1440
+ ], quoted, { text: 'Mass-energy equivalence:', footer: '_Einstein_' })
1441
+ ```
1442
+
1443
+ ---
1444
+
1445
+ ##### Capture & Relay (forward an AI message)
1446
+
1447
+ ```javascript
1448
+ // Capture a received AI rich message
1449
+ const captured = sock.nexusHandler.captureAiRich(message.message)
1450
+
1451
+ // Relay it to another jid
1452
+ if (captured) await sock.nexusHandler.relayAiRich(jid, captured, quoted)
1453
+ ```
1454
+
1455
+ ---
1456
+
1457
+ ##### `aiRich` Options Reference
1458
+
1459
+ | Key | Type | Description |
1460
+ |-----|------|-------------|
1461
+ | `text` | `string` | Single markdown text block |
1462
+ | `texts` | `string[]` | Multiple text blocks in order |
1463
+ | `code` | `string \| { language, code }` | Single code block |
1464
+ | `codes` | `Array` | Multiple code blocks |
1465
+ | `language` | `string` | Default language for `code`/`codes` |
1466
+ | `table` | `Array` | `[title, headers[], ...rows[]]` |
1467
+ | `headers` + `rows` | `Array` | Alternative table format |
1468
+ | `images` | `Array` | Grid images with `url`, `sourceUrl` |
1469
+ | `sources` | `Array` | Search source cards |
1470
+ | `reels` | `Array` | Horizontal reel cards |
1471
+ | `latex` | `Array` | LaTeX expression objects |
1472
+ | `latexText` | `string` | Text shown above latex |
1473
+ | `parts` | `Array` | Composite ordered parts array |
1474
+ | `header` | `string` | Text prepended before content |
1475
+ | `footer` | `string` | Text appended after content |
1476
+ | `botJid` | `string` | Custom bot JID (default: `259786046210223@bot`) |
1477
+ | `forwardingScore` | `number` | Forward score (default: `2`) |
1478
+ | `disclaimerText` | `string` | Disclaimer shown in metadata |
1479
+ | `searchEngine` | `string` | Search engine label (default: `MAME`) |
1480
+ | `responseId` | `string` | Custom response UUID |
1481
+ | `forwarded` | `boolean` | Set `false` to disable forwarded context |
1482
+ | `includesUnifiedResponse` | `boolean` | Set `false` to send V1 only |
1483
+
1484
+ ---
1485
+
1036
1486
  ### Shorthand Wrappers
1037
1487
 
1038
1488
  ```javascript
@@ -1047,6 +1497,17 @@ await sock.sendReaction(jid, message.key, 'šŸ’–', options)
1047
1497
  await sock.sendSticker(jid, { url: './sticker.webp' }, options)
1048
1498
  await sock.sendContact(jid, { vcard }, options)
1049
1499
  await sock.sendForward(jid, message, { force: true })
1500
+
1501
+ // ── AI Rich Messages ──────────────────────────────────────────────────────────
1502
+ await sock.sendCodeBlock(jid, code, quoted, { language, title, footer })
1503
+ await sock.sendCodeBlockV2(jid, code, quoted, { language, title, text, footer })
1504
+ await sock.sendTable(jid, title, headers, rows, quoted, { headerText, footer })
1505
+ await sock.sendTableV2(jid, tableArray, quoted, { headerText, text, footer })
1506
+ await sock.sendList(jid, title, items, quoted, { footer })
1507
+ await sock.sendLink(jid, text, links, quoted, { headerText, footer, botJid })
1508
+ await sock.sendLinkV2(jid, text, links, quoted, { headerText, footer, searchEngine })
1509
+ await sock.sendLatex(jid, expressions, quoted, { text, headerText, footer })
1510
+ await sock.sendRichMessage(jid, data, quoted)
1050
1511
  ```
1051
1512
 
1052
1513
  ---
@@ -151,15 +151,11 @@ export const MEDIA_HKDF_KEY_MAPPING = {
151
151
  };
152
152
 
153
153
  export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
154
-
155
154
  export const MIN_PREKEY_COUNT = 5;
156
-
157
155
  export const INITIAL_PREKEY_COUNT = 95;
158
-
159
156
  export const UPLOAD_TIMEOUT = 30000;
160
157
  export const MIN_UPLOAD_INTERVAL = 5000;
161
158
  export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
162
-
163
159
  export const DEFAULT_CACHE_TTLS = {
164
160
  SIGNAL_STORE: 5 * 60,
165
161
  MSG_RETRY: 60 * 60,