alipclutch-baileys 8.5.1 → 8.5.3
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 +11 -5
- package/lib/Socket/messages-send.js +19 -67
- package/lib/Socket/setup.js +380 -332
- package/lib/Socket/setup.ts +201 -117
- package/lib/Utils/messages.js +15 -3
- package/package.json +1 -1
package/lib/Socket/setup.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/* modified by alip */
|
|
2
2
|
const WAProto = require('../../WAProto').proto;
|
|
3
3
|
const crypto = require('crypto');
|
|
4
|
-
|
|
5
|
-
// const { jidNormalizedUser, isJidGroup, unixTimestampSeconds } = require('../WABinary');
|
|
4
|
+
const Utils_1 = require("../Utils");
|
|
6
5
|
|
|
7
6
|
class yaoii {
|
|
8
7
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
9
8
|
this.utils = utils;
|
|
10
9
|
this.relayMessage = relayMessageFn
|
|
11
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
|
+
};
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
detectType(content) {
|
|
@@ -17,9 +21,10 @@ class yaoii {
|
|
|
17
21
|
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
18
22
|
if (content.albumMessage) return 'ALBUM';
|
|
19
23
|
if (content.eventMessage) return 'EVENT';
|
|
20
|
-
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
21
|
-
if (content.listMessage) return 'LIST';
|
|
22
|
-
if (content.
|
|
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';
|
|
23
28
|
return null;
|
|
24
29
|
}
|
|
25
30
|
|
|
@@ -77,6 +82,8 @@ class yaoii {
|
|
|
77
82
|
body = "",
|
|
78
83
|
footer = "",
|
|
79
84
|
buttons = [],
|
|
85
|
+
priceAmount1000 = null,
|
|
86
|
+
currencyCode = "IDR"
|
|
80
87
|
} = content.productMessage;
|
|
81
88
|
|
|
82
89
|
let productImage;
|
|
@@ -110,6 +117,8 @@ class yaoii {
|
|
|
110
117
|
productId,
|
|
111
118
|
title,
|
|
112
119
|
description,
|
|
120
|
+
currencyCode,
|
|
121
|
+
priceAmount1000,
|
|
113
122
|
retailerId,
|
|
114
123
|
url,
|
|
115
124
|
productImageCount: 1
|
|
@@ -138,13 +147,13 @@ class yaoii {
|
|
|
138
147
|
contextInfo,
|
|
139
148
|
externalAdReply,
|
|
140
149
|
buttons = [],
|
|
141
|
-
nativeFlowMessage
|
|
150
|
+
nativeFlowMessage,
|
|
151
|
+
header
|
|
142
152
|
} = content.interactiveMessage;
|
|
143
153
|
|
|
144
154
|
let media = null;
|
|
145
155
|
let mediaType = null;
|
|
146
156
|
|
|
147
|
-
// Fungsi untuk mengambil media dari URL atau Buffer
|
|
148
157
|
const getMediaPayload = (mediaData, type) => {
|
|
149
158
|
if (typeof mediaData === 'object' && mediaData.url) {
|
|
150
159
|
return { [type]: { url: mediaData.url } };
|
|
@@ -213,20 +222,19 @@ class yaoii {
|
|
|
213
222
|
|
|
214
223
|
if (media) {
|
|
215
224
|
interactiveMessage.header = {
|
|
216
|
-
title: "",
|
|
225
|
+
title: header || "",
|
|
217
226
|
hasMediaAttachment: true,
|
|
218
227
|
...media
|
|
219
228
|
};
|
|
220
229
|
} else {
|
|
221
230
|
interactiveMessage.header = {
|
|
222
|
-
title: "",
|
|
231
|
+
title: header || "",
|
|
223
232
|
hasMediaAttachment: false
|
|
224
233
|
};
|
|
225
234
|
}
|
|
226
235
|
|
|
227
236
|
let finalContextInfo = {};
|
|
228
237
|
|
|
229
|
-
// Gabungkan contextInfo dari input dan quoted
|
|
230
238
|
const inputContextInfo = contextInfo || {};
|
|
231
239
|
if (quoted) {
|
|
232
240
|
inputContextInfo.stanzaId = quoted.key.id;
|
|
@@ -268,19 +276,16 @@ class yaoii {
|
|
|
268
276
|
|
|
269
277
|
async handleAlbum(content, jid, quoted) {
|
|
270
278
|
const array = content.albumMessage;
|
|
271
|
-
|
|
272
|
-
// --- 1. Buat Message Album Utama ---
|
|
273
279
|
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
274
280
|
messageContextInfo: {
|
|
275
281
|
messageSecret: crypto.randomBytes(32),
|
|
276
282
|
},
|
|
277
283
|
albumMessage: {
|
|
278
|
-
expectedImageCount: array.filter((a) => a.image).length,
|
|
279
|
-
expectedVideoCount: array.filter((a) => a.video).length,
|
|
284
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
285
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
280
286
|
},
|
|
281
287
|
}, {
|
|
282
|
-
|
|
283
|
-
userJid: this.utils.jidNormalizedUser(this.utils.auth.creds.me.id),
|
|
288
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
284
289
|
quoted,
|
|
285
290
|
upload: this.waUploadToServer
|
|
286
291
|
});
|
|
@@ -289,26 +294,69 @@ class yaoii {
|
|
|
289
294
|
messageId: album.key.id,
|
|
290
295
|
});
|
|
291
296
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const img = await this.utils.generateWAMessage(jid, item, {
|
|
297
|
+
for (let content of array) {
|
|
298
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
295
299
|
upload: this.waUploadToServer,
|
|
296
300
|
});
|
|
297
301
|
|
|
298
|
-
// Konteks Album/Message Association
|
|
299
302
|
img.message.messageContextInfo = {
|
|
300
|
-
|
|
303
|
+
messageSecret: crypto.randomBytes(32),
|
|
301
304
|
messageAssociation: {
|
|
302
|
-
associationType: 1,
|
|
305
|
+
associationType: 1,
|
|
303
306
|
parentMessageKey: album.key,
|
|
304
307
|
},
|
|
305
|
-
|
|
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,
|
|
306
349
|
};
|
|
307
350
|
|
|
308
351
|
await this.relayMessage(jid, img.message, {
|
|
309
352
|
messageId: img.key.id,
|
|
310
353
|
quoted: {
|
|
311
|
-
key:
|
|
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
|
+
},
|
|
312
360
|
message: album.message,
|
|
313
361
|
},
|
|
314
362
|
});
|
|
@@ -326,13 +374,23 @@ class yaoii {
|
|
|
326
374
|
deviceListMetadata: {},
|
|
327
375
|
deviceListMetadataVersion: 2,
|
|
328
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
|
+
})
|
|
329
383
|
},
|
|
330
384
|
eventMessage: {
|
|
331
385
|
contextInfo: {
|
|
332
386
|
mentionedJid: [jid],
|
|
333
387
|
participant: jid,
|
|
334
388
|
remoteJid: "status@broadcast",
|
|
335
|
-
|
|
389
|
+
forwardedNewsletterMessageInfo: {
|
|
390
|
+
newsletterName: "alip clutch.",
|
|
391
|
+
newsletterJid: "120363401467939056@newsletter",
|
|
392
|
+
serverMessageId: 1
|
|
393
|
+
},
|
|
336
394
|
...(quoted ? {
|
|
337
395
|
stanzaId: quoted.key.id,
|
|
338
396
|
participant: quoted.key.participant || quoted.key.remoteJid,
|
|
@@ -376,7 +434,7 @@ class yaoii {
|
|
|
376
434
|
}))
|
|
377
435
|
}
|
|
378
436
|
}, {
|
|
379
|
-
userJid: this.utils.
|
|
437
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
380
438
|
quoted
|
|
381
439
|
});
|
|
382
440
|
|
|
@@ -387,7 +445,6 @@ class yaoii {
|
|
|
387
445
|
return msg;
|
|
388
446
|
}
|
|
389
447
|
|
|
390
|
-
// --- BARU: handleList ---
|
|
391
448
|
async handleList(content, jid, quoted) {
|
|
392
449
|
const data = content.listMessage;
|
|
393
450
|
|
|
@@ -413,7 +470,6 @@ class yaoii {
|
|
|
413
470
|
|
|
414
471
|
const contextInfo = data.contextInfo || {};
|
|
415
472
|
|
|
416
|
-
// Tambahkan quoted ke contextInfo
|
|
417
473
|
if (quoted) {
|
|
418
474
|
contextInfo.stanzaId = quoted.key.id;
|
|
419
475
|
contextInfo.participant = quoted.key.participant || quoted.key.remoteJid;
|
|
@@ -434,105 +490,133 @@ class yaoii {
|
|
|
434
490
|
|
|
435
491
|
return msg;
|
|
436
492
|
}
|
|
437
|
-
|
|
438
|
-
// --- BARU: handleGroupStory (SWGC) ---
|
|
439
|
-
async handleGroupStory(content, jid, quoted) {
|
|
440
|
-
const { groupStoryMessage } = content;
|
|
441
|
-
|
|
442
|
-
// Asumsi isJidGroup tersedia di this.utils
|
|
443
|
-
if (!this.utils.isJidGroup(jid)) {
|
|
444
|
-
throw new Error("Group Story messages must be sent to a group JID.");
|
|
445
|
-
}
|
|
446
493
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const mediaData = groupStoryMessage.image || groupStoryMessage.video;
|
|
452
|
-
const mediaType = groupStoryMessage.image ? 'image' : 'video';
|
|
494
|
+
async handleGroupStory(content, jid, quoted) {
|
|
495
|
+
if (content.groupStatusMessage) {
|
|
496
|
+
const storyData = content.groupStatusMessage;
|
|
497
|
+
let waMsgContent;
|
|
453
498
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
stream = mediaData;
|
|
457
|
-
} else if (typeof mediaData === 'object' && mediaData.url) {
|
|
458
|
-
// Asumsi waUploadToServer bisa menangani URL (atau Anda fetch dulu)
|
|
459
|
-
// Untuk contoh ini, saya asumsikan ia menangani Buffer/Stream
|
|
460
|
-
throw new Error("Group Story media from URL is not supported in this simplified handler. Use Buffer or fetch it first.");
|
|
499
|
+
if (storyData.message) {
|
|
500
|
+
waMsgContent = storyData;
|
|
461
501
|
} else {
|
|
462
|
-
|
|
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
|
+
}
|
|
463
519
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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()
|
|
468
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 = {};
|
|
469
541
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
// Asumsi unixTimestampSeconds tersedia di this.utils
|
|
482
|
-
mediaKeyTimestamp: this.utils.unixTimestampSeconds(),
|
|
483
|
-
jpegThumbnail: groupStoryMessage.jpegThumbnail,
|
|
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');
|
|
484
553
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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
|
+
},
|
|
491
602
|
}
|
|
492
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;
|
|
493
617
|
} else {
|
|
494
|
-
throw new Error("
|
|
618
|
+
throw new Error("Invalid content for handleGroupStory. Neither groupStatusMessage nor groupStoryMessage found.");
|
|
495
619
|
}
|
|
496
|
-
|
|
497
|
-
// 2. Bungkus ke dalam GroupStatusMessage
|
|
498
|
-
const groupStatusMessageContent = {
|
|
499
|
-
groupStatusMessage: {
|
|
500
|
-
key: {
|
|
501
|
-
remoteJid: jid,
|
|
502
|
-
fromMe: true,
|
|
503
|
-
id: this.utils.generateMessageID(),
|
|
504
|
-
// Asumsi jidNormalizedUser dan auth state tersedia di this.utils
|
|
505
|
-
participant: this.utils.jidNormalizedUser(this.utils.auth.creds.me.id)
|
|
506
|
-
},
|
|
507
|
-
message: {
|
|
508
|
-
...mediaContent,
|
|
509
|
-
// Tambahkan context info jika ada quoted atau mentions
|
|
510
|
-
contextInfo: {
|
|
511
|
-
mentionedJid: groupStoryMessage.mentions || [],
|
|
512
|
-
...(quoted ? {
|
|
513
|
-
stanzaId: quoted.key.id,
|
|
514
|
-
participant: quoted.key.participant || quoted.key.remoteJid,
|
|
515
|
-
quotedMessage: quoted.message
|
|
516
|
-
} : {})
|
|
517
|
-
}
|
|
518
|
-
},
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
// 3. Generate WAMessage
|
|
523
|
-
const fullMsg = await this.utils.generateWAMessageFromContent(
|
|
524
|
-
jid,
|
|
525
|
-
groupStatusMessageContent,
|
|
526
|
-
{ quoted, logger: this.utils.logger }
|
|
527
|
-
);
|
|
528
|
-
|
|
529
|
-
// 4. Relay Message
|
|
530
|
-
await this.relayMessage(jid, fullMsg.message, {
|
|
531
|
-
messageId: fullMsg.key.id,
|
|
532
|
-
type: 'group_status',
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
return fullMsg;
|
|
536
620
|
}
|
|
537
621
|
}
|
|
538
622
|
|
package/lib/Utils/messages.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* modified by alip*/
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -224,10 +225,21 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
224
225
|
media: undefined
|
|
225
226
|
})
|
|
226
227
|
});
|
|
228
|
+
|
|
229
|
+
// START PERBAIKAN PTV UNTUK CHANNEL
|
|
227
230
|
if (uploadData.ptv) {
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
if (options.newsletter) {
|
|
232
|
+
// Untuk Channel (Newsletter), set flag viewOnce di videoMessage
|
|
233
|
+
obj.videoMessage = obj.videoMessage;
|
|
234
|
+
obj.videoMessage.viewOnce = true;
|
|
235
|
+
} else {
|
|
236
|
+
// Untuk chat biasa, gunakan ptvMessage
|
|
237
|
+
obj.ptvMessage = obj.videoMessage;
|
|
238
|
+
delete obj.videoMessage;
|
|
239
|
+
}
|
|
230
240
|
}
|
|
241
|
+
// END PERBAIKAN PTV UNTUK CHANNEL
|
|
242
|
+
|
|
231
243
|
if (cacheableKey) {
|
|
232
244
|
logger === null || logger === void 0 ? void 0 : logger.debug({ cacheableKey }, 'set cache');
|
|
233
245
|
options.mediaCache.set(cacheableKey, Types_1.WAProto.Message.encode(obj).finish());
|
|
@@ -419,7 +431,7 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
419
431
|
}
|
|
420
432
|
}
|
|
421
433
|
else if ('ptv' in message && message.ptv) {
|
|
422
|
-
const { videoMessage } = await (0, exports.prepareWAMessageMedia)({ video: message.video }, options);
|
|
434
|
+
const { videoMessage } = await (0, exports.prepareWAMessageMedia)({ video: message.video, ptv: true }, options); // <-- Perbaikan ptv: true
|
|
423
435
|
m.ptvMessage = videoMessage;
|
|
424
436
|
}
|
|
425
437
|
else if ('product' in message) {
|