@fvckerss/baileys 1.0.9 → 1.0.11
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 +45 -63
- package/lib/Types/RichType.js +1 -0
- package/lib/Utils/rich-message-utils.js +83 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align='center'><img alt="Baileys logo" src="https://upload.fvckers.my.id/
|
|
1
|
+
<h1 align='center'><img alt="Baileys logo" src="https://upload.fvckers.my.id/jsezegmrak03cc.jpg" height="200"/></h1>
|
|
2
2
|
|
|
3
3
|
----
|
|
4
4
|
|
|
@@ -197,19 +197,40 @@ END:VCARD`
|
|
|
197
197
|
|
|
198
198
|
---
|
|
199
199
|
|
|
200
|
-
### ✨ Rich
|
|
200
|
+
### ✨ Rich Product Card
|
|
201
201
|
|
|
202
202
|
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
await sock.sendMessage(jid, {
|
|
204
|
+
disclaimerText: "🚀 SWIPER FVCK",
|
|
205
|
+
product: [{
|
|
206
|
+
title: "FVCKERS",
|
|
207
|
+
brand: "Swiper Fvck",
|
|
208
|
+
price: "Rp 999.999.999",
|
|
209
|
+
sale_price: "Rp 666.666.666",
|
|
210
|
+
product_url: "https://wa.me/6283895883216",
|
|
211
|
+
image_url: "https://c.termai.cc/i116/Z6flN6.jpg",
|
|
212
|
+
icon_url: "https://static.nike.com/a/images/t_PDP_1280_v1/f_auto,q_auto:eco/additional_image_1.png"
|
|
213
|
+
}],
|
|
214
|
+
|
|
215
|
+
suggested: [
|
|
216
|
+
"SWIPER FVCK",
|
|
217
|
+
"FVCKERS"
|
|
218
|
+
],
|
|
219
|
+
|
|
220
|
+
footerText: 'Generate By Fvckers'
|
|
221
|
+
}, {
|
|
222
|
+
quoted: m
|
|
223
|
+
})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
207
227
|
|
|
208
|
-
|
|
209
|
-
headerText: "JavaScript Example",
|
|
228
|
+
### ✨ Rich Code Block
|
|
210
229
|
|
|
211
|
-
|
|
212
|
-
|
|
230
|
+
```
|
|
231
|
+
await sock.sendMessage(jid, {
|
|
232
|
+
headerText: "# JavaScript Example",
|
|
233
|
+
contentText: "Berikut contoh code sederhana",
|
|
213
234
|
|
|
214
235
|
code: `
|
|
215
236
|
async function hello() {
|
|
@@ -218,23 +239,8 @@ async function hello() {
|
|
|
218
239
|
`,
|
|
219
240
|
|
|
220
241
|
language: "javascript",
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
const msg = generateWAMessageFromContent(
|
|
226
|
-
jid,
|
|
227
|
-
rich,
|
|
228
|
-
{}
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
await conn.relayMessage(
|
|
232
|
-
jid,
|
|
233
|
-
msg.message,
|
|
234
|
-
{
|
|
235
|
-
messageId: msg.key.id
|
|
236
|
-
}
|
|
237
|
-
)
|
|
242
|
+
footerText: 'Generate By Fvckers'
|
|
243
|
+
}, { quoted: m })
|
|
238
244
|
```
|
|
239
245
|
|
|
240
246
|
---
|
|
@@ -242,37 +248,18 @@ await conn.relayMessage(
|
|
|
242
248
|
### ✨ Rich Table
|
|
243
249
|
|
|
244
250
|
```
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
} = require("@fvckerss/baileys")
|
|
249
|
-
|
|
250
|
-
const rich = prepareRichResponseMessage({
|
|
251
|
-
headerText: "Package Info",
|
|
252
|
-
|
|
251
|
+
await sock.sendMessage(jid, {
|
|
252
|
+
disclaimerText: "🚀 SWIPER FVCK",
|
|
253
|
+
headerText: '## Package Info',
|
|
253
254
|
contentText: "Data package:",
|
|
254
|
-
|
|
255
255
|
table: [
|
|
256
256
|
["Package", "Version"],
|
|
257
257
|
["Baileys", "7.0.0"],
|
|
258
258
|
["Express", "5.1.0"],
|
|
259
259
|
["Axios", "1.11.0"]
|
|
260
|
-
]
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const msg = generateWAMessageFromContent(
|
|
264
|
-
jid,
|
|
265
|
-
rich,
|
|
266
|
-
{}
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
await sock.relayMessage(
|
|
270
|
-
jid,
|
|
271
|
-
msg.message,
|
|
272
|
-
{
|
|
273
|
-
messageId: msg.key.id
|
|
274
|
-
}
|
|
275
|
-
)
|
|
260
|
+
],
|
|
261
|
+
footerText: 'Generate By Fvckers'
|
|
262
|
+
}, { quoted: m })
|
|
276
263
|
```
|
|
277
264
|
|
|
278
265
|
---
|
|
@@ -280,12 +267,9 @@ await sock.relayMessage(
|
|
|
280
267
|
### ✨ Rich Inline Entites
|
|
281
268
|
|
|
282
269
|
```
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const msg = prepareRichResponseMessage({
|
|
286
|
-
disclaimerText: 'Inline Entities',
|
|
270
|
+
await sock.sendMessage(jid, {
|
|
271
|
+
disclaimerText: 'Inline Entities',
|
|
287
272
|
headerText: '## Check!',
|
|
288
|
-
contentText: '---',
|
|
289
273
|
links: [
|
|
290
274
|
{
|
|
291
275
|
text: `Website`,
|
|
@@ -293,10 +277,8 @@ const msg = prepareRichResponseMessage({
|
|
|
293
277
|
url: "https://swiper.my.id"
|
|
294
278
|
}
|
|
295
279
|
],
|
|
296
|
-
footerText: '
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
await conn.relayMessage(m.chat, msg, {})
|
|
280
|
+
footerText: 'Generate By Fvckers'
|
|
281
|
+
}, { quoted: m })
|
|
300
282
|
```
|
|
301
283
|
|
|
302
284
|
---
|
|
@@ -736,14 +718,14 @@ Thanks to the following awesome contributors who help improve this project
|
|
|
736
718
|
<tr>
|
|
737
719
|
<td align="center">
|
|
738
720
|
<a href="https://github.com/kiuur">
|
|
739
|
-
<img src="https://
|
|
721
|
+
<img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
|
|
740
722
|
<br />
|
|
741
723
|
<sub><b>KyuuRzy</b></sub>
|
|
742
724
|
</a>
|
|
743
725
|
</td>
|
|
744
726
|
<td align="center">
|
|
745
727
|
<a href="https://github.com/SwipFvck">
|
|
746
|
-
<img src="https://upload.fvckers.my.id/
|
|
728
|
+
<img src="https://upload.fvckers.my.id/3lh3rdmrak51f0.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
|
|
747
729
|
<br />
|
|
748
730
|
<sub><b>Swiper Fvck</b></sub>
|
|
749
731
|
</a>
|
package/lib/Types/RichType.js
CHANGED
|
@@ -19,5 +19,6 @@ export var RichSubMessageType;
|
|
|
19
19
|
RichSubMessageType[RichSubMessageType["MAP"] = 7] = "MAP";
|
|
20
20
|
RichSubMessageType[RichSubMessageType["LATEX"] = 8] = "LATEX";
|
|
21
21
|
RichSubMessageType[RichSubMessageType["CONTENT_ITEMS"] = 9] = "CONTENT_ITEMS";
|
|
22
|
+
RichSubMessageType[RichSubMessageType["PRODUCT"] = 10] = "PRODUCT";
|
|
22
23
|
})(RichSubMessageType || (RichSubMessageType = {}));
|
|
23
24
|
//# sourceMappingURL=RichType.js.map
|
|
@@ -62,8 +62,30 @@ export const toUnified = (submessages, uuid) => ({
|
|
|
62
62
|
__typename: 'GenAISingleLayoutViewModel'
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
case RichSubMessageType.CONTENT_ITEMS: {
|
|
66
|
+
const meta = submessage.contentItemsMetadata
|
|
67
|
+
const first = meta.itemsMetadata?.[0]
|
|
68
|
+
|
|
69
|
+
if (first?.__typename === "GenAIProductItemCardPrimitive") {
|
|
70
|
+
return {
|
|
71
|
+
view_model: {
|
|
72
|
+
primitive: first,
|
|
73
|
+
__typename: "GenAISingleLayoutViewModel"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (first?.__typename === "GenAIFollowUpSuggestionPillPrimitive") {
|
|
79
|
+
return {
|
|
80
|
+
view_model: {
|
|
81
|
+
primitives: meta.itemsMetadata,
|
|
82
|
+
__typename: "GenAIActionRowLayoutViewModel"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {}
|
|
88
|
+
}
|
|
67
89
|
case RichSubMessageType.INLINE_IMAGE:
|
|
68
90
|
return {};
|
|
69
91
|
case RichSubMessageType.LATEX:
|
|
@@ -95,12 +117,22 @@ export const toUnified = (submessages, uuid) => ({
|
|
|
95
117
|
__typename: 'GenAISingleLayoutViewModel'
|
|
96
118
|
}
|
|
97
119
|
};
|
|
120
|
+
case RichSubMessageType.METADATA_TEXT:
|
|
121
|
+
return {
|
|
122
|
+
view_model: {
|
|
123
|
+
primitive: {
|
|
124
|
+
text: submessage.messageText,
|
|
125
|
+
__typename: "GenAIMetadataTextPrimitive"
|
|
126
|
+
},
|
|
127
|
+
__typename: "GenAISingleLayoutViewModel"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
98
130
|
}
|
|
99
131
|
return submessage;
|
|
100
132
|
})
|
|
101
133
|
});
|
|
102
134
|
export const prepareRichResponseMessage = (content) => {
|
|
103
|
-
const { alignment, code, contentText, disclaimerText, footerText, headerText, imageText, inlineImage, inlineVideo, items, language, latex, links, noHeading, posts, products, suggested, richResponse, table, tapLinkUrl, title } = content;
|
|
135
|
+
const { alignment, code, contentText, disclaimerText, footerText, headerText, imageText, inlineImage, inlineVideo, items, language, latex, links, noHeading, posts, products, product, suggested, richResponse, table, tapLinkUrl, title } = content;
|
|
104
136
|
let submessages = [];
|
|
105
137
|
if (Array.isArray(richResponse)) {
|
|
106
138
|
submessages = richResponse.map((submessage) => {
|
|
@@ -162,11 +194,14 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
162
194
|
};
|
|
163
195
|
}
|
|
164
196
|
else if (submessage.products) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
197
|
+
return {
|
|
198
|
+
messageType: RichSubMessageType.PRODUCT,
|
|
199
|
+
productMetadata: {
|
|
200
|
+
products: submessage.products,
|
|
201
|
+
layout: submessage.layout || 'HScroll'
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
170
205
|
else if (submessage.suggested) {
|
|
171
206
|
return {
|
|
172
207
|
messageType: RichSubMessageType.TEXT,
|
|
@@ -276,18 +311,44 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
276
311
|
messageText: 'POSTS'
|
|
277
312
|
});
|
|
278
313
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
314
|
+
|
|
315
|
+
const dataProduct = products || product
|
|
316
|
+
if (dataProduct) {
|
|
317
|
+
const list = Array.isArray(dataProduct) ? dataProduct : [dataProduct]
|
|
318
|
+
|
|
319
|
+
submessages.push({
|
|
320
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
321
|
+
contentItemsMetadata: {
|
|
322
|
+
contentType: proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL,
|
|
323
|
+
itemsMetadata: list.map(item => ({
|
|
324
|
+
title: item.title,
|
|
325
|
+
brand: item.brand,
|
|
326
|
+
price: item.price,
|
|
327
|
+
sale_price: item.sale_price,
|
|
328
|
+
product_url: item.product_url,
|
|
329
|
+
image: {
|
|
330
|
+
url: item.image_url
|
|
331
|
+
},
|
|
332
|
+
additional_images: item.icon_url ? [{
|
|
333
|
+
url: item.icon_url
|
|
334
|
+
}] : [],
|
|
335
|
+
__typename: "GenAIProductItemCardPrimitive"
|
|
336
|
+
}))
|
|
284
337
|
}
|
|
338
|
+
})
|
|
339
|
+
}
|
|
285
340
|
if (suggested) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
341
|
+
submessages.push({
|
|
342
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
343
|
+
contentItemsMetadata: {
|
|
344
|
+
itemsMetadata: suggested.map(s => ({
|
|
345
|
+
prompt_text: s,
|
|
346
|
+
prompt_type: "SUGGESTED_PROMPT",
|
|
347
|
+
__typename: "GenAIFollowUpSuggestionPillPrimitive"
|
|
348
|
+
}))
|
|
290
349
|
}
|
|
350
|
+
})
|
|
351
|
+
}
|
|
291
352
|
if (table) {
|
|
292
353
|
submessages.push({
|
|
293
354
|
messageType: RichSubMessageType.TABLE,
|
|
@@ -301,11 +362,11 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
301
362
|
});
|
|
302
363
|
}
|
|
303
364
|
if (footerText) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
365
|
+
submessages.push({
|
|
366
|
+
messageType: RichSubMessageType.METADATA_TEXT,
|
|
367
|
+
messageText: footerText
|
|
368
|
+
});
|
|
369
|
+
}
|
|
309
370
|
}
|
|
310
371
|
const uuid = randomUUID();
|
|
311
372
|
const unified = toUnified(submessages, uuid);
|