dibosockets 1.0.2 → 1.0.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.
Files changed (40) hide show
  1. package/WAProto/WAProto.proto +5619 -5619
  2. package/lib/Api/Internet/growagarden.js +28 -28
  3. package/lib/Api/creator.json +13 -13
  4. package/lib/Api/downloader/tiktokdownload.js +132 -132
  5. package/lib/Api/index.js +38 -38
  6. package/lib/Api/nsfw/loli.js +79 -79
  7. package/lib/Api/stalker/githubstalk.js +46 -46
  8. package/lib/Api/stalker/stalkroblox.js +94 -94
  9. package/lib/Api/stalker/tiktokstalk.js +68 -68
  10. package/lib/Api/tools/ssweb.js +38 -38
  11. package/lib/Defaults/baileys-version.json +3 -3
  12. package/lib/Defaults/index.js +122 -122
  13. package/lib/Defaults/phonenumber_mcc.json +223 -223
  14. package/lib/Socket/RHandler.js +448 -448
  15. package/lib/Socket/business.js +266 -266
  16. package/lib/Socket/chats.js +1137 -1137
  17. package/lib/Socket/communities.js +441 -441
  18. package/lib/Socket/index.js +43 -43
  19. package/lib/Socket/messages-recv.js +1065 -1065
  20. package/lib/Socket/messages-send.js +881 -881
  21. package/lib/Socket/newsletter.js +286 -286
  22. package/lib/Socket/socket.js +666 -666
  23. package/lib/Store/make-in-memory-store.js +439 -439
  24. package/lib/Types/Newsletter.js +18 -18
  25. package/lib/Utils/async-iterable.js +41 -41
  26. package/lib/Utils/baileys-event-stream.js +63 -63
  27. package/lib/Utils/browser-utils.js +34 -34
  28. package/lib/Utils/event-buffer.js +518 -518
  29. package/lib/Utils/generics.js +431 -431
  30. package/lib/Utils/index.js +36 -36
  31. package/lib/Utils/message-retry-manager.js +127 -127
  32. package/lib/Utils/messages-media.js +926 -926
  33. package/lib/Utils/messages.js +1105 -1105
  34. package/lib/Utils/process-message.js +404 -404
  35. package/lib/Utils/resolveJid.js +52 -52
  36. package/lib/Utils/use-multi-file-auth-state.js +122 -122
  37. package/lib/Utils/validate-connection.js +228 -228
  38. package/lib/WABinary/jid-utils.js +85 -85
  39. package/lib/index.js +87 -74
  40. package/package.json +2 -2
@@ -1,448 +1,448 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
-
5
- const WAProto = require("../../WAProto").proto;
6
- const crypto = require("crypto");
7
- const Utils_1 = require("../Utils");
8
-
9
- class RexxHayanasi {
10
- constructor(utils, waUploadToServer, relayMessageFn) {
11
- this.utils = utils;
12
- this.relayMessage = relayMessageFn;
13
- this.waUploadToServer = waUploadToServer;
14
- this.bail = {
15
- generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
16
- generateMessageID: Utils_1.generateMessageID,
17
- getContentType: (msg) => {
18
- if (!msg || typeof msg !== "object") return null;
19
- const m = msg.message || {};
20
- if (typeof m !== "object") return null;
21
- return Object.keys(m)[0] || null;
22
- }
23
- };
24
- }
25
-
26
- detectType(content) {
27
- if (content.requestPaymentMessage) return "PAYMENT";
28
- if (content.productMessage) return "PRODUCT";
29
- if (content.interactiveMessage) return "INTERACTIVE";
30
- if (content.albumMessage) return "ALBUM";
31
- if (content.eventMessage) return "EVENT";
32
- if (content.pollResultMessage) return "POLL_RESULT";
33
- if (content.groupStatusMessage) return "GROUP_STORY";
34
- return null;
35
- }
36
-
37
- async handlePayment(content, quoted) {
38
- const data = content?.requestPaymentMessage;
39
- if (!data) throw new Error("Missing requestPaymentMessage in content");
40
- try {
41
- let notes = {};
42
- if (data.sticker?.stickerMessage) {
43
- notes = {
44
- stickerMessage: {
45
- ...data.sticker.stickerMessage,
46
- contextInfo: {
47
- stanzaId: quoted?.key?.id,
48
- participant: quoted?.key?.participant || content.sender,
49
- quotedMessage: quoted?.message
50
- }
51
- }
52
- };
53
- } else if (data.note) {
54
- notes = {
55
- extendedTextMessage: {
56
- text: data.note,
57
- contextInfo: {
58
- stanzaId: quoted?.key?.id,
59
- participant: quoted?.key?.participant || content.sender,
60
- quotedMessage: quoted?.message
61
- }
62
- }
63
- };
64
- }
65
- return {
66
- requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
67
- expiryTimestamp: data.expiry || 0,
68
- amount1000: data.amount || 0,
69
- currencyCodeIso4217: data.currency || "IDR",
70
- requestFrom: data.from || "0@s.whatsapp.net",
71
- noteMessage: notes,
72
- background: data.background ?? {
73
- id: "DEFAULT",
74
- placeholderArgb: 0xfff0f0f0
75
- }
76
- })
77
- };
78
- } catch (err) {
79
- console.error("handlePayment error:", err);
80
- throw err;
81
- }
82
- }
83
-
84
- async handleProduct(content, jid, quoted) {
85
- try {
86
- const {
87
- title = "",
88
- description = "",
89
- thumbnail,
90
- productId,
91
- retailerId,
92
- url,
93
- body = "",
94
- footer = "",
95
- buttons = [],
96
- priceAmount1000 = null,
97
- currencyCode = "IDR"
98
- } = content.productMessage || {};
99
- let productImage = null;
100
- if (thumbnail) {
101
- try {
102
- if (Buffer.isBuffer(thumbnail)) {
103
- const res = await this.utils.generateWAMessageContent({ image: thumbnail }, { upload: this.waUploadToServer });
104
- productImage = res?.imageMessage || res?.message?.imageMessage || null;
105
- } else if (typeof thumbnail === "object" && thumbnail.url) {
106
- const res = await this.utils.generateWAMessageContent({ image: { url: thumbnail.url } }, { upload: this.waUploadToServer });
107
- productImage = res?.imageMessage || res?.message?.imageMessage || null;
108
- }
109
- } catch {}
110
- }
111
- const product = {
112
- productId,
113
- title,
114
- description,
115
- currencyCode,
116
- priceAmount1000,
117
- retailerId,
118
- url,
119
- productImageCount: productImage ? 1 : 0
120
- };
121
- if (productImage) product.productImage = productImage;
122
- return {
123
- viewOnceMessage: {
124
- message: {
125
- interactiveMessage: {
126
- body: { text: body },
127
- footer: { text: footer },
128
- header: {
129
- title,
130
- hasMediaAttachment: !!productImage,
131
- productMessage: {
132
- product,
133
- businessOwnerJid: "0@s.whatsapp.net"
134
- }
135
- },
136
- nativeFlowMessage: { buttons }
137
- }
138
- }
139
- }
140
- };
141
- } catch (err) {
142
- console.error("handleProduct error:", err);
143
- throw err;
144
- }
145
- }
146
-
147
- async handleInteractive(content, jid, quoted) {
148
- try {
149
- const {
150
- title,
151
- footer,
152
- thumbnail,
153
- image,
154
- video,
155
- document,
156
- mimetype,
157
- fileName,
158
- jpegThumbnail,
159
- contextInfo,
160
- externalAdReply,
161
- buttons = [],
162
- nativeFlowMessage,
163
- header
164
- } = content.interactiveMessage || {};
165
- let media = null;
166
- if (thumbnail) {
167
- media = await this.utils.prepareWAMessageMedia({ image: { url: thumbnail } }, { upload: this.waUploadToServer });
168
- } else if (image) {
169
- media = await this.utils.prepareWAMessageMedia(
170
- typeof image === "object" && image.url ? { image: { url: image.url } } : { image },
171
- { upload: this.waUploadToServer }
172
- );
173
- } else if (video) {
174
- media = await this.utils.prepareWAMessageMedia(
175
- typeof video === "object" && video.url ? { video: { url: video.url } } : { video },
176
- { upload: this.waUploadToServer }
177
- );
178
- } else if (document) {
179
- const docPayload = { document };
180
- if (jpegThumbnail) {
181
- docPayload.jpegThumbnail = typeof jpegThumbnail === "object" && jpegThumbnail.url ? { url: jpegThumbnail.url } : jpegThumbnail;
182
- }
183
- media = await this.utils.prepareWAMessageMedia(docPayload, { upload: this.waUploadToServer });
184
- if (fileName) media.documentMessage.fileName = fileName;
185
- if (mimetype) media.documentMessage.mimetype = mimetype;
186
- }
187
- const interactiveMessage = {
188
- body: { text: title || "" },
189
- footer: { text: footer || "" }
190
- };
191
- if (buttons.length > 0) {
192
- interactiveMessage.nativeFlowMessage = { buttons };
193
- if (nativeFlowMessage) Object.assign(interactiveMessage.nativeFlowMessage, nativeFlowMessage);
194
- } else if (nativeFlowMessage) {
195
- interactiveMessage.nativeFlowMessage = nativeFlowMessage;
196
- }
197
- if (media) {
198
- const headerMedia = {};
199
- if (media.imageMessage) headerMedia.imageMessage = media.imageMessage;
200
- if (media.videoMessage) headerMedia.videoMessage = media.videoMessage;
201
- if (media.documentMessage) headerMedia.documentMessage = media.documentMessage;
202
- interactiveMessage.header = { title: header || "", hasMediaAttachment: true, ...headerMedia };
203
- } else {
204
- interactiveMessage.header = { title: header || "", hasMediaAttachment: false };
205
- }
206
- let finalContextInfo = {};
207
- if (contextInfo) {
208
- finalContextInfo = {
209
- mentionedJid: contextInfo.mentionedJid || [],
210
- forwardingScore: contextInfo.forwardingScore || 0,
211
- isForwarded: contextInfo.isForwarded || false,
212
- ...contextInfo
213
- };
214
- }
215
- if (externalAdReply) {
216
- finalContextInfo.externalAdReply = {
217
- title: externalAdReply.title || "",
218
- body: externalAdReply.body || "",
219
- mediaType: externalAdReply.mediaType || 1,
220
- thumbnailUrl: externalAdReply.thumbnailUrl || "",
221
- mediaUrl: externalAdReply.mediaUrl || "",
222
- sourceUrl: externalAdReply.sourceUrl || "",
223
- showAdAttribution: externalAdReply.showAdAttribution || false,
224
- renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
225
- ...externalAdReply
226
- };
227
- }
228
- if (Object.keys(finalContextInfo).length > 0) {
229
- interactiveMessage.contextInfo = finalContextInfo;
230
- }
231
- return { interactiveMessage };
232
- } catch (err) {
233
- console.error("handleInteractive error:", err);
234
- throw err;
235
- }
236
- }
237
-
238
- async handleAlbum(content, jid, quoted) {
239
- try {
240
- const array = Array.isArray(content.albumMessage) ? content.albumMessage : [];
241
- if (array.length === 0) throw new Error("albumMessage harus berupa array dengan isi media");
242
- const album = await this.utils.generateWAMessageFromContent(
243
- jid,
244
- {
245
- messageContextInfo: { messageSecret: crypto.randomBytes(32) },
246
- albumMessage: {
247
- expectedImageCount: array.filter((a) => a.image).length,
248
- expectedVideoCount: array.filter((a) => a.video).length
249
- }
250
- },
251
- {
252
- userJid: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net",
253
- quoted,
254
- upload: this.waUploadToServer
255
- }
256
- );
257
- await this.relayMessage(jid, album.message, { messageId: album.key.id });
258
- for (const item of array) {
259
- const img = await this.utils.generateWAMessage(jid, item, { upload: this.waUploadToServer });
260
- img.message.messageContextInfo = {
261
- messageSecret: crypto.randomBytes(32),
262
- messageAssociation: {
263
- associationType: 1,
264
- parentMessageKey: album.key
265
- },
266
- participant: "0@s.whatsapp.net",
267
- remoteJid: "status@broadcast",
268
- forwardingScore: 99999,
269
- isForwarded: true,
270
- mentionedJid: [jid],
271
- starred: true,
272
- labels: ["Y", "Important"],
273
- isHighlighted: true,
274
- businessMessageForwardInfo: { businessOwnerJid: jid },
275
- dataSharingContext: { showMmDisclosure: true }
276
- };
277
- img.message.forwardedNewsletterMessageInfo = {
278
- newsletterJid: "0@newsletter",
279
- serverMessageId: 1,
280
- newsletterName: "WhatsApp",
281
- contentType: 1,
282
- timestamp: new Date().toISOString(),
283
- senderName: "kikyy dugonggg",
284
- content: "Text Message",
285
- priority: "high",
286
- status: "sent"
287
- };
288
- img.message.disappearingMode = {
289
- initiator: 3,
290
- trigger: 4,
291
- initiatorDeviceJid: jid,
292
- initiatedByExternalService: true,
293
- initiatedByUserDevice: true,
294
- initiatedBySystem: true,
295
- initiatedByServer: true,
296
- initiatedByAdmin: true,
297
- initiatedByUser: true,
298
- initiatedByApp: true,
299
- initiatedByBot: true,
300
- initiatedByMe: true
301
- };
302
- await this.relayMessage(jid, img.message, {
303
- messageId: img.key.id,
304
- quoted: {
305
- key: {
306
- remoteJid: album.key.remoteJid,
307
- id: album.key.id,
308
- fromMe: true,
309
- participant: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net"
310
- },
311
- message: album.message
312
- }
313
- });
314
- }
315
- return album;
316
- } catch (err) {
317
- console.error("handleAlbum error:", err);
318
- throw err;
319
- }
320
- }
321
-
322
- async handleEvent(content, jid, quoted) {
323
- try {
324
- const eventData = content.eventMessage;
325
- if (!eventData) throw new Error("Missing eventMessage");
326
- const msg = await this.utils.generateWAMessageFromContent(
327
- jid,
328
- {
329
- viewOnceMessage: {
330
- message: {
331
- messageContextInfo: {
332
- deviceListMetadata: {},
333
- deviceListMetadataVersion: 2,
334
- messageSecret: crypto.randomBytes(32),
335
- supportPayload: JSON.stringify({
336
- version: 2,
337
- is_ai_message: true,
338
- should_show_system_message: true,
339
- ticket_id: crypto.randomBytes(16).toString("hex")
340
- })
341
- },
342
- eventMessage: {
343
- contextInfo: {
344
- mentionedJid: [jid],
345
- participant: jid,
346
- remoteJid: "status@broadcast",
347
- forwardedNewsletterMessageInfo: {
348
- newsletterName: "shenvn.",
349
- newsletterJid: "120363297591152843@newsletter",
350
- serverMessageId: 1
351
- }
352
- },
353
- isCanceled: eventData.isCanceled || false,
354
- name: eventData.name,
355
- description: eventData.description,
356
- location: eventData.location || {
357
- degreesLatitude: 0,
358
- degreesLongitude: 0,
359
- name: "Location"
360
- },
361
- joinLink: eventData.joinLink || "",
362
- startTime: typeof eventData.startTime === "string" ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
363
- endTime: typeof eventData.endTime === "string" ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
364
- extraGuestsAllowed: eventData.extraGuestsAllowed !== false
365
- }
366
- }
367
- }
368
- },
369
- { quoted }
370
- );
371
- await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
372
- return msg;
373
- } catch (err) {
374
- console.error("handleEvent error:", err);
375
- throw err;
376
- }
377
- }
378
-
379
- async handlePollResult(content, jid, quoted) {
380
- try {
381
- const pollData = content.pollResultMessage;
382
- if (!pollData) throw new Error("Missing pollResultMessage");
383
- const msg = await this.utils.generateWAMessageFromContent(
384
- jid,
385
- {
386
- pollResultSnapshotMessage: {
387
- name: pollData.name,
388
- pollVotes: (pollData.pollVotes || []).map((v) => ({
389
- optionName: v.optionName,
390
- optionVoteCount: typeof v.optionVoteCount === "number" ? v.optionVoteCount.toString() : v.optionVoteCount
391
- }))
392
- }
393
- },
394
- {
395
- userJid: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net",
396
- quoted
397
- }
398
- );
399
- await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
400
- return msg;
401
- } catch (err) {
402
- console.error("handlePollResult error:", err);
403
- throw err;
404
- }
405
- }
406
-
407
- async handleGroupStory(content, jid, quoted) {
408
- try {
409
- const storyData = content.groupStatusMessage;
410
- if (!storyData) throw new Error("Missing groupStatusMessage");
411
- let waMsgContent;
412
- if (storyData.message) {
413
- waMsgContent = storyData;
414
- } else if (typeof this.bail?.generateWAMessageContent === "function") {
415
- waMsgContent = await this.bail.generateWAMessageContent(storyData, {
416
- upload: this.waUploadToServer
417
- });
418
- } else if (typeof this.utils?.generateWAMessageContent === "function") {
419
- waMsgContent = await this.utils.generateWAMessageContent(storyData, {
420
- upload: this.waUploadToServer
421
- });
422
- } else if (typeof this.utils?.prepareMessageContent === "function") {
423
- waMsgContent = await this.utils.prepareMessageContent(storyData, {
424
- upload: this.waUploadToServer
425
- });
426
- } else {
427
- waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
428
- upload: this.waUploadToServer
429
- });
430
- }
431
- const msg = {
432
- message: {
433
- groupStatusMessageV2: {
434
- message: waMsgContent.message || waMsgContent
435
- }
436
- }
437
- };
438
- return await this.relayMessage(jid, msg.message, {
439
- messageId: this.bail.generateMessageID()
440
- });
441
- } catch (err) {
442
- console.error("handleGroupStory error:", err);
443
- throw err;
444
- }
445
- }
446
- }
447
-
448
- module.exports = RexxHayanasi;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+
5
+ const WAProto = require("../../WAProto").proto;
6
+ const crypto = require("crypto");
7
+ const Utils_1 = require("../Utils");
8
+
9
+ class RexxHayanasi {
10
+ constructor(utils, waUploadToServer, relayMessageFn) {
11
+ this.utils = utils;
12
+ this.relayMessage = relayMessageFn;
13
+ this.waUploadToServer = waUploadToServer;
14
+ this.bail = {
15
+ generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
16
+ generateMessageID: Utils_1.generateMessageID,
17
+ getContentType: (msg) => {
18
+ if (!msg || typeof msg !== "object") return null;
19
+ const m = msg.message || {};
20
+ if (typeof m !== "object") return null;
21
+ return Object.keys(m)[0] || null;
22
+ }
23
+ };
24
+ }
25
+
26
+ detectType(content) {
27
+ if (content.requestPaymentMessage) return "PAYMENT";
28
+ if (content.productMessage) return "PRODUCT";
29
+ if (content.interactiveMessage) return "INTERACTIVE";
30
+ if (content.albumMessage) return "ALBUM";
31
+ if (content.eventMessage) return "EVENT";
32
+ if (content.pollResultMessage) return "POLL_RESULT";
33
+ if (content.groupStatusMessage) return "GROUP_STORY";
34
+ return null;
35
+ }
36
+
37
+ async handlePayment(content, quoted) {
38
+ const data = content?.requestPaymentMessage;
39
+ if (!data) throw new Error("Missing requestPaymentMessage in content");
40
+ try {
41
+ let notes = {};
42
+ if (data.sticker?.stickerMessage) {
43
+ notes = {
44
+ stickerMessage: {
45
+ ...data.sticker.stickerMessage,
46
+ contextInfo: {
47
+ stanzaId: quoted?.key?.id,
48
+ participant: quoted?.key?.participant || content.sender,
49
+ quotedMessage: quoted?.message
50
+ }
51
+ }
52
+ };
53
+ } else if (data.note) {
54
+ notes = {
55
+ extendedTextMessage: {
56
+ text: data.note,
57
+ contextInfo: {
58
+ stanzaId: quoted?.key?.id,
59
+ participant: quoted?.key?.participant || content.sender,
60
+ quotedMessage: quoted?.message
61
+ }
62
+ }
63
+ };
64
+ }
65
+ return {
66
+ requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
67
+ expiryTimestamp: data.expiry || 0,
68
+ amount1000: data.amount || 0,
69
+ currencyCodeIso4217: data.currency || "IDR",
70
+ requestFrom: data.from || "0@s.whatsapp.net",
71
+ noteMessage: notes,
72
+ background: data.background ?? {
73
+ id: "DEFAULT",
74
+ placeholderArgb: 0xfff0f0f0
75
+ }
76
+ })
77
+ };
78
+ } catch (err) {
79
+ console.error("handlePayment error:", err);
80
+ throw err;
81
+ }
82
+ }
83
+
84
+ async handleProduct(content, jid, quoted) {
85
+ try {
86
+ const {
87
+ title = "",
88
+ description = "",
89
+ thumbnail,
90
+ productId,
91
+ retailerId,
92
+ url,
93
+ body = "",
94
+ footer = "",
95
+ buttons = [],
96
+ priceAmount1000 = null,
97
+ currencyCode = "IDR"
98
+ } = content.productMessage || {};
99
+ let productImage = null;
100
+ if (thumbnail) {
101
+ try {
102
+ if (Buffer.isBuffer(thumbnail)) {
103
+ const res = await this.utils.generateWAMessageContent({ image: thumbnail }, { upload: this.waUploadToServer });
104
+ productImage = res?.imageMessage || res?.message?.imageMessage || null;
105
+ } else if (typeof thumbnail === "object" && thumbnail.url) {
106
+ const res = await this.utils.generateWAMessageContent({ image: { url: thumbnail.url } }, { upload: this.waUploadToServer });
107
+ productImage = res?.imageMessage || res?.message?.imageMessage || null;
108
+ }
109
+ } catch {}
110
+ }
111
+ const product = {
112
+ productId,
113
+ title,
114
+ description,
115
+ currencyCode,
116
+ priceAmount1000,
117
+ retailerId,
118
+ url,
119
+ productImageCount: productImage ? 1 : 0
120
+ };
121
+ if (productImage) product.productImage = productImage;
122
+ return {
123
+ viewOnceMessage: {
124
+ message: {
125
+ interactiveMessage: {
126
+ body: { text: body },
127
+ footer: { text: footer },
128
+ header: {
129
+ title,
130
+ hasMediaAttachment: !!productImage,
131
+ productMessage: {
132
+ product,
133
+ businessOwnerJid: "0@s.whatsapp.net"
134
+ }
135
+ },
136
+ nativeFlowMessage: { buttons }
137
+ }
138
+ }
139
+ }
140
+ };
141
+ } catch (err) {
142
+ console.error("handleProduct error:", err);
143
+ throw err;
144
+ }
145
+ }
146
+
147
+ async handleInteractive(content, jid, quoted) {
148
+ try {
149
+ const {
150
+ title,
151
+ footer,
152
+ thumbnail,
153
+ image,
154
+ video,
155
+ document,
156
+ mimetype,
157
+ fileName,
158
+ jpegThumbnail,
159
+ contextInfo,
160
+ externalAdReply,
161
+ buttons = [],
162
+ nativeFlowMessage,
163
+ header
164
+ } = content.interactiveMessage || {};
165
+ let media = null;
166
+ if (thumbnail) {
167
+ media = await this.utils.prepareWAMessageMedia({ image: { url: thumbnail } }, { upload: this.waUploadToServer });
168
+ } else if (image) {
169
+ media = await this.utils.prepareWAMessageMedia(
170
+ typeof image === "object" && image.url ? { image: { url: image.url } } : { image },
171
+ { upload: this.waUploadToServer }
172
+ );
173
+ } else if (video) {
174
+ media = await this.utils.prepareWAMessageMedia(
175
+ typeof video === "object" && video.url ? { video: { url: video.url } } : { video },
176
+ { upload: this.waUploadToServer }
177
+ );
178
+ } else if (document) {
179
+ const docPayload = { document };
180
+ if (jpegThumbnail) {
181
+ docPayload.jpegThumbnail = typeof jpegThumbnail === "object" && jpegThumbnail.url ? { url: jpegThumbnail.url } : jpegThumbnail;
182
+ }
183
+ media = await this.utils.prepareWAMessageMedia(docPayload, { upload: this.waUploadToServer });
184
+ if (fileName) media.documentMessage.fileName = fileName;
185
+ if (mimetype) media.documentMessage.mimetype = mimetype;
186
+ }
187
+ const interactiveMessage = {
188
+ body: { text: title || "" },
189
+ footer: { text: footer || "" }
190
+ };
191
+ if (buttons.length > 0) {
192
+ interactiveMessage.nativeFlowMessage = { buttons };
193
+ if (nativeFlowMessage) Object.assign(interactiveMessage.nativeFlowMessage, nativeFlowMessage);
194
+ } else if (nativeFlowMessage) {
195
+ interactiveMessage.nativeFlowMessage = nativeFlowMessage;
196
+ }
197
+ if (media) {
198
+ const headerMedia = {};
199
+ if (media.imageMessage) headerMedia.imageMessage = media.imageMessage;
200
+ if (media.videoMessage) headerMedia.videoMessage = media.videoMessage;
201
+ if (media.documentMessage) headerMedia.documentMessage = media.documentMessage;
202
+ interactiveMessage.header = { title: header || "", hasMediaAttachment: true, ...headerMedia };
203
+ } else {
204
+ interactiveMessage.header = { title: header || "", hasMediaAttachment: false };
205
+ }
206
+ let finalContextInfo = {};
207
+ if (contextInfo) {
208
+ finalContextInfo = {
209
+ mentionedJid: contextInfo.mentionedJid || [],
210
+ forwardingScore: contextInfo.forwardingScore || 0,
211
+ isForwarded: contextInfo.isForwarded || false,
212
+ ...contextInfo
213
+ };
214
+ }
215
+ if (externalAdReply) {
216
+ finalContextInfo.externalAdReply = {
217
+ title: externalAdReply.title || "",
218
+ body: externalAdReply.body || "",
219
+ mediaType: externalAdReply.mediaType || 1,
220
+ thumbnailUrl: externalAdReply.thumbnailUrl || "",
221
+ mediaUrl: externalAdReply.mediaUrl || "",
222
+ sourceUrl: externalAdReply.sourceUrl || "",
223
+ showAdAttribution: externalAdReply.showAdAttribution || false,
224
+ renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
225
+ ...externalAdReply
226
+ };
227
+ }
228
+ if (Object.keys(finalContextInfo).length > 0) {
229
+ interactiveMessage.contextInfo = finalContextInfo;
230
+ }
231
+ return { interactiveMessage };
232
+ } catch (err) {
233
+ console.error("handleInteractive error:", err);
234
+ throw err;
235
+ }
236
+ }
237
+
238
+ async handleAlbum(content, jid, quoted) {
239
+ try {
240
+ const array = Array.isArray(content.albumMessage) ? content.albumMessage : [];
241
+ if (array.length === 0) throw new Error("albumMessage harus berupa array dengan isi media");
242
+ const album = await this.utils.generateWAMessageFromContent(
243
+ jid,
244
+ {
245
+ messageContextInfo: { messageSecret: crypto.randomBytes(32) },
246
+ albumMessage: {
247
+ expectedImageCount: array.filter((a) => a.image).length,
248
+ expectedVideoCount: array.filter((a) => a.video).length
249
+ }
250
+ },
251
+ {
252
+ userJid: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net",
253
+ quoted,
254
+ upload: this.waUploadToServer
255
+ }
256
+ );
257
+ await this.relayMessage(jid, album.message, { messageId: album.key.id });
258
+ for (const item of array) {
259
+ const img = await this.utils.generateWAMessage(jid, item, { upload: this.waUploadToServer });
260
+ img.message.messageContextInfo = {
261
+ messageSecret: crypto.randomBytes(32),
262
+ messageAssociation: {
263
+ associationType: 1,
264
+ parentMessageKey: album.key
265
+ },
266
+ participant: "0@s.whatsapp.net",
267
+ remoteJid: "status@broadcast",
268
+ forwardingScore: 99999,
269
+ isForwarded: true,
270
+ mentionedJid: [jid],
271
+ starred: true,
272
+ labels: ["Y", "Important"],
273
+ isHighlighted: true,
274
+ businessMessageForwardInfo: { businessOwnerJid: jid },
275
+ dataSharingContext: { showMmDisclosure: true }
276
+ };
277
+ img.message.forwardedNewsletterMessageInfo = {
278
+ newsletterJid: "0@newsletter",
279
+ serverMessageId: 1,
280
+ newsletterName: "WhatsApp",
281
+ contentType: 1,
282
+ timestamp: new Date().toISOString(),
283
+ senderName: "kikyy dugonggg",
284
+ content: "Text Message",
285
+ priority: "high",
286
+ status: "sent"
287
+ };
288
+ img.message.disappearingMode = {
289
+ initiator: 3,
290
+ trigger: 4,
291
+ initiatorDeviceJid: jid,
292
+ initiatedByExternalService: true,
293
+ initiatedByUserDevice: true,
294
+ initiatedBySystem: true,
295
+ initiatedByServer: true,
296
+ initiatedByAdmin: true,
297
+ initiatedByUser: true,
298
+ initiatedByApp: true,
299
+ initiatedByBot: true,
300
+ initiatedByMe: true
301
+ };
302
+ await this.relayMessage(jid, img.message, {
303
+ messageId: img.key.id,
304
+ quoted: {
305
+ key: {
306
+ remoteJid: album.key.remoteJid,
307
+ id: album.key.id,
308
+ fromMe: true,
309
+ participant: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net"
310
+ },
311
+ message: album.message
312
+ }
313
+ });
314
+ }
315
+ return album;
316
+ } catch (err) {
317
+ console.error("handleAlbum error:", err);
318
+ throw err;
319
+ }
320
+ }
321
+
322
+ async handleEvent(content, jid, quoted) {
323
+ try {
324
+ const eventData = content.eventMessage;
325
+ if (!eventData) throw new Error("Missing eventMessage");
326
+ const msg = await this.utils.generateWAMessageFromContent(
327
+ jid,
328
+ {
329
+ viewOnceMessage: {
330
+ message: {
331
+ messageContextInfo: {
332
+ deviceListMetadata: {},
333
+ deviceListMetadataVersion: 2,
334
+ messageSecret: crypto.randomBytes(32),
335
+ supportPayload: JSON.stringify({
336
+ version: 2,
337
+ is_ai_message: true,
338
+ should_show_system_message: true,
339
+ ticket_id: crypto.randomBytes(16).toString("hex")
340
+ })
341
+ },
342
+ eventMessage: {
343
+ contextInfo: {
344
+ mentionedJid: [jid],
345
+ participant: jid,
346
+ remoteJid: "status@broadcast",
347
+ forwardedNewsletterMessageInfo: {
348
+ newsletterName: "shenvn.",
349
+ newsletterJid: "120363297591152843@newsletter",
350
+ serverMessageId: 1
351
+ }
352
+ },
353
+ isCanceled: eventData.isCanceled || false,
354
+ name: eventData.name,
355
+ description: eventData.description,
356
+ location: eventData.location || {
357
+ degreesLatitude: 0,
358
+ degreesLongitude: 0,
359
+ name: "Location"
360
+ },
361
+ joinLink: eventData.joinLink || "",
362
+ startTime: typeof eventData.startTime === "string" ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
363
+ endTime: typeof eventData.endTime === "string" ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
364
+ extraGuestsAllowed: eventData.extraGuestsAllowed !== false
365
+ }
366
+ }
367
+ }
368
+ },
369
+ { quoted }
370
+ );
371
+ await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
372
+ return msg;
373
+ } catch (err) {
374
+ console.error("handleEvent error:", err);
375
+ throw err;
376
+ }
377
+ }
378
+
379
+ async handlePollResult(content, jid, quoted) {
380
+ try {
381
+ const pollData = content.pollResultMessage;
382
+ if (!pollData) throw new Error("Missing pollResultMessage");
383
+ const msg = await this.utils.generateWAMessageFromContent(
384
+ jid,
385
+ {
386
+ pollResultSnapshotMessage: {
387
+ name: pollData.name,
388
+ pollVotes: (pollData.pollVotes || []).map((v) => ({
389
+ optionName: v.optionName,
390
+ optionVoteCount: typeof v.optionVoteCount === "number" ? v.optionVoteCount.toString() : v.optionVoteCount
391
+ }))
392
+ }
393
+ },
394
+ {
395
+ userJid: this.utils.generateMessageID().split("@")[0] + "@s.whatsapp.net",
396
+ quoted
397
+ }
398
+ );
399
+ await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
400
+ return msg;
401
+ } catch (err) {
402
+ console.error("handlePollResult error:", err);
403
+ throw err;
404
+ }
405
+ }
406
+
407
+ async handleGroupStory(content, jid, quoted) {
408
+ try {
409
+ const storyData = content.groupStatusMessage;
410
+ if (!storyData) throw new Error("Missing groupStatusMessage");
411
+ let waMsgContent;
412
+ if (storyData.message) {
413
+ waMsgContent = storyData;
414
+ } else if (typeof this.bail?.generateWAMessageContent === "function") {
415
+ waMsgContent = await this.bail.generateWAMessageContent(storyData, {
416
+ upload: this.waUploadToServer
417
+ });
418
+ } else if (typeof this.utils?.generateWAMessageContent === "function") {
419
+ waMsgContent = await this.utils.generateWAMessageContent(storyData, {
420
+ upload: this.waUploadToServer
421
+ });
422
+ } else if (typeof this.utils?.prepareMessageContent === "function") {
423
+ waMsgContent = await this.utils.prepareMessageContent(storyData, {
424
+ upload: this.waUploadToServer
425
+ });
426
+ } else {
427
+ waMsgContent = await Utils_1.generateWAMessageContent(storyData, {
428
+ upload: this.waUploadToServer
429
+ });
430
+ }
431
+ const msg = {
432
+ message: {
433
+ groupStatusMessageV2: {
434
+ message: waMsgContent.message || waMsgContent
435
+ }
436
+ }
437
+ };
438
+ return await this.relayMessage(jid, msg.message, {
439
+ messageId: this.bail.generateMessageID()
440
+ });
441
+ } catch (err) {
442
+ console.error("handleGroupStory error:", err);
443
+ throw err;
444
+ }
445
+ }
446
+ }
447
+
448
+ module.exports = RexxHayanasi;