@ryuu-reinzz/haruka-lib 3.0.0 → 3.2.0
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/main/socket.js +18 -56
- package/package.json +1 -1
package/main/socket.js
CHANGED
|
@@ -179,7 +179,6 @@ export default function addProperty(socket, baileys) {
|
|
|
179
179
|
document = null,
|
|
180
180
|
fileName = null,
|
|
181
181
|
mimetype = null,
|
|
182
|
-
jpegThumbnail = null,
|
|
183
182
|
location = null,
|
|
184
183
|
product = null,
|
|
185
184
|
businessOwnerJid = null,
|
|
@@ -187,7 +186,7 @@ export default function addProperty(socket, baileys) {
|
|
|
187
186
|
bottom_sheet = false,
|
|
188
187
|
bottom_name = ""
|
|
189
188
|
} = content;
|
|
190
|
-
|
|
189
|
+
|
|
191
190
|
|
|
192
191
|
if (!Array.isArray(buttons) || buttons.length === 0) {
|
|
193
192
|
throw new Error("buttons must be a non-empty array");
|
|
@@ -281,57 +280,20 @@ export default function addProperty(socket, baileys) {
|
|
|
281
280
|
videoMessage: preparedMedia.videoMessage,
|
|
282
281
|
};
|
|
283
282
|
} else if (document) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
mediaInput.document = {
|
|
292
|
-
url: document.url
|
|
293
|
-
};
|
|
294
|
-
} else if (typeof document === "string") {
|
|
295
|
-
mediaInput.document = {
|
|
296
|
-
url: document
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (fileName) {
|
|
301
|
-
if (typeof mediaInput.document === "object") {
|
|
302
|
-
mediaInput.document.fileName = fileName;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (mimetype) {
|
|
307
|
-
if (typeof mediaInput.document === "object") {
|
|
308
|
-
mediaInput.document.mimetype = mimetype;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (jpegThumbnail) {
|
|
313
|
-
if (typeof mediaInput.document === "object") {
|
|
314
|
-
if (Buffer.isBuffer(jpegThumbnail)) {
|
|
315
|
-
mediaInput.document.jpegThumbnail = jpegThumbnail;
|
|
316
|
-
} else if (typeof jpegThumbnail === "string") {
|
|
317
|
-
try {
|
|
318
|
-
const response = await fetch(jpegThumbnail);
|
|
319
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
320
|
-
mediaInput.document.jpegThumbnail = Buffer.from(arrayBuffer);
|
|
321
|
-
} catch {
|
|
322
|
-
//
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
283
|
+
if (!fileName) throw new Error("fileName requiered");
|
|
284
|
+
if (!mimetype) throw new Error("mimetype requiered");
|
|
285
|
+
const mediaInput = {
|
|
286
|
+
document: document,
|
|
287
|
+
fileName: fileName,
|
|
288
|
+
mimetype: mimetype
|
|
289
|
+
};
|
|
328
290
|
const preparedMedia = await prepareWAMessageMedia(mediaInput, {
|
|
329
291
|
upload: socket.waUploadToServer,
|
|
330
292
|
});
|
|
331
293
|
|
|
332
294
|
messageContent.header = {
|
|
333
295
|
title: title || "",
|
|
334
|
-
hasMediaAttachment:
|
|
296
|
+
hasMediaAttachment: true,
|
|
335
297
|
documentMessage: preparedMedia.documentMessage,
|
|
336
298
|
};
|
|
337
299
|
} else if (location && typeof location === "object") {
|
|
@@ -413,17 +375,17 @@ export default function addProperty(socket, baileys) {
|
|
|
413
375
|
messageContent.nativeFlowMessage = {
|
|
414
376
|
buttons: processedButtons,
|
|
415
377
|
};
|
|
416
|
-
|
|
378
|
+
|
|
417
379
|
if (bottom_sheet) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
380
|
+
messageContent.nativeFlowMessage.messageParamsJson = JSON.stringify({
|
|
381
|
+
bottom_sheet: {
|
|
382
|
+
in_thread_buttons_limit: 1,
|
|
383
|
+
divider_indices: [1, 2],
|
|
384
|
+
list_title: bottom_name,
|
|
385
|
+
button_title: bottom_name
|
|
386
|
+
}
|
|
425
387
|
});
|
|
426
|
-
|
|
388
|
+
}
|
|
427
389
|
|
|
428
390
|
if (contextInfo.externalAdReply && typeof contextInfo.externalAdReply === "object") {
|
|
429
391
|
messageContent.contextInfo = {
|