@vanzxy/baileys 2.0.0 → 2.0.1
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 +48 -2
- package/lib/{Utils → Builders}/A2UI.js +2 -2
- package/lib/Builders/AIRich.js +2286 -0
- package/lib/Builders/Button.js +883 -0
- package/lib/Builders/ButtonV2.js +144 -0
- package/lib/Builders/ButtonV3.js +184 -0
- package/lib/Builders/Carousel.js +111 -0
- package/lib/Builders/Poll.js +128 -0
- package/lib/Builders/VanzxyBaileys.js +108 -0
- package/lib/Builders/index.js +11 -0
- package/lib/Builders/shared.js +652 -0
- package/lib/Utils/MessageBuilder.js +2 -4405
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +0 -1
- package/lib/index.js +3 -0
- package/package.json +4 -7
- package/postinstall-banner.js +51 -25
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
- [Poll](#poll)
|
|
58
58
|
- [Carousel](#carousel)
|
|
59
59
|
- [AIRich — rich response cards](#airich--rich-response-cards)
|
|
60
|
+
- [📁 Builders Folder Map](#-builders-folder-map-libbuilders)
|
|
60
61
|
- [📞 Voice & Video Calls](#-voice--video-calls)
|
|
61
62
|
- [🔎 User Sync Queries](#-user-sync-queries)
|
|
62
63
|
- [👤 Username Management](#-username-management)
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
- [💖 Support](#-support)
|
|
74
75
|
- [👑 Maintainer](#-maintainer)
|
|
75
76
|
- [⚠️ Disclaimer](#-disclaimer)
|
|
76
|
-
- [📝 Patch Notes](#-
|
|
77
|
+
- [📝 Patch Notes](#-v6-patch-notes)
|
|
77
78
|
|
|
78
79
|
</details>
|
|
79
80
|
|
|
@@ -511,6 +512,41 @@ await new AIRich(sock)
|
|
|
511
512
|
|
|
512
513
|
Other builders worth knowing about: **`ButtonV2`** (simpler quick-reply-only buttons), **`ButtonV3`** (`loadFrom(msg)` to edit an existing template message in place), and **`Toolkit`** (static helpers: `Toolkit.resize()`, `Toolkit.fetchBuffer()`, `Toolkit.waitAllPromises()`, `Toolkit.extractIE()` for parsing `[label](url)` links/citations/LaTeX out of plain text).
|
|
513
514
|
|
|
515
|
+
### 📁 Builders Folder Map (`lib/Builders/`)
|
|
516
|
+
|
|
517
|
+
Every message builder lives in its own file under `lib/Builders/`, so you can trace exactly where a class comes from instead of digging through one giant `MessageBuilder.js`. `index.js` is just the barrel file that re-exports everything below (plus their aliases) for the top-level `import { ... } from '@vanzxy/baileys'` syntax.
|
|
518
|
+
|
|
519
|
+
| File | Exports | What it's for |
|
|
520
|
+
|---|---|---|
|
|
521
|
+
| `shared.js` | `Toolkit`, `BaseBuilder`, `RowBuilder` | The shared foundation every other builder is built on. `BaseBuilder` holds the common chainable `send()`/context-info plumbing, `RowBuilder` is the shared row/section helper, and `Toolkit` is the static-helper grab bag (`resize`, `fetchBuffer`, `waitAllPromises`, `extractIE`, media-duration/preview helpers). Nothing here is meant to be instantiated directly in bot code — it exists so `Button`, `Poll`, `Carousel`, etc. don't each reimplement the same plumbing. |
|
|
522
|
+
| `Button.js` | `Button`, `CardBuilder` | The main interactive/native-flow button builder — headers (image/video/document), CTA helpers (`addUrl`, `addCall`, `addReply`, and the wider native-flow set), and `.toCard()` to turn a button message into a `Carousel` card. |
|
|
523
|
+
| `ButtonV2.js` | `ButtonV2` | A lighter-weight variant limited to simple quick-reply buttons — reach for this when you don't need the full native-flow surface of `Button`. |
|
|
524
|
+
| `ButtonV3.js` | `ButtonV3` | Built around `loadFrom(msg)` — loads an existing `templateMessage` (e.g. one you fetched or that was quoted) so you can edit it in place instead of building one from scratch. |
|
|
525
|
+
| `Carousel.js` | `Carousel` | Chains `Button(...).toCard()` results into a swipeable card carousel. Capped at `Carousel.MAX_CARDS` (10) since WhatsApp silently truncates anything beyond that. |
|
|
526
|
+
| `Poll.js` | `Poll` | Poll/vote message builder — question, options, single/multi-select, hidden-voter mode, correct-answer marking, expiry. |
|
|
527
|
+
| `AIRich.js` | `AIRich` (+ aliases `ORich`, `AIVanzxy`, `LeafRich`, `VanzxyAI`, `VanzxyRich`, `RichVanzxy`) | The rich AI-assistant-style response builder described above — headings, formatted text, tables, media/product/post cards, task/progress cards, tip banners, quick-reply suggestions. |
|
|
528
|
+
| `A2UI.js` | `A2UI`, `sendA2UIWidget` | Lower-level A2UI/Bloks widget builder. Builds the flat `components` tree (Column/Row → `children`, Card/Button → `child`, Modal → `trigger`/`content`) that Bloks widgets expect and sends it through the same `getBizBinaryNode()` path as `Button`/`ButtonV2`, so the wire-level node always matches the button names actually sent. |
|
|
529
|
+
| `VanzxyBaileys.js` | `VanzxyBaileys` | A unified builder **hub** — one object that wraps all the builders above behind short method names (`.button()`, `.buttonV2()`, `.buttonV3()`, `.carousel()`, `.poll()`, `.airich()`, `.a2ui()`), plus PascalCase aliases (`.Button()`, `.Carousel()`, `.Poll()`, `.AIRich()`, `.A2UI()`) for developers who prefer that naming style. Nothing new is implemented here — it's purely a single entry point over the individual classes. |
|
|
530
|
+
| `index.js` | everything above, plus `MESSAGE_BUILDER_VERSION` | The barrel file — re-exports every builder and its aliases so `import { Button, Poll, AIRich, VanzxyBaileys } from '@vanzxy/baileys'` works without reaching into individual files. `MESSAGE_BUILDER_VERSION` tracks the builder API surface's own version, independent of the package version. |
|
|
531
|
+
|
|
532
|
+
**Unified hub example** — useful if you'd rather carry one object around than import each builder individually:
|
|
533
|
+
|
|
534
|
+
```js
|
|
535
|
+
import { VanzxyBaileys } from '@vanzxy/baileys'
|
|
536
|
+
|
|
537
|
+
const vx = new VanzxyBaileys(sock)
|
|
538
|
+
|
|
539
|
+
await vx.button()
|
|
540
|
+
.setTitle('Promo Spesial')
|
|
541
|
+
.addReply('Klaim Sekarang', 'claim_promo')
|
|
542
|
+
.send(jid)
|
|
543
|
+
|
|
544
|
+
await vx.poll()
|
|
545
|
+
.setName('Mau makan apa hari ini?')
|
|
546
|
+
.addOptions(['Nasi Goreng', 'Mie Ayam'])
|
|
547
|
+
.send(jid)
|
|
548
|
+
```
|
|
549
|
+
|
|
514
550
|
---
|
|
515
551
|
|
|
516
552
|
## 📞 Voice & Video Calls
|
|
@@ -790,6 +826,16 @@ Use responsibly and follow WhatsApp Terms of Service.
|
|
|
790
826
|
|
|
791
827
|
---
|
|
792
828
|
|
|
829
|
+
## 📝 V6 Patch Notes
|
|
830
|
+
|
|
831
|
+
- Fixed a `package.json` typo: the version field was mistakenly left at `1.0.1` instead of `2.0.1` after the V5 release — corrected to `2.0.1` so the published package version matches the intended release.
|
|
832
|
+
- Expanded README documentation, especially around `lib/Builders/`:
|
|
833
|
+
- Added the new [📁 Builders Folder Map](#-builders-folder-map-libbuilders) section — a per-file breakdown of everything under `lib/Builders/` (`shared.js`, `Button.js`, `ButtonV2.js`, `ButtonV3.js`, `Carousel.js`, `Poll.js`, `AIRich.js`, `A2UI.js`, `VanzxyBaileys.js`, `index.js`), what each file exports, and what it's for — previously `A2UI` and `VanzxyBaileys` in particular had no usage documentation at all.
|
|
834
|
+
- Added a usage example for the `VanzxyBaileys` unified builder hub.
|
|
835
|
+
- Redesigned `postinstall-banner.js`: cleaner box layout with a divider separating the title block from a small info section (Node version + docs link), a 256-color palette instead of basic ANSI colors, and a plain-text fallback when stdout isn't a TTY or `NO_COLOR` is set (CI logs, piped output) instead of forcing a box that may render misaligned.
|
|
836
|
+
|
|
837
|
+
---
|
|
838
|
+
|
|
793
839
|
## 📝 V5 Patch Notes
|
|
794
840
|
|
|
795
841
|
- Added [Username Management](#-username-management): `checkUsername`, `checkUsernameMulti`, `setUsername`, `deleteUsername`, `getMyUsername`, `setUsernamePin`, `findUserByUsername`, `fetchContactUsernames`, `getUsernameRecommendations` — ported from `@queenanya/baileys`, layered onto this fork's existing `USyncUsernameProtocol` support.
|
|
@@ -798,7 +844,7 @@ Use responsibly and follow WhatsApp Terms of Service.
|
|
|
798
844
|
- `MediaManager`'s sticker/voice-note conversion now reuses this fork's existing lazy `fluent-ffmpeg` loader (see `Utils/MessageBuilder.js`) instead of adding `ffmpeg-static` + a second ffmpeg dependency; `node-webpmux` (sticker EXIF metadata) is lazy-loaded the same way and only when packname/author is actually requested.
|
|
799
845
|
- `Bot`'s default logger now falls back to this fork's own pino instance instead of a silent no-op stub.
|
|
800
846
|
- No `.d.ts` files were written for the new Framework module yet — see the note in that section.
|
|
801
|
-
- Bumped to `1.0.
|
|
847
|
+
- Bumped to `1.0.1`.
|
|
802
848
|
|
|
803
849
|
---
|
|
804
850
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/
|
|
2
|
+
* lib/Builders/A2UI.js — A2UI (Bloks) widget builder + sender
|
|
3
3
|
*
|
|
4
4
|
* Part of @vanzxy/baileys. Builds the flat `components` array A2UI/Bloks
|
|
5
5
|
* expects (id-referencing tree: Column/Row hold `children`, Card/Button hold
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"use strict";
|
|
17
17
|
|
|
18
18
|
import crypto from "crypto";
|
|
19
|
-
import { generateWAMessageFromContent, prepareWAMessageMedia } from "
|
|
19
|
+
import { generateWAMessageFromContent, prepareWAMessageMedia } from "../Utils/messages.js";
|
|
20
20
|
import { getBizBinaryNode } from "../WABinary/index.js";
|
|
21
21
|
|
|
22
22
|
class A2UI {
|