alipclutch-baileys 8.5.1 → 8.5.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/lib/Socket/messages-send.js +19 -67
- package/lib/Socket/setup.js +380 -332
- package/lib/Socket/setup.ts +201 -117
- package/package.json +1 -1
package/lib/Socket/setup.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
/* modified by alip clutch*/
|
|
1
2
|
const WAProto = require('../../WAProto').proto;
|
|
2
3
|
const crypto = require('crypto');
|
|
4
|
+
const Utils_1 = require("../Utils");
|
|
3
5
|
|
|
4
6
|
class yaoii {
|
|
5
7
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
6
8
|
this.utils = utils;
|
|
7
9
|
this.relayMessage = relayMessageFn
|
|
8
10
|
this.waUploadToServer = waUploadToServer;
|
|
11
|
+
|
|
12
|
+
this.bail = {
|
|
13
|
+
generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
|
|
14
|
+
generateMessageID: Utils_1.generateMessageID,
|
|
15
|
+
getContentType: (msg) => Object.keys(msg.message || {})[0]
|
|
16
|
+
};
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
detectType(content) {
|
|
@@ -14,7 +22,8 @@ class yaoii {
|
|
|
14
22
|
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
15
23
|
if (content.albumMessage) return 'ALBUM';
|
|
16
24
|
if (content.eventMessage) return 'EVENT';
|
|
17
|
-
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
25
|
+
if (content.pollResultMessage) return 'POLL_RESULT';
|
|
26
|
+
if (content.groupStatusMessage) return 'GROUP_STORY';
|
|
18
27
|
return null;
|
|
19
28
|
}
|
|
20
29
|
|
|
@@ -61,373 +70,412 @@ class yaoii {
|
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
async handleProduct(content, jid, quoted) {
|
|
74
|
+
const {
|
|
75
|
+
title,
|
|
76
|
+
description,
|
|
77
|
+
thumbnail,
|
|
78
|
+
productId,
|
|
79
|
+
retailerId,
|
|
80
|
+
url,
|
|
81
|
+
body = "",
|
|
82
|
+
footer = "",
|
|
83
|
+
buttons = [],
|
|
84
|
+
priceAmount1000 = null,
|
|
85
|
+
currencyCode = "IDR"
|
|
86
|
+
} = content.productMessage;
|
|
87
|
+
|
|
88
|
+
let productImage;
|
|
89
|
+
|
|
90
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
91
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
92
|
+
{ image: thumbnail },
|
|
93
|
+
{ upload: this.waUploadToServer }
|
|
94
|
+
);
|
|
95
|
+
productImage = imageMessage;
|
|
96
|
+
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
97
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
98
|
+
{ image: { url: thumbnail.url }},
|
|
99
|
+
{ upload: this.waUploadToServer }
|
|
100
|
+
);
|
|
101
|
+
productImage = imageMessage;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
viewOnceMessage: {
|
|
106
|
+
message: {
|
|
107
|
+
interactiveMessage: {
|
|
108
|
+
body: { text: body },
|
|
109
|
+
footer: { text: footer },
|
|
110
|
+
header: {
|
|
111
|
+
title,
|
|
112
|
+
hasMediaAttachment: true,
|
|
113
|
+
productMessage: {
|
|
114
|
+
product: {
|
|
115
|
+
productImage,
|
|
116
|
+
productId,
|
|
117
|
+
title,
|
|
118
|
+
description,
|
|
119
|
+
currencyCode,
|
|
120
|
+
priceAmount1000,
|
|
121
|
+
retailerId,
|
|
122
|
+
url,
|
|
123
|
+
productImageCount: 1
|
|
124
|
+
},
|
|
125
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
nativeFlowMessage: { buttons }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
78
134
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
135
|
+
async handleInteractive(content, jid, quoted) {
|
|
136
|
+
const {
|
|
137
|
+
title,
|
|
138
|
+
footer,
|
|
139
|
+
thumbnail,
|
|
140
|
+
image,
|
|
141
|
+
video,
|
|
142
|
+
document,
|
|
143
|
+
mimetype,
|
|
144
|
+
fileName,
|
|
145
|
+
jpegThumbnail,
|
|
146
|
+
contextInfo,
|
|
147
|
+
externalAdReply,
|
|
148
|
+
buttons = [],
|
|
149
|
+
nativeFlowMessage,
|
|
150
|
+
header
|
|
151
|
+
} = content.interactiveMessage;
|
|
152
|
+
|
|
153
|
+
let media = null;
|
|
154
|
+
let mediaType = null;
|
|
155
|
+
|
|
156
|
+
if (thumbnail) {
|
|
157
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
158
|
+
{ image: { url: thumbnail } },
|
|
159
|
+
{ upload: this.waUploadToServer }
|
|
160
|
+
);
|
|
161
|
+
mediaType = 'image';
|
|
162
|
+
} else if (image) {
|
|
163
|
+
if (typeof image === 'object' && image.url) {
|
|
164
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
165
|
+
{ image: { url: image.url } },
|
|
82
166
|
{ upload: this.waUploadToServer }
|
|
83
167
|
);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{ image: { url: thumbnail.url }},
|
|
168
|
+
} else {
|
|
169
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
170
|
+
{ image: image },
|
|
88
171
|
{ upload: this.waUploadToServer }
|
|
89
172
|
);
|
|
90
|
-
productImage = imageMessage;
|
|
91
173
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
message: {
|
|
96
|
-
interactiveMessage: {
|
|
97
|
-
body: { text: body },
|
|
98
|
-
footer: { text: footer },
|
|
99
|
-
header: {
|
|
100
|
-
title,
|
|
101
|
-
hasMediaAttachment: true,
|
|
102
|
-
productMessage: {
|
|
103
|
-
product: {
|
|
104
|
-
productImage,
|
|
105
|
-
productId,
|
|
106
|
-
title,
|
|
107
|
-
description,
|
|
108
|
-
retailerId,
|
|
109
|
-
url,
|
|
110
|
-
productImageCount: 1
|
|
111
|
-
},
|
|
112
|
-
businessOwnerJid: "0@s.whatsapp.net"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
nativeFlowMessage: { buttons }
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async handleInteractive(content, jid, quoted) {
|
|
123
|
-
const {
|
|
124
|
-
title,
|
|
125
|
-
footer,
|
|
126
|
-
thumbnail,
|
|
127
|
-
image,
|
|
128
|
-
video,
|
|
129
|
-
document,
|
|
130
|
-
mimetype,
|
|
131
|
-
fileName,
|
|
132
|
-
jpegThumbnail,
|
|
133
|
-
contextInfo,
|
|
134
|
-
externalAdReply,
|
|
135
|
-
buttons = [],
|
|
136
|
-
nativeFlowMessage
|
|
137
|
-
} = content.interactiveMessage;
|
|
138
|
-
|
|
139
|
-
let media = null;
|
|
140
|
-
let mediaType = null;
|
|
141
|
-
|
|
142
|
-
if (thumbnail) {
|
|
174
|
+
mediaType = 'image';
|
|
175
|
+
} else if (video) {
|
|
176
|
+
if (typeof video === 'object' && video.url) {
|
|
143
177
|
media = await this.utils.prepareWAMessageMedia(
|
|
144
|
-
{
|
|
178
|
+
{ video: { url: video.url } },
|
|
145
179
|
{ upload: this.waUploadToServer }
|
|
146
180
|
);
|
|
147
|
-
|
|
148
|
-
} else if (image) {
|
|
149
|
-
if (typeof image === 'object' && image.url) {
|
|
150
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
151
|
-
{ image: { url: image.url } },
|
|
152
|
-
{ upload: this.waUploadToServer }
|
|
153
|
-
);
|
|
154
|
-
} else {
|
|
155
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
156
|
-
{ image: image },
|
|
157
|
-
{ upload: this.waUploadToServer }
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
mediaType = 'image';
|
|
161
|
-
} else if (video) {
|
|
162
|
-
if (typeof video === 'object' && video.url) {
|
|
163
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
164
|
-
{ video: { url: video.url } },
|
|
165
|
-
{ upload: this.waUploadToServer }
|
|
166
|
-
);
|
|
167
|
-
} else {
|
|
168
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
169
|
-
{ video: video },
|
|
170
|
-
{ upload: this.waUploadToServer }
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
mediaType = 'video';
|
|
174
|
-
} else if (document) {
|
|
175
|
-
let documentPayload = { document: document };
|
|
176
|
-
|
|
177
|
-
if (jpegThumbnail) {
|
|
178
|
-
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
179
|
-
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
180
|
-
} else {
|
|
181
|
-
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
181
|
+
} else {
|
|
185
182
|
media = await this.utils.prepareWAMessageMedia(
|
|
186
|
-
|
|
183
|
+
{ video: video },
|
|
187
184
|
{ upload: this.waUploadToServer }
|
|
188
185
|
);
|
|
189
|
-
|
|
190
|
-
if (fileName) {
|
|
191
|
-
media.documentMessage.fileName = fileName;
|
|
192
|
-
}
|
|
193
|
-
if (mimetype) {
|
|
194
|
-
media.documentMessage.mimetype = mimetype;
|
|
195
|
-
}
|
|
196
|
-
mediaType = 'document';
|
|
197
186
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
187
|
+
mediaType = 'video';
|
|
188
|
+
} else if (document) {
|
|
189
|
+
let documentPayload = {
|
|
190
|
+
document: document
|
|
202
191
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (nativeFlowMessage) {
|
|
210
|
-
interactiveMessage.nativeFlowMessage = {
|
|
211
|
-
...interactiveMessage.nativeFlowMessage,
|
|
212
|
-
...nativeFlowMessage
|
|
213
|
-
};
|
|
192
|
+
if (jpegThumbnail) {
|
|
193
|
+
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
194
|
+
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
195
|
+
} else {
|
|
196
|
+
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
214
197
|
}
|
|
215
|
-
} else if (nativeFlowMessage) {
|
|
216
|
-
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
217
198
|
}
|
|
218
199
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
} else {
|
|
226
|
-
interactiveMessage.header = {
|
|
227
|
-
title: "",
|
|
228
|
-
hasMediaAttachment: false
|
|
229
|
-
};
|
|
200
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
201
|
+
documentPayload,
|
|
202
|
+
{ upload: this.waUploadToServer }
|
|
203
|
+
);
|
|
204
|
+
if (fileName) {
|
|
205
|
+
media.documentMessage.fileName = fileName;
|
|
230
206
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (contextInfo) {
|
|
235
|
-
finalContextInfo = {
|
|
236
|
-
mentionedJid: contextInfo.mentionedJid || [],
|
|
237
|
-
forwardingScore: contextInfo.forwardingScore || 0,
|
|
238
|
-
isForwarded: contextInfo.isForwarded || false,
|
|
239
|
-
...contextInfo
|
|
240
|
-
};
|
|
207
|
+
if (mimetype) {
|
|
208
|
+
media.documentMessage.mimetype = mimetype;
|
|
241
209
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
210
|
+
mediaType = 'document';
|
|
211
|
+
}
|
|
212
|
+
let interactiveMessage = {
|
|
213
|
+
body: { text: title || "" },
|
|
214
|
+
footer: { text: footer || "" }
|
|
215
|
+
};
|
|
216
|
+
if (buttons && buttons.length > 0) {
|
|
217
|
+
interactiveMessage.nativeFlowMessage = {
|
|
218
|
+
buttons: buttons
|
|
219
|
+
};
|
|
220
|
+
if (nativeFlowMessage) {
|
|
221
|
+
interactiveMessage.nativeFlowMessage = {
|
|
222
|
+
...interactiveMessage.nativeFlowMessage,
|
|
223
|
+
...nativeFlowMessage
|
|
254
224
|
};
|
|
255
225
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
226
|
+
} else if (nativeFlowMessage) {
|
|
227
|
+
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (media) {
|
|
231
|
+
interactiveMessage.header = {
|
|
232
|
+
title: header || "",
|
|
233
|
+
hasMediaAttachment: true,
|
|
234
|
+
...media
|
|
235
|
+
};
|
|
236
|
+
} else {
|
|
237
|
+
interactiveMessage.header = {
|
|
238
|
+
title: header || "",
|
|
239
|
+
hasMediaAttachment: false
|
|
263
240
|
};
|
|
264
241
|
}
|
|
265
242
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
243
|
+
let finalContextInfo = {};
|
|
244
|
+
if (contextInfo) {
|
|
245
|
+
finalContextInfo = {
|
|
246
|
+
mentionedJid: contextInfo.mentionedJid || [],
|
|
247
|
+
forwardingScore: contextInfo.forwardingScore || 0,
|
|
248
|
+
isForwarded: contextInfo.isForwarded || false,
|
|
249
|
+
...contextInfo
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (externalAdReply) {
|
|
254
|
+
finalContextInfo.externalAdReply = {
|
|
255
|
+
title: externalAdReply.title || "",
|
|
256
|
+
body: externalAdReply.body || "",
|
|
257
|
+
mediaType: externalAdReply.mediaType || 1,
|
|
258
|
+
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
259
|
+
mediaUrl: externalAdReply.mediaUrl || "",
|
|
260
|
+
sourceUrl: externalAdReply.sourceUrl || "",
|
|
261
|
+
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
262
|
+
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
263
|
+
...externalAdReply
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (Object.keys(finalContextInfo).length > 0) {
|
|
268
|
+
interactiveMessage.contextInfo = finalContextInfo;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
interactiveMessage: interactiveMessage
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async handleAlbum(content, jid, quoted) {
|
|
276
|
+
const array = content.albumMessage;
|
|
277
|
+
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
278
|
+
messageContextInfo: {
|
|
279
|
+
messageSecret: crypto.randomBytes(32),
|
|
280
|
+
},
|
|
281
|
+
albumMessage: {
|
|
282
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
283
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
284
|
+
},
|
|
285
|
+
}, {
|
|
286
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
287
|
+
quoted,
|
|
288
|
+
upload: this.waUploadToServer
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
await this.relayMessage(jid, album.message, {
|
|
292
|
+
messageId: album.key.id,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
for (let content of array) {
|
|
296
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
297
|
+
upload: this.waUploadToServer,
|
|
280
298
|
});
|
|
281
299
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
300
|
+
img.message.messageContextInfo = {
|
|
301
|
+
messageSecret: crypto.randomBytes(32),
|
|
302
|
+
messageAssociation: {
|
|
303
|
+
associationType: 1,
|
|
304
|
+
parentMessageKey: album.key,
|
|
305
|
+
},
|
|
306
|
+
participant: "0@s.whatsapp.net",
|
|
307
|
+
remoteJid: "status@broadcast",
|
|
308
|
+
forwardingScore: 99999,
|
|
309
|
+
isForwarded: true,
|
|
310
|
+
mentionedJid: [jid],
|
|
311
|
+
starred: true,
|
|
312
|
+
labels: ["Y", "Important"],
|
|
313
|
+
isHighlighted: true,
|
|
314
|
+
businessMessageForwardInfo: {
|
|
315
|
+
businessOwnerJid: jid,
|
|
316
|
+
},
|
|
317
|
+
dataSharingContext: {
|
|
318
|
+
showMmDisclosure: true,
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
img.message.forwardedNewsletterMessageInfo = {
|
|
323
|
+
newsletterJid: "0@newsletter",
|
|
324
|
+
serverMessageId: 1,
|
|
325
|
+
newsletterName: `WhatsApp`,
|
|
326
|
+
contentType: 1,
|
|
327
|
+
timestamp: new Date().toISOString(),
|
|
328
|
+
senderName: "Alip Clutch",
|
|
329
|
+
content: "Text Message",
|
|
330
|
+
priority: "high",
|
|
331
|
+
status: "sent",
|
|
332
|
+
};
|
|
285
333
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
isForwarded: true,
|
|
301
|
-
mentionedJid: [jid],
|
|
302
|
-
starred: true,
|
|
303
|
-
labels: ["Y", "Important"],
|
|
304
|
-
isHighlighted: true,
|
|
305
|
-
businessMessageForwardInfo: {
|
|
306
|
-
businessOwnerJid: jid,
|
|
307
|
-
},
|
|
308
|
-
dataSharingContext: {
|
|
309
|
-
showMmDisclosure: true,
|
|
310
|
-
},
|
|
311
|
-
};
|
|
334
|
+
img.message.disappearingMode = {
|
|
335
|
+
initiator: 3,
|
|
336
|
+
trigger: 4,
|
|
337
|
+
initiatorDeviceJid: jid,
|
|
338
|
+
initiatedByExternalService: true,
|
|
339
|
+
initiatedByUserDevice: true,
|
|
340
|
+
initiatedBySystem: true,
|
|
341
|
+
initiatedByServer: true,
|
|
342
|
+
initiatedByAdmin: true,
|
|
343
|
+
initiatedByUser: true,
|
|
344
|
+
initiatedByApp: true,
|
|
345
|
+
initiatedByBot: true,
|
|
346
|
+
initiatedByMe: true,
|
|
347
|
+
};
|
|
312
348
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
initiatorDeviceJid: jid,
|
|
329
|
-
initiatedByExternalService: true,
|
|
330
|
-
initiatedByUserDevice: true,
|
|
331
|
-
initiatedBySystem: true,
|
|
332
|
-
initiatedByServer: true,
|
|
333
|
-
initiatedByAdmin: true,
|
|
334
|
-
initiatedByUser: true,
|
|
335
|
-
initiatedByApp: true,
|
|
336
|
-
initiatedByBot: true,
|
|
337
|
-
initiatedByMe: true,
|
|
338
|
-
};
|
|
349
|
+
await this.relayMessage(jid, img.message, {
|
|
350
|
+
messageId: img.key.id,
|
|
351
|
+
quoted: {
|
|
352
|
+
key: {
|
|
353
|
+
remoteJid: album.key.remoteJid,
|
|
354
|
+
id: album.key.id,
|
|
355
|
+
fromMe: true,
|
|
356
|
+
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
357
|
+
},
|
|
358
|
+
message: album.message,
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return album;
|
|
363
|
+
}
|
|
339
364
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
365
|
+
async handleEvent(content, jid, quoted) {
|
|
366
|
+
const eventData = content.eventMessage;
|
|
367
|
+
|
|
368
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
369
|
+
viewOnceMessage: {
|
|
370
|
+
message: {
|
|
371
|
+
messageContextInfo: {
|
|
372
|
+
deviceListMetadata: {},
|
|
373
|
+
deviceListMetadataVersion: 2,
|
|
374
|
+
messageSecret: crypto.randomBytes(32),
|
|
375
|
+
supportPayload: JSON.stringify({
|
|
376
|
+
version: 2,
|
|
377
|
+
is_ai_message: true,
|
|
378
|
+
should_show_system_message: true,
|
|
379
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
380
|
+
})
|
|
350
381
|
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
should_show_system_message: true,
|
|
370
|
-
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
371
|
-
})
|
|
382
|
+
eventMessage: {
|
|
383
|
+
contextInfo: {
|
|
384
|
+
mentionedJid: [jid],
|
|
385
|
+
participant: jid,
|
|
386
|
+
remoteJid: "status@broadcast",
|
|
387
|
+
forwardedNewsletterMessageInfo: {
|
|
388
|
+
newsletterName: "alip clutch.",
|
|
389
|
+
newsletterJid: "120363401467939056@newsletter",
|
|
390
|
+
serverMessageId: 1
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
isCanceled: eventData.isCanceled || false,
|
|
394
|
+
name: eventData.name,
|
|
395
|
+
description: eventData.description,
|
|
396
|
+
location: eventData.location || {
|
|
397
|
+
degreesLatitude: 0,
|
|
398
|
+
degreesLongitude: 0,
|
|
399
|
+
name: "Location"
|
|
372
400
|
},
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
remoteJid: "status@broadcast",
|
|
378
|
-
forwardedNewsletterMessageInfo: {
|
|
379
|
-
newsletterName: "Alippp — Baileys",
|
|
380
|
-
newsletterJid: "120363401467939056@newsletter",
|
|
381
|
-
serverMessageId: 1
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
isCanceled: eventData.isCanceled || false,
|
|
385
|
-
name: eventData.name,
|
|
386
|
-
description: eventData.description,
|
|
387
|
-
location: eventData.location || {
|
|
388
|
-
degreesLatitude: 0,
|
|
389
|
-
degreesLongitude: 0,
|
|
390
|
-
name: "Location"
|
|
391
|
-
},
|
|
392
|
-
joinLink: eventData.joinLink || '',
|
|
393
|
-
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
394
|
-
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
395
|
-
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
396
|
-
}
|
|
401
|
+
joinLink: eventData.joinLink || '',
|
|
402
|
+
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
403
|
+
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
404
|
+
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
await this.relayMessage(jid, msg.message, {
|
|
402
|
-
messageId: msg.key.id
|
|
403
|
-
});
|
|
404
|
-
return msg;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
async handlePollResult(content, jid, quoted) {
|
|
408
|
-
const pollData = content.pollResultMessage;
|
|
407
|
+
}
|
|
408
|
+
}, { quoted });
|
|
409
409
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
410
|
+
await this.relayMessage(jid, msg.message, {
|
|
411
|
+
messageId: msg.key.id
|
|
412
|
+
});
|
|
413
|
+
return msg;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async handlePollResult(content, jid, quoted) {
|
|
417
|
+
const pollData = content.pollResultMessage;
|
|
418
|
+
|
|
419
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
420
|
+
pollResultSnapshotMessage: {
|
|
421
|
+
name: pollData.name,
|
|
422
|
+
pollVotes: pollData.pollVotes.map(vote => ({
|
|
423
|
+
optionName: vote.optionName,
|
|
424
|
+
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
425
|
+
? vote.optionVoteCount.toString()
|
|
426
|
+
: vote.optionVoteCount
|
|
427
|
+
}))
|
|
428
|
+
}
|
|
429
|
+
}, {
|
|
430
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
431
|
+
quoted
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
await this.relayMessage(jid, msg.message, {
|
|
435
|
+
messageId: msg.key.id
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
return msg;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
async handleGroupStory(content, jid, quoted) {
|
|
442
|
+
const storyData = content.groupStatusMessage;
|
|
443
|
+
let waMsgContent;
|
|
424
444
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
445
|
+
if (storyData.message) {
|
|
446
|
+
waMsgContent = storyData;
|
|
447
|
+
} else {
|
|
448
|
+
if (typeof this.bail?.generateWAMessageContent === "function") {
|
|
449
|
+
waMsgContent = await this.bail.generateWAMessageContent(storyData, {
|
|
450
|
+
upload: this.waUploadToServer
|
|
451
|
+
});
|
|
452
|
+
} else if (typeof this.utils?.generateWAMessageContent === "function") {
|
|
453
|
+
waMsgContent = await this.utils.generateWAMessageContent(storyData, {
|
|
454
|
+
upload: this.waUploadToServer
|
|
455
|
+
});
|
|
456
|
+
} else if (typeof this.utils?.prepareMessageContent === "function") {
|
|
457
|
+
waMsgContent = await this.utils.prepareMessageContent(storyData, {
|
|
458
|
+
upload: this.waUploadToServer
|
|
459
|
+
});
|
|
460
|
+
} else {
|
|
461
|
+
waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
|
|
462
|
+
upload: this.waUploadToServer
|
|
463
|
+
});
|
|
464
|
+
}
|
|
430
465
|
}
|
|
466
|
+
|
|
467
|
+
let msg = {
|
|
468
|
+
message: {
|
|
469
|
+
groupStatusMessageV2: {
|
|
470
|
+
message: waMsgContent.message || waMsgContent
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
return await this.relayMessage(jid, msg.message, {
|
|
476
|
+
messageId: this.bail.generateMessageID()
|
|
477
|
+
});
|
|
431
478
|
}
|
|
479
|
+
}
|
|
432
480
|
|
|
433
481
|
module.exports = yaoii;
|