@dyyxyzz/baileys-mod 6.0.37 → 6.0.41

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.
@@ -8,7 +8,6 @@ const boom_1 = require("@hapi/boom");
8
8
  const node_cache_1 = __importDefault(require("node-cache"));
9
9
  const WAProto_1 = require("../../WAProto");
10
10
  const Defaults_1 = require("../Defaults");
11
- const axios_1 = require("axios")
12
11
  const Types_1 = require("../Types")
13
12
  const Utils_1 = require("../Utils");
14
13
  const link_preview_1 = require("../Utils/link-preview");
@@ -16,7 +15,9 @@ const WABinary_1 = require("../WABinary");
16
15
  const newsletter_1 = require("./newsletter");
17
16
  const WAUSync_1 = require("../WAUSync")
18
17
  const kikyy = require('./dugong');
18
+
19
19
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
20
+
20
21
  const makeMessagesSocket = (config) => {
21
22
  const {
22
23
  logger,
@@ -25,6 +26,7 @@ const makeMessagesSocket = (config) => {
25
26
  options: axiosOptions,
26
27
  patchMessageBeforeSending
27
28
  } = config;
29
+
28
30
  const sock = (0, newsletter_1.makeNewsletterSocket)(config);
29
31
  const {
30
32
  ev,
@@ -40,11 +42,14 @@ const makeMessagesSocket = (config) => {
40
42
  groupToggleEphemeral,
41
43
  executeUSyncQuery
42
44
  } = sock;
45
+
43
46
  const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
44
47
  stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
45
48
  useClones: false
46
49
  });
50
+
47
51
  let mediaConn;
52
+
48
53
  const refreshMediaConn = async (forceGet = false) => {
49
54
  const media = await mediaConn;
50
55
  if (!media || forceGet || (new Date().getTime() - media.fetchDate.getTime()) > media.ttl * 1000) {
@@ -74,10 +79,7 @@ const makeMessagesSocket = (config) => {
74
79
  }
75
80
  return mediaConn;
76
81
  };
77
- /**
78
- * generic send receipt function
79
- * used for receipts of phone call, read, delivery etc.
80
- * */
82
+
81
83
  const sendReceipt = async (jid, participant, messageIds, type) => {
82
84
  const node = {
83
85
  tag: 'receipt',
@@ -118,86 +120,69 @@ const makeMessagesSocket = (config) => {
118
120
  logger.debug({ attrs: node.attrs, messageIds }, 'sending receipt for messages');
119
121
  await sendNode(node);
120
122
  };
121
- /** Correctly bulk send receipts to multiple chats, participants */
123
+
122
124
  const sendReceipts = async (keys, type) => {
123
125
  const recps = (0, Utils_1.aggregateMessageKeysNotFromMe)(keys);
124
126
  for (const { jid, participant, messageIds } of recps) {
125
127
  await sendReceipt(jid, participant, messageIds, type);
126
128
  }
127
129
  };
128
- /** Bulk read messages. Keys can be from different chats & participants */
130
+
129
131
  const readMessages = async (keys) => {
130
132
  const privacySettings = await fetchPrivacySettings();
131
- // based on privacy settings, we have to change the read type
132
133
  const readType = privacySettings.readreceipts === 'all' ? 'read' : 'read-self';
133
134
  await sendReceipts(keys, readType);
134
135
  };
135
- /** Fetch all the devices we've to send a message to */
136
+
136
137
  const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
137
138
  const deviceResults = []
138
-
139
139
  if (!useCache) {
140
140
  logger.debug('not using cache for devices')
141
141
  }
142
-
143
142
  const toFetch = []
144
-
145
143
  jids = Array.from(new Set(jids))
146
-
147
144
  for (let jid of jids) {
148
145
  const user = WABinary_1.jidDecode(jid)?.user
149
-
150
146
  jid = WABinary_1.jidNormalizedUser(jid)
151
-
152
147
  if (useCache) {
153
148
  const devices = userDevicesCache.get(user)
154
-
155
149
  if (devices) {
156
150
  deviceResults.push(...devices)
157
151
  logger.trace({ user }, 'using cache for devices')
158
152
  }
159
-
160
153
  else {
161
154
  toFetch.push(jid)
162
155
  }
163
156
  }
164
-
165
157
  else {
166
158
  toFetch.push(jid)
167
159
  }
168
160
  }
169
-
170
161
  if (!toFetch.length) {
171
162
  return deviceResults
172
163
  }
173
-
174
164
  const query = new WAUSync_1.USyncQuery()
175
165
  .withContext('message')
176
166
  .withDeviceProtocol()
177
-
178
167
  for (const jid of toFetch) {
179
168
  query.withUser(new WAUSync_1.USyncUser().withId(jid))
180
169
  }
181
-
182
170
  const result = await executeUSyncQuery(query)
183
-
184
171
  if (result) {
185
172
  const extracted = Utils_1.extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices)
186
173
  const deviceMap = {}
187
-
188
174
  for (const item of extracted) {
189
175
  deviceMap[item.user] = deviceMap[item.user] || []
190
176
  deviceMap[item.user].push(item)
191
177
  deviceResults.push(item)
192
178
  }
193
-
194
179
  for (const key in deviceMap) {
195
180
  userDevicesCache.set(key, deviceMap[key])
196
181
  }
197
182
  }
198
-
199
183
  return deviceResults
200
184
  }
185
+
201
186
  const assertSessions = async (jids, force) => {
202
187
  let didFetchNewSession = false;
203
188
  let jidsRequiringFetch = [];
@@ -205,12 +190,10 @@ const makeMessagesSocket = (config) => {
205
190
  jidsRequiringFetch = jids;
206
191
  }
207
192
  else {
208
- const addrs = jids.map(jid => (signalRepository
209
- .jidToSignalProtocolAddress(jid)));
193
+ const addrs = jids.map(jid => (signalRepository.jidToSignalProtocolAddress(jid)));
210
194
  const sessions = await authState.keys.get('session', addrs);
211
195
  for (const jid of jids) {
212
- const signalId = signalRepository
213
- .jidToSignalProtocolAddress(jid);
196
+ const signalId = signalRepository.jidToSignalProtocolAddress(jid);
214
197
  if (!sessions[signalId]) {
215
198
  jidsRequiringFetch.push(jid);
216
199
  }
@@ -241,13 +224,11 @@ const makeMessagesSocket = (config) => {
241
224
  }
242
225
  return didFetchNewSession;
243
226
  };
244
-
245
-
227
+
246
228
  const sendPeerDataOperationMessage = async (pdoMessage) => {
247
229
  if (!authState.creds.me?.id) {
248
230
  throw new boom_1.Boom('Not authenticated')
249
231
  }
250
-
251
232
  const protocolMessage = {
252
233
  protocolMessage: {
253
234
  peerDataOperationRequestMessage: pdoMessage,
@@ -258,19 +239,18 @@ const makeMessagesSocket = (config) => {
258
239
  const msgId = await relayMessage(meJid, protocolMessage, {
259
240
  additionalAttributes: {
260
241
  category: 'peer',
261
- // eslint-disable-next-line camelcase
262
242
  push_priority: 'high_force',
263
243
  },
264
244
  });
265
245
  return msgId;
266
246
  };
247
+
267
248
  const createParticipantNodes = async (jids, message, extraAttrs) => {
268
249
  const patched = await patchMessageBeforeSending(message, jids);
269
250
  const bytes = (0, Utils_1.encodeWAMessage)(patched);
270
251
  let shouldIncludeDeviceIdentity = false;
271
252
  const nodes = await Promise.all(jids.map(async (jid) => {
272
- const { type, ciphertext } = await signalRepository
273
- .encryptMessage({ jid, data: bytes });
253
+ const { type, ciphertext } = await signalRepository.encryptMessage({ jid, data: bytes });
274
254
  if (type === 'pkmsg') {
275
255
  shouldIncludeDeviceIdentity = true;
276
256
  }
@@ -278,19 +258,20 @@ const makeMessagesSocket = (config) => {
278
258
  tag: 'to',
279
259
  attrs: { jid },
280
260
  content: [{
281
- tag: 'enc',
282
- attrs: {
283
- v: '2',
284
- type,
285
- ...extraAttrs || {}
286
- },
287
- content: ciphertext
288
- }]
261
+ tag: 'enc',
262
+ attrs: {
263
+ v: '2',
264
+ type,
265
+ ...extraAttrs || {}
266
+ },
267
+ content: ciphertext
268
+ }]
289
269
  };
290
270
  return node;
291
271
  }));
292
272
  return { nodes, shouldIncludeDeviceIdentity };
293
- }; //apela
273
+ };
274
+
294
275
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
295
276
  const meId = authState.creds.me.id;
296
277
  let shouldIncludeDeviceIdentity = false;
@@ -318,16 +299,15 @@ const makeMessagesSocket = (config) => {
318
299
  const extraAttrs = {}
319
300
  const messages = Utils_1.normalizeMessageContent(message)
320
301
  const buttonType = getButtonType(messages);
302
+
321
303
  if (participant) {
322
- // when the retry request is not for a group
323
- // only send to the specific device that asked for a retry
324
- // otherwise the message is sent out to every device that should be a recipient
325
304
  if (!isGroup && !isStatus) {
326
305
  additionalAttributes = { ...additionalAttributes, 'device_fanout': 'false' };
327
306
  }
328
307
  const { user, device } = WABinary_1.jidDecode(participant.jid);
329
308
  devices.push({ user, device });
330
309
  }
310
+
331
311
  await authState.keys.transaction(async () => {
332
312
  const mediaType = getMediaType(messages);
333
313
 
@@ -350,11 +330,9 @@ const makeMessagesSocket = (config) => {
350
330
  if (groupData) {
351
331
  logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
352
332
  }
353
-
354
333
  else if (!isStatus) {
355
334
  groupData = await groupMetadata(jid)
356
335
  }
357
-
358
336
  return groupData;
359
337
  })(),
360
338
  (async () => {
@@ -362,27 +340,15 @@ const makeMessagesSocket = (config) => {
362
340
  const result = await authState.keys.get('sender-key-memory', [jid])
363
341
  return result[jid] || {}
364
342
  }
365
-
366
343
  return {}
367
-
368
344
  })()
369
345
  ]);
346
+
370
347
  if (!participant) {
371
348
  const participantsList = (groupData && !isStatus) ? groupData.participants.map(p => p.id) : []
372
-
373
349
  if (isStatus && statusJidList) {
374
350
  participantsList.push(...statusJidList)
375
351
  }
376
-
377
- // if (!isStatus) {
378
- // const expiration = await getEphemeralGroup(jid)
379
- // additionalAttributes = {
380
- // ...additionalAttributes,
381
- // addressing_mode: 'pn',
382
- // ...expiration ? { expiration: expiration.toString() } : null
383
- // }
384
- // }
385
-
386
352
  const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
387
353
  devices.push(...additionalDevices)
388
354
  }
@@ -395,18 +361,16 @@ const makeMessagesSocket = (config) => {
395
361
  data: bytes,
396
362
  meId,
397
363
  });
398
- const senderKeyJids = [];
399
364
 
365
+ const senderKeyJids = [];
400
366
  for (const { user, device } of devices) {
401
367
  const jid = WABinary_1.jidEncode(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
402
368
  if (!senderKeyMap[jid] || !!participant) {
403
369
  senderKeyJids.push(jid);
404
- // store that this person has had the sender keys sent to them
405
370
  senderKeyMap[jid] = true;
406
371
  }
407
372
  }
408
- // if there are some participants with whom the session has not been established
409
- // if there are, we re-send the senderkey
373
+
410
374
  if (senderKeyJids.length) {
411
375
  logger.debug({ senderKeyJids }, 'sending new sender key');
412
376
  const senderKeyMsg = {
@@ -420,6 +384,7 @@ const makeMessagesSocket = (config) => {
420
384
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
421
385
  participants.push(...result.nodes);
422
386
  }
387
+
423
388
  binaryNodeContent.push({
424
389
  tag: 'enc',
425
390
  attrs: { v: '2', type: 'skmsg', ...extraAttrs },
@@ -428,26 +393,36 @@ const makeMessagesSocket = (config) => {
428
393
  await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
429
394
  }
430
395
  else if (isNewsletter) {
431
- // Message edit
432
396
  if (message.protocolMessage?.editedMessage) {
433
397
  msgId = message.protocolMessage.key?.id
434
398
  message = message.protocolMessage.editedMessage
435
399
  }
436
-
437
- // Message delete
438
400
  if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
439
401
  msgId = message.protocolMessage.key?.id
440
402
  message = {}
441
403
  }
442
-
404
+
405
+ // 🔥 FIX: Deteksi button di newsletter SEBELUM encoding
406
+ const hasButtonParams = buttonType ||
407
+ messages.interactiveMessage?.nativeFlowMessage ||
408
+ messages.buttonsMessage ||
409
+ messages.listMessage;
410
+
411
+ // Patch message dengan button support
443
412
  const patched = await patchMessageBeforeSending(message, [])
444
413
  const bytes = Utils_1.encodeNewsletterMessage(patched)
445
-
414
+
415
+ // Push plaintext content
446
416
  binaryNodeContent.push({
447
417
  tag: 'plaintext',
448
418
  attrs: extraAttrs ? extraAttrs : {},
449
419
  content: bytes
450
420
  })
421
+
422
+ // 🔥 CRITICAL: Tambahin button node untuk newsletter
423
+ if (hasButtonParams) {
424
+ logger.debug({ jid, buttonType }, 'adding button node for newsletter')
425
+ }
451
426
  }
452
427
  else {
453
428
  const { user: meUser } = WABinary_1.jidDecode(meId);
@@ -456,30 +431,27 @@ const makeMessagesSocket = (config) => {
456
431
  if (user !== meUser) {
457
432
  devices.push({ user: meUser })
458
433
  }
459
-
460
434
  if (additionalAttributes?.['category'] !== 'peer') {
461
435
  const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true)
462
-
463
436
  devices.push(...additionalDevices)
464
437
  }
465
438
  }
439
+
466
440
  const allJids = [];
467
441
  const meJids = [];
468
442
  const otherJids = [];
469
443
  for (const { user, device } of devices) {
470
444
  const isMe = user === meUser
471
445
  const jid = WABinary_1.jidEncode(isMe && isLid ? authState.creds?.me?.lid?.split(':')[0] || user : user, isLid ? 'lid' : 's.whatsapp.net', device)
472
-
473
446
  if (isMe) {
474
447
  meJids.push(jid)
475
448
  }
476
-
477
449
  else {
478
450
  otherJids.push(jid)
479
451
  }
480
-
481
452
  allJids.push(jid)
482
453
  }
454
+
483
455
  await assertSessions(allJids, false);
484
456
  const [{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 }, { nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }] = await Promise.all([
485
457
  createParticipantNodes(meJids, meMsg, extraAttrs),
@@ -489,15 +461,14 @@ const makeMessagesSocket = (config) => {
489
461
  participants.push(...otherNodes);
490
462
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
491
463
  }
464
+
492
465
  if (participants.length) {
493
466
  if (additionalAttributes?.['category'] === 'peer') {
494
467
  const peerNode = participants[0]?.content?.[0]
495
-
496
468
  if (peerNode) {
497
- binaryNodeContent.push(peerNode) // push only enc
469
+ binaryNodeContent.push(peerNode)
498
470
  }
499
471
  }
500
-
501
472
  else {
502
473
  binaryNodeContent.push({
503
474
  tag: 'participants',
@@ -516,9 +487,7 @@ const makeMessagesSocket = (config) => {
516
487
  },
517
488
  content: binaryNodeContent
518
489
  }
519
- // if the participant to send to is explicitly specified (generally retry recp)
520
- // ensure the message is only sent to that person
521
- // if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
490
+
522
491
  if (participant) {
523
492
  if (WABinary_1.isJidGroup(destinationJid)) {
524
493
  stanza.attrs.to = destinationJid;
@@ -535,6 +504,7 @@ const makeMessagesSocket = (config) => {
535
504
  else {
536
505
  stanza.attrs.to = destinationJid;
537
506
  }
507
+
538
508
  if (shouldIncludeDeviceIdentity) {
539
509
  stanza.content.push({
540
510
  tag: 'device-identity',
@@ -551,31 +521,39 @@ const makeMessagesSocket = (config) => {
551
521
  biz_bot: '1'
552
522
  }
553
523
  }
554
-
555
524
  const filteredBizBot = WABinary_1.getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
556
-
557
525
  if (filteredBizBot) {
558
526
  stanza.content.push(...additionalNodes)
559
527
  didPushAdditional = true
560
528
  }
561
-
562
529
  else {
563
530
  stanza.content.push(botNode)
564
531
  }
565
532
  }
566
533
 
567
- if(!isNewsletter && buttonType && !isStatus) {
568
- const content = WABinary_1.getAdditionalNode(buttonType)
569
- const filteredNode = WABinary_1.getBinaryNodeFilter(additionalNodes)
570
-
571
- if (filteredNode) {
572
- didPushAdditional = true
573
- stanza.content.push(...additionalNodes)
574
- }
575
- else {
576
- stanza.content.push(...content)
534
+ // 🔥 FIX UTAMA: Support button params untuk SEMUA tipe (termasuk channel/newsletter)
535
+ if (!isStatus) {
536
+ // Deteksi apakah ada button params dalam message
537
+ const hasButtonParams = buttonType ||
538
+ messages.interactiveMessage?.nativeFlowMessage ||
539
+ messages.buttonsMessage ||
540
+ messages.listMessage;
541
+
542
+ if (hasButtonParams) {
543
+ // 🔥 CRITICAL FIX: Newsletter butuh business node meskipun plaintext
544
+ const content = WABinary_1.getAdditionalNode(buttonType || 'interactive')
545
+ const filteredNode = WABinary_1.getBinaryNodeFilter(additionalNodes)
546
+
547
+ if (filteredNode) {
548
+ didPushAdditional = true
549
+ stanza.content.push(...additionalNodes)
550
+ }
551
+ else if (content && content.length > 0) {
552
+ // Push business node bahkan untuk newsletter
553
+ stanza.content.push(...content)
554
+ logger.debug({ jid, buttonType, isNewsletter }, 'added business node for buttons')
555
+ }
577
556
  }
578
- logger.debug({ jid }, 'adding business node')
579
557
  }
580
558
 
581
559
  if (!didPushAdditional && additionalNodes && additionalNodes.length > 0) {
@@ -602,10 +580,10 @@ const makeMessagesSocket = (config) => {
602
580
  }
603
581
 
604
582
  return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
605
- // return msgId;
606
583
  };
584
+
607
585
  const getTypeMessage = (msg) => {
608
- const message = Utils_1.normalizeMessageContent(msg)
586
+ const message = Utils_1.normalizeMessageContent(msg)
609
587
  if (message.reactionMessage) {
610
588
  return 'reaction'
611
589
  }
@@ -690,13 +668,14 @@ const makeMessagesSocket = (config) => {
690
668
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
691
669
  return 'payment_method'
692
670
  }
693
- else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
694
- return 'interactive'
695
- }
696
671
  else if (message.interactiveMessage?.nativeFlowMessage) {
697
672
  return 'native_flow'
698
673
  }
674
+ else if (message.interactiveMessage) {
675
+ return 'interactive'
676
+ }
699
677
  }
678
+
700
679
  const getPrivacyTokens = async (jids) => {
701
680
  const t = Utils_1.unixTimestampSeconds().toString();
702
681
  const result = await query({
@@ -723,9 +702,11 @@ const makeMessagesSocket = (config) => {
723
702
  });
724
703
  return result;
725
704
  }
705
+
726
706
  const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
727
707
  const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
728
708
  const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
709
+
729
710
  return {
730
711
  ...sock,
731
712
  getPrivacyTokens,
@@ -793,117 +774,120 @@ const makeMessagesSocket = (config) => {
793
774
  const { filter = false, quoted } = options;
794
775
  const getParticipantAttr = () => filter ? { participant: { jid } } : {};
795
776
  const messageType = rahmi.detectType(content);
777
+
796
778
  if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
797
779
  typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
798
780
  const { disappearingMessagesInChat } = content
799
-
800
781
  const value = typeof disappearingMessagesInChat === 'boolean' ?
801
782
  (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
802
783
  disappearingMessagesInChat
803
-
804
784
  await groupToggleEphemeral(jid, value)
805
785
  }
806
-
807
786
  else {
808
- let mediaHandle
809
-
810
-
811
- if (messageType) {
812
- switch(messageType) {
813
- case 'PAYMENT':
814
- const paymentContent = await rahmi.handlePayment(content, quoted);
815
- return await relayMessage(jid, paymentContent, {
816
- messageId: Utils_1.generateMessageID(),
817
- ...getParticipantAttr()
818
- });
819
-
820
- case 'PRODUCT':
821
- const productContent = await rahmi.handleProduct(content, jid, quoted);
822
- const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
823
- return await relayMessage(jid, productMsg.message, {
824
- messageId: productMsg.key.id,
825
- ...getParticipantAttr()
826
- });
787
+ if (messageType) {
788
+ switch(messageType) {
789
+ case 'PAYMENT':
790
+ const paymentContent = await rahmi.handlePayment(content, quoted);
791
+ return await relayMessage(jid, paymentContent, {
792
+ messageId: Utils_1.generateMessageID(),
793
+ ...getParticipantAttr()
794
+ });
795
+
796
+ case 'PRODUCT':
797
+ const productContent = await rahmi.handleProduct(content, jid, quoted);
798
+ const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
799
+ return await relayMessage(jid, productMsg.message, {
800
+ messageId: productMsg.key.id,
801
+ ...getParticipantAttr()
802
+ });
803
+
804
+ case 'INTERACTIVE':
805
+ const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
806
+ const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
807
+ return await relayMessage(jid, interactiveMsg.message, {
808
+ messageId: interactiveMsg.key.id,
809
+ ...getParticipantAttr()
810
+ });
811
+
812
+ case 'ALBUM':
813
+ return await rahmi.handleAlbum(content, jid, quoted)
814
+
815
+ case 'EVENT':
816
+ return await rahmi.handleEvent(content, jid, quoted)
817
+
818
+ case 'POLL_RESULT':
819
+ return await rahmi.handlePollResult(content, jid, quoted)
820
+
821
+ case 'GROUP_STORY':
822
+ return await rahmi.handleGroupStory(content, jid, quoted)
823
+ }
824
+ }
827
825
 
828
- case 'INTERACTIVE':
829
- const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
830
- const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
831
- return await relayMessage(jid, interactiveMsg.message, {
832
- messageId: interactiveMsg.key.id,
833
- ...getParticipantAttr()
826
+ const fullMsg = await Utils_1.generateWAMessage(jid, content, {
827
+ logger,
828
+ userJid,
829
+ quoted,
830
+ getUrlInfo: text => link_preview_1.getUrlInfo(text, {
831
+ thumbnailWidth: linkPreviewImageThumbnailWidth,
832
+ fetchOpts: {
833
+ timeout: 3000,
834
+ ...axiosOptions || {}
835
+ },
836
+ logger,
837
+ uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
838
+ }),
839
+ upload: async (readStream, opts) => {
840
+ const up = await waUploadToServer(readStream, {
841
+ ...opts,
842
+ newsletter: WABinary_1.isJidNewsLetter(jid)
834
843
  });
835
- case 'ALBUM':
836
- return await rahmi.handleAlbum(content, jid, quoted)
837
- case 'EVENT':
838
- return await rahmi.handleEvent(content, jid, quoted)
839
- case 'POLL_RESULT':
840
- return await rahmi.handlePollResult(content, jid, quoted)
841
- case 'GROUP_STORY':
842
- return await rahmi.handleGroupStory(content, jid, quoted)
843
- }
844
- }
845
- const fullMsg = await Utils_1.generateWAMessage(jid, content, {
846
- logger,
847
- userJid,
848
- quoted,
849
- getUrlInfo: text => link_preview_1.getUrlInfo(text, {
850
- thumbnailWidth: linkPreviewImageThumbnailWidth,
851
- fetchOpts: {
852
- timeout: 3000,
853
- ...axiosOptions || {}
844
+ return up;
854
845
  },
855
- logger,
856
- uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
857
- }),
858
- upload: async (readStream, opts) => {
859
- const up = await waUploadToServer(readStream, {
860
- ...opts,
861
- newsletter: WABinary_1.isJidNewsLetter(jid)
862
- });
863
- return up;
864
- },
865
- mediaCache: config.mediaCache,
866
- options: config.options,
867
- ...options
868
- });
869
-
870
- const isDeleteMsg = 'delete' in content && !!content.delete;
871
- const isEditMsg = 'edit' in content && !!content.edit;
872
- const isAiMsg = 'ai' in content && !!content.ai;
873
-
874
- const additionalAttributes = {};
875
- const additionalNodes = [];
876
-
877
- if (isDeleteMsg) {
878
- const fromMe = content.delete?.fromMe;
879
- const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
880
- additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
881
- } else if (isEditMsg) {
882
- additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
883
- } else if (isAiMsg) {
884
- additionalNodes.push({
885
- attrs: {
886
- biz_bot: '1'
887
- }, tag: "bot"
846
+ mediaCache: config.mediaCache,
847
+ options: config.options,
848
+ ...options
888
849
  });
889
- }
890
-
891
- await relayMessage(jid, fullMsg.message, {
892
- messageId: fullMsg.key.id,
893
- cachedGroupMetadata: options.cachedGroupMetadata,
894
- additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
895
- additionalAttributes,
896
- statusJidList: options.statusJidList
897
- });
898
-
899
- if (config.emitOwnEvents) {
900
- process.nextTick(() => {
901
- processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
850
+
851
+ const isDeleteMsg = 'delete' in content && !!content.delete;
852
+ const isEditMsg = 'edit' in content && !!content.edit;
853
+ const isAiMsg = 'ai' in content && !!content.ai;
854
+
855
+ const additionalAttributes = {};
856
+ const additionalNodes = [];
857
+
858
+ if (isDeleteMsg) {
859
+ const fromMe = content.delete?.fromMe;
860
+ const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
861
+ additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
862
+ } else if (isEditMsg) {
863
+ additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
864
+ } else if (isAiMsg) {
865
+ additionalNodes.push({
866
+ attrs: {
867
+ biz_bot: '1'
868
+ },
869
+ tag: "bot"
870
+ });
871
+ }
872
+
873
+ await relayMessage(jid, fullMsg.message, {
874
+ messageId: fullMsg.key.id,
875
+ cachedGroupMetadata: options.cachedGroupMetadata,
876
+ additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
877
+ additionalAttributes,
878
+ statusJidList: options.statusJidList,
879
+ AI: isAiMsg
902
880
  });
903
- }
904
- return fullMsg;
881
+
882
+ if (config.emitOwnEvents) {
883
+ process.nextTick(() => {
884
+ processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
885
+ });
886
+ }
887
+ return fullMsg;
905
888
  }
906
889
  }
907
- }
890
+ };
908
891
  };
892
+
909
893
  exports.makeMessagesSocket = makeMessagesSocket;
@@ -93,11 +93,11 @@ const prepareWAMessageMedia = async (message, options) => {
93
93
  { x: 20.840980529785156, y: -47.80188751220703 }
94
94
  ],
95
95
  newsletter: {
96
- newsletterJid: "120363405681118264@newsletter",
96
+ newsletterJid: "120363425809110720@newsletter",
97
97
  serverMessageId: 1, // ← WAJIB 1
98
- newsletterName: "DYYSOMNIA ▪︎ CLOUD",
98
+ newsletterName: "DYYSOMNIA",
99
99
  contentType: "LINK_SNIPPET", // ← WAJIB LINK_SNIPPET
100
- url: "https://whatsapp.com/channel/0029VbBcRiyJ3juskMXqoH10" // ← URL CHANNEL LO
100
+ url: "https://whatsapp.com/channel/0029Vb7uLYxIHphOIWOY8727" // ← URL CHANNEL LO
101
101
 
102
102
  }
103
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyyxyzz/baileys-mod",
3
- "version": "6.0.37",
3
+ "version": "6.0.41",
4
4
  "description": "WhatsApp API Modification",
5
5
  "keywords": [
6
6
  "whatsapp",