baileys-mbuilder 4.5.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.
Files changed (4) hide show
  1. package/MessageBuilder.js +1627 -0
  2. package/README.md +204 -0
  3. package/index.js +1663 -0
  4. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # Baileys Mbuilder
2
+
3
+ > **By Nixel** | Published by FongsiDev
4
+
5
+ Advanced WhatsApp Interactive Message Builder built for creating buttons, carousels, native flows, and AI rich response payloads using Baileys with fluent chaining, flexible payload customization, and scalable architecture for modern bot development.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - **Button (v1)** — Single-row button messages with up to 3 buttons
12
+ - **ButtonV2 (v2)** — Multi-row button messages with configurable layout
13
+ - **Carousel** — Rich horizontal card carousel with images, text, and buttons
14
+ - **AIRich** — AI-powered rich response with hyperlinks, LaTeX, citations, code blocks, tables
15
+ - **Auto-Update** — Built-in auto-update mechanism from official repo
16
+ - **Hot Reload** — Proxy-based default export always points to latest module version
17
+
18
+ ---
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ npm install baileys-mbuilder
24
+ ```
25
+
26
+ > `postinstall` automatically downloads the latest `MessageBuilder.js` from the official repo.
27
+
28
+ ### Dependencies
29
+
30
+ | Package | Type |
31
+ | --------- | ---------------------------------------- |
32
+ | `baileys` | peer (wajib sudah terinstall di project) |
33
+ | `sharp` | langsung terinstall otomatis |
34
+
35
+ ---
36
+
37
+ ## 🚀 Quick Start
38
+
39
+ ```js
40
+ // Default import (recommended — supports hot-reload / auto-update)
41
+ import MB from "baileys-mbuilder";
42
+
43
+ // ── Simple Button ────────────────────────
44
+ const msg = new MB.Button()
45
+ .text("Hello! Click below.")
46
+ .button("Click Me", "click_1")
47
+ .button("Cancel", "cancel_1")
48
+ .footer("Footer here")
49
+ .build();
50
+
51
+ // ── Multi-row Button ─────────────────────
52
+ const msg2 = new MB.ButtonV2()
53
+ .text("Choose:")
54
+ .row((r) => r.button("A", "a").button("B", "b"))
55
+ .row((r) => r.button("C", "c"))
56
+ .build();
57
+
58
+ // ── Carousel ─────────────────────────────
59
+ const msg3 = new MB.Carousel()
60
+ .card((c) =>
61
+ c
62
+ .image("https://example.com/img.jpg")
63
+ .title("Card Title")
64
+ .text("Description")
65
+ .button("Detail", "detail_1"),
66
+ )
67
+ .build();
68
+
69
+ // ── AI Rich Response ─────────────────────
70
+ const msg4 = new MB.AIRich()
71
+ .text("Visit [Google](https://google.com) for details")
72
+ .build();
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🔄 Auto-Update System
78
+
79
+ Package ini punya sistem auto-update bawaan yang selalu menjaga versi terbaru dari MessageBuilder.
80
+
81
+ ### Manual Update
82
+
83
+ ```js
84
+ import MB from "baileys-mbuilder";
85
+
86
+ await MB.update();
87
+ console.log("Updated to version:", MB.VERSION);
88
+ ```
89
+
90
+ ### Enable Auto-Update (periodic check)
91
+
92
+ ```js
93
+ import MB from "baileys-mbuilder";
94
+
95
+ // Cek update setiap 5 menit, dengan callback
96
+ MB.enableAutoUpdate(300000, (status) => {
97
+ if (status === "updated") {
98
+ console.log("Ada versi baru!");
99
+ }
100
+ });
101
+
102
+ // Nonaktifkan
103
+ MB.disableAutoUpdate();
104
+ ```
105
+
106
+ ### Cara Kerja
107
+
108
+ 1. Setiap interval, fetch dari repo untuk melihat perubahan
109
+ 2. Bandingkan hash sha dengan file lokal dengan repo commit
110
+ 3. Jika berbeda, download ulang & reload module via `import()`
111
+ 4. Default export (Proxy) otomatis mengarah ke module terbaru
112
+
113
+ > **Catatan:** Named imports (`import MB from ...`) bersifat **static** — tidak akan berubah setelah auto-update, kecuali di panggil lagi
114
+ > Gunakan **default import** (`import MB from ...`) untuk selalu mendapatkan class/fungsi terbaru.
115
+
116
+ ---
117
+
118
+ ## 📚 API Documentation
119
+
120
+ ### `Button` — Simple Button Builder
121
+
122
+ ```js
123
+ new MB.Button();
124
+ ```
125
+
126
+ | Method | Description |
127
+ | -------------------- | --------------------- |
128
+ | `.text(t)` | Body text |
129
+ | `.button(label, id)` | Tambah button (max 3) |
130
+ | `.footer(t)` | Footer text |
131
+ | `.header(t)` | Header text |
132
+ | `.viewOnce()` | View-once mode |
133
+ | `.build()` | Generate payload |
134
+
135
+ ### `ButtonV2` — Multi-row Button Builder
136
+
137
+ ```js
138
+ new MB.ButtonV2();
139
+ ```
140
+
141
+ | Method | Description |
142
+ | ---------------- | --------------------------------------- |
143
+ | `.text(t)` | Body text |
144
+ | `.row(callback)` | Tambah row (callback punya `.button()`) |
145
+ | `.footer(t)` | Footer text |
146
+ | `.header(t)` | Header text |
147
+ | `.viewOnce()` | View-once mode |
148
+ | `.build()` | Generate payload |
149
+
150
+ ### `Carousel` — Rich Card Carousel
151
+
152
+ ```js
153
+ new MB.Carousel();
154
+ ```
155
+
156
+ | Method | Description |
157
+ | ----------------- | --------------------------------------------------------------------------- |
158
+ | `.card(callback)` | Tambah card (callback punya `.image()`, `.title()`, `.text()`, `.button()`) |
159
+ | `.build()` | Generate payload |
160
+
161
+ ### `AIRich` — AI Rich Response
162
+
163
+ ```js
164
+ new MB.AIRich();
165
+ ```
166
+
167
+ | Method | Description |
168
+ | ------------------ | ---------------------------------------------- |
169
+ | `.text(t)` | Set text dengan inline syntax |
170
+ | `.extract(bool)` | Aktifkan/nonaktifkan ekstraksi (default: true) |
171
+ | `.hyperlink(bool)` | Aktifkan hyperlink `[text](url)` |
172
+ | `.citation(bool)` | Aktifkan auto citation |
173
+ | `.latex(bool)` | Aktifkan LaTeX `[text\|...](url)` |
174
+ | `.build()` | Generate payload |
175
+
176
+ ---
177
+
178
+ ## 🔧 API Functions
179
+
180
+ | Function | Description |
181
+ | ------------------------------------- | ------------------------------ |
182
+ | `MB.update(callback?)` | Force download & reload module |
183
+ | `MB.enableAutoUpdate(ms?, onUpdate?)` | Aktifkan periodic auto-update |
184
+ | `MB.disableAutoUpdate()` | Nonaktifkan auto-update |
185
+
186
+ ---
187
+
188
+ ## 📄 License
189
+
190
+ MIT © FongsiDev
191
+
192
+ **Note:** The underlying MBuilder library (downloaded from repo) is Copyright © 2026 Nixel(Dev) & FgsiDev(Contributor)
193
+
194
+ ---
195
+
196
+ ## 👤 Author
197
+
198
+ - **Nixel** — Original author
199
+ - **FongsiDev** — npm package publisher
200
+
201
+ ## 📞 Contact Support
202
+
203
+ - WhatsApp: [WhatsApp Number](https://wa.me/6282139672290)
204
+ - Channel: [WhatsApp Channel](https://whatsapp.com/channel/0029VbCV1ck8fewpdNb2TY2k)