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