@itsliaaa/baileys 0.1.25 โ 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 +82 -55
- package/lib/Socket/messages-send.js +3 -4
- package/lib/Utils/messages.js +15 -9
- package/lib/Utils/rich-message-utils.js +1 -0
- package/package.json +1 -1
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:
|
|
@@ -102,9 +104,7 @@ import { makeWASocket } from '@itsliaaa/baileys'
|
|
|
102
104
|
const { makeWASocket } = require('@itsliaaa/baileys')
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
###
|
|
106
|
-
|
|
107
|
-
#### ๐ Connect to WhatsApp (Quick Step)
|
|
107
|
+
### ๐ Connect to WhatsApp (Quick Step)
|
|
108
108
|
|
|
109
109
|
```javascript
|
|
110
110
|
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
@@ -160,7 +160,7 @@ const connectToWhatsApp = async () => {
|
|
|
160
160
|
connectToWhatsApp()
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
### ๐๏ธ Implementing Data Store
|
|
164
164
|
|
|
165
165
|
> [!CAUTION]
|
|
166
166
|
I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
@@ -233,7 +233,7 @@ const connectToWhatsApp = async () => {
|
|
|
233
233
|
connectToWhatsApp()
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
### ๐ชช WhatsApp IDs Explain
|
|
237
237
|
|
|
238
238
|
`id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
|
|
239
239
|
- It must be in the format `[country code][phone number]@s.whatsapp.net`
|
|
@@ -243,12 +243,12 @@ connectToWhatsApp()
|
|
|
243
243
|
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
244
244
|
- For stories, the ID is `status@broadcast`.
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
### โ๏ธ Sending Messages
|
|
247
247
|
|
|
248
248
|
> [!NOTE]
|
|
249
249
|
You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
#### ๐ Text
|
|
252
252
|
|
|
253
253
|
```javascript
|
|
254
254
|
sock.sendMessage(jid, {
|
|
@@ -258,7 +258,7 @@ sock.sendMessage(jid, {
|
|
|
258
258
|
})
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
#### ๐ Mention
|
|
262
262
|
|
|
263
263
|
```javascript
|
|
264
264
|
// --- Regular mention
|
|
@@ -278,7 +278,7 @@ sock.sendMessage(jid, {
|
|
|
278
278
|
})
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
|
|
281
|
+
#### ๐ Reaction
|
|
282
282
|
|
|
283
283
|
```javascript
|
|
284
284
|
sock.sendMessage(jid, {
|
|
@@ -291,7 +291,7 @@ sock.sendMessage(jid, {
|
|
|
291
291
|
})
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
#### ๐ Pin Message
|
|
295
295
|
|
|
296
296
|
```javascript
|
|
297
297
|
sock.sendMessage(jid, {
|
|
@@ -303,7 +303,7 @@ sock.sendMessage(jid, {
|
|
|
303
303
|
})
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
|
|
306
|
+
#### ๐ค Contact
|
|
307
307
|
|
|
308
308
|
```javascript
|
|
309
309
|
const vcard = 'BEGIN:VCARD\n'
|
|
@@ -325,7 +325,7 @@ sock.sendMessage(jid, {
|
|
|
325
325
|
})
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
#### ๐ Location
|
|
329
329
|
|
|
330
330
|
```javascript
|
|
331
331
|
sock.sendMessage(jid, {
|
|
@@ -338,7 +338,8 @@ sock.sendMessage(jid, {
|
|
|
338
338
|
quoted: message
|
|
339
339
|
})
|
|
340
340
|
```
|
|
341
|
-
|
|
341
|
+
|
|
342
|
+
#### ๐๏ธ Event
|
|
342
343
|
|
|
343
344
|
```javascript
|
|
344
345
|
sock.sendMessage(jid, {
|
|
@@ -362,7 +363,7 @@ sock.sendMessage(jid, {
|
|
|
362
363
|
})
|
|
363
364
|
```
|
|
364
365
|
|
|
365
|
-
|
|
366
|
+
#### ๐ Poll
|
|
366
367
|
|
|
367
368
|
```javascript
|
|
368
369
|
// --- Regular poll message
|
|
@@ -421,7 +422,7 @@ sock.sendMessage(jid, {
|
|
|
421
422
|
})
|
|
422
423
|
```
|
|
423
424
|
|
|
424
|
-
|
|
425
|
+
#### ๐ญ Response
|
|
425
426
|
|
|
426
427
|
```javascript
|
|
427
428
|
// --- Using buttonsResponseMessage
|
|
@@ -474,7 +475,7 @@ sock.sendMessage(jid, {
|
|
|
474
475
|
})
|
|
475
476
|
```
|
|
476
477
|
|
|
477
|
-
|
|
478
|
+
#### โจ Rich Response
|
|
478
479
|
|
|
479
480
|
> [!NOTE]
|
|
480
481
|
`richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
|
|
@@ -515,7 +516,31 @@ sock.sendMessage(jid, {
|
|
|
515
516
|
})
|
|
516
517
|
```
|
|
517
518
|
|
|
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
|
+
|
|
540
|
+
#### ๐งพ Message with Code Block
|
|
541
|
+
|
|
542
|
+
> [!NOTE]
|
|
543
|
+
This feature already includes a built-in tokenizer.
|
|
519
544
|
|
|
520
545
|
```javascript
|
|
521
546
|
sock.sendMessage(jid, {
|
|
@@ -527,7 +552,7 @@ sock.sendMessage(jid, {
|
|
|
527
552
|
})
|
|
528
553
|
```
|
|
529
554
|
|
|
530
|
-
|
|
555
|
+
#### ๐ Message with Table
|
|
531
556
|
|
|
532
557
|
```javascript
|
|
533
558
|
sock.sendMessage(jid, {
|
|
@@ -543,7 +568,7 @@ sock.sendMessage(jid, {
|
|
|
543
568
|
})
|
|
544
569
|
```
|
|
545
570
|
|
|
546
|
-
|
|
571
|
+
#### ๐๏ธ Status Mention
|
|
547
572
|
|
|
548
573
|
```javascript
|
|
549
574
|
sock.sendMessage([jidA, jidB, jidC], {
|
|
@@ -551,12 +576,12 @@ sock.sendMessage([jidA, jidB, jidC], {
|
|
|
551
576
|
})
|
|
552
577
|
```
|
|
553
578
|
|
|
554
|
-
|
|
579
|
+
### ๐ Sending Media Messages
|
|
555
580
|
|
|
556
581
|
> [!NOTE]
|
|
557
582
|
For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
|
|
558
583
|
|
|
559
|
-
|
|
584
|
+
#### ๐ผ๏ธ Image
|
|
560
585
|
|
|
561
586
|
```javascript
|
|
562
587
|
sock.sendMessage(jid, {
|
|
@@ -569,7 +594,7 @@ sock.sendMessage(jid, {
|
|
|
569
594
|
})
|
|
570
595
|
```
|
|
571
596
|
|
|
572
|
-
|
|
597
|
+
#### ๐ฅ Video
|
|
573
598
|
|
|
574
599
|
```javascript
|
|
575
600
|
sock.sendMessage(jid, {
|
|
@@ -584,7 +609,7 @@ sock.sendMessage(jid, {
|
|
|
584
609
|
})
|
|
585
610
|
```
|
|
586
611
|
|
|
587
|
-
|
|
612
|
+
#### ๐ Sticker
|
|
588
613
|
|
|
589
614
|
```javascript
|
|
590
615
|
sock.sendMessage(jid, {
|
|
@@ -596,7 +621,7 @@ sock.sendMessage(jid, {
|
|
|
596
621
|
})
|
|
597
622
|
```
|
|
598
623
|
|
|
599
|
-
|
|
624
|
+
#### ๐ฝ Audio
|
|
600
625
|
|
|
601
626
|
```javascript
|
|
602
627
|
sock.sendMessage(jid, {
|
|
@@ -609,7 +634,7 @@ sock.sendMessage(jid, {
|
|
|
609
634
|
})
|
|
610
635
|
```
|
|
611
636
|
|
|
612
|
-
|
|
637
|
+
#### ๐ผ๏ธ Album (Image & Video)
|
|
613
638
|
|
|
614
639
|
```javascript
|
|
615
640
|
sock.sendMessage(jid, {
|
|
@@ -639,7 +664,7 @@ sock.sendMessage(jid, {
|
|
|
639
664
|
})
|
|
640
665
|
```
|
|
641
666
|
|
|
642
|
-
|
|
667
|
+
#### ๐ฆ Sticker Pack
|
|
643
668
|
|
|
644
669
|
> [!IMPORTANT]
|
|
645
670
|
If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
@@ -670,9 +695,9 @@ sock.sendMessage(jid, {
|
|
|
670
695
|
})
|
|
671
696
|
```
|
|
672
697
|
|
|
673
|
-
|
|
698
|
+
### ๐๐ป Sending Interactive Messages
|
|
674
699
|
|
|
675
|
-
|
|
700
|
+
#### 1๏ธโฃ Buttons
|
|
676
701
|
|
|
677
702
|
```javascript
|
|
678
703
|
// --- Regular buttons message
|
|
@@ -723,7 +748,7 @@ sock.sendMessage(jid, {
|
|
|
723
748
|
})
|
|
724
749
|
```
|
|
725
750
|
|
|
726
|
-
|
|
751
|
+
#### 2๏ธโฃ List
|
|
727
752
|
|
|
728
753
|
> [!NOTE]
|
|
729
754
|
It only works in private chat (`@s.whatsapp.net`).
|
|
@@ -754,7 +779,7 @@ sock.sendMessage(jid, {
|
|
|
754
779
|
})
|
|
755
780
|
```
|
|
756
781
|
|
|
757
|
-
|
|
782
|
+
#### 3๏ธโฃ Interactive
|
|
758
783
|
|
|
759
784
|
```javascript
|
|
760
785
|
// --- Native Flow
|
|
@@ -772,7 +797,8 @@ sock.sendMessage(jid, {
|
|
|
772
797
|
offerExpiration: Date.now() + 3_600_000, // --- Optional
|
|
773
798
|
nativeFlow: [{
|
|
774
799
|
text: '๐๐ป Greeting',
|
|
775
|
-
id: '#Greeting'
|
|
800
|
+
id: '#Greeting',
|
|
801
|
+
icon: 'review' // --- Optional
|
|
776
802
|
}, {
|
|
777
803
|
text: '๐ Call',
|
|
778
804
|
call: '628123456789'
|
|
@@ -801,7 +827,8 @@ sock.sendMessage(jid, {
|
|
|
801
827
|
description: '',
|
|
802
828
|
id: '#SecretIngredient'
|
|
803
829
|
}]
|
|
804
|
-
}]
|
|
830
|
+
}],
|
|
831
|
+
icon: 'default' // --- Optional
|
|
805
832
|
}],
|
|
806
833
|
interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
|
|
807
834
|
}, {
|
|
@@ -861,7 +888,7 @@ sock.sendMessage(jid, {
|
|
|
861
888
|
})
|
|
862
889
|
```
|
|
863
890
|
|
|
864
|
-
|
|
891
|
+
#### 4๏ธโฃ Hydrated Template
|
|
865
892
|
|
|
866
893
|
```javascript
|
|
867
894
|
sock.sendMessage(jid, {
|
|
@@ -886,9 +913,9 @@ sock.sendMessage(jid, {
|
|
|
886
913
|
})
|
|
887
914
|
```
|
|
888
915
|
|
|
889
|
-
|
|
916
|
+
### ๐ณ Sending Payment Messages
|
|
890
917
|
|
|
891
|
-
|
|
918
|
+
#### 1๏ธโฃ Invite Payment
|
|
892
919
|
|
|
893
920
|
```javascript
|
|
894
921
|
sock.sendMessage(jid, {
|
|
@@ -896,7 +923,7 @@ sock.sendMessage(jid, {
|
|
|
896
923
|
})
|
|
897
924
|
```
|
|
898
925
|
|
|
899
|
-
|
|
926
|
+
#### 2๏ธโฃ Invoice
|
|
900
927
|
|
|
901
928
|
> [!NOTE]
|
|
902
929
|
Invoice message are not supported yet.
|
|
@@ -910,7 +937,7 @@ sock.sendMessage(jid, {
|
|
|
910
937
|
})
|
|
911
938
|
```
|
|
912
939
|
|
|
913
|
-
|
|
940
|
+
#### 3๏ธโฃ Order
|
|
914
941
|
|
|
915
942
|
```javascript
|
|
916
943
|
sock.sendMessage(chat, {
|
|
@@ -921,7 +948,7 @@ sock.sendMessage(chat, {
|
|
|
921
948
|
})
|
|
922
949
|
```
|
|
923
950
|
|
|
924
|
-
|
|
951
|
+
#### 4๏ธโฃ Product
|
|
925
952
|
|
|
926
953
|
```javascript
|
|
927
954
|
sock.sendMessage(jid, {
|
|
@@ -937,7 +964,7 @@ sock.sendMessage(jid, {
|
|
|
937
964
|
})
|
|
938
965
|
```
|
|
939
966
|
|
|
940
|
-
|
|
967
|
+
#### 5๏ธโฃ Request Payment
|
|
941
968
|
|
|
942
969
|
```javascript
|
|
943
970
|
sock.sendMessage(jid, {
|
|
@@ -946,9 +973,9 @@ sock.sendMessage(jid, {
|
|
|
946
973
|
})
|
|
947
974
|
```
|
|
948
975
|
|
|
949
|
-
|
|
976
|
+
### ๐๏ธ Other Message Options
|
|
950
977
|
|
|
951
|
-
|
|
978
|
+
#### 1๏ธโฃ AI Icon
|
|
952
979
|
|
|
953
980
|
> [!NOTE]
|
|
954
981
|
It only works in private chat (`@s.whatsapp.net`).
|
|
@@ -965,7 +992,7 @@ sock.sendMessage(jid, {
|
|
|
965
992
|
})
|
|
966
993
|
```
|
|
967
994
|
|
|
968
|
-
|
|
995
|
+
#### 2๏ธโฃ Ephemeral
|
|
969
996
|
|
|
970
997
|
> [!NOTE]
|
|
971
998
|
Wrap message into `ephemeralMessage`
|
|
@@ -980,7 +1007,7 @@ sock.sendMessage(jid, {
|
|
|
980
1007
|
})
|
|
981
1008
|
```
|
|
982
1009
|
|
|
983
|
-
|
|
1010
|
+
#### 3๏ธโฃ External Ad Reply
|
|
984
1011
|
|
|
985
1012
|
> [!NOTE]
|
|
986
1013
|
Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
@@ -1000,7 +1027,7 @@ sock.sendMessage(jid, {
|
|
|
1000
1027
|
})
|
|
1001
1028
|
```
|
|
1002
1029
|
|
|
1003
|
-
|
|
1030
|
+
#### 4๏ธโฃ Group Status
|
|
1004
1031
|
|
|
1005
1032
|
> [!NOTE]
|
|
1006
1033
|
It only works in group chat (`@g.us`)
|
|
@@ -1015,7 +1042,7 @@ sock.sendMessage(jid, {
|
|
|
1015
1042
|
})
|
|
1016
1043
|
```
|
|
1017
1044
|
|
|
1018
|
-
|
|
1045
|
+
#### 5๏ธโฃ Raw
|
|
1019
1046
|
|
|
1020
1047
|
```javascript
|
|
1021
1048
|
sock.sendMessage(jid, {
|
|
@@ -1037,7 +1064,7 @@ sock.sendMessage(jid, {
|
|
|
1037
1064
|
})
|
|
1038
1065
|
```
|
|
1039
1066
|
|
|
1040
|
-
|
|
1067
|
+
#### 6๏ธโฃ Secure Meta Service Label
|
|
1041
1068
|
|
|
1042
1069
|
```javascript
|
|
1043
1070
|
sock.sendMessage(jid, {
|
|
@@ -1046,7 +1073,7 @@ sock.sendMessage(jid, {
|
|
|
1046
1073
|
})
|
|
1047
1074
|
```
|
|
1048
1075
|
|
|
1049
|
-
|
|
1076
|
+
#### 7๏ธโฃ View Once
|
|
1050
1077
|
|
|
1051
1078
|
> [!NOTE]
|
|
1052
1079
|
Wrap message into `viewOnceMessage`
|
|
@@ -1061,7 +1088,7 @@ sock.sendMessage(jid, {
|
|
|
1061
1088
|
})
|
|
1062
1089
|
```
|
|
1063
1090
|
|
|
1064
|
-
|
|
1091
|
+
#### 8๏ธโฃ View Once V2
|
|
1065
1092
|
|
|
1066
1093
|
> [!NOTE]
|
|
1067
1094
|
Wrap message into `viewOnceMessageV2`
|
|
@@ -1076,7 +1103,7 @@ sock.sendMessage(jid, {
|
|
|
1076
1103
|
})
|
|
1077
1104
|
```
|
|
1078
1105
|
|
|
1079
|
-
|
|
1106
|
+
#### 9๏ธโฃ View Once V2 Extension
|
|
1080
1107
|
|
|
1081
1108
|
> [!NOTE]
|
|
1082
1109
|
Wrap message into `viewOnceMessageV2Extension`
|
|
@@ -1091,9 +1118,9 @@ sock.sendMessage(jid, {
|
|
|
1091
1118
|
})
|
|
1092
1119
|
```
|
|
1093
1120
|
|
|
1094
|
-
|
|
1121
|
+
### ๐งฐ Additional Contents
|
|
1095
1122
|
|
|
1096
|
-
|
|
1123
|
+
#### ๐ท๏ธ Find User ID (JID|PN/LID)
|
|
1097
1124
|
|
|
1098
1125
|
> [!NOTE]
|
|
1099
1126
|
The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
@@ -1126,7 +1153,7 @@ console.log('๐ท๏ธ Got user ID', ':', ids)
|
|
|
1126
1153
|
// --- Same output shape regardless of input type
|
|
1127
1154
|
```
|
|
1128
1155
|
|
|
1129
|
-
|
|
1156
|
+
#### ๐ Request Custom Pairing Code
|
|
1130
1157
|
|
|
1131
1158
|
> [!NOTE]
|
|
1132
1159
|
The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
@@ -1140,7 +1167,7 @@ await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
|
1140
1167
|
console.log('๐ Pairing code', ':', customPairingCode)
|
|
1141
1168
|
```
|
|
1142
1169
|
|
|
1143
|
-
|
|
1170
|
+
#### ๐ผ๏ธ Image Processing
|
|
1144
1171
|
|
|
1145
1172
|
> [!NOTE]
|
|
1146
1173
|
Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
|
|
@@ -1196,7 +1223,7 @@ console.log('โ
Process completed!')
|
|
|
1196
1223
|
console.dir(output, { depth: null })
|
|
1197
1224
|
```
|
|
1198
1225
|
|
|
1199
|
-
|
|
1226
|
+
#### ๐ฃ Newsletter Management
|
|
1200
1227
|
|
|
1201
1228
|
```javascript
|
|
1202
1229
|
// --- Create a new one
|
|
@@ -1234,7 +1261,7 @@ const newsletters = await sock.newsletterSubscribed()
|
|
|
1234
1261
|
console.dir(newsletters, { depth: null })
|
|
1235
1262
|
```
|
|
1236
1263
|
|
|
1237
|
-
|
|
1264
|
+
#### ๐ฅ Group Management
|
|
1238
1265
|
|
|
1239
1266
|
```javascript
|
|
1240
1267
|
// --- Create a new one and add participants using their JIDs
|
|
@@ -811,15 +811,14 @@ export const makeMessagesSocket = (config) => {
|
|
|
811
811
|
content: tcTokenBuffer
|
|
812
812
|
});
|
|
813
813
|
}
|
|
814
|
+
let alreadyHasBizNode = false;
|
|
814
815
|
if (additionalNodes && additionalNodes.length > 0) {
|
|
815
816
|
;
|
|
816
817
|
stanza.content.push(...additionalNodes);
|
|
818
|
+
alreadyHasBizNode = !addBizAttributes &&
|
|
819
|
+
additionalNodes.some(node => node.tag === 'biz');
|
|
817
820
|
}
|
|
818
821
|
// Lia@Changes 30-01-26 --- Add Biz Binary Node to support button messages
|
|
819
|
-
let alreadyHasBizNode = false;
|
|
820
|
-
if (!addBizAttributes) {
|
|
821
|
-
alreadyHasBizNode = additionalNodes.some(node => node.tag === 'biz');
|
|
822
|
-
}
|
|
823
822
|
if ((!alreadyHasBizNode && shouldIncludeBizBinaryNode(innerMessage)) || addBizAttributes) {
|
|
824
823
|
const bizNode = getBizBinaryNode(innerMessage, addBizAttributes);
|
|
825
824
|
stanza.content.push(bizNode);
|
package/lib/Utils/messages.js
CHANGED
|
@@ -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
|
|
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.
|
|
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",
|