alipclutch-baileys 8.5.3 → 8.5.4
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/WAProto/index.js +77698 -117050
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +7 -16
- package/lib/Defaults/index.js +119 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +58 -59
- package/lib/Socket/chats.d.ts +230 -45
- package/lib/Socket/chats.js +238 -139
- package/lib/Socket/groups.d.ts +32 -41
- package/lib/Socket/groups.js +23 -38
- package/lib/Socket/index.d.ts +64 -63
- package/lib/Socket/index.js +3 -2
- package/lib/Socket/messages-recv.js +65 -9
- package/lib/Socket/messages-send.d.ts +47 -49
- package/lib/Socket/messages-send.js +395 -543
- package/lib/Socket/newsletter.d.ts +37 -39
- package/lib/Socket/newsletter.js +123 -88
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/setup.d.ts +253 -0
- package/lib/Socket/setup.js +4 -5
- package/lib/Socket/socket.d.ts +43 -270
- package/lib/Socket/socket.js +38 -62
- package/lib/Socket/usync.d.ts +3 -3
- package/lib/Store/index.d.ts +2 -1
- package/lib/Store/index.js +3 -1
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +24 -24
- package/lib/Store/make-in-memory-store.js +14 -26
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +7 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -14
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +2 -44
- package/lib/Types/GroupMetadata.d.ts +2 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +21 -148
- package/lib/Types/Message.js +2 -0
- package/lib/Types/Newsletter.d.ts +97 -73
- package/lib/Types/Newsletter.js +38 -18
- package/lib/Types/Socket.d.ts +9 -17
- package/lib/Types/index.d.ts +1 -8
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -6
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +16 -15
- package/lib/Utils/chat-utils.js +35 -36
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +29 -71
- package/lib/Utils/decode-wa-message.d.ts +6 -22
- package/lib/Utils/decode-wa-message.js +56 -65
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +7 -11
- package/lib/Utils/generics.d.ts +20 -17
- package/lib/Utils/generics.js +75 -95
- package/lib/Utils/history.d.ts +0 -4
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +1 -34
- package/lib/Utils/logger.d.ts +3 -10
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +24 -28
- package/lib/Utils/messages-media.js +111 -272
- package/lib/Utils/messages.d.ts +10 -13
- package/lib/Utils/messages.js +51 -336
- package/lib/Utils/noise-handler.d.ts +12 -10
- package/lib/Utils/noise-handler.js +23 -18
- package/lib/Utils/process-message.d.ts +4 -5
- package/lib/Utils/process-message.js +25 -108
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +26 -26
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +6 -51
- package/lib/Utils/validate-connection.d.ts +4 -3
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +13 -26
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +152 -137
- package/lib/WABinary/generic-utils.d.ts +4 -1
- package/lib/WABinary/generic-utils.js +125 -37
- package/lib/WABinary/jid-utils.d.ts +5 -11
- package/lib/WABinary/jid-utils.js +5 -28
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -27
- package/package.json +31 -18
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -4775
- package/WAProto/index.d.ts +0 -55057
- package/WAProto/index.ts.ts +0 -53473
- package/lib/Socket/setup.ts +0 -623
- package/lib/WABinary/jid-utils.js.bak +0 -83
package/lib/Socket/setup.ts
DELETED
|
@@ -1,623 +0,0 @@
|
|
|
1
|
-
/* modified by alip */
|
|
2
|
-
const WAProto = require('../../WAProto').proto;
|
|
3
|
-
const crypto = require('crypto');
|
|
4
|
-
const Utils_1 = require("../Utils");
|
|
5
|
-
|
|
6
|
-
class yaoii {
|
|
7
|
-
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
8
|
-
this.utils = utils;
|
|
9
|
-
this.relayMessage = relayMessageFn
|
|
10
|
-
this.waUploadToServer = waUploadToServer;
|
|
11
|
-
this.bail = {
|
|
12
|
-
generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
|
|
13
|
-
generateMessageID: Utils_1.generateMessageID,
|
|
14
|
-
getContentType: (msg) => Object.keys(msg.message || {})[0]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
detectType(content) {
|
|
19
|
-
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
20
|
-
if (content.productMessage) return 'PRODUCT';
|
|
21
|
-
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
22
|
-
if (content.albumMessage) return 'ALBUM';
|
|
23
|
-
if (content.eventMessage) return 'EVENT';
|
|
24
|
-
if (content.pollResultMessage) return 'POLL_RESULT';
|
|
25
|
-
if (content.listMessage) return 'LIST';
|
|
26
|
-
if (content.groupStatusMessage) return 'GROUP_STORY';
|
|
27
|
-
if (content.groupStoryMessage) return 'GROUP_STORY';
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async handlePayment(content, quoted) {
|
|
32
|
-
const data = content.requestPaymentMessage;
|
|
33
|
-
let notes = {};
|
|
34
|
-
|
|
35
|
-
if (data.sticker?.stickerMessage) {
|
|
36
|
-
notes = {
|
|
37
|
-
stickerMessage: {
|
|
38
|
-
...data.sticker.stickerMessage,
|
|
39
|
-
contextInfo: {
|
|
40
|
-
stanzaId: quoted?.key?.id,
|
|
41
|
-
participant: quoted?.key?.participant || content.sender,
|
|
42
|
-
quotedMessage: quoted?.message
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
} else if (data.note) {
|
|
47
|
-
notes = {
|
|
48
|
-
extendedTextMessage: {
|
|
49
|
-
text: data.note,
|
|
50
|
-
contextInfo: {
|
|
51
|
-
stanzaId: quoted?.key?.id,
|
|
52
|
-
participant: quoted?.key?.participant || content.sender,
|
|
53
|
-
quotedMessage: quoted?.message
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
61
|
-
expiryTimestamp: data.expiry || 0,
|
|
62
|
-
amount1000: data.amount || 0,
|
|
63
|
-
currencyCodeIso4217: data.currency || "IDR",
|
|
64
|
-
requestFrom: data.from || "0@s.whatsapp.net",
|
|
65
|
-
noteMessage: notes,
|
|
66
|
-
background: data.background ?? {
|
|
67
|
-
id: "DEFAULT",
|
|
68
|
-
placeholderArgb: 0xFFF0F0F0
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async handleProduct(content, jid, quoted) {
|
|
75
|
-
const {
|
|
76
|
-
title,
|
|
77
|
-
description,
|
|
78
|
-
thumbnail,
|
|
79
|
-
productId,
|
|
80
|
-
retailerId,
|
|
81
|
-
url,
|
|
82
|
-
body = "",
|
|
83
|
-
footer = "",
|
|
84
|
-
buttons = [],
|
|
85
|
-
priceAmount1000 = null,
|
|
86
|
-
currencyCode = "IDR"
|
|
87
|
-
} = content.productMessage;
|
|
88
|
-
|
|
89
|
-
let productImage;
|
|
90
|
-
|
|
91
|
-
if (Buffer.isBuffer(thumbnail)) {
|
|
92
|
-
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
93
|
-
{ image: thumbnail },
|
|
94
|
-
{ upload: this.waUploadToServer }
|
|
95
|
-
);
|
|
96
|
-
productImage = imageMessage;
|
|
97
|
-
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
98
|
-
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
99
|
-
{ image: { url: thumbnail.url }},
|
|
100
|
-
{ upload: this.waUploadToServer }
|
|
101
|
-
);
|
|
102
|
-
productImage = imageMessage;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
viewOnceMessage: {
|
|
107
|
-
message: {
|
|
108
|
-
interactiveMessage: {
|
|
109
|
-
body: { text: body },
|
|
110
|
-
footer: { text: footer },
|
|
111
|
-
header: {
|
|
112
|
-
title,
|
|
113
|
-
hasMediaAttachment: true,
|
|
114
|
-
productMessage: {
|
|
115
|
-
product: {
|
|
116
|
-
productImage,
|
|
117
|
-
productId,
|
|
118
|
-
title,
|
|
119
|
-
description,
|
|
120
|
-
currencyCode,
|
|
121
|
-
priceAmount1000,
|
|
122
|
-
retailerId,
|
|
123
|
-
url,
|
|
124
|
-
productImageCount: 1
|
|
125
|
-
},
|
|
126
|
-
businessOwnerJid: "0@s.whatsapp.net"
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
nativeFlowMessage: { buttons }
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async handleInteractive(content, jid, quoted) {
|
|
137
|
-
const {
|
|
138
|
-
title,
|
|
139
|
-
footer,
|
|
140
|
-
thumbnail,
|
|
141
|
-
image,
|
|
142
|
-
video,
|
|
143
|
-
document,
|
|
144
|
-
mimetype,
|
|
145
|
-
fileName,
|
|
146
|
-
jpegThumbnail,
|
|
147
|
-
contextInfo,
|
|
148
|
-
externalAdReply,
|
|
149
|
-
buttons = [],
|
|
150
|
-
nativeFlowMessage,
|
|
151
|
-
header
|
|
152
|
-
} = content.interactiveMessage;
|
|
153
|
-
|
|
154
|
-
let media = null;
|
|
155
|
-
let mediaType = null;
|
|
156
|
-
|
|
157
|
-
const getMediaPayload = (mediaData, type) => {
|
|
158
|
-
if (typeof mediaData === 'object' && mediaData.url) {
|
|
159
|
-
return { [type]: { url: mediaData.url } };
|
|
160
|
-
}
|
|
161
|
-
return { [type]: mediaData };
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
if (thumbnail) {
|
|
165
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
166
|
-
getMediaPayload(thumbnail, 'image'),
|
|
167
|
-
{ upload: this.waUploadToServer }
|
|
168
|
-
);
|
|
169
|
-
mediaType = 'image';
|
|
170
|
-
} else if (image) {
|
|
171
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
172
|
-
getMediaPayload(image, 'image'),
|
|
173
|
-
{ upload: this.waUploadToServer }
|
|
174
|
-
);
|
|
175
|
-
mediaType = 'image';
|
|
176
|
-
} else if (video) {
|
|
177
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
178
|
-
getMediaPayload(video, 'video'),
|
|
179
|
-
{ upload: this.waUploadToServer }
|
|
180
|
-
);
|
|
181
|
-
mediaType = 'video';
|
|
182
|
-
} else if (document) {
|
|
183
|
-
let documentPayload = getMediaPayload(document, 'document');
|
|
184
|
-
|
|
185
|
-
if (jpegThumbnail) {
|
|
186
|
-
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
190
|
-
documentPayload,
|
|
191
|
-
{ upload: this.waUploadToServer }
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
if (fileName) {
|
|
195
|
-
media.documentMessage.fileName = fileName;
|
|
196
|
-
}
|
|
197
|
-
if (mimetype) {
|
|
198
|
-
media.documentMessage.mimetype = mimetype;
|
|
199
|
-
}
|
|
200
|
-
mediaType = 'document';
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
let interactiveMessage = {
|
|
204
|
-
body: { text: title || "" },
|
|
205
|
-
footer: { text: footer || "" }
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
if (buttons && buttons.length > 0) {
|
|
209
|
-
interactiveMessage.nativeFlowMessage = {
|
|
210
|
-
buttons: buttons
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
if (nativeFlowMessage) {
|
|
214
|
-
interactiveMessage.nativeFlowMessage = {
|
|
215
|
-
...interactiveMessage.nativeFlowMessage,
|
|
216
|
-
...nativeFlowMessage
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
} else if (nativeFlowMessage) {
|
|
220
|
-
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (media) {
|
|
224
|
-
interactiveMessage.header = {
|
|
225
|
-
title: header || "",
|
|
226
|
-
hasMediaAttachment: true,
|
|
227
|
-
...media
|
|
228
|
-
};
|
|
229
|
-
} else {
|
|
230
|
-
interactiveMessage.header = {
|
|
231
|
-
title: header || "",
|
|
232
|
-
hasMediaAttachment: false
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
let finalContextInfo = {};
|
|
237
|
-
|
|
238
|
-
const inputContextInfo = contextInfo || {};
|
|
239
|
-
if (quoted) {
|
|
240
|
-
inputContextInfo.stanzaId = quoted.key.id;
|
|
241
|
-
inputContextInfo.participant = quoted.key.participant || quoted.key.remoteJid;
|
|
242
|
-
inputContextInfo.quotedMessage = quoted.message;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (Object.keys(inputContextInfo).length > 0) {
|
|
246
|
-
finalContextInfo = {
|
|
247
|
-
mentionedJid: inputContextInfo.mentionedJid || [],
|
|
248
|
-
forwardingScore: inputContextInfo.forwardingScore || 0,
|
|
249
|
-
isForwarded: inputContextInfo.isForwarded || false,
|
|
250
|
-
...inputContextInfo
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (externalAdReply) {
|
|
255
|
-
finalContextInfo.externalAdReply = {
|
|
256
|
-
title: externalAdReply.title || "",
|
|
257
|
-
body: externalAdReply.body || "",
|
|
258
|
-
mediaType: externalAdReply.mediaType || 1,
|
|
259
|
-
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
260
|
-
mediaUrl: externalAdReply.mediaUrl || "",
|
|
261
|
-
sourceUrl: externalAdReply.sourceUrl || "",
|
|
262
|
-
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
263
|
-
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
264
|
-
...externalAdReply
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (Object.keys(finalContextInfo).length > 0) {
|
|
269
|
-
interactiveMessage.contextInfo = finalContextInfo;
|
|
270
|
-
}
|
|
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: "Alip Clutch",
|
|
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: "alip clutch.",
|
|
391
|
-
newsletterJid: "120363401467939056@newsletter",
|
|
392
|
-
serverMessageId: 1
|
|
393
|
-
},
|
|
394
|
-
...(quoted ? {
|
|
395
|
-
stanzaId: quoted.key.id,
|
|
396
|
-
participant: quoted.key.participant || quoted.key.remoteJid,
|
|
397
|
-
quotedMessage: quoted.message
|
|
398
|
-
} : {})
|
|
399
|
-
},
|
|
400
|
-
isCanceled: eventData.isCanceled || false,
|
|
401
|
-
name: eventData.name,
|
|
402
|
-
description: eventData.description,
|
|
403
|
-
location: eventData.location || {
|
|
404
|
-
degreesLatitude: 0,
|
|
405
|
-
degreesLongitude: 0,
|
|
406
|
-
name: "Location"
|
|
407
|
-
},
|
|
408
|
-
joinLink: eventData.joinLink || '',
|
|
409
|
-
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
410
|
-
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
411
|
-
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}, { quoted });
|
|
416
|
-
|
|
417
|
-
await this.relayMessage(jid, msg.message, {
|
|
418
|
-
messageId: msg.key.id
|
|
419
|
-
});
|
|
420
|
-
return msg;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
async handlePollResult(content, jid, quoted) {
|
|
424
|
-
const pollData = content.pollResultMessage;
|
|
425
|
-
|
|
426
|
-
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
427
|
-
pollResultSnapshotMessage: {
|
|
428
|
-
name: pollData.name,
|
|
429
|
-
pollVotes: pollData.pollVotes.map(vote => ({
|
|
430
|
-
optionName: vote.optionName,
|
|
431
|
-
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
432
|
-
? vote.optionVoteCount.toString()
|
|
433
|
-
: vote.optionVoteCount
|
|
434
|
-
}))
|
|
435
|
-
}
|
|
436
|
-
}, {
|
|
437
|
-
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
438
|
-
quoted
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
await this.relayMessage(jid, msg.message, {
|
|
442
|
-
messageId: msg.key.id
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
return msg;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
async handleList(content, jid, quoted) {
|
|
449
|
-
const data = content.listMessage;
|
|
450
|
-
|
|
451
|
-
const listMessagePayload = WAProto.Message.ListMessage.fromObject({
|
|
452
|
-
title: data.title || '',
|
|
453
|
-
description: data.description || '',
|
|
454
|
-
buttonText: data.buttonText || 'Pilih',
|
|
455
|
-
sections: data.sections.map(section => ({
|
|
456
|
-
title: section.title,
|
|
457
|
-
rows: section.rows.map(row => ({
|
|
458
|
-
rowId: row.rowId || this.utils.generateMessageID(),
|
|
459
|
-
title: row.title,
|
|
460
|
-
description: row.description || ''
|
|
461
|
-
}))
|
|
462
|
-
})),
|
|
463
|
-
listType: data.listType || 1,
|
|
464
|
-
footerText: data.footer || ''
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
const listContent = {
|
|
468
|
-
listMessage: listMessagePayload
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
const contextInfo = data.contextInfo || {};
|
|
472
|
-
|
|
473
|
-
if (quoted) {
|
|
474
|
-
contextInfo.stanzaId = quoted.key.id;
|
|
475
|
-
contextInfo.participant = quoted.key.participant || quoted.key.remoteJid;
|
|
476
|
-
contextInfo.quotedMessage = quoted.message;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (Object.keys(contextInfo).length > 0) {
|
|
480
|
-
listContent.listMessage.contextInfo = contextInfo;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
const msg = await this.utils.generateWAMessageFromContent(
|
|
484
|
-
jid,
|
|
485
|
-
listContent,
|
|
486
|
-
{ quoted }
|
|
487
|
-
);
|
|
488
|
-
|
|
489
|
-
await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
|
|
490
|
-
|
|
491
|
-
return msg;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
async handleGroupStory(content, jid, quoted) {
|
|
495
|
-
if (content.groupStatusMessage) {
|
|
496
|
-
const storyData = content.groupStatusMessage;
|
|
497
|
-
let waMsgContent;
|
|
498
|
-
|
|
499
|
-
if (storyData.message) {
|
|
500
|
-
waMsgContent = storyData;
|
|
501
|
-
} else {
|
|
502
|
-
if (typeof this.bail?.generateWAMessageContent === "function") {
|
|
503
|
-
waMsgContent = await this.bail.generateWAMessageContent(storyData, {
|
|
504
|
-
upload: this.waUploadToServer
|
|
505
|
-
});
|
|
506
|
-
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
507
|
-
waMsgContent = await this.utils.generateWAMessageContent(storyData, {
|
|
508
|
-
upload: this.waUploadToServer
|
|
509
|
-
});
|
|
510
|
-
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
511
|
-
waMsgContent = await this.utils.prepareMessageContent(storyData, {
|
|
512
|
-
upload: this.waUploadToServer
|
|
513
|
-
});
|
|
514
|
-
} else {
|
|
515
|
-
waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
|
|
516
|
-
upload: this.waUploadToServer
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
let msg = {
|
|
522
|
-
message: {
|
|
523
|
-
groupStatusMessageV2: {
|
|
524
|
-
message: waMsgContent.message || waMsgContent
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
return await this.relayMessage(jid, msg.message, {
|
|
530
|
-
messageId: this.bail.generateMessageID()
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
} else if (content.groupStoryMessage) {
|
|
534
|
-
const { groupStoryMessage } = content;
|
|
535
|
-
|
|
536
|
-
if (!this.utils.isJidGroup(jid)) {
|
|
537
|
-
throw new Error("Group Story messages must be sent to a group JID.");
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
let mediaContent = {};
|
|
541
|
-
|
|
542
|
-
if (groupStoryMessage.image || groupStoryMessage.video) {
|
|
543
|
-
const mediaData = groupStoryMessage.image || groupStoryMessage.video;
|
|
544
|
-
const mediaType = groupStoryMessage.image ? 'image' : 'video';
|
|
545
|
-
|
|
546
|
-
let stream;
|
|
547
|
-
if (Buffer.isBuffer(mediaData)) {
|
|
548
|
-
stream = mediaData;
|
|
549
|
-
} else if (typeof mediaData === 'object' && mediaData.url) {
|
|
550
|
-
throw new Error("Group Story media from URL is not supported in this simplified handler. Use Buffer or fetch it first.");
|
|
551
|
-
} else {
|
|
552
|
-
stream = Buffer.from(mediaData, 'base64');
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const upload = await this.waUploadToServer(stream, {
|
|
556
|
-
mediaType: mediaType,
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
mediaContent = {
|
|
560
|
-
[mediaType + 'Message']: {
|
|
561
|
-
url: upload.url,
|
|
562
|
-
mimetype: mediaType === 'image' ? 'image/jpeg' : 'video/mp4',
|
|
563
|
-
caption: groupStoryMessage.caption,
|
|
564
|
-
fileSha256: upload.fileSha256,
|
|
565
|
-
fileEncSha256: upload.fileEncSha256,
|
|
566
|
-
mediaKey: upload.mediaKey,
|
|
567
|
-
fileLength: upload.fileLength,
|
|
568
|
-
directPath: upload.directPath,
|
|
569
|
-
mediaKeyTimestamp: this.utils.unixTimestampSeconds(),
|
|
570
|
-
jpegThumbnail: groupStoryMessage.jpegThumbnail,
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
} else if (groupStoryMessage.caption) {
|
|
574
|
-
mediaContent = {
|
|
575
|
-
extendedTextMessage: {
|
|
576
|
-
text: groupStoryMessage.caption
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
} else {
|
|
580
|
-
throw new Error("Group Story content must contain image, video, or caption.");
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
const groupStatusMessageContent = {
|
|
584
|
-
groupStatusMessage: {
|
|
585
|
-
key: {
|
|
586
|
-
remoteJid: jid,
|
|
587
|
-
fromMe: true,
|
|
588
|
-
id: this.utils.generateMessageID(),
|
|
589
|
-
participant: this.utils.jidNormalizedUser(this.utils.auth.creds.me.id)
|
|
590
|
-
},
|
|
591
|
-
message: {
|
|
592
|
-
...mediaContent,
|
|
593
|
-
contextInfo: {
|
|
594
|
-
mentionedJid: groupStoryMessage.mentions || [],
|
|
595
|
-
...(quoted ? {
|
|
596
|
-
stanzaId: quoted.key.id,
|
|
597
|
-
participant: quoted.key.participant || quoted.key.remoteJid,
|
|
598
|
-
quotedMessage: quoted.message
|
|
599
|
-
} : {})
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
const fullMsg = await this.utils.generateWAMessageFromContent(
|
|
606
|
-
jid,
|
|
607
|
-
groupStatusMessageContent,
|
|
608
|
-
{ quoted, logger: this.utils.logger }
|
|
609
|
-
);
|
|
610
|
-
|
|
611
|
-
await this.relayMessage(jid, fullMsg.message, {
|
|
612
|
-
messageId: fullMsg.key.id,
|
|
613
|
-
type: 'group_status',
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
return fullMsg;
|
|
617
|
-
} else {
|
|
618
|
-
throw new Error("Invalid content for handleGroupStory. Neither groupStatusMessage nor groupStoryMessage found.");
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
module.exports = yaoii;
|