@ryuu-reinzz/haruka-lib 3.0.0 → 3.1.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 +36 -36
- package/package.json +1 -1
package/main/socket.js
CHANGED
|
@@ -187,7 +187,7 @@ export default function addProperty(socket, baileys) {
|
|
|
187
187
|
bottom_sheet = false,
|
|
188
188
|
bottom_name = ""
|
|
189
189
|
} = content;
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
|
|
192
192
|
if (!Array.isArray(buttons) || buttons.length === 0) {
|
|
193
193
|
throw new Error("buttons must be a non-empty array");
|
|
@@ -281,47 +281,47 @@ export default function addProperty(socket, baileys) {
|
|
|
281
281
|
videoMessage: preparedMedia.videoMessage,
|
|
282
282
|
};
|
|
283
283
|
} else if (document) {
|
|
284
|
-
const mediaInput = {
|
|
285
|
-
document: {}
|
|
286
|
-
};
|
|
284
|
+
const mediaInput = {};
|
|
287
285
|
|
|
288
286
|
if (Buffer.isBuffer(document)) {
|
|
289
|
-
mediaInput.document = document;
|
|
290
|
-
} else if (typeof document === "object" && document.url) {
|
|
291
287
|
mediaInput.document = {
|
|
292
|
-
|
|
288
|
+
buffer: document
|
|
293
289
|
};
|
|
294
290
|
} else if (typeof document === "string") {
|
|
291
|
+
if (/^https?:\/\//i.test(document)) {
|
|
292
|
+
mediaInput.document = {
|
|
293
|
+
url: document
|
|
294
|
+
};
|
|
295
|
+
} else {
|
|
296
|
+
mediaInput.document = {
|
|
297
|
+
buffer: fs.readFileSync(document)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
} else if (typeof document === "object" && document.url) {
|
|
295
301
|
mediaInput.document = {
|
|
296
|
-
url: document
|
|
302
|
+
url: document.url
|
|
297
303
|
};
|
|
304
|
+
} else {
|
|
305
|
+
throw new Error("Invalid document input");
|
|
298
306
|
}
|
|
299
307
|
|
|
300
308
|
if (fileName) {
|
|
301
|
-
|
|
302
|
-
mediaInput.document.fileName = fileName;
|
|
303
|
-
}
|
|
309
|
+
mediaInput.document.fileName = fileName;
|
|
304
310
|
}
|
|
305
311
|
|
|
306
312
|
if (mimetype) {
|
|
307
|
-
|
|
308
|
-
mediaInput.document.mimetype = mimetype;
|
|
309
|
-
}
|
|
313
|
+
mediaInput.document.mimetype = mimetype;
|
|
310
314
|
}
|
|
311
315
|
|
|
312
316
|
if (jpegThumbnail) {
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
} catch {
|
|
322
|
-
//
|
|
323
|
-
}
|
|
324
|
-
}
|
|
317
|
+
if (Buffer.isBuffer(jpegThumbnail)) {
|
|
318
|
+
mediaInput.document.jpegThumbnail = jpegThumbnail;
|
|
319
|
+
} else if (typeof jpegThumbnail === "string") {
|
|
320
|
+
try {
|
|
321
|
+
const response = await fetch(jpegThumbnail);
|
|
322
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
323
|
+
mediaInput.document.jpegThumbnail = Buffer.from(arrayBuffer);
|
|
324
|
+
} catch {}
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -331,7 +331,7 @@ export default function addProperty(socket, baileys) {
|
|
|
331
331
|
|
|
332
332
|
messageContent.header = {
|
|
333
333
|
title: title || "",
|
|
334
|
-
hasMediaAttachment:
|
|
334
|
+
hasMediaAttachment: true,
|
|
335
335
|
documentMessage: preparedMedia.documentMessage,
|
|
336
336
|
};
|
|
337
337
|
} else if (location && typeof location === "object") {
|
|
@@ -413,17 +413,17 @@ export default function addProperty(socket, baileys) {
|
|
|
413
413
|
messageContent.nativeFlowMessage = {
|
|
414
414
|
buttons: processedButtons,
|
|
415
415
|
};
|
|
416
|
-
|
|
416
|
+
|
|
417
417
|
if (bottom_sheet) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
418
|
+
messageContent.nativeFlowMessage.messageParamsJson = JSON.stringify({
|
|
419
|
+
bottom_sheet: {
|
|
420
|
+
in_thread_buttons_limit: 1,
|
|
421
|
+
divider_indices: [1, 2],
|
|
422
|
+
list_title: bottom_name,
|
|
423
|
+
button_title: bottom_name
|
|
424
|
+
}
|
|
425
425
|
});
|
|
426
|
-
|
|
426
|
+
}
|
|
427
427
|
|
|
428
428
|
if (contextInfo.externalAdReply && typeof contextInfo.externalAdReply === "object") {
|
|
429
429
|
messageContent.contextInfo = {
|