@ryuu-reinzz/haruka-lib 2.7.0 → 3.0.0-beta.2
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 +2 -2
- package/main/socket.js +32 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
# How to use
|
|
10
10
|
``` bash
|
|
11
|
-
npm install @ryuu-reinzz/haruka-lib@
|
|
11
|
+
npm install @ryuu-reinzz/haruka-lib@3.0.0-beta.1
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
*how to use it in JavaScript:*
|
|
@@ -35,7 +35,7 @@ const property = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const conn = makeWASocket({});
|
|
38
|
-
haruka.addProperty(conn,
|
|
38
|
+
haruka.addProperty(conn, property);
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## 1. Send Button
|
package/main/socket.js
CHANGED
|
@@ -16,7 +16,7 @@ const __dirname = dirname(__filename);
|
|
|
16
16
|
* @param {import('baileys').WASocket} socket
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export default function addProperty(socket,
|
|
19
|
+
export default function addProperty(socket, baileys) {
|
|
20
20
|
const {
|
|
21
21
|
proto,
|
|
22
22
|
generateWAMessageFromContent,
|
|
@@ -183,8 +183,11 @@ export default function addProperty(socket, store, smsg, baileys) {
|
|
|
183
183
|
location = null,
|
|
184
184
|
product = null,
|
|
185
185
|
businessOwnerJid = null,
|
|
186
|
-
|
|
186
|
+
contextInfo = {},
|
|
187
|
+
bottom_sheet = false,
|
|
188
|
+
bottom_name = ""
|
|
187
189
|
} = content;
|
|
190
|
+
|
|
188
191
|
|
|
189
192
|
if (!Array.isArray(buttons) || buttons.length === 0) {
|
|
190
193
|
throw new Error("buttons must be a non-empty array");
|
|
@@ -410,27 +413,38 @@ export default function addProperty(socket, store, smsg, baileys) {
|
|
|
410
413
|
messageContent.nativeFlowMessage = {
|
|
411
414
|
buttons: processedButtons,
|
|
412
415
|
};
|
|
416
|
+
|
|
417
|
+
if (bottom_sheet) {
|
|
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
|
+
});
|
|
426
|
+
}
|
|
413
427
|
|
|
414
|
-
if (externalAdReply && typeof externalAdReply === "object") {
|
|
428
|
+
if (contextInfo.externalAdReply && typeof contextInfo.externalAdReply === "object") {
|
|
415
429
|
messageContent.contextInfo = {
|
|
416
430
|
externalAdReply: {
|
|
417
|
-
title: externalAdReply.title || "",
|
|
418
|
-
body: externalAdReply.body || "",
|
|
419
|
-
mediaType: externalAdReply.mediaType || 1,
|
|
420
|
-
sourceUrl: externalAdReply.sourceUrl || externalAdReply.url || "",
|
|
421
|
-
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
422
|
-
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
423
|
-
showAdAttribution: externalAdReply.showAdAttribution !== false,
|
|
424
|
-
containsAutoReply: externalAdReply.containsAutoReply || false,
|
|
425
|
-
...(externalAdReply.mediaUrl && {
|
|
426
|
-
mediaUrl: externalAdReply.mediaUrl,
|
|
431
|
+
title: contextInfo.externalAdReply.title || "",
|
|
432
|
+
body: contextInfo.externalAdReply.body || "",
|
|
433
|
+
mediaType: contextInfo.externalAdReply.mediaType || 1,
|
|
434
|
+
sourceUrl: contextInfo.externalAdReply.sourceUrl || contextInfo.externalAdReply.url || "",
|
|
435
|
+
thumbnailUrl: contextInfo.externalAdReply.thumbnailUrl || "",
|
|
436
|
+
renderLargerThumbnail: contextInfo.externalAdReply.renderLargerThumbnail || false,
|
|
437
|
+
showAdAttribution: contextInfo.externalAdReply.showAdAttribution !== false,
|
|
438
|
+
containsAutoReply: contextInfo.externalAdReply.containsAutoReply || false,
|
|
439
|
+
...(contextInfo.externalAdReply.mediaUrl && {
|
|
440
|
+
mediaUrl: contextInfo.externalAdReply.mediaUrl,
|
|
427
441
|
}),
|
|
428
|
-
...(externalAdReply.thumbnail &&
|
|
429
|
-
Buffer.isBuffer(externalAdReply.thumbnail) && {
|
|
430
|
-
thumbnail: externalAdReply.thumbnail,
|
|
442
|
+
...(contextInfo.externalAdReply.thumbnail &&
|
|
443
|
+
Buffer.isBuffer(contextInfo.externalAdReply.thumbnail) && {
|
|
444
|
+
thumbnail: contextInfo.externalAdReply.thumbnail,
|
|
431
445
|
}),
|
|
432
|
-
...(externalAdReply.jpegThumbnail && {
|
|
433
|
-
jpegThumbnail: externalAdReply.jpegThumbnail,
|
|
446
|
+
...(contextInfo.externalAdReply.jpegThumbnail && {
|
|
447
|
+
jpegThumbnail: contextInfo.externalAdReply.jpegThumbnail,
|
|
434
448
|
}),
|
|
435
449
|
},
|
|
436
450
|
...(options.mentionedJid && {
|