@rizzkezik/bails 6.1.0 → 6.1.2
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 +269 -411
- package/WAProto/fix-import.js +29 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/community.js +392 -0
- package/lib/Socket/dugong.js +637 -0
- package/lib/Socket/luxu.js +7 -7
- package/lib/Socket/messages-send.js +2 -2
- package/lib/Socket/newsletter.js +18 -19
- package/lib/Socket/registration.js +167 -0
- package/lib/Socket/socket.js +5 -5
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/generics.js +2 -2
- package/lib/index.js +19 -16
- package/package.json +129 -136
- package/LICENSE +0 -21
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
const WAProto = require('../../WAProto').proto;
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
const Utils_1 = require("../Utils");
|
|
4
|
+
const WABinary_1 = require("../WABinary");
|
|
5
|
+
|
|
6
|
+
class kikyy {
|
|
7
|
+
constructor(utils, waUploadToServer, relayMessageFn, config, sock) {
|
|
8
|
+
this.utils = utils;
|
|
9
|
+
this.relayMessage = relayMessageFn;
|
|
10
|
+
this.waUploadToServer = waUploadToServer;
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.sock = sock;
|
|
13
|
+
|
|
14
|
+
this.bail = {
|
|
15
|
+
generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
|
|
16
|
+
generateMessageID: Utils_1.generateMessageID,
|
|
17
|
+
getContentType: (msg) => Object.keys(msg.message || {})[0]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
detectType(content) {
|
|
22
|
+
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
23
|
+
if (content.productMessage) return 'PRODUCT';
|
|
24
|
+
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
25
|
+
if (content.albumMessage) return 'ALBUM';
|
|
26
|
+
if (content.eventMessage) return 'EVENT';
|
|
27
|
+
if (content.pollResultMessage) return 'POLL_RESULT';
|
|
28
|
+
if (content.groupStatusMessage) return 'GROUP_STORY';
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async handlePayment(content, quoted) {
|
|
33
|
+
const data = content.requestPaymentMessage;
|
|
34
|
+
let notes = {};
|
|
35
|
+
|
|
36
|
+
if (data.sticker?.stickerMessage) {
|
|
37
|
+
notes = {
|
|
38
|
+
stickerMessage: {
|
|
39
|
+
...data.sticker.stickerMessage,
|
|
40
|
+
contextInfo: {
|
|
41
|
+
stanzaId: quoted?.key?.id,
|
|
42
|
+
participant: quoted?.key?.participant || content.sender,
|
|
43
|
+
quotedMessage: quoted?.message
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
} else if (data.note) {
|
|
48
|
+
notes = {
|
|
49
|
+
extendedTextMessage: {
|
|
50
|
+
text: data.note,
|
|
51
|
+
contextInfo: {
|
|
52
|
+
stanzaId: quoted?.key?.id,
|
|
53
|
+
participant: quoted?.key?.participant || content.sender,
|
|
54
|
+
quotedMessage: quoted?.message
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
62
|
+
expiryTimestamp: data.expiry || 0,
|
|
63
|
+
amount1000: data.amount || 0,
|
|
64
|
+
currencyCodeIso4217: data.currency || "IDR",
|
|
65
|
+
requestFrom: data.from || "0@s.whatsapp.net",
|
|
66
|
+
noteMessage: notes,
|
|
67
|
+
background: data.background ?? {
|
|
68
|
+
id: "DEFAULT",
|
|
69
|
+
placeholderArgb: 0xFFF0F0F0
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async handleProduct(content, jid, quoted) {
|
|
76
|
+
const {
|
|
77
|
+
title,
|
|
78
|
+
description,
|
|
79
|
+
thumbnail,
|
|
80
|
+
productId,
|
|
81
|
+
retailerId,
|
|
82
|
+
url,
|
|
83
|
+
body = "",
|
|
84
|
+
footer = "",
|
|
85
|
+
buttons = [],
|
|
86
|
+
priceAmount1000 = null,
|
|
87
|
+
currencyCode = "IDR"
|
|
88
|
+
} = content.productMessage;
|
|
89
|
+
|
|
90
|
+
let productImage;
|
|
91
|
+
|
|
92
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
93
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
94
|
+
{ image: thumbnail },
|
|
95
|
+
{ upload: this.waUploadToServer }
|
|
96
|
+
);
|
|
97
|
+
productImage = imageMessage;
|
|
98
|
+
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
99
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
100
|
+
{ image: { url: thumbnail.url }},
|
|
101
|
+
{ upload: this.waUploadToServer }
|
|
102
|
+
);
|
|
103
|
+
productImage = imageMessage;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
viewOnceMessage: {
|
|
108
|
+
message: {
|
|
109
|
+
interactiveMessage: {
|
|
110
|
+
body: { text: body },
|
|
111
|
+
footer: { text: footer },
|
|
112
|
+
header: {
|
|
113
|
+
title,
|
|
114
|
+
hasMediaAttachment: true,
|
|
115
|
+
productMessage: {
|
|
116
|
+
product: {
|
|
117
|
+
productImage,
|
|
118
|
+
productId,
|
|
119
|
+
title,
|
|
120
|
+
description,
|
|
121
|
+
currencyCode,
|
|
122
|
+
priceAmount1000,
|
|
123
|
+
retailerId,
|
|
124
|
+
url,
|
|
125
|
+
productImageCount: 1
|
|
126
|
+
},
|
|
127
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
nativeFlowMessage: { buttons }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async handleInteractive(content, jid, quoted) {
|
|
138
|
+
const {
|
|
139
|
+
title,
|
|
140
|
+
footer,
|
|
141
|
+
thumbnail,
|
|
142
|
+
image,
|
|
143
|
+
video,
|
|
144
|
+
document,
|
|
145
|
+
mimetype,
|
|
146
|
+
fileName,
|
|
147
|
+
jpegThumbnail,
|
|
148
|
+
contextInfo,
|
|
149
|
+
externalAdReply,
|
|
150
|
+
buttons = [],
|
|
151
|
+
nativeFlowMessage,
|
|
152
|
+
header
|
|
153
|
+
} = content.interactiveMessage;
|
|
154
|
+
|
|
155
|
+
let media = null;
|
|
156
|
+
let mediaType = null;
|
|
157
|
+
|
|
158
|
+
if (thumbnail) {
|
|
159
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
160
|
+
{ image: { url: thumbnail } },
|
|
161
|
+
{ upload: this.waUploadToServer }
|
|
162
|
+
);
|
|
163
|
+
mediaType = 'image';
|
|
164
|
+
} else if (image) {
|
|
165
|
+
if (typeof image === 'object' && image.url) {
|
|
166
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
167
|
+
{ image: { url: image.url } },
|
|
168
|
+
{ upload: this.waUploadToServer }
|
|
169
|
+
);
|
|
170
|
+
} else {
|
|
171
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
172
|
+
{ image: image },
|
|
173
|
+
{ upload: this.waUploadToServer }
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
mediaType = 'image';
|
|
177
|
+
} else if (video) {
|
|
178
|
+
if (typeof video === 'object' && video.url) {
|
|
179
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
180
|
+
{ video: { url: video.url } },
|
|
181
|
+
{ upload: this.waUploadToServer }
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
185
|
+
{ video: video },
|
|
186
|
+
{ upload: this.waUploadToServer }
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
mediaType = 'video';
|
|
190
|
+
} else if (document) {
|
|
191
|
+
let documentPayload = {
|
|
192
|
+
document: document
|
|
193
|
+
};
|
|
194
|
+
if (jpegThumbnail) {
|
|
195
|
+
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
196
|
+
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
197
|
+
} else {
|
|
198
|
+
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
203
|
+
documentPayload,
|
|
204
|
+
{ upload: this.waUploadToServer }
|
|
205
|
+
);
|
|
206
|
+
if (fileName) {
|
|
207
|
+
media.documentMessage.fileName = fileName;
|
|
208
|
+
}
|
|
209
|
+
if (mimetype) {
|
|
210
|
+
media.documentMessage.mimetype = mimetype;
|
|
211
|
+
}
|
|
212
|
+
mediaType = 'document';
|
|
213
|
+
}
|
|
214
|
+
let interactiveMessage = {
|
|
215
|
+
body: { text: title || "" },
|
|
216
|
+
footer: { text: footer || "" }
|
|
217
|
+
};
|
|
218
|
+
if (buttons && buttons.length > 0) {
|
|
219
|
+
interactiveMessage.nativeFlowMessage = {
|
|
220
|
+
buttons: buttons
|
|
221
|
+
};
|
|
222
|
+
if (nativeFlowMessage) {
|
|
223
|
+
interactiveMessage.nativeFlowMessage = {
|
|
224
|
+
...interactiveMessage.nativeFlowMessage,
|
|
225
|
+
...nativeFlowMessage
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
} else if (nativeFlowMessage) {
|
|
229
|
+
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (media) {
|
|
233
|
+
interactiveMessage.header = {
|
|
234
|
+
title: header || "",
|
|
235
|
+
hasMediaAttachment: true,
|
|
236
|
+
...media
|
|
237
|
+
};
|
|
238
|
+
} else {
|
|
239
|
+
interactiveMessage.header = {
|
|
240
|
+
title: header || "",
|
|
241
|
+
hasMediaAttachment: false
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
let finalContextInfo = {};
|
|
246
|
+
if (contextInfo) {
|
|
247
|
+
finalContextInfo = {
|
|
248
|
+
mentionedJid: contextInfo.mentionedJid || [],
|
|
249
|
+
forwardingScore: contextInfo.forwardingScore || 0,
|
|
250
|
+
isForwarded: contextInfo.isForwarded || false,
|
|
251
|
+
...contextInfo
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (externalAdReply) {
|
|
256
|
+
finalContextInfo.externalAdReply = {
|
|
257
|
+
title: externalAdReply.title || "",
|
|
258
|
+
body: externalAdReply.body || "",
|
|
259
|
+
mediaType: externalAdReply.mediaType || 1,
|
|
260
|
+
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
261
|
+
mediaUrl: externalAdReply.mediaUrl || "",
|
|
262
|
+
sourceUrl: externalAdReply.sourceUrl || "",
|
|
263
|
+
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
264
|
+
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
265
|
+
...externalAdReply
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (Object.keys(finalContextInfo).length > 0) {
|
|
270
|
+
interactiveMessage.contextInfo = finalContextInfo;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
interactiveMessage: interactiveMessage
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async handleAlbum(content, jid, quoted) {
|
|
278
|
+
const array = content.albumMessage;
|
|
279
|
+
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
280
|
+
messageContextInfo: {
|
|
281
|
+
messageSecret: crypto.randomBytes(32),
|
|
282
|
+
},
|
|
283
|
+
albumMessage: {
|
|
284
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
285
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
286
|
+
},
|
|
287
|
+
}, {
|
|
288
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
289
|
+
quoted,
|
|
290
|
+
upload: this.waUploadToServer
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
await this.relayMessage(jid, album.message, {
|
|
294
|
+
messageId: album.key.id,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
for (let content of array) {
|
|
298
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
299
|
+
upload: this.waUploadToServer,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
img.message.messageContextInfo = {
|
|
303
|
+
messageSecret: crypto.randomBytes(32),
|
|
304
|
+
messageAssociation: {
|
|
305
|
+
associationType: 1,
|
|
306
|
+
parentMessageKey: album.key,
|
|
307
|
+
},
|
|
308
|
+
participant: "0@s.whatsapp.net",
|
|
309
|
+
remoteJid: "status@broadcast",
|
|
310
|
+
forwardingScore: 99999,
|
|
311
|
+
isForwarded: true,
|
|
312
|
+
mentionedJid: [jid],
|
|
313
|
+
starred: true,
|
|
314
|
+
labels: ["Y", "Important"],
|
|
315
|
+
isHighlighted: true,
|
|
316
|
+
businessMessageForwardInfo: {
|
|
317
|
+
businessOwnerJid: jid,
|
|
318
|
+
},
|
|
319
|
+
dataSharingContext: {
|
|
320
|
+
showMmDisclosure: true,
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
img.message.forwardedNewsletterMessageInfo = {
|
|
325
|
+
newsletterJid: "0@newsletter",
|
|
326
|
+
serverMessageId: 1,
|
|
327
|
+
newsletterName: `WhatsApp`,
|
|
328
|
+
contentType: 1,
|
|
329
|
+
timestamp: new Date().toISOString(),
|
|
330
|
+
senderName: "kikyy dugonggg",
|
|
331
|
+
content: "Text Message",
|
|
332
|
+
priority: "high",
|
|
333
|
+
status: "sent",
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
img.message.disappearingMode = {
|
|
337
|
+
initiator: 3,
|
|
338
|
+
trigger: 4,
|
|
339
|
+
initiatorDeviceJid: jid,
|
|
340
|
+
initiatedByExternalService: true,
|
|
341
|
+
initiatedByUserDevice: true,
|
|
342
|
+
initiatedBySystem: true,
|
|
343
|
+
initiatedByServer: true,
|
|
344
|
+
initiatedByAdmin: true,
|
|
345
|
+
initiatedByUser: true,
|
|
346
|
+
initiatedByApp: true,
|
|
347
|
+
initiatedByBot: true,
|
|
348
|
+
initiatedByMe: true,
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
await this.relayMessage(jid, img.message, {
|
|
352
|
+
messageId: img.key.id,
|
|
353
|
+
quoted: {
|
|
354
|
+
key: {
|
|
355
|
+
remoteJid: album.key.remoteJid,
|
|
356
|
+
id: album.key.id,
|
|
357
|
+
fromMe: true,
|
|
358
|
+
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
359
|
+
},
|
|
360
|
+
message: album.message,
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return album;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
async handleEvent(content, jid, quoted) {
|
|
368
|
+
const eventData = content.eventMessage;
|
|
369
|
+
|
|
370
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
371
|
+
viewOnceMessage: {
|
|
372
|
+
message: {
|
|
373
|
+
messageContextInfo: {
|
|
374
|
+
deviceListMetadata: {},
|
|
375
|
+
deviceListMetadataVersion: 2,
|
|
376
|
+
messageSecret: crypto.randomBytes(32),
|
|
377
|
+
supportPayload: JSON.stringify({
|
|
378
|
+
version: 2,
|
|
379
|
+
is_ai_message: true,
|
|
380
|
+
should_show_system_message: true,
|
|
381
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
382
|
+
})
|
|
383
|
+
},
|
|
384
|
+
eventMessage: {
|
|
385
|
+
contextInfo: {
|
|
386
|
+
mentionedJid: [jid],
|
|
387
|
+
participant: jid,
|
|
388
|
+
remoteJid: "status@broadcast",
|
|
389
|
+
forwardedNewsletterMessageInfo: {
|
|
390
|
+
newsletterName: "shenvn.",
|
|
391
|
+
newsletterJid: "120363430179804706@newsletter",
|
|
392
|
+
serverMessageId: 1
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
isCanceled: eventData.isCanceled || false,
|
|
396
|
+
name: eventData.name,
|
|
397
|
+
description: eventData.description,
|
|
398
|
+
location: eventData.location || {
|
|
399
|
+
degreesLatitude: 0,
|
|
400
|
+
degreesLongitude: 0,
|
|
401
|
+
name: "Location"
|
|
402
|
+
},
|
|
403
|
+
joinLink: eventData.joinLink || '',
|
|
404
|
+
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
405
|
+
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
406
|
+
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}, { quoted });
|
|
411
|
+
|
|
412
|
+
await this.relayMessage(jid, msg.message, {
|
|
413
|
+
messageId: msg.key.id
|
|
414
|
+
});
|
|
415
|
+
return msg;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async handlePollResult(content, jid, quoted) {
|
|
419
|
+
const pollData = content.pollResultMessage;
|
|
420
|
+
|
|
421
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
422
|
+
pollResultSnapshotMessage: {
|
|
423
|
+
name: pollData.name,
|
|
424
|
+
pollVotes: pollData.pollVotes.map(vote => ({
|
|
425
|
+
optionName: vote.optionName,
|
|
426
|
+
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
427
|
+
? vote.optionVoteCount.toString()
|
|
428
|
+
: vote.optionVoteCount
|
|
429
|
+
}))
|
|
430
|
+
}
|
|
431
|
+
}, {
|
|
432
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
433
|
+
quoted
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
await this.relayMessage(jid, msg.message, {
|
|
437
|
+
messageId: msg.key.id
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
return msg;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async handleGroupStory(content, jid, quoted) {
|
|
444
|
+
const storyData = content.groupStatusMessage;
|
|
445
|
+
let waMsgContent;
|
|
446
|
+
|
|
447
|
+
if (storyData.message) {
|
|
448
|
+
waMsgContent = storyData;
|
|
449
|
+
} else {
|
|
450
|
+
if (typeof this.bail?.generateWAMessageContent === "function") {
|
|
451
|
+
waMsgContent = await this.bail.generateWAMessageContent(storyData, {
|
|
452
|
+
upload: this.waUploadToServer
|
|
453
|
+
});
|
|
454
|
+
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
455
|
+
waMsgContent = await this.utils.generateWAMessageContent(storyData, {
|
|
456
|
+
upload: this.waUploadToServer
|
|
457
|
+
});
|
|
458
|
+
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
459
|
+
waMsgContent = await this.utils.prepareMessageContent(storyData, {
|
|
460
|
+
upload: this.waUploadToServer
|
|
461
|
+
});
|
|
462
|
+
} else {
|
|
463
|
+
waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
|
|
464
|
+
upload: this.waUploadToServer
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
let msg = {
|
|
470
|
+
message: {
|
|
471
|
+
groupStatusMessageV2: {
|
|
472
|
+
message: waMsgContent.message || waMsgContent
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
return await this.relayMessage(jid, msg.message, {
|
|
478
|
+
messageId: this.bail.generateMessageID()
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
async sendStatusWhatsApp(content, jids = []) {
|
|
483
|
+
const userJid = WABinary_1.jidNormalizedUser(this.sock.authState.creds.me.id);
|
|
484
|
+
let allUsers = new Set();
|
|
485
|
+
allUsers.add(userJid);
|
|
486
|
+
|
|
487
|
+
for (const id of jids) {
|
|
488
|
+
const isGroup = WABinary_1.isJidGroup(id);
|
|
489
|
+
const isPrivate = WABinary_1.isJidUser(id);
|
|
490
|
+
|
|
491
|
+
if (isGroup) {
|
|
492
|
+
try {
|
|
493
|
+
const metadata = await this.sock.groupMetadata(id);
|
|
494
|
+
const participants = metadata.participants.map(p => WABinary_1.jidNormalizedUser(p.id));
|
|
495
|
+
participants.forEach(jid => allUsers.add(jid));
|
|
496
|
+
} catch (error) {
|
|
497
|
+
this.config.logger.error(`Error getting metadata for group ${id}: ${error}`);
|
|
498
|
+
}
|
|
499
|
+
} else if (isPrivate) {
|
|
500
|
+
allUsers.add(WABinary_1.jidNormalizedUser(id));
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const uniqueUsers = Array.from(allUsers);
|
|
505
|
+
const getRandomHexColor = () => "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
|
|
506
|
+
|
|
507
|
+
const isMedia = content.image || content.video || content.audio;
|
|
508
|
+
const isAudio = !!content.audio;
|
|
509
|
+
|
|
510
|
+
const messageContent = { ...content };
|
|
511
|
+
|
|
512
|
+
if (isMedia && !isAudio) {
|
|
513
|
+
if (messageContent.text) {
|
|
514
|
+
messageContent.caption = messageContent.text;
|
|
515
|
+
delete messageContent.text;
|
|
516
|
+
}
|
|
517
|
+
delete messageContent.ptt;
|
|
518
|
+
delete messageContent.font;
|
|
519
|
+
delete messageContent.backgroundColor;
|
|
520
|
+
delete messageContent.textColor;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (isAudio) {
|
|
524
|
+
delete messageContent.text;
|
|
525
|
+
delete messageContent.caption;
|
|
526
|
+
delete messageContent.font;
|
|
527
|
+
delete messageContent.textColor;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const font = !isMedia ? (content.font || Math.floor(Math.random() * 9)) : undefined;
|
|
531
|
+
const textColor = !isMedia ? (content.textColor || getRandomHexColor()) : undefined;
|
|
532
|
+
const backgroundColor = (!isMedia || isAudio) ? (content.backgroundColor || getRandomHexColor()) : undefined;
|
|
533
|
+
const ptt = isAudio ? (typeof content.ptt === 'boolean' ? content.ptt : true) : undefined;
|
|
534
|
+
|
|
535
|
+
let msg;
|
|
536
|
+
let mediaHandle;
|
|
537
|
+
|
|
538
|
+
try {
|
|
539
|
+
const link_preview_1 = require("../Utils/link-preview");
|
|
540
|
+
|
|
541
|
+
msg = await Utils_1.generateWAMessage(WABinary_1.STORIES_JID, messageContent, {
|
|
542
|
+
logger: this.config.logger,
|
|
543
|
+
userJid,
|
|
544
|
+
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
545
|
+
thumbnailWidth: this.config.linkPreviewImageThumbnailWidth,
|
|
546
|
+
fetchOpts: { timeout: 3000, ...this.config.options || {} },
|
|
547
|
+
logger: this.config.logger,
|
|
548
|
+
uploadImage: this.config.generateHighQualityLinkPreview ? this.waUploadToServer : undefined
|
|
549
|
+
}),
|
|
550
|
+
upload: async (encFilePath, opts) => {
|
|
551
|
+
const up = await this.waUploadToServer(encFilePath, { ...opts });
|
|
552
|
+
mediaHandle = up.handle;
|
|
553
|
+
return up;
|
|
554
|
+
},
|
|
555
|
+
mediaCache: this.config.mediaCache,
|
|
556
|
+
options: this.config.options,
|
|
557
|
+
font,
|
|
558
|
+
textColor,
|
|
559
|
+
backgroundColor,
|
|
560
|
+
ptt
|
|
561
|
+
});
|
|
562
|
+
} catch (error) {
|
|
563
|
+
this.config.logger.error(`Error generating message: ${error}`);
|
|
564
|
+
throw error;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
await this.relayMessage(WABinary_1.STORIES_JID, msg.message, {
|
|
568
|
+
messageId: msg.key.id,
|
|
569
|
+
statusJidList: uniqueUsers,
|
|
570
|
+
additionalNodes: [
|
|
571
|
+
{
|
|
572
|
+
tag: 'meta',
|
|
573
|
+
attrs: {},
|
|
574
|
+
content: [
|
|
575
|
+
{
|
|
576
|
+
tag: 'mentioned_users',
|
|
577
|
+
attrs: {},
|
|
578
|
+
content: jids.map(jid => ({
|
|
579
|
+
tag: 'to',
|
|
580
|
+
attrs: { jid: WABinary_1.jidNormalizedUser(jid) }
|
|
581
|
+
}))
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
]
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
for (const id of jids) {
|
|
589
|
+
try {
|
|
590
|
+
const normalizedId = WABinary_1.jidNormalizedUser(id);
|
|
591
|
+
const isPrivate = WABinary_1.isJidUser(normalizedId);
|
|
592
|
+
const type = isPrivate ? 'statusMentionMessage' : 'groupStatusMentionMessage';
|
|
593
|
+
|
|
594
|
+
const protocolMessage = {
|
|
595
|
+
[type]: {
|
|
596
|
+
message: {
|
|
597
|
+
protocolMessage: {
|
|
598
|
+
key: msg.key,
|
|
599
|
+
type: 25
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
messageContextInfo: {
|
|
604
|
+
messageSecret: crypto.randomBytes(32)
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
const statusMsg = await Utils_1.generateWAMessageFromContent(
|
|
609
|
+
normalizedId,
|
|
610
|
+
protocolMessage,
|
|
611
|
+
{}
|
|
612
|
+
);
|
|
613
|
+
|
|
614
|
+
await this.relayMessage(
|
|
615
|
+
normalizedId,
|
|
616
|
+
statusMsg.message,
|
|
617
|
+
{
|
|
618
|
+
additionalNodes: [{
|
|
619
|
+
tag: 'meta',
|
|
620
|
+
attrs: isPrivate ?
|
|
621
|
+
{ is_status_mention: 'true' } :
|
|
622
|
+
{ is_group_status_mention: 'true' }
|
|
623
|
+
}]
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
await Utils_1.delay(2000);
|
|
628
|
+
} catch (error) {
|
|
629
|
+
this.config.logger.error(`Error sending to ${id}: ${error}`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return msg;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
module.exports = kikyy;
|
package/lib/Socket/luxu.js
CHANGED
|
@@ -179,7 +179,7 @@ export default class imup {
|
|
|
179
179
|
newsletterName: `WhatsApp`,
|
|
180
180
|
contentType: 1,
|
|
181
181
|
timestamp: new Date().toISOString(),
|
|
182
|
-
senderName: "
|
|
182
|
+
senderName: "badzz-xyz",
|
|
183
183
|
contentType: "UPDATE_CARD",
|
|
184
184
|
priority: "high",
|
|
185
185
|
status: "sent",
|
|
@@ -239,8 +239,8 @@ export default class imup {
|
|
|
239
239
|
participant: jid,
|
|
240
240
|
remoteJid: "status@broadcast",
|
|
241
241
|
forwardedNewsletterMessageInfo: {
|
|
242
|
-
newsletterName: "
|
|
243
|
-
newsletterJid: "
|
|
242
|
+
newsletterName: "D | 7eppeli-Exloration",
|
|
243
|
+
newsletterJid: "120363421563597486@newsletter",
|
|
244
244
|
serverMessageId: 1
|
|
245
245
|
}
|
|
246
246
|
},
|
|
@@ -282,7 +282,7 @@ export default class imup {
|
|
|
282
282
|
isForwarded: true,
|
|
283
283
|
forwardingScore: 1,
|
|
284
284
|
forwardedNewsletterMessageInfo: {
|
|
285
|
-
newsletterName: pollData.newsletter.newsletterName || "
|
|
285
|
+
newsletterName: pollData.newsletter.newsletterName || "120363399602691477@newsletter",
|
|
286
286
|
newsletterJid: pollData.newsletter.newsletterJid || "Newsletter",
|
|
287
287
|
serverMessageId: 1000,
|
|
288
288
|
contentType: "UPDATE"
|
|
@@ -306,7 +306,7 @@ export default class imup {
|
|
|
306
306
|
|
|
307
307
|
const Haha = await this.utils.generateWAMessageFromContent(jid, {
|
|
308
308
|
orderMessage: {
|
|
309
|
-
orderId: "
|
|
309
|
+
orderId: "7EPPELI25022008",
|
|
310
310
|
thumbnail: orderData.thumbnail || null,
|
|
311
311
|
itemCount: orderData.itemCount || 0,
|
|
312
312
|
status: "ACCEPTED",
|
|
@@ -314,7 +314,7 @@ export default class imup {
|
|
|
314
314
|
message: orderData.message,
|
|
315
315
|
orderTitle: orderData.orderTitle,
|
|
316
316
|
sellerJid: "0@whatsapp.net",
|
|
317
|
-
token: "
|
|
317
|
+
token: "7EPPELI_EXAMPLE_TOKEN",
|
|
318
318
|
totalAmount1000: orderData.totalAmount1000 || 0,
|
|
319
319
|
totalCurrencyCode: orderData.totalCurrencyCode || "IDR",
|
|
320
320
|
messageVersion: 2
|
|
@@ -384,4 +384,4 @@ export default class imup {
|
|
|
384
384
|
]
|
|
385
385
|
})
|
|
386
386
|
}
|
|
387
|
-
}
|
|
387
|
+
}
|
|
@@ -433,10 +433,10 @@ export const makeMessagesSocket = (config) => {
|
|
|
433
433
|
message,
|
|
434
434
|
{
|
|
435
435
|
messageId: msgId,
|
|
436
|
-
|
|
436
|
+
participant = false,
|
|
437
437
|
additionalAttributes,
|
|
438
438
|
additionalNodes,
|
|
439
|
-
|
|
439
|
+
useUserDevicesCache,
|
|
440
440
|
useCachedGroupMetadata,
|
|
441
441
|
statusJidList
|
|
442
442
|
}
|