@itsliaaa/baileys 0.1.26 โ†’ 0.1.27

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
@@ -52,6 +52,8 @@ This fork designed for production use with a focus on clarity and safety:
52
52
  - ๐Ÿ“‹ [Message with Table](#-message-with-table) **[NEW]**
53
53
  - ๐Ÿ’ณ [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
54
54
  - ๐Ÿ“ฐ Simplified sending messages with ad thumbnail using [`externalAdReply`](#3%EF%B8%8Fโƒฃ-external-ad-reply), without requiring manual `contextInfo`.
55
+ - ๐Ÿ’ญ Added support for quoting messages inside channel (newsletter). **[NEW]**
56
+ - ๐ŸŽ€ Added support for [custom button icon](#-sending-interactive-messages). **[NEW]**
55
57
 
56
58
  ### ๐Ÿงฉ Additional Message Options
57
59
  - ๐Ÿ‘๏ธ Added optional boolean flags for message handling:
@@ -514,8 +516,32 @@ sock.sendMessage(jid, {
514
516
  })
515
517
  ```
516
518
 
519
+ > [!TIP]
520
+ You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
521
+
522
+ ```javascript
523
+ import { tokenizeCode } from '@itsliaaa/baileys'
524
+
525
+ const language = 'javascript'
526
+ const code = 'console.log("Hello, World!")'
527
+
528
+ sock.sendMessage(jid, {
529
+ richResponse: [{
530
+ text: 'Example Usage',
531
+ }, {
532
+ language,
533
+ code: tokenizeCode(code, language)
534
+ }, {
535
+ text: 'Pretty simple, right?'
536
+ }]
537
+ })
538
+ ```
539
+
517
540
  #### ๐Ÿงพ Message with Code Block
518
541
 
542
+ > [!NOTE]
543
+ This feature already includes a built-in tokenizer.
544
+
519
545
  ```javascript
520
546
  sock.sendMessage(jid, {
521
547
  headerText: '## Example Usage',
@@ -771,7 +797,8 @@ sock.sendMessage(jid, {
771
797
  offerExpiration: Date.now() + 3_600_000, // --- Optional
772
798
  nativeFlow: [{
773
799
  text: '๐Ÿ‘‹๐Ÿป Greeting',
774
- id: '#Greeting'
800
+ id: '#Greeting',
801
+ icon: 'review' // --- Optional
775
802
  }, {
776
803
  text: '๐Ÿ“ž Call',
777
804
  call: '628123456789'
@@ -800,7 +827,8 @@ sock.sendMessage(jid, {
800
827
  description: '',
801
828
  id: '#SecretIngredient'
802
829
  }]
803
- }]
830
+ }],
831
+ icon: 'default' // --- Optional
804
832
  }],
805
833
  interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
806
834
  }, {
@@ -561,13 +561,15 @@ const prepareNativeFlowButtons = (message) => {
561
561
  }
562
562
  return {
563
563
  buttons: correctedField.map(button => {
564
- const buttonText = button.text;
564
+ const buttonText = button.text || button.buttonText;
565
+ const buttonIcon = button.icon?.toUpperCase();
565
566
  if (hasOptionalProperty(button, 'id') && !!button.id) {
566
567
  return {
567
568
  name: 'quick_reply',
568
569
  buttonParamsJson: JSON.stringify({
569
570
  display_text: buttonText || '๐Ÿ‘‰๐Ÿป Click',
570
- id: button.id
571
+ id: button.id,
572
+ icon: buttonIcon
571
573
  })
572
574
  };
573
575
  }
@@ -576,7 +578,8 @@ const prepareNativeFlowButtons = (message) => {
576
578
  name: 'cta_copy',
577
579
  buttonParamsJson: JSON.stringify({
578
580
  display_text: buttonText || '๐Ÿ“‹ Copy',
579
- copy_code: button.copy
581
+ copy_code: button.copy,
582
+ icon: buttonIcon
580
583
  })
581
584
  };
582
585
  }
@@ -586,7 +589,8 @@ const prepareNativeFlowButtons = (message) => {
586
589
  buttonParamsJson: JSON.stringify({
587
590
  display_text: buttonText || '๐ŸŒ Visit',
588
591
  url: button.url,
589
- merchant_url: button.url
592
+ merchant_url: button.url,
593
+ icon: buttonIcon
590
594
  })
591
595
  };
592
596
  }
@@ -595,7 +599,8 @@ const prepareNativeFlowButtons = (message) => {
595
599
  name: 'cta_call',
596
600
  buttonParamsJson: JSON.stringify({
597
601
  display_text: buttonText || '๐Ÿ“ž Call',
598
- phone_number: button.call
602
+ phone_number: button.call,
603
+ icon: buttonIcon
599
604
  })
600
605
  };
601
606
  }
@@ -605,7 +610,8 @@ const prepareNativeFlowButtons = (message) => {
605
610
  name: 'single_select',
606
611
  buttonParamsJson: JSON.stringify({
607
612
  title: buttonText || '๐Ÿ“‹ Select',
608
- sections: button.sections
613
+ sections: button.sections,
614
+ icon: buttonIcon
609
615
  })
610
616
  };
611
617
  }
@@ -1095,7 +1101,7 @@ export const generateWAMessageContent = async (message, options) => {
1095
1101
  else if (hasNonNullishProperty(message, 'templateButtons')) {
1096
1102
  const hydratedTemplate = {
1097
1103
  hydratedButtons: message.templateButtons.map((button, i) => {
1098
- const buttonText = button.text;
1104
+ const buttonText = button.text || button.buttonText;
1099
1105
  if (hasOptionalProperty(button, 'id')) {
1100
1106
  return {
1101
1107
  index: i,
@@ -1447,7 +1453,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
1447
1453
  const timestamp = unixTimestampSeconds(options.timestamp);
1448
1454
  const isNewsletter = isJidNewsletter(jid);
1449
1455
  const { quoted, userJid } = options;
1450
- if (quoted && !isNewsletter) {
1456
+ if (quoted) {
1451
1457
  const participant = quoted.key.fromMe
1452
1458
  ? userJid // TODO: Add support for LIDs
1453
1459
  : quoted.participant || quoted.key.participant || quoted.key.remoteJid;
@@ -1465,7 +1471,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
1465
1471
  contextInfo.quotedMessage = quotedMsg;
1466
1472
  // if a participant is quoted, then it must be a group
1467
1473
  // hence, remoteJid of group must also be entered
1468
- if (jid !== quoted.key.remoteJid) {
1474
+ if (!isNewsletter && jid !== quoted.key.remoteJid) {
1469
1475
  contextInfo.remoteJid = quoted.key.remoteJid;
1470
1476
  }
1471
1477
  if (contextInfo && innerMessage[key]) {
@@ -3,6 +3,7 @@
3
3
  * Adds support for tables and code blocks with richResponseMessage (wrapped inside botForwardedMessage).
4
4
  *
5
5
  * If you use or copy this code, please credit my name or project.
6
+ * @itsliaaa/baileys
6
7
  */
7
8
  import { getRandomValues, randomUUID, randomBytes } from 'crypto';
8
9
  import { BOT_RENDERING_CONFIG_METADATA, DONATE_URL, LEXER_REGEX } from '../Defaults/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itsliaaa/baileys",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
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",