@pontalabs/baileys 1.1.9 → 1.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/README.md +120 -64
- package/lib/Socket/messages-send.js +17 -0
- package/lib/Utils/mbuilder.d.ts +17 -17
- package/lib/Utils/mbuilder.js +44 -21
- package/lib/Utils/messages.js +1 -0
- package/lib/Utils/rich-message-utils.js +35 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -586,108 +586,164 @@ await sock.sendMessage(jid, {
|
|
|
586
586
|
|
|
587
587
|
### 🧱 Rich Builder API — `build.*`
|
|
588
588
|
|
|
589
|
-
|
|
589
|
+
`build.*` adalah cara singkat untuk membuat **Rich AI item** yang langsung bisa dipakai di `sock.sendMessage()`.
|
|
590
590
|
|
|
591
|
-
**
|
|
591
|
+
> **Tidak perlu import `build`.** Package mengekspos `build` secara global saat dimuat.
|
|
592
592
|
|
|
593
|
-
|
|
594
|
-
- `build.richText()`, `build.richCode()`, dan seterusnya adalah **factory builder**, bukan pengganti shortcut lama.
|
|
595
|
-
- Factory `build.*` mengembalikan instance `AIRich`, sehingga bisa dilanjutkan dengan operasi builder seperti `addText()`, `replace()`, `delete()`, `insertAt()`, `buildEdit()`, dan `sendEdit()`.
|
|
596
|
-
|
|
597
|
-
#### Import
|
|
593
|
+
#### 🚀 Cara paling sederhana
|
|
598
594
|
|
|
599
595
|
```js
|
|
600
|
-
|
|
596
|
+
await sock.sendMessage(jid, {
|
|
597
|
+
items: [
|
|
598
|
+
build.richText('Halo! 👋'),
|
|
599
|
+
build.richCode('console.log("hello")', 'javascript'),
|
|
600
|
+
build.richTip('Selesai!')
|
|
601
|
+
]
|
|
602
|
+
})
|
|
601
603
|
```
|
|
602
604
|
|
|
603
|
-
|
|
605
|
+
Factory `build.rich*()` **tidak mengirim pesan sendiri**. Mereka hanya membuat item payload. Pengiriman tetap menggunakan API Baileys biasa: `sock.sendMessage()`.
|
|
604
606
|
|
|
605
|
-
|
|
606
|
-
const ai = build.richText(sock, 'Halo! 👋')
|
|
607
|
+
#### ⏱️ Delay antar build
|
|
607
608
|
|
|
608
|
-
|
|
609
|
+
Kalau setiap item builder ingin dikirim sebagai **pesan terpisah**, gunakan `buildDelay` dalam milidetik:
|
|
609
610
|
|
|
610
|
-
|
|
611
|
+
```js
|
|
612
|
+
await sock.sendMessage(jid, {
|
|
613
|
+
items: [
|
|
614
|
+
build.richText('Build 1'),
|
|
615
|
+
build.richText('Build 2'),
|
|
616
|
+
build.richTip('Build 3')
|
|
617
|
+
],
|
|
618
|
+
buildDelay: 1000
|
|
619
|
+
})
|
|
611
620
|
```
|
|
612
621
|
|
|
613
|
-
|
|
622
|
+
Urutannya menjadi `Build 1 → tunggu 1 detik → Build 2 → tunggu 1 detik → Build 3`.
|
|
614
623
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
|
622
|
-
|
|
|
623
|
-
| `build.
|
|
624
|
-
| `build.
|
|
625
|
-
| `build.
|
|
626
|
-
| `build.
|
|
627
|
-
| `build.
|
|
628
|
-
| `build.
|
|
629
|
-
| `build.
|
|
630
|
-
| `build.
|
|
631
|
-
| `build.
|
|
632
|
-
| `build.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
624
|
+
Tanpa `buildDelay`, perilaku `items` lama tetap dipakai: semua item digabung menjadi **satu Rich AI message**.
|
|
625
|
+
|
|
626
|
+
> `buildDelay` hanya berlaku untuk `items`. Nilai dalam milidetik harus lebih besar dari `0`.
|
|
627
|
+
|
|
628
|
+
#### ✨ Semua factory
|
|
629
|
+
|
|
630
|
+
| Factory | Contoh | Hasil |
|
|
631
|
+
| --- | --- | --- |
|
|
632
|
+
| `build.richText(text)` | `build.richText('Halo')` | Text |
|
|
633
|
+
| `build.richFOAText(text)` | `build.richFOAText('Halo')` | FOA text |
|
|
634
|
+
| `build.richHtml(html)` | `build.richHtml('<html>...</html>')` | HTML WebView |
|
|
635
|
+
| `build.richCode(code, language)` | `build.richCode('console.log(1)', 'javascript')` | Code |
|
|
636
|
+
| `build.richTable(table)` | `build.richTable([['A', 'B']])` | Table |
|
|
637
|
+
| `build.richSource(sources)` | `build.richSource([...])` | Sources |
|
|
638
|
+
| `build.richReels(items)` | `build.richReels([...])` | Reels |
|
|
639
|
+
| `build.richImage(url)` | `build.richImage('https://...')` | Image |
|
|
640
|
+
| `build.richVideo(url)` | `build.richVideo('https://...')` | Video |
|
|
641
|
+
| `build.richProduct(data)` | `build.richProduct({...})` | Product |
|
|
642
|
+
| `build.richPost(data)` | `build.richPost({...})` | Post |
|
|
643
|
+
| `build.richMetadata(text)` | `build.richMetadata('Info')` | Metadata |
|
|
644
|
+
| `build.richTip(text)` | `build.richTip('Tip')` | Tip |
|
|
645
|
+
| `build.richWidget(data)` | `build.richWidget({...})` | Widget |
|
|
646
|
+
| `build.richFooterAction(data)` | `build.richFooterAction({...})` | Footer action |
|
|
647
|
+
| `build.richSuggest(value)` | `build.richSuggest('Lanjutkan')` | Suggestion |
|
|
648
|
+
|
|
649
|
+
#### 🧩 Campur dengan shortcut lama
|
|
650
|
+
|
|
651
|
+
API lama **tetap dipertahankan**. Builder bisa dicampur dengan object Rich AI biasa di `items`.
|
|
637
652
|
|
|
638
653
|
```js
|
|
639
|
-
|
|
654
|
+
await sock.sendMessage(jid, {
|
|
655
|
+
items: [
|
|
656
|
+
{ richText: 'Shortcut lama tetap jalan' },
|
|
657
|
+
build.richText('Item dari Builder'),
|
|
658
|
+
{ richTip: 'Shortcut lama' },
|
|
659
|
+
build.richTip('Tip dari Builder')
|
|
660
|
+
]
|
|
661
|
+
})
|
|
662
|
+
```
|
|
640
663
|
|
|
641
|
-
|
|
642
|
-
ai.addCode('javascript', 'console.log("hello")')
|
|
643
|
-
ai.addTip('Selesai diproses.')
|
|
644
|
-
ai.addImage('https://example.com/image.jpg')
|
|
664
|
+
#### 🌐 HTML WebView
|
|
645
665
|
|
|
646
|
-
|
|
666
|
+
`build.richHtml()` membuat primitive HTML Rich AI seperti webview. HTML dikirim sebagai payload langsung ke primitive `GenAIaeacdsnwHtmlPrimitive`.
|
|
667
|
+
|
|
668
|
+
```js
|
|
669
|
+
const html = `<!DOCTYPE html>
|
|
670
|
+
<html>
|
|
671
|
+
<body style="margin:0;padding:20px;font-family:Arial">
|
|
672
|
+
<h2>🎮 Game Center</h2>
|
|
673
|
+
<button onclick="document.body.innerHTML += '<p>Clicked!</p>'">
|
|
674
|
+
Play
|
|
675
|
+
</button>
|
|
676
|
+
</body>
|
|
677
|
+
</html>`
|
|
678
|
+
|
|
679
|
+
await sock.sendMessage(jid, {
|
|
680
|
+
items: [build.richHtml(html)]
|
|
681
|
+
})
|
|
647
682
|
```
|
|
648
683
|
|
|
649
|
-
|
|
684
|
+
Karena HTML berjalan di sisi client/webview, gunakan HTML/JavaScript yang memang kamu kontrol dan sesuaikan dengan dukungan client WhatsApp yang dituju.
|
|
685
|
+
|
|
686
|
+
#### 🛠️ Builder untuk edit / delete
|
|
650
687
|
|
|
651
|
-
|
|
688
|
+
Untuk kebutuhan yang benar-benar membutuhkan state dan manipulasi node, gunakan `build.AIRich(sock)`.
|
|
652
689
|
|
|
653
690
|
```js
|
|
654
691
|
const ai = build.AIRich(sock)
|
|
655
|
-
ai.addText('Loading...')
|
|
656
692
|
|
|
657
|
-
|
|
693
|
+
ai.addText('⏳ Loading...', { id: 'status' })
|
|
694
|
+
ai.addTip('Mohon tunggu')
|
|
658
695
|
|
|
659
|
-
|
|
660
|
-
ai.addText('Selesai!')
|
|
696
|
+
await ai.send(jid)
|
|
661
697
|
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
```
|
|
698
|
+
// Ganti node berdasarkan ID
|
|
699
|
+
ai.addText('✅ Selesai!', { replace: 'status' })
|
|
665
700
|
|
|
666
|
-
|
|
701
|
+
// Hapus node
|
|
702
|
+
ai.delete('status')
|
|
667
703
|
|
|
668
|
-
|
|
669
|
-
|
|
704
|
+
// Sisipkan setelah node tertentu
|
|
705
|
+
ai.addTip('Tambahan', { insertAt: 'status' })
|
|
670
706
|
```
|
|
671
707
|
|
|
672
|
-
|
|
708
|
+
> `replace` dan `insertAt` adalah **options pada `add*()`**, bukan method `ai.replace()` atau `ai.insertAt()`.
|
|
673
709
|
|
|
674
|
-
|
|
710
|
+
#### 📝 Contoh workflow edit
|
|
675
711
|
|
|
676
712
|
```js
|
|
677
713
|
const ai = build.AIRich(sock)
|
|
678
|
-
ai.
|
|
714
|
+
ai.addText('⏳ Memproses...', { id: 'answer' })
|
|
715
|
+
|
|
716
|
+
await ai.send(jid)
|
|
717
|
+
|
|
718
|
+
const result = await getAIResponse()
|
|
679
719
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
// ai.delete(...)
|
|
683
|
-
// ai.insertAt(...)
|
|
720
|
+
ai.addText(result, { replace: 'answer' })
|
|
721
|
+
ai.addTip('Generated by AI')
|
|
684
722
|
|
|
685
|
-
await ai.sendEdit(jid
|
|
723
|
+
await ai.sendEdit(jid)
|
|
686
724
|
```
|
|
687
725
|
|
|
688
|
-
|
|
726
|
+
#### 🔌 API lama tetap kompatibel
|
|
727
|
+
|
|
728
|
+
```js
|
|
729
|
+
await sock.sendMessage(jid, {
|
|
730
|
+
richText: 'Halo'
|
|
731
|
+
})
|
|
732
|
+
|
|
733
|
+
await sock.sendMessage(jid, {
|
|
734
|
+
items: [
|
|
735
|
+
{ richText: 'Halo' },
|
|
736
|
+
{ richTip: 'Testing' }
|
|
737
|
+
]
|
|
738
|
+
})
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
Dengan desain ini, developer bisa memilih:
|
|
742
|
+
|
|
743
|
+
- **`sock.sendMessage()` + shortcut** → paling sederhana.
|
|
744
|
+
- **`sock.sendMessage()` + `build.rich*()`** → payload Rich AI yang lebih rapi dan mudah dirangkai.
|
|
745
|
+
- **`build.AIRich(sock)`** → kebutuhan advanced seperti `id`, `replace`, `insertAt`, `delete`, dan edit message.
|
|
689
746
|
|
|
690
|
-
---
|
|
691
747
|
|
|
692
748
|
### 🤖 Rich Messages
|
|
693
749
|
|
|
@@ -1128,6 +1128,23 @@ export const makeMessagesSocket = (config) => {
|
|
|
1128
1128
|
},
|
|
1129
1129
|
sendMessage: async (jid, content, options = {}) => {
|
|
1130
1130
|
const userJid = authState.creds.me.id;
|
|
1131
|
+
|
|
1132
|
+
// `buildDelay` sends each item in `content.items` as its own Rich AI
|
|
1133
|
+
// message, waiting between items. Without buildDelay, the existing
|
|
1134
|
+
// mixed-items behavior is unchanged (all items are one Rich AI message).
|
|
1135
|
+
if (content && !Array.isArray(jid) && Array.isArray(content.items) && content.items.length > 1) {
|
|
1136
|
+
const buildDelay = Number(options.buildDelay ?? content.buildDelay ?? 0);
|
|
1137
|
+
if (Number.isFinite(buildDelay) && buildDelay > 0) {
|
|
1138
|
+
const sendOptions = { ...options };
|
|
1139
|
+
delete sendOptions.buildDelay;
|
|
1140
|
+
const results = [];
|
|
1141
|
+
for (let index = 0; index < content.items.length; index++) {
|
|
1142
|
+
if (index > 0) await delay(buildDelay);
|
|
1143
|
+
results.push(await sock.sendMessage(jid, content.items[index], sendOptions));
|
|
1144
|
+
}
|
|
1145
|
+
return results;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1131
1148
|
// Update rahmi's userJid in case it changed after login
|
|
1132
1149
|
if (rahmi && userJid) rahmi.userJid = userJid;
|
|
1133
1150
|
if (Array.isArray(jid)) {
|
package/lib/Utils/mbuilder.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class AIRich {
|
|
|
12
12
|
createAlert(type: any): any;
|
|
13
13
|
addText(text: string, options?: any): this;
|
|
14
14
|
addFOAText(text: string, options?: any): this;
|
|
15
|
+
addHtml(html: string, options?: any): this;
|
|
15
16
|
addCode(language: string, code: string, options?: any): this;
|
|
16
17
|
addTable(table: any, options?: any): this;
|
|
17
18
|
addSource(sources?: any[], options?: any): this;
|
|
@@ -28,8 +29,6 @@ export declare class AIRich {
|
|
|
28
29
|
addSection(section: any, options?: any): this;
|
|
29
30
|
addSubmessage(submessage: any, options?: any): this;
|
|
30
31
|
delete(id: any): this;
|
|
31
|
-
replace(id: any, content: any): this;
|
|
32
|
-
insertAt(index: number, content: any): this;
|
|
33
32
|
build(jid: string, options?: any): Promise<any>;
|
|
34
33
|
buildEdit(targetJid: string, targetId: string, options?: any): Promise<any>;
|
|
35
34
|
send(jid: string, options?: any): Promise<any>;
|
|
@@ -39,19 +38,20 @@ export declare class AIRich {
|
|
|
39
38
|
export declare class Toolkit { [key: string]: any; }
|
|
40
39
|
export declare const build: {
|
|
41
40
|
AIRich: (client: any, options?: any) => AIRich;
|
|
42
|
-
richText: (
|
|
43
|
-
richFOAText: (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
richText: (text: string) => any;
|
|
42
|
+
richFOAText: (text: string) => any;
|
|
43
|
+
richHtml: (html: string) => any;
|
|
44
|
+
richCode: (code: string, language?: string) => any;
|
|
45
|
+
richTable: (table: any) => any;
|
|
46
|
+
richSource: (sources: any) => any;
|
|
47
|
+
richReels: (reelsItems: any) => any;
|
|
48
|
+
richImage: (imageUrl: any) => any;
|
|
49
|
+
richVideo: (videoUrl: any) => any;
|
|
50
|
+
richProduct: (data: any) => any;
|
|
51
|
+
richPost: (data: any) => any;
|
|
52
|
+
richMetadata: (text: string) => any;
|
|
53
|
+
richTip: (text: string) => any;
|
|
54
|
+
richWidget: (data: any) => any;
|
|
55
|
+
richFooterAction: (data: any) => any;
|
|
56
|
+
richSuggest: (suggestion: any) => any;
|
|
57
57
|
};
|
package/lib/Utils/mbuilder.js
CHANGED
|
@@ -1333,6 +1333,22 @@ class AIRich extends BaseBuilder {
|
|
|
1333
1333
|
});
|
|
1334
1334
|
}
|
|
1335
1335
|
|
|
1336
|
+
addHtml(html, { id, replace, insertAt } = {}) {
|
|
1337
|
+
if (typeof html !== 'string') throw new TypeError('HTML must be a string');
|
|
1338
|
+
const section = {
|
|
1339
|
+
view_model: {
|
|
1340
|
+
primitive: {
|
|
1341
|
+
__typename: 'GenAIaeacdsnwHtmlPrimitive',
|
|
1342
|
+
payload: html,
|
|
1343
|
+
trusted_sources: []
|
|
1344
|
+
},
|
|
1345
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
const submessage = this.createAlert('GenAIaeacdsnwHtmlPrimitive');
|
|
1349
|
+
return this._addContent(section, submessage, { id, replace, insertAt });
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1336
1352
|
addFOAText(text, { id, replace, insertAt } = {}) {
|
|
1337
1353
|
if (typeof text !== 'string') {
|
|
1338
1354
|
throw new TypeError('Text must be a string');
|
|
@@ -3174,31 +3190,38 @@ class AIRich extends BaseBuilder {
|
|
|
3174
3190
|
|
|
3175
3191
|
|
|
3176
3192
|
/**
|
|
3177
|
-
*
|
|
3193
|
+
* `build.*` creates lightweight Rich AI items for `sock.sendMessage()`.
|
|
3194
|
+
*
|
|
3195
|
+
* Advanced editing is still available through `build.AIRich(sock)`.
|
|
3196
|
+
* Keeping factories payload-only makes the common API simple:
|
|
3178
3197
|
*
|
|
3179
|
-
*
|
|
3180
|
-
*
|
|
3181
|
-
*
|
|
3182
|
-
* primitive, making it ready for further edits (`replace`, `delete`, etc.) or
|
|
3183
|
-
* `send()` / `build()`.
|
|
3198
|
+
* await sock.sendMessage(jid, {
|
|
3199
|
+
* items: [build.richText('Hello'), build.richTip('Done')]
|
|
3200
|
+
* })
|
|
3184
3201
|
*/
|
|
3185
3202
|
const build = {
|
|
3186
3203
|
AIRich: (client, options) => new AIRich(client, options),
|
|
3187
|
-
richText: (
|
|
3188
|
-
richFOAText: (
|
|
3189
|
-
richCode: (
|
|
3190
|
-
richTable: (
|
|
3191
|
-
richSource: (
|
|
3192
|
-
richReels: (
|
|
3193
|
-
richImage: (
|
|
3194
|
-
richVideo: (
|
|
3195
|
-
richProduct: (
|
|
3196
|
-
richPost: (
|
|
3197
|
-
richMetadata: (
|
|
3198
|
-
richTip: (
|
|
3199
|
-
richWidget: (
|
|
3200
|
-
richFooterAction: (
|
|
3201
|
-
richSuggest: (
|
|
3204
|
+
richText: (text) => ({ richText: text }),
|
|
3205
|
+
richFOAText: (text) => ({ richFOAText: text }),
|
|
3206
|
+
richCode: (code, language = 'javascript') => ({ richCode: code, language }),
|
|
3207
|
+
richTable: (table) => ({ richTable: table }),
|
|
3208
|
+
richSource: (sources) => ({ richSource: sources }),
|
|
3209
|
+
richReels: (reelsItems) => ({ richReels: reelsItems }),
|
|
3210
|
+
richImage: (imageUrl) => ({ richImage: imageUrl }),
|
|
3211
|
+
richVideo: (videoUrl) => ({ richVideo: videoUrl }),
|
|
3212
|
+
richProduct: (data) => ({ richProduct: data }),
|
|
3213
|
+
richPost: (data) => ({ richPost: data }),
|
|
3214
|
+
richMetadata: (text) => ({ richMetadata: text }),
|
|
3215
|
+
richTip: (text) => ({ richTip: text }),
|
|
3216
|
+
richWidget: (data) => ({ richWidget: data }),
|
|
3217
|
+
richFooterAction: (data) => ({ richFooterAction: data }),
|
|
3218
|
+
richSuggest: (suggestion) => ({ richSuggest: suggestion }),
|
|
3202
3219
|
};
|
|
3203
3220
|
|
|
3221
|
+
// Expose the namespace globally so applications can use build.* without
|
|
3222
|
+
// importing another symbol. The named export remains available as well.
|
|
3223
|
+
if (!globalThis.build) {
|
|
3224
|
+
globalThis.build = build;
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3204
3227
|
export { VERSION, Button, ButtonV2, Carousel, AIRich, Toolkit, build };
|
package/lib/Utils/messages.js
CHANGED
|
@@ -595,6 +595,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
595
595
|
hasNonNullishProperty(message, 'footerAction') ||
|
|
596
596
|
hasNonNullishProperty(message, 'metadata') ||
|
|
597
597
|
hasNonNullishProperty(message, 'foaText') ||
|
|
598
|
+
hasNonNullishProperty(message, 'richHtml') ||
|
|
598
599
|
hasNonNullishProperty(message, 'contentText')) {
|
|
599
600
|
m = prepareRichResponseMessage(message);
|
|
600
601
|
}
|
|
@@ -775,6 +775,20 @@ const makeMetadataSub = (text, typename = 'GenAIMetadataTextPrimitive', prefix =
|
|
|
775
775
|
sub: { messageType: RichSubMessageType.TEXT, messageText: text },
|
|
776
776
|
section: { view_model: { primitive: { text: prefix + text, __typename: typename }, __typename: 'GenAISingleLayoutViewModel' } }
|
|
777
777
|
});
|
|
778
|
+
/** Rich HTML WebView primitive. The HTML is rendered as a trusted Rich AI webview payload. */
|
|
779
|
+
const makeHtmlSection = (html) => {
|
|
780
|
+
if (typeof html !== 'string') throw new TypeError('HTML must be a string');
|
|
781
|
+
return {
|
|
782
|
+
view_model: {
|
|
783
|
+
primitive: {
|
|
784
|
+
__typename: 'GenAIaeacdsnwHtmlPrimitive',
|
|
785
|
+
payload: html,
|
|
786
|
+
trusted_sources: []
|
|
787
|
+
},
|
|
788
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
};
|
|
778
792
|
const makeWidgetSection = (data) => {
|
|
779
793
|
const items = Array.isArray(data) ? data : [data];
|
|
780
794
|
const widgets = items.map(item => ({
|
|
@@ -825,7 +839,7 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
825
839
|
map: mapContent, latex, contentItems,
|
|
826
840
|
// sub-types baru (prefixed 'rich' agar tidak konflik dengan media biasa)
|
|
827
841
|
richImage, richVideo, reels, source, richProduct, richPost, tip, suggest,
|
|
828
|
-
richWidget, widget, richFooterAction, footerAction, richMetadata, metadata, richFOAText, foaText,
|
|
842
|
+
richWidget, widget, richFooterAction, footerAction, richMetadata, metadata, richFOAText, foaText, richHtml,
|
|
829
843
|
// opsi tambahan (belum ada di versi ponta.zip semula)
|
|
830
844
|
aiForwarded
|
|
831
845
|
} = content;
|
|
@@ -914,6 +928,7 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
914
928
|
if (sub.footerAction != null) return push(null, makeFooterActionSection(sub.footerAction));
|
|
915
929
|
if (sub.metadata != null) { const built = makeMetadataSub(sub.metadata); return push(built.sub, built.section); }
|
|
916
930
|
if (sub.foaText != null) { const built = makeMetadataSub(sub.foaText, 'FOATextPrimitive'); return push(built.sub, built.section); }
|
|
931
|
+
if (sub.richHtml != null) return push(null, makeHtmlSection(sub.richHtml));
|
|
917
932
|
// passthrough — kalau sudah bentuk proto submessage manual
|
|
918
933
|
return push(sub, buildUnifiedSection(sub));
|
|
919
934
|
};
|
|
@@ -951,6 +966,7 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
951
966
|
if (richFooterAction ?? footerAction) buildOne({ footerAction: richFooterAction ?? footerAction });
|
|
952
967
|
if (richMetadata ?? metadata) buildOne({ metadata: richMetadata ?? metadata });
|
|
953
968
|
if (richFOAText ?? foaText) buildOne({ foaText: richFOAText ?? foaText });
|
|
969
|
+
if (richHtml != null) buildOne({ richHtml });
|
|
954
970
|
|
|
955
971
|
/* links — bisa dikombinasi dengan tipe lain di atas */
|
|
956
972
|
if (links && Array.isArray(links)) {
|
|
@@ -1517,6 +1533,24 @@ const mapVideoField = (data) => {
|
|
|
1517
1533
|
* jadi item internal fork ({richImage},{richVideo},{suggest}, dst). */
|
|
1518
1534
|
const translateReadmeItem = (item) => {
|
|
1519
1535
|
const out = {};
|
|
1536
|
+
// Builder aliases: build.* returns lightweight items that can be passed
|
|
1537
|
+
// directly to sendMessage({ items: [...] }).
|
|
1538
|
+
if (item.richText != null) { out.text = item.richText; }
|
|
1539
|
+
if (item.richFOAText != null) { out.foaText = item.richFOAText; }
|
|
1540
|
+
if (item.richHtml != null) { out.richHtml = item.richHtml; }
|
|
1541
|
+
if (item.richCode != null) { out.code = item.richCode; out.language = item.language; }
|
|
1542
|
+
if (item.richTable != null) { out.table = item.richTable; }
|
|
1543
|
+
if (item.richSource != null) { out.source = item.richSource; }
|
|
1544
|
+
if (item.richReels != null) { out.reels = item.richReels; }
|
|
1545
|
+
if (item.richImage != null) { out.richImage = item.richImage; }
|
|
1546
|
+
if (item.richVideo != null) { out.richVideo = mapVideoField(item.richVideo); }
|
|
1547
|
+
if (item.richProduct != null) { out.richProduct = mapProductFields(item.richProduct); }
|
|
1548
|
+
if (item.richPost != null) { out.richPost = mapPostFields(item.richPost); }
|
|
1549
|
+
if (item.richMetadata != null) { out.metadata = item.richMetadata; }
|
|
1550
|
+
if (item.richTip != null) { out.tip = item.richTip; }
|
|
1551
|
+
if (item.richWidget != null) { out.widget = item.richWidget; }
|
|
1552
|
+
if (item.richFooterAction != null) { out.footerAction = item.richFooterAction; }
|
|
1553
|
+
if (item.richSuggest != null) { out.suggest = item.richSuggest; }
|
|
1520
1554
|
if (item.text != null) { out.text = item.text; if (item.inlineEntities) out.inlineEntities = item.inlineEntities; }
|
|
1521
1555
|
if (item.code != null) { out.code = item.code; out.language = item.language; }
|
|
1522
1556
|
if (item.table != null) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pontalabs/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "PontaLabs Baileys is a lightweight, modern, and customizable WhatsApp Web API library built on Baileys.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@eslint/eslintrc": "^3.3.1",
|
|
62
62
|
"@eslint/js": "^9.31.0",
|
|
63
63
|
"@types/jest": "^30.0.0",
|
|
64
|
-
"@types/node": "^20.
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
65
|
"@types/ws": "^8.0.0",
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
67
67
|
"@typescript-eslint/parser": "^8",
|