@itsliaaa/baileys 0.1.31 โ†’ 0.1.33

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
@@ -41,9 +41,12 @@ Hi everyone,
41
41
  >
42
42
  > Recently, I found a few packages published on npm that are essentially just **renamed** versions of a fork I personally worked on:
43
43
  >
44
- > - [@noya4u_27](https://www.npmjs.com/package/@noya4u_27/baileys) **[STEALER]**
45
- > - [@phrolovaa](https://www.npmjs.com/package/@phrolovaa/baileys) **[STEALER]**
44
+ > - ~[RESOLVED]~
45
+ > - ~[RESOLVED]~
46
+ > - ~[RESOLVED]~
47
+ > - [@zackmans](https://www.npmjs.com/package/@zackmans/baileys) **[STEALER]**
46
48
  > - [@dnuzi](https://www.npmjs.com/package/@dnuzi/baileys) **[STEALER]**
49
+ > - ["Update rich.js"](https://github.com/gcamerator/mbaileys/commits/main/) **[STEALER]**
47
50
  >
48
51
  > To be clear, Iโ€™m **not** the original maintainer of Baileys all respect goes to the amazing work behind [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys). I only created and maintained my own fork ([@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys)) where I spent a **lot** of time improving and adapting things on my own.
49
52
  >
@@ -108,6 +111,7 @@ Hi everyone,
108
111
  - [๐Ÿ’ญ Button Response](#-button-response)
109
112
  - [โœจ Rich Response](#-rich-response)
110
113
  - [๐Ÿงพ Message with Code Block](#-message-with-code-block)
114
+ - [๐ŸŒ Message with Inline Entities](#-message-with-inline-entities)
111
115
  - [๐Ÿ“‹ Message with Table](#-message-with-table)
112
116
  - [๐ŸŽž๏ธ Status Mention](#%EF%B8%8F-status-mention)
113
117
  - [๐Ÿ“ Sending Media Messages](#-sending-media-messages)
@@ -147,6 +151,9 @@ Hi everyone,
147
151
  - [๐Ÿ–ผ๏ธ Image Processing](#%EF%B8%8F-image-processing)
148
152
  - [๐Ÿ“ฃ Newsletter Management](#-newsletter-management)
149
153
  - [๐Ÿ‘ฅ Group Management](#-group-management)
154
+ - [๐Ÿ‘ค Profile Management](#-profile-management)
155
+ - [๐Ÿ” Privacy Management](#-privacy-management)
156
+ - [๐Ÿ“ก Events](#-events)
150
157
  - [๐Ÿ“ฆ Fork Base](#-fork-base)
151
158
  - [๐Ÿ“ฃ Credits](#-credits)
152
159
 
@@ -692,6 +699,29 @@ sock.sendMessage(jid, {
692
699
  })
693
700
  ```
694
701
 
702
+ #### ๐ŸŒ Message with Inline Entities
703
+
704
+ ```javascript
705
+ sock.sendMessage(jid, {
706
+ headerText: '## Check Out!',
707
+ contentText: '---',
708
+ links: [{
709
+ text: '1. Google',
710
+ title: 'Popular Search Engine',
711
+ url: 'https://www.google.com/'
712
+ }, {
713
+ text: '2. YouTube',
714
+ title: 'Popular Streaming Platform',
715
+ url: 'https://www.youtube.com/'
716
+ }, {
717
+ text: '3. Modded Baileys',
718
+ title: 'Underrated Baileys Fork',
719
+ url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
720
+ }],
721
+ footerText: '---'
722
+ })
723
+ ```
724
+
695
725
  #### ๐Ÿ“‹ Message with Table
696
726
 
697
727
  ```javascript
@@ -704,6 +734,7 @@ sock.sendMessage(jid, {
704
734
  ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
705
735
  ['Performance', '4/5', '5/5', '4/5']
706
736
  ],
737
+ noHeading: false, // --- Optional
707
738
  footerText: 'Does this help clarify the differences?'
708
739
  })
709
740
  ```
@@ -941,7 +972,7 @@ sock.sendMessage(jid, {
941
972
  image: {
942
973
  url: './path/to/image.jpg'
943
974
  },
944
- caption: '??๏ธ Interactive!',
975
+ caption: '๐Ÿ—„๏ธ๏ธ Interactive!',
945
976
  footer: '@itsliaaa/baileys',
946
977
  optionText: '๐Ÿ‘‰๐Ÿป Select Options', // --- Optional, wrap all native flow into a single list
947
978
  optionTitle: '๐Ÿ“„ Select Options', // --- Optional
@@ -1378,7 +1409,7 @@ else if (lib.jimp?.Jimp) {
1378
1409
 
1379
1410
  output = await img
1380
1411
  .resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
1381
- .getBuffer('image/jpeg', { quality: 50 });
1412
+ .getBuffer('image/jpeg', { quality: 50 })
1382
1413
  }
1383
1414
 
1384
1415
  // --- Fallback
@@ -1394,10 +1425,23 @@ console.dir(output, { depth: null })
1394
1425
 
1395
1426
  ```javascript
1396
1427
  // --- Create a new one
1397
- sock.newsletterCreate('@itsliaaa/baileys')
1428
+ sock.newsletterCreate('@itsliaaa/baileys', '๐Ÿ“ฃ Fresh updates weekly')
1398
1429
 
1399
1430
  // --- Get info
1400
- sock.newsletterMetadata('1231111111111@newsletter')
1431
+ const metadata = sock.newsletterMetadata('1231111111111@newsletter')
1432
+ console.dir(metadata, { depth: null })
1433
+
1434
+ // --- Get subscribers count
1435
+ const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
1436
+ console.dir(subscribers, { depth: null })
1437
+
1438
+ // --- Follow and Unfollow
1439
+ sock.newsletterFollow('1231111111111@newsletter')
1440
+ sock.newsletterUnfollow('1231111111111@newsletter')
1441
+
1442
+ // --- Mute and Unmute
1443
+ sock.newsletterMute('1231111111111@newsletter')
1444
+ sock.newsletterUnmute('1231111111111@newsletter')
1401
1445
 
1402
1446
  // --- Demote admin
1403
1447
  sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
@@ -1405,6 +1449,9 @@ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net'
1405
1449
  // --- Change owner
1406
1450
  sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
1407
1451
 
1452
+ // --- Update newsletter
1453
+ sock.newsletterUpdate('1231111111111@newsletter', { name: '@itsliaaa/baileys' })
1454
+
1408
1455
  // --- Change name
1409
1456
  sock.newsletterUpdateName('1231111111111@newsletter', '๐Ÿ“ฆ @itsliaaa/baileys')
1410
1457
 
@@ -1422,27 +1469,41 @@ sock.newsletterRemovePicture('1231111111111@newsletter')
1422
1469
  // --- React to a message
1423
1470
  sock.newsletterReactMessage('1231111111111@newsletter', '100', '๐Ÿ’›')
1424
1471
 
1472
+ // --- Get admin count
1473
+ const count = await sock.newsletterAdminCount('1231111111111@newsletter')
1474
+
1425
1475
  // --- Get all subscribed newsletters
1426
1476
  const newsletters = await sock.newsletterSubscribed()
1427
-
1428
1477
  console.dir(newsletters, { depth: null })
1478
+
1479
+ // --- Fetch newsletter messages
1480
+ const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
1481
+ console.dir(messages, { depth: null })
1482
+
1483
+ // --- Delete newsletter
1484
+ sock.newsletterDelete('1231111111111@newsletter')
1429
1485
  ```
1430
1486
 
1431
1487
  #### ๐Ÿ‘ฅ Group Management
1432
1488
 
1433
1489
  ```javascript
1434
1490
  // --- Create a new one and add participants using their JIDs
1435
- sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
1491
+ const group = sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
1492
+ console.dir(group, { depth: null })
1436
1493
 
1437
1494
  // --- Get info
1438
- sock.groupMetadata(jid)
1495
+ const metadata = await sock.groupMetadata(jid)
1496
+ console.dir(metadata, { depth: null })
1439
1497
 
1440
- // --- Get invite code
1498
+ // --- Get group invite code
1441
1499
  sock.groupInviteCode(jid)
1442
1500
 
1443
1501
  // --- Revoke invite link
1444
1502
  sock.groupRevokeInvite(jid)
1445
1503
 
1504
+ // --- Accept group invite
1505
+ sock.groupAcceptInvite(inviteCode)
1506
+
1446
1507
  // --- Leave group
1447
1508
  sock.groupLeave(jid)
1448
1509
 
@@ -1458,6 +1519,9 @@ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
1458
1519
  // --- Demote from admin
1459
1520
  sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
1460
1521
 
1522
+ // --- Accept join requests
1523
+ sock.groupRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
1524
+
1461
1525
  // --- Change name
1462
1526
  sock.groupUpdateSubject(jid, '๐Ÿ“ฆ @itsliaaa/baileys')
1463
1527
 
@@ -1502,21 +1566,163 @@ sock.groupJoinApprovalMode(jid, 'off')
1502
1566
 
1503
1567
  // --- Get all groups metadata
1504
1568
  const groups = await sock.groupFetchAllParticipating()
1505
-
1506
1569
  console.dir(groups, { depth: null })
1507
1570
 
1508
- // --- Get pending invites
1509
- const invites = await sock.groupGetInviteInfo(code)
1510
-
1511
- console.dir(invites, { depth: null })
1512
-
1513
- // --- Accept group invite
1514
- sock.groupAcceptInvite(code)
1571
+ // --- Get pending join requests
1572
+ const requests = await sock.groupRequestParticipantsList(jid)
1573
+ console.dir(requests, { depth: null })
1515
1574
 
1516
1575
  // --- Get group info from link
1517
1576
  const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
1518
-
1519
1577
  console.log('๐Ÿ‘ฅ Got group info from link', ':', group)
1578
+
1579
+ // --- Update bot member label
1580
+ sock.updateMemberLabel(jid, '@itsliaaa/baileys')
1581
+ ```
1582
+
1583
+ #### ๐Ÿ‘ค Profile Management
1584
+
1585
+ ```javascript
1586
+ // --- Get user profile picture
1587
+ const url = await sock.profilePictureUrl(jid, 'image')
1588
+ console.log('๐Ÿ–ผ๏ธ Got user profile url', url)
1589
+
1590
+ // --- Update profile picture
1591
+ sock.updateProfilePicture(jid, buffer)
1592
+ sock.updateProfilePicture(jid, { url })
1593
+
1594
+ // --- Remove profile picture
1595
+ sock.removeProfilePicture(jid)
1596
+
1597
+ // --- Update profile name
1598
+ sock.updateProfileName('My Name')
1599
+
1600
+ // --- Update profile status
1601
+ sock.updateProfileStatus('Available')
1602
+
1603
+ // --- Presence
1604
+ sock.sendPresenceUpdate('available', jid)
1605
+ sock.presenceSubscribe(jid)
1606
+
1607
+ // --- Read receipts
1608
+ sock.readMessages([message.key])
1609
+ sock.sendReceipt(jid, participant, [messageId], 'read')
1610
+
1611
+ // --- Block user
1612
+ sock.updateBlockStatus(jid, 'block')
1613
+
1614
+ // --- Unblock user
1615
+ sock.updateBlockStatus(jid, 'unblock')
1616
+
1617
+ // --- Fetch blocklist
1618
+ const blocked = await sock.fetchBlocklist()
1619
+ console.dir(blocked, { depth: null })
1620
+
1621
+ // --- Modify chats
1622
+ sock.chatModify({
1623
+ archive: true,
1624
+ lastMessageOrig: message,
1625
+ lastMessage: message
1626
+ }, jid)
1627
+
1628
+ // --- Star messages
1629
+ sock.star(jid, [{ id: messageId, fromMe: true }], true)
1630
+
1631
+ // --- Contact
1632
+ sock.addOrEditContact(jid, { displayName: 'Starseed' })
1633
+ sock.removeContact(jid)
1634
+
1635
+ // --- Label
1636
+ sock.addChatLabel(jid, labelId)
1637
+ sock.removeChatLabel(jid, labelId)
1638
+ sock.addMessageLabel(jid, messageId, labelId)
1639
+
1640
+ // --- App state sync
1641
+ sock.resyncAppState(['regular', 'critical_block'], true)
1642
+
1643
+ // --- Get business profile
1644
+ const profile = await sock.getBusinessProfile(jid)
1645
+ console.dir(profile, { depth: null })
1646
+ ```
1647
+
1648
+ #### ๐Ÿ” Privacy Management
1649
+
1650
+ ```javascript
1651
+ // --- Update last seen privacy
1652
+ sock.updateLastSeenPrivacy('all')
1653
+ sock.updateLastSeenPrivacy('contacts')
1654
+ sock.updateLastSeenPrivacy('contact_blacklist')
1655
+ sock.updateLastSeenPrivacy('nobody')
1656
+
1657
+ // --- Update online privacy
1658
+ sock.updateOnlinePrivacy('all')
1659
+ sock.updateOnlinePrivacy('match_last_seen')
1660
+
1661
+ // --- Update profile picture privacy
1662
+ sock.updateProfilePicturePrivacy('contacts')
1663
+
1664
+ // --- Update status privacy
1665
+ sock.updateStatusPrivacy('contacts')
1666
+
1667
+ // --- Update read receipts privacy
1668
+ sock.updateReadReceiptsPrivacy('all')
1669
+ sock.updateReadReceiptsPrivacy('none')
1670
+
1671
+ // --- Update groups add privacy
1672
+ sock.updateGroupsAddPrivacy('all')
1673
+ sock.updateGroupsAddPrivacy('contacts')
1674
+
1675
+ // --- Update messages privacy
1676
+ sock.updateMessagesPrivacy('all')
1677
+ sock.updateMessagesPrivacy('contacts')
1678
+ sock.updateMessagesPrivacy('nobody')
1679
+
1680
+ // --- Update call privacy
1681
+ sock.updateCallPrivacy('everyone')
1682
+
1683
+ // --- Update default disappearing mode
1684
+ sock.updateDefaultDisappearingMode(86400)
1685
+
1686
+ // --- Update link previews privacy
1687
+ sock.updateDisableLinkPreviewsPrivacy(true)
1688
+ ```
1689
+
1690
+ #### ๐Ÿ“ก Events
1691
+
1692
+ ```javascript
1693
+ sock.ev.on('connection.update', (update) => {})
1694
+ sock.ev.on('creds.update', (update) => {})
1695
+ sock.ev.on('messaging-history.set', (update) => {})
1696
+ sock.ev.on('messaging-history.status', (update) => {})
1697
+ sock.ev.on('chats.upsert', (update) => {})
1698
+ sock.ev.on('chats.update', (update) => {})
1699
+ sock.ev.on('chats.delete', (update) => {})
1700
+ sock.ev.on('chats.lock', (update) => {})
1701
+ sock.ev.on('lid-mapping.update', (update) => {})
1702
+ sock.ev.on('presence.update', (update) => {})
1703
+ sock.ev.on('contacts.upsert', (update) => {})
1704
+ sock.ev.on('contacts.update', (update) => {})
1705
+ sock.ev.on('messages.delete', (update) => {})
1706
+ sock.ev.on('messages.update', (update) => {})
1707
+ sock.ev.on('messages.media-update', (update) => {})
1708
+ sock.ev.on('messages.upsert', (update) => {})
1709
+ sock.ev.on('messages.reaction', (update) => {})
1710
+ sock.ev.on('message-receipt.update', (update) => {})
1711
+ sock.ev.on('groups.upsert', (update) => {})
1712
+ sock.ev.on('groups.update', (update) => {})
1713
+ sock.ev.on('group-participants.update', (update) => {})
1714
+ sock.ev.on('group.join-request', (update) => {})
1715
+ sock.ev.on('group.member-tag.update', (update) => {})
1716
+ sock.ev.on('blocklist.set', (update) => {})
1717
+ sock.ev.on('blocklist.update', (update) => {})
1718
+ sock.ev.on('call', (update) => {})
1719
+ sock.ev.on('labels.edit', (update) => {})
1720
+ sock.ev.on('labels.association', (update) => {})
1721
+ sock.ev.on('newsletter.reaction', (update) => {})
1722
+ sock.ev.on('newsletter.view', (update) => {})
1723
+ sock.ev.on('newsletter-participants.update', (update) => {})
1724
+ sock.ev.on('newsletter-settings.update', (update) => {})
1725
+ sock.ev.on('settings.update', (update) => {})
1520
1726
  ```
1521
1727
 
1522
1728
  ## ๐Ÿ“ฆ Fork Base
@@ -1532,4 +1738,6 @@ This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://g
1532
1738
  > - [jlucaso1](https://github.com/jlucaso1)
1533
1739
  > - [adiwajshing](https://github.com/adiwajshing)
1534
1740
  >
1535
- > This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
1741
+ > This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
1742
+ >
1743
+ > **Credits are mandatory and must remain unchanged in any form of redistribution or fork.**
package/WAProto/index.js CHANGED
@@ -12,14 +12,18 @@ function longToString(value, unsigned) {
12
12
  if (typeof value === "number") {
13
13
  return String(value);
14
14
  }
15
- if (!$util.Long) {
16
- return String(value);
15
+ // Fast path: convert Long {low, high} directly via native BigInt
16
+ // BigInt.toString() is a native C++ operation, much faster than Long's pure JS division loops
17
+ if (value && typeof value.low === "number" && typeof value.high === "number") {
18
+ const lo = BigInt(value.low >>> 0);
19
+ const hi = BigInt(value.high >>> 0);
20
+ const combined = (hi << 32n) | lo;
21
+ if (!unsigned && value.high < 0) {
22
+ return (combined - (1n << 64n)).toString();
23
+ }
24
+ return combined.toString();
17
25
  }
18
- const normalized = $util.Long.fromValue(value);
19
- const prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"
20
- ? normalized.toUnsigned()
21
- : normalized;
22
- return prepared.toString();
26
+ return String(value);
23
27
  }
24
28
 
25
29
  function longToNumber(value, unsigned) {
@@ -27,19 +31,19 @@ function longToNumber(value, unsigned) {
27
31
  return value;
28
32
  }
29
33
  if (typeof value === "string") {
30
- const numeric = Number(value);
31
- return numeric;
32
- }
33
- if (!$util.Long) {
34
34
  return Number(value);
35
35
  }
36
- const normalized = $util.Long.fromValue(value);
37
- const prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"
38
- ? normalized.toUnsigned()
39
- : typeof normalized.toSigned === "function"
40
- ? normalized.toSigned()
41
- : normalized;
42
- return prepared.toNumber();
36
+ // Fast path: convert Long {low, high} directly via native BigInt
37
+ if (value && typeof value.low === "number" && typeof value.high === "number") {
38
+ const lo = BigInt(value.low >>> 0);
39
+ const hi = BigInt(value.high >>> 0);
40
+ const combined = (hi << 32n) | lo;
41
+ if (!unsigned && value.high < 0) {
42
+ return Number(combined - (1n << 64n));
43
+ }
44
+ return Number(combined);
45
+ }
46
+ return Number(value);
43
47
  }
44
48
 
45
49
  export const proto = $root.proto = (() => {
@@ -8,7 +8,7 @@ import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeS
8
8
  import { makeMutex } from '../Utils/make-mutex.js';
9
9
  import processMessage from '../Utils/process-message.js';
10
10
  import { buildTcTokenFromJid } from '../Utils/tc-token-utils.js';
11
- import { getBinaryNodeChild, getBinaryNodeChildren, isLidUser, isPnUser, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
11
+ import { getBinaryNodeChild, getBinaryNodeChildren, isPnUser, isLidUser, isHostedLidUser, isHostedPnUser, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
12
12
  import { USyncQuery, USyncUser } from '../WAUSync/index.js';
13
13
  import { makeSocket } from './socket.js';
14
14
  const MAX_SYNC_ATTEMPTS = 2;
@@ -293,6 +293,42 @@ export const makeChatsSocket = (config) => {
293
293
  return getBinaryNodeChildren(listNode, 'item').map(n => n.attrs.jid);
294
294
  };
295
295
  const updateBlockStatus = async (jid, action) => {
296
+ const normalizedJid = jidNormalizedUser(jid);
297
+ let lid;
298
+ let pn_jid;
299
+ if (isLidUser(normalizedJid) || isHostedLidUser(normalizedJid)) {
300
+ lid = normalizedJid;
301
+ if (action === 'block') {
302
+ const pn = (await findUserId(normalizedJid)).phoneNumber;
303
+ if (pn.startsWith('id')) {
304
+ throw new Boom(`Unable to resolve PN JID for LID: ${jid}`, { statusCode: 400 });
305
+ }
306
+ pn_jid = jidNormalizedUser(pn);
307
+ }
308
+ }
309
+ else if (isPnUser(normalizedJid) || isHostedPnUser(normalizedJid)) {
310
+ const mapped = (await findUserId(normalizedJid)).lid;
311
+ if (mapped.startsWith('id')) {
312
+ throw new Boom(`Unable to resolve LID for PN JID: ${jid}`, { statusCode: 400 });
313
+ }
314
+ lid = mapped;
315
+ if (action === 'block') {
316
+ pn_jid = jidNormalizedUser(normalizedJid);
317
+ }
318
+ }
319
+ else {
320
+ throw new Boom(`Invalid jid: ${jid}`, { statusCode: 400 });
321
+ }
322
+ const itemAttrs = {
323
+ action,
324
+ jid: lid
325
+ };
326
+ if (action === 'block') {
327
+ if (!pn_jid) {
328
+ throw new Boom(`pn_jid required for block: ${jid}`, { statusCode: 400 });
329
+ }
330
+ itemAttrs.pn_jid = pn_jid;
331
+ }
296
332
  await query({
297
333
  tag: 'iq',
298
334
  attrs: {
@@ -303,10 +339,7 @@ export const makeChatsSocket = (config) => {
303
339
  content: [
304
340
  {
305
341
  tag: 'item',
306
- attrs: {
307
- action,
308
- jid
309
- }
342
+ attrs: itemAttrs
310
343
  }
311
344
  ]
312
345
  });
@@ -657,6 +657,7 @@ export const generateWAMessageContent = async (message, options) => {
657
657
  else if (hasNonNullishProperty(message, 'code') ||
658
658
  hasNonNullishProperty(message, 'expressions') ||
659
659
  hasNonNullishProperty(message, 'items') ||
660
+ hasNonNullishProperty(message, 'links') ||
660
661
  hasNonNullishProperty(message, 'table') ||
661
662
  hasNonNullishProperty(message, 'richResponse')) {
662
663
  m = prepareRichResponseMessage(message);
@@ -672,7 +673,7 @@ export const generateWAMessageContent = async (message, options) => {
672
673
  extContent.jpegThumbnail = urlInfo.jpegThumbnail;
673
674
  extContent.description = urlInfo.description;
674
675
  extContent.title = urlInfo.title;
675
- extContent.previewType = 0;
676
+ extContent.previewType = urlInfo.previewType ?? 0;
676
677
  const img = urlInfo.highQualityThumbnail;
677
678
  if (img) {
678
679
  extContent.thumbnailDirectPath = img.directPath;
@@ -1270,12 +1271,6 @@ export const generateWAMessageContent = async (message, options) => {
1270
1271
  }
1271
1272
  m = { invoiceMessage };
1272
1273
  }
1273
- if (shouldIncludeReportingToken(m)) {
1274
- m.messageContextInfo = m.messageContextInfo || {};
1275
- if (!m.messageContextInfo.messageSecret) {
1276
- m.messageContextInfo.messageSecret = randomBytes(32);
1277
- }
1278
- }
1279
1274
  // Lia@Changes 31-01-26 --- Add direct externalAdReply access (no need to create contextInfo first)
1280
1275
  if (hasOptionalProperty(message, 'externalAdReply') && !!message.externalAdReply) {
1281
1276
  const messageType = Object.keys(m)[0];
@@ -1391,6 +1386,12 @@ export const generateWAMessageContent = async (message, options) => {
1391
1386
  }
1392
1387
  }
1393
1388
  }
1389
+ if (shouldIncludeReportingToken(m)) {
1390
+ m.messageContextInfo = m.messageContextInfo || {};
1391
+ if (!m.messageContextInfo.messageSecret) {
1392
+ m.messageContextInfo.messageSecret = randomBytes(32);
1393
+ }
1394
+ }
1394
1395
  return proto.Message.create(m);
1395
1396
  };
1396
1397
  export const generateWAMessageFromContent = (jid, message, options) => {
@@ -11,7 +11,6 @@ import { LANGUAGE_KEYWORDS } from '../WABinary/constants.js';
11
11
  import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
12
12
  import { proto } from '../../WAProto/index.js';
13
13
  import { unixTimestampSeconds } from './generics.js';
14
- const textEncoder = new TextEncoder();
15
14
  const NOOP = new Set([]);
16
15
  export const tokenizeCode = (code, language = 'javascript') => {
17
16
  const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
@@ -121,33 +120,11 @@ export const toUnified = (submessages) =>
121
120
  }
122
121
  };
123
122
  case RichSubMessageType.TEXT:
124
- const shouldAddInlineEntity = index == 0;
125
- const inlineEntity = [{
126
- key: 'Starseed',
127
- metadata: {
128
- reference_id: 1,
129
- reference_url: DONATE_URL,
130
- reference_title: 'For Donation via Saweria',
131
- reference_display_name: 'Donate',
132
- sources: [{
133
- source_type: 'THIRD_PARTY',
134
- source_display_name: 'Donate',
135
- source_subtitle: '',
136
- source_url: DONATE_URL
137
- }],
138
- __typename: 'GenAISearchCitationItem'
139
- }
140
- }];
141
- const textEntity = shouldAddInlineEntity ?
142
- '{{Starseed}}ยน{{/Starseed}}' :
143
- '';
144
123
  return {
145
124
  view_model: {
146
125
  primitive: {
147
- text: submessage.messageText + textEntity,
148
- inline_entities: shouldAddInlineEntity ?
149
- inlineEntity :
150
- [],
126
+ text: submessage.messageText,
127
+ inline_entities: submessage.inlineEntities || [],
151
128
  __typename: 'GenAIMarkdownTextUXPrimitive'
152
129
  },
153
130
  __typename: 'GenAISingleLayoutViewModel'
@@ -212,14 +189,15 @@ export const buildAdditionalBotMetadataContext = (submessages) => {
212
189
  return { sources, mediaDetailsMetadataList };
213
190
  }
214
191
  export const prepareRichResponseMessage = (content) => {
215
- const { code, contentText, expressions, footerText, headerText, items, language, richResponse, table, text, title } = content;
192
+ const { code, contentText, expressions, footerText, headerText, items, language, links, noHeading, richResponse, table, text, title } = content;
216
193
  let submessages = [];
217
194
  if (Array.isArray(richResponse)) {
218
195
  submessages = richResponse.map((submessage) => {
219
196
  if (submessage.text) {
220
197
  return {
221
198
  messageType: RichSubMessageType.TEXT,
222
- messageText: submessage.text
199
+ messageText: submessage.text,
200
+ inlineEntities: submessage.inlineEntities
223
201
  };
224
202
  }
225
203
  else if (submessage.code) {
@@ -301,16 +279,42 @@ export const prepareRichResponseMessage = (content) => {
301
279
  }
302
280
  });
303
281
  }
282
+ else if (links) {
283
+ links.forEach((linkField, index) => {
284
+ const prefix = 'SS_' + index;
285
+ const url = linkField.url || DONATE_URL;
286
+ const sources = linkField.sources?.map((sourceField) => ({
287
+ source_type: 'THIRD_PARTY',
288
+ source_display_name: sourceField.displayName || 'Donate',
289
+ source_subtitle: sourceField.subtitle || 'Saweria',
290
+ source_url: sourceField.url || url
291
+ }));
292
+ submessages.push({
293
+ messageType: RichSubMessageType.TEXT,
294
+ messageText: linkField.text + `{{${prefix}}}ยน{{/${prefix}}}`,
295
+ inlineEntities: [{
296
+ key: prefix,
297
+ metadata: {
298
+ reference_id: index + 1,
299
+ reference_url: url,
300
+ reference_title: linkField.title || 'For Donation via Saweria',
301
+ reference_display_name: linkField.displayName || 'Donation',
302
+ sources: sources || [],
303
+ __typename: 'GenAISearchCitationItem'
304
+ }
305
+ }]
306
+ });
307
+ });
308
+ }
304
309
  else if (table) {
305
- const tableRows = table.map((items, index) => ({
306
- isHeading: index == 0,
307
- items
308
- }));
309
310
  submessages.push({
310
311
  messageType: RichSubMessageType.TABLE,
311
312
  tableMetadata: {
312
313
  title,
313
- rows: tableRows
314
+ rows: table.map((items, index) => ({
315
+ isHeading: !noHeading && index == 0,
316
+ items
317
+ }))
314
318
  }
315
319
  });
316
320
  }
@@ -323,16 +327,17 @@ export const prepareRichResponseMessage = (content) => {
323
327
  }
324
328
  const unified = toUnified(submessages);
325
329
  const message = wrapToBotForwardedMessage({
326
- submessages,
330
+ submessages: [],
327
331
  messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
328
332
  unifiedResponse: {
329
- data: textEncoder.encode(JSON.stringify(unified))
333
+ data: Buffer.from(JSON.stringify(unified), 'utf-8') // Lia@Note 25-04-26 --- Expects "ArrayBufferLike"
330
334
  },
331
335
  contextInfo: {
332
336
  isForwarded: true,
333
337
  forwardingScore: 1,
334
338
  forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
335
- forwardOrigin: 4
339
+ forwardOrigin: 4,
340
+ botMessageSharingInfo: { forwardScore: 1 }
336
341
  }
337
342
  });
338
343
  // Lia@Note 17-04-26 --- TODO: Fill mediaDetailsMetadataList and sources field
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itsliaaa/baileys",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "Enhanced Baileys v7 with fixed newsletter media upload, plus support for interactive messages, albums, and more message types.",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "fflate": "^0.8.2",
46
46
  "libsignal": "github:WhiskeySockets/libsignal-wasm#master",
47
47
  "lru-cache": "^11.2.6",
48
- "music-metadata": "^11.7.0",
48
+ "music-metadata": "11.12.1",
49
49
  "p-queue": "^9.1.0",
50
50
  "pino": "^9.6.0",
51
51
  "protobufjs": "^7.5.4",