@elrayyxml/baileys 1.0.2 → 1.0.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 +2485 -0
- package/lib/Defaults/index.js +5 -1
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/messages-send.js +260 -55
- package/lib/Utils/generics.js +32 -4
- package/lib/Utils/messages.js +96 -4
- package/lib/WABinary/generic-utils.js +12 -1
- package/package.json +4 -10
- package/README.MD +0 -78
- package/lib/Socket/type.js +0 -405
package/lib/Defaults/index.js
CHANGED
|
@@ -3,14 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
6
|
+
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
7
|
const WAProto_1 = require("../../WAProto");
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
9
|
const browser_utils_1 = require("../Utils/browser-utils");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
11
|
const baileys_version_json_1 = require("./baileys-version.json");
|
|
12
|
+
const phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
12
13
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
14
|
+
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default
|
|
13
15
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
16
|
+
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/'
|
|
17
|
+
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/'
|
|
14
18
|
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
15
19
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
16
20
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
{
|
|
2
|
+
"93": 412,
|
|
3
|
+
"355": 276,
|
|
4
|
+
"213": 603,
|
|
5
|
+
"1-684": 544,
|
|
6
|
+
"376": 213,
|
|
7
|
+
"244": 631,
|
|
8
|
+
"1-264": 365,
|
|
9
|
+
"1-268": 344,
|
|
10
|
+
"54": 722,
|
|
11
|
+
"374": 283,
|
|
12
|
+
"297": 363,
|
|
13
|
+
"61": 505,
|
|
14
|
+
"43": 232,
|
|
15
|
+
"994": 400,
|
|
16
|
+
"1-242": 364,
|
|
17
|
+
"973": 426,
|
|
18
|
+
"880": 470,
|
|
19
|
+
"1-246": 342,
|
|
20
|
+
"375": 257,
|
|
21
|
+
"32": 206,
|
|
22
|
+
"501": 702,
|
|
23
|
+
"229": 616,
|
|
24
|
+
"1-441": 350,
|
|
25
|
+
"975": 402,
|
|
26
|
+
"591": 736,
|
|
27
|
+
"387": 218,
|
|
28
|
+
"267": 652,
|
|
29
|
+
"55": 724,
|
|
30
|
+
"1-284": 348,
|
|
31
|
+
"673": 528,
|
|
32
|
+
"359": 284,
|
|
33
|
+
"226": 613,
|
|
34
|
+
"257": 642,
|
|
35
|
+
"855": 456,
|
|
36
|
+
"237": 624,
|
|
37
|
+
"238": 625,
|
|
38
|
+
"1-345": 346,
|
|
39
|
+
"236": 623,
|
|
40
|
+
"235": 622,
|
|
41
|
+
"56": 730,
|
|
42
|
+
"86": 454,
|
|
43
|
+
"57": 732,
|
|
44
|
+
"269": 654,
|
|
45
|
+
"682": 548,
|
|
46
|
+
"506": 712,
|
|
47
|
+
"385": 219,
|
|
48
|
+
"53": 368,
|
|
49
|
+
"357": 280,
|
|
50
|
+
"420": 230,
|
|
51
|
+
"243": 630,
|
|
52
|
+
"45": 238,
|
|
53
|
+
"253": 638,
|
|
54
|
+
"1-767": 366,
|
|
55
|
+
"1-809": 370,
|
|
56
|
+
"1-849": 370,
|
|
57
|
+
"1-829": 370,
|
|
58
|
+
"593": 740,
|
|
59
|
+
"20": 602,
|
|
60
|
+
"503": 706,
|
|
61
|
+
"240": 627,
|
|
62
|
+
"291": 657,
|
|
63
|
+
"372": 248,
|
|
64
|
+
"251": 636,
|
|
65
|
+
"500": 750,
|
|
66
|
+
"298": 288,
|
|
67
|
+
"679": 542,
|
|
68
|
+
"358": 244,
|
|
69
|
+
"33": 208,
|
|
70
|
+
"689": 547,
|
|
71
|
+
"241": 628,
|
|
72
|
+
"220": 607,
|
|
73
|
+
"995": 282,
|
|
74
|
+
"49": 262,
|
|
75
|
+
"233": 620,
|
|
76
|
+
"350": 266,
|
|
77
|
+
"30": 202,
|
|
78
|
+
"299": 290,
|
|
79
|
+
"1-473": 352,
|
|
80
|
+
"1-671": 535,
|
|
81
|
+
"502": 704,
|
|
82
|
+
"224": 537,
|
|
83
|
+
"592": 738,
|
|
84
|
+
"509": 372,
|
|
85
|
+
"504": 708,
|
|
86
|
+
"852": 454,
|
|
87
|
+
"36": 216,
|
|
88
|
+
"354": 274,
|
|
89
|
+
"91": 404,
|
|
90
|
+
"62": 510,
|
|
91
|
+
"98": 432,
|
|
92
|
+
"964": 418,
|
|
93
|
+
"353": 234,
|
|
94
|
+
"972": 425,
|
|
95
|
+
"39": 222,
|
|
96
|
+
"225": 612,
|
|
97
|
+
"1-876": 338,
|
|
98
|
+
"81": 440,
|
|
99
|
+
"962": 416,
|
|
100
|
+
"254": 639,
|
|
101
|
+
"686": 545,
|
|
102
|
+
"383": 221,
|
|
103
|
+
"965": 419,
|
|
104
|
+
"371": 247,
|
|
105
|
+
"961": 415,
|
|
106
|
+
"266": 651,
|
|
107
|
+
"231": 618,
|
|
108
|
+
"218": 606,
|
|
109
|
+
"423": 295,
|
|
110
|
+
"370": 246,
|
|
111
|
+
"352": 270,
|
|
112
|
+
"389": 294,
|
|
113
|
+
"261": 646,
|
|
114
|
+
"265": 650,
|
|
115
|
+
"60": 502,
|
|
116
|
+
"960": 472,
|
|
117
|
+
"223": 610,
|
|
118
|
+
"356": 278,
|
|
119
|
+
"692": 551,
|
|
120
|
+
"222": 609,
|
|
121
|
+
"230": 617,
|
|
122
|
+
"52": 334,
|
|
123
|
+
"691": 550,
|
|
124
|
+
"373": 259,
|
|
125
|
+
"377": 212,
|
|
126
|
+
"976": 428,
|
|
127
|
+
"382": 297,
|
|
128
|
+
"1-664": 354,
|
|
129
|
+
"212": 604,
|
|
130
|
+
"258": 643,
|
|
131
|
+
"95": 414,
|
|
132
|
+
"264": 649,
|
|
133
|
+
"674": 536,
|
|
134
|
+
"977": 429,
|
|
135
|
+
"31": 204,
|
|
136
|
+
"687": 546,
|
|
137
|
+
"64": 530,
|
|
138
|
+
"505": 710,
|
|
139
|
+
"227": 614,
|
|
140
|
+
"234": 621,
|
|
141
|
+
"683": 555,
|
|
142
|
+
"1-670": 534,
|
|
143
|
+
"47": 242,
|
|
144
|
+
"968": 226,
|
|
145
|
+
"92": 410,
|
|
146
|
+
"680": 552,
|
|
147
|
+
"970": 423,
|
|
148
|
+
"507": 714,
|
|
149
|
+
"675": 537,
|
|
150
|
+
"595": 744,
|
|
151
|
+
"51": 716,
|
|
152
|
+
"63": 515,
|
|
153
|
+
"48": 260,
|
|
154
|
+
"351": 268,
|
|
155
|
+
"1-787, 1-939": 330,
|
|
156
|
+
"974": 427,
|
|
157
|
+
"242": 630,
|
|
158
|
+
"40": 226,
|
|
159
|
+
"7": 250,
|
|
160
|
+
"250": 635,
|
|
161
|
+
"290": 658,
|
|
162
|
+
"1-869": 356,
|
|
163
|
+
"1-758": 358,
|
|
164
|
+
"508": 308,
|
|
165
|
+
"1-784": 360,
|
|
166
|
+
"685": 544,
|
|
167
|
+
"378": 292,
|
|
168
|
+
"239": 626,
|
|
169
|
+
"966": 420,
|
|
170
|
+
"221": 608,
|
|
171
|
+
"381": 220,
|
|
172
|
+
"248": 633,
|
|
173
|
+
"232": 619,
|
|
174
|
+
"65": 525,
|
|
175
|
+
"386": 293,
|
|
176
|
+
"677": 540,
|
|
177
|
+
"27": 655,
|
|
178
|
+
"211": 659,
|
|
179
|
+
"34": 214,
|
|
180
|
+
"94": 413,
|
|
181
|
+
"249": 634,
|
|
182
|
+
"597": 746,
|
|
183
|
+
"268": 653,
|
|
184
|
+
"46": 240,
|
|
185
|
+
"41": 228,
|
|
186
|
+
"963": 417,
|
|
187
|
+
"886": 466,
|
|
188
|
+
"992": 436,
|
|
189
|
+
"255": 640,
|
|
190
|
+
"66": 520,
|
|
191
|
+
"228": 615,
|
|
192
|
+
"690": 554,
|
|
193
|
+
"676": 539,
|
|
194
|
+
"1-868": 374,
|
|
195
|
+
"216": 605,
|
|
196
|
+
"90": 286,
|
|
197
|
+
"993": 438,
|
|
198
|
+
"1-649": 376,
|
|
199
|
+
"688": 553,
|
|
200
|
+
"1-340": 332,
|
|
201
|
+
"256": 641,
|
|
202
|
+
"380": 255,
|
|
203
|
+
"971": 424,
|
|
204
|
+
"44": 234,
|
|
205
|
+
"1": 310,
|
|
206
|
+
"598": 748,
|
|
207
|
+
"998": 434,
|
|
208
|
+
"678": 541,
|
|
209
|
+
"379": 225,
|
|
210
|
+
"58": 734,
|
|
211
|
+
"681": 543,
|
|
212
|
+
"967": 421,
|
|
213
|
+
"260": 645,
|
|
214
|
+
"263": 648,
|
|
215
|
+
"670": 514,
|
|
216
|
+
"245": 632,
|
|
217
|
+
"856": 457,
|
|
218
|
+
"599": 362,
|
|
219
|
+
"850": 467,
|
|
220
|
+
"262": 647,
|
|
221
|
+
"82": 450,
|
|
222
|
+
"84": 452
|
|
223
|
+
}
|
|
@@ -14,7 +14,6 @@ const link_preview_1 = require("../Utils/link-preview");
|
|
|
14
14
|
const WABinary_1 = require("../WABinary");
|
|
15
15
|
const WAUSync_1 = require("../WAUSync");
|
|
16
16
|
const newsletter_1 = require("./newsletter");
|
|
17
|
-
const elrayyxml_1 = require("./type");
|
|
18
17
|
const makeMessagesSocket = (config) => {
|
|
19
18
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
|
|
20
19
|
const sock = (0, newsletter_1.makeNewsletterSocket)(config);
|
|
@@ -494,12 +493,22 @@ const makeMessagesSocket = (config) => {
|
|
|
494
493
|
if (AI && isPrivate) {
|
|
495
494
|
const botNode = {
|
|
496
495
|
tag: 'bot',
|
|
497
|
-
attrs: {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
496
|
+
attrs: {
|
|
497
|
+
biz_bot: '1'
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const filteredBizBot = WABinary_1.getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
|
|
502
|
+
|
|
503
|
+
if (filteredBizBot) {
|
|
504
|
+
stanza.content.push(...additionalNodes)
|
|
505
|
+
didPushAdditional = true
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
else {
|
|
509
|
+
stanza.content.push(botNode)
|
|
510
|
+
}
|
|
511
|
+
}
|
|
503
512
|
if (additionalNodes && additionalNodes.length > 0) {
|
|
504
513
|
stanza.content.push(...additionalNodes);
|
|
505
514
|
}
|
|
@@ -561,6 +570,9 @@ const makeMessagesSocket = (config) => {
|
|
|
561
570
|
else if (msg.pollCreationMessage || msg.pollCreationMessageV2 || msg.pollCreationMessageV3 || msg.pollUpdateMessage) {
|
|
562
571
|
return 'poll';
|
|
563
572
|
}
|
|
573
|
+
else if (msg.eventMessage) {
|
|
574
|
+
return 'event';
|
|
575
|
+
}
|
|
564
576
|
else if (getMediaType(msg)) {
|
|
565
577
|
return 'media';
|
|
566
578
|
}
|
|
@@ -578,6 +590,12 @@ const makeMessagesSocket = (config) => {
|
|
|
578
590
|
else if (message.audioMessage) {
|
|
579
591
|
return message.audioMessage.ptt ? 'ptt' : 'audio';
|
|
580
592
|
}
|
|
593
|
+
else if (message.ptvMessage) {
|
|
594
|
+
return 'ptv';
|
|
595
|
+
}
|
|
596
|
+
else if (message.albumMessage) {
|
|
597
|
+
return 'collection';
|
|
598
|
+
}
|
|
581
599
|
else if (message.contactMessage) {
|
|
582
600
|
return 'vcard';
|
|
583
601
|
}
|
|
@@ -587,6 +605,9 @@ const makeMessagesSocket = (config) => {
|
|
|
587
605
|
else if (message.contactsArrayMessage) {
|
|
588
606
|
return 'contact_array';
|
|
589
607
|
}
|
|
608
|
+
else if (message.locationMessage) {
|
|
609
|
+
return 'location';
|
|
610
|
+
}
|
|
590
611
|
else if (message.liveLocationMessage) {
|
|
591
612
|
return 'livelocation';
|
|
592
613
|
}
|
|
@@ -611,10 +632,45 @@ const makeMessagesSocket = (config) => {
|
|
|
611
632
|
else if (message.interactiveResponseMessage) {
|
|
612
633
|
return 'native_flow_response';
|
|
613
634
|
}
|
|
635
|
+
else if (/https:\/\/wa\.me\/c\/\d+/.test(message.extendedTextMessage?.text)) {
|
|
636
|
+
return 'cataloglink'
|
|
637
|
+
}
|
|
638
|
+
else if (/https:\/\/wa\.me\/p\/\d+\/\d+/.test(message.extendedTextMessage?.text)) {
|
|
639
|
+
return 'productlink'
|
|
640
|
+
}
|
|
614
641
|
else if (message.groupInviteMessage) {
|
|
615
642
|
return 'url';
|
|
616
643
|
}
|
|
617
644
|
};
|
|
645
|
+
const getButtonType = (message) => {
|
|
646
|
+
if (message.listMessage) {
|
|
647
|
+
return 'list'
|
|
648
|
+
}
|
|
649
|
+
else if (message.buttonsMessage) {
|
|
650
|
+
return 'buttons'
|
|
651
|
+
}
|
|
652
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') {
|
|
653
|
+
return 'review_and_pay'
|
|
654
|
+
}
|
|
655
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_order') {
|
|
656
|
+
return 'review_order'
|
|
657
|
+
}
|
|
658
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
|
|
659
|
+
return 'payment_info'
|
|
660
|
+
}
|
|
661
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
|
|
662
|
+
return 'payment_status'
|
|
663
|
+
}
|
|
664
|
+
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
|
|
665
|
+
return 'payment_method'
|
|
666
|
+
}
|
|
667
|
+
else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
|
|
668
|
+
return 'interactive'
|
|
669
|
+
}
|
|
670
|
+
else if (message.interactiveMessage?.nativeFlowMessage) {
|
|
671
|
+
return 'native_flow'
|
|
672
|
+
}
|
|
673
|
+
}
|
|
618
674
|
const getPrivacyTokens = async (jids) => {
|
|
619
675
|
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
620
676
|
const result = await query({
|
|
@@ -642,7 +698,6 @@ const makeMessagesSocket = (config) => {
|
|
|
642
698
|
return result;
|
|
643
699
|
};
|
|
644
700
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
645
|
-
const elrayy = new elrayyxml_1(Utils_1, waUploadToServer, relayMessage, authState);
|
|
646
701
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
647
702
|
return {
|
|
648
703
|
...sock,
|
|
@@ -699,9 +754,189 @@ const makeMessagesSocket = (config) => {
|
|
|
699
754
|
]);
|
|
700
755
|
return message;
|
|
701
756
|
},
|
|
757
|
+
groupStatusMessage: async (jid, content) => {
|
|
758
|
+
const normalizedJid = WABinary_1.jidNormalizedUser(jid);
|
|
759
|
+
|
|
760
|
+
let waMsgContent;
|
|
761
|
+
if (content.message) {
|
|
762
|
+
waMsgContent = content;
|
|
763
|
+
} else {
|
|
764
|
+
waMsgContent = await Utils_1.generateWAMessageContent(content, {
|
|
765
|
+
upload: waUploadToServer
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const groupStoryContent = {
|
|
770
|
+
groupStatusMessageV2: {
|
|
771
|
+
message: waMsgContent.message || waMsgContent
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
const msg = await Utils_1.generateWAMessageFromContent(
|
|
776
|
+
normalizedJid,
|
|
777
|
+
groupStoryContent,
|
|
778
|
+
{
|
|
779
|
+
userJid: authState.creds.me.id
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
|
|
783
|
+
await relayMessage(normalizedJid, msg.message, {
|
|
784
|
+
messageId: msg.key.id
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
return msg;
|
|
788
|
+
},
|
|
789
|
+
sendStatusMentions: async (content, jids = []) => {
|
|
790
|
+
const userJid = WABinary_1.jidNormalizedUser(authState.creds.me.id);
|
|
791
|
+
let allUsers = new Set();
|
|
792
|
+
allUsers.add(userJid);
|
|
793
|
+
|
|
794
|
+
for (const id of jids) {
|
|
795
|
+
const isGroup = WABinary_1.isJidGroup(id);
|
|
796
|
+
const isPrivate = WABinary_1.isJidUser(id);
|
|
797
|
+
|
|
798
|
+
if (isGroup) {
|
|
799
|
+
try {
|
|
800
|
+
const metadata = await (cachedGroupMetadata ? cachedGroupMetadata(id) : groupMetadata(id)) || await groupMetadata(id);
|
|
801
|
+
const participants = metadata.participants.map(p => WABinary_1.jidNormalizedUser(p.jid));
|
|
802
|
+
participants.forEach(jid => allUsers.add(jid));
|
|
803
|
+
} catch (error) {
|
|
804
|
+
logger.error(`Error getting metadata for group ${id}: ${error}`);
|
|
805
|
+
}
|
|
806
|
+
} else if (isPrivate) {
|
|
807
|
+
allUsers.add(WABinary_1.jidNormalizedUser(id));
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
const uniqueUsers = Array.from(allUsers);
|
|
812
|
+
const getRandomHexColor = () => "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
|
|
813
|
+
|
|
814
|
+
const isMedia = content.image || content.video || content.audio;
|
|
815
|
+
const isAudio = !!content.audio;
|
|
816
|
+
|
|
817
|
+
const messageContent = { ...content };
|
|
818
|
+
|
|
819
|
+
if (isMedia && !isAudio) {
|
|
820
|
+
if (messageContent.text) {
|
|
821
|
+
messageContent.caption = messageContent.text;
|
|
822
|
+
delete messageContent.text;
|
|
823
|
+
}
|
|
824
|
+
delete messageContent.ptt;
|
|
825
|
+
delete messageContent.font;
|
|
826
|
+
delete messageContent.backgroundColor;
|
|
827
|
+
delete messageContent.textColor;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
if (isAudio) {
|
|
831
|
+
delete messageContent.text;
|
|
832
|
+
delete messageContent.caption;
|
|
833
|
+
delete messageContent.font;
|
|
834
|
+
delete messageContent.textColor;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const font = !isMedia ? (content.font || Math.floor(Math.random() * 9)) : undefined;
|
|
838
|
+
const textColor = !isMedia ? (content.textColor || getRandomHexColor()) : undefined;
|
|
839
|
+
const backgroundColor = (!isMedia || isAudio) ? (content.backgroundColor || getRandomHexColor()) : undefined;
|
|
840
|
+
const ptt = isAudio ? (typeof content.ptt === 'boolean' ? content.ptt : true) : undefined;
|
|
841
|
+
|
|
842
|
+
let msg;
|
|
843
|
+
let mediaHandle;
|
|
844
|
+
try {
|
|
845
|
+
msg = await Utils_1.generateWAMessage(WABinary_1.STORIES_JID, messageContent, {
|
|
846
|
+
logger,
|
|
847
|
+
userJid,
|
|
848
|
+
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
849
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
850
|
+
fetchOpts: { timeout: 3000, ...axiosOptions || {} },
|
|
851
|
+
logger,
|
|
852
|
+
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
853
|
+
}),
|
|
854
|
+
upload: async (encFilePath, opts) => {
|
|
855
|
+
const up = await waUploadToServer(encFilePath, { ...opts });
|
|
856
|
+
mediaHandle = up.handle;
|
|
857
|
+
return up;
|
|
858
|
+
},
|
|
859
|
+
mediaCache: config.mediaCache,
|
|
860
|
+
options: config.options,
|
|
861
|
+
font,
|
|
862
|
+
textColor,
|
|
863
|
+
backgroundColor,
|
|
864
|
+
ptt
|
|
865
|
+
});
|
|
866
|
+
} catch (error) {
|
|
867
|
+
logger.error(`Error generating message: ${error}`);
|
|
868
|
+
throw error;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
await relayMessage(WABinary_1.STORIES_JID, msg.message, {
|
|
872
|
+
messageId: msg.key.id,
|
|
873
|
+
statusJidList: uniqueUsers,
|
|
874
|
+
additionalNodes: [
|
|
875
|
+
{
|
|
876
|
+
tag: 'meta',
|
|
877
|
+
attrs: {},
|
|
878
|
+
content: [
|
|
879
|
+
{
|
|
880
|
+
tag: 'mentioned_users',
|
|
881
|
+
attrs: {},
|
|
882
|
+
content: jids.map(jid => ({
|
|
883
|
+
tag: 'to',
|
|
884
|
+
attrs: { jid: WABinary_1.jidNormalizedUser(jid) }
|
|
885
|
+
}))
|
|
886
|
+
}]
|
|
887
|
+
}]
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
for (const id of jids) {
|
|
891
|
+
try {
|
|
892
|
+
const normalizedId = WABinary_1.jidNormalizedUser(id);
|
|
893
|
+
const isPrivate = WABinary_1.isJidUser(normalizedId);
|
|
894
|
+
const type = isPrivate ? 'statusMentionMessage' : 'groupStatusMentionMessage';
|
|
895
|
+
|
|
896
|
+
const protocolMessage = {
|
|
897
|
+
[type]: {
|
|
898
|
+
message: {
|
|
899
|
+
protocolMessage: {
|
|
900
|
+
key: msg.key,
|
|
901
|
+
type: 25
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
messageContextInfo: {
|
|
906
|
+
messageSecret: (0, crypto_1.randomBytes)(32)
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
const statusMsg = await Utils_1.generateWAMessageFromContent(normalizedId,
|
|
911
|
+
protocolMessage,
|
|
912
|
+
{}
|
|
913
|
+
);
|
|
914
|
+
|
|
915
|
+
await relayMessage(
|
|
916
|
+
normalizedId,
|
|
917
|
+
statusMsg.message,
|
|
918
|
+
{
|
|
919
|
+
additionalNodes: [{
|
|
920
|
+
tag: 'meta',
|
|
921
|
+
attrs: isPrivate ?
|
|
922
|
+
{ is_status_mention: 'true' } :
|
|
923
|
+
{ is_group_status_mention: 'true' }
|
|
924
|
+
}]
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
|
|
928
|
+
await (0, Utils_1.delay)(2000);
|
|
929
|
+
} catch (error) {
|
|
930
|
+
logger.error(`Error sending to ${id}: ${error}`);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
return msg;
|
|
935
|
+
},
|
|
702
936
|
sendMessage: async (jid, content, options = {}) => {
|
|
703
937
|
var _a, _b, _c;
|
|
704
938
|
const userJid = authState.creds.me.id;
|
|
939
|
+
const additionalAttributes = {};
|
|
705
940
|
if (!options.ephemeralExpiration) {
|
|
706
941
|
if ((0, WABinary_1.isJidGroup)(jid)) {
|
|
707
942
|
const groups = await sock.groupQuery(jid, 'get', [{
|
|
@@ -724,52 +959,21 @@ const makeMessagesSocket = (config) => {
|
|
|
724
959
|
(disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
|
|
725
960
|
disappearingMessagesInChat;
|
|
726
961
|
await groupToggleEphemeral(jid, value);
|
|
962
|
+
}
|
|
963
|
+
else if (typeof content === 'object' && 'album' in content && content.album) {
|
|
964
|
+
const albumMsg = await Utils_1.prepareAlbumMessageContent(jid, content.album, {
|
|
965
|
+
sock: {
|
|
966
|
+
relayMessage,
|
|
967
|
+
waUploadToServer
|
|
968
|
+
},
|
|
969
|
+
userJid: userJid,
|
|
970
|
+
quoted: options.quoted,
|
|
971
|
+
ephemeralExpiration: options.ephemeralExpiration,
|
|
972
|
+
...options
|
|
973
|
+
});
|
|
974
|
+
return albumMsg;
|
|
727
975
|
}
|
|
728
|
-
|
|
729
|
-
const getParticipantAttr = () => options.filter ? { participant: { jid } } : {};
|
|
730
|
-
const { quoted } = options;
|
|
731
|
-
|
|
732
|
-
const messageType = elrayy.detectType(content);
|
|
733
|
-
|
|
734
|
-
if (messageType) {
|
|
735
|
-
switch(messageType) {
|
|
736
|
-
case 'PAYMENT':
|
|
737
|
-
const paymentContent = await elrayy.handlePayment(content, quoted);
|
|
738
|
-
return await relayMessage(jid, paymentContent, {
|
|
739
|
-
messageId: (0, Utils_1.generateMessageID)(),
|
|
740
|
-
...getParticipantAttr()
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
case 'PRODUCT':
|
|
744
|
-
const productContent = await elrayy.handleProduct(content, jid, quoted);
|
|
745
|
-
const productMsg = await (0, Utils_1.generateWAMessageFromContent)(jid, productContent, { quoted });
|
|
746
|
-
return await relayMessage(jid, productMsg.message, {
|
|
747
|
-
messageId: (0, Utils_1.generateMessageID)(),
|
|
748
|
-
...getParticipantAttr()
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
case 'INTERACTIVE':
|
|
752
|
-
const interactiveContent = await elrayy.handleInteractive(content, jid, quoted);
|
|
753
|
-
const interactiveMsg = await (0, Utils_1.generateWAMessageFromContent)(jid, interactiveContent, { quoted });
|
|
754
|
-
return await relayMessage(jid, interactiveMsg.message, {
|
|
755
|
-
messageId: (0, Utils_1.generateMessageID)(),
|
|
756
|
-
...getParticipantAttr()
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
case 'ALBUM':
|
|
760
|
-
return await elrayy.handleAlbum(content, jid, quoted);
|
|
761
|
-
|
|
762
|
-
case 'EVENT':
|
|
763
|
-
return await elrayy.handleEvent(content, jid, quoted);
|
|
764
|
-
|
|
765
|
-
case 'POLL_RESULT':
|
|
766
|
-
return await elrayy.handlePollResult(content, jid, quoted);
|
|
767
|
-
|
|
768
|
-
case 'GROUP_STORY':
|
|
769
|
-
return await elrayy.handleGroupStory(content, jid, quoted);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
|
|
976
|
+
else {
|
|
773
977
|
let mediaHandle;
|
|
774
978
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
775
979
|
logger,
|
|
@@ -786,6 +990,7 @@ const makeMessagesSocket = (config) => {
|
|
|
786
990
|
: undefined
|
|
787
991
|
}),
|
|
788
992
|
getProfilePicUrl: sock.profilePictureUrl,
|
|
993
|
+
getCallLink: sock.createCallLink,
|
|
789
994
|
upload: async (readStream, opts) => {
|
|
790
995
|
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
|
|
791
996
|
mediaHandle = up.handle;
|
|
@@ -802,7 +1007,6 @@ const makeMessagesSocket = (config) => {
|
|
|
802
1007
|
const isKeepMsg = 'keep' in content && content.keep;
|
|
803
1008
|
const isPollMessage = 'poll' in content && !!content.poll;
|
|
804
1009
|
const isAiMsg = 'ai' in content && !!content.ai;
|
|
805
|
-
const additionalAttributes = {};
|
|
806
1010
|
const additionalNodes = [];
|
|
807
1011
|
// required for delete
|
|
808
1012
|
if (isDeleteMsg) {
|
|
@@ -836,7 +1040,7 @@ const makeMessagesSocket = (config) => {
|
|
|
836
1040
|
});
|
|
837
1041
|
// required to display AI icon on message
|
|
838
1042
|
}
|
|
839
|
-
else if (isAiMsg
|
|
1043
|
+
else if (isAiMsg) {
|
|
840
1044
|
additionalNodes.push({
|
|
841
1045
|
attrs: {
|
|
842
1046
|
biz_bot: '1'
|
|
@@ -859,5 +1063,6 @@ const makeMessagesSocket = (config) => {
|
|
|
859
1063
|
return fullMsg;
|
|
860
1064
|
}
|
|
861
1065
|
}
|
|
1066
|
+
};
|
|
862
1067
|
};
|
|
863
1068
|
exports.makeMessagesSocket = makeMessagesSocket;
|