Skip to content

Commit 3fb58c2

Browse files
committed
docs: document Lottie/premium sticker conversion + optional rlottie
1 parent 97d42be commit 3fb58c2

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

docs/content/media.mdx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ const fromBuffer = new Media(await fs.readFile('./assets/clip.mp4'))
6262
native). If `sharp` is absent, Zaileys transparently falls back to the pure-JS `jimp` path and
6363
prints a one-line warning suggesting `npm install sharp`. Everything works either way — `sharp`
6464
is purely an accelerator.
65+
66+
**Lottie renderer** — premium / avatar stickers (`application/was`) are Lottie animations. Converting
67+
them to a normal sticker needs the optional **`rlottie`** wasm engine. Install it only if you need
68+
Lottie conversion; without it, every other sticker path keeps working and passing a Lottie buffer
69+
throws a clear, catchable error. See [`media.sticker`](#mediasticker) below.
6570
</Callout>
6671

6772
<Tabs items={['npm', 'pnpm', 'yarn', 'bun']}>
@@ -161,7 +166,8 @@ const thumb = await media.image.thumbnail() // base64 JPEG string
161166

162167
Turn an image, GIF, or video into a WhatsApp WebP sticker. Animated sources (GIF/video) produce
163168
animated stickers (capped at 6 s, 10 fps, 512×512); static images become static stickers. Already-WebP
164-
inputs are passed through. EXIF pack metadata is embedded automatically.
169+
inputs are passed through. Premium / Lottie stickers (`application/was`) are auto-detected and
170+
rasterized to animated WebP (see below). EXIF pack metadata is embedded automatically.
165171

166172
```typescript
167173
create(metadata?: StickerMetadataType): Promise<Buffer>
@@ -197,6 +203,52 @@ const animated = await new Media('./assets/loop.gif').sticker.create({ quality:
197203
await client.send('6281234567890@s.whatsapp.net').sticker(animated)
198204
```
199205

206+
### Premium / Lottie stickers (`application/was`)
207+
208+
WhatsApp's **premium** and **avatar** stickers are [Lottie](https://lottiefiles.com/) vector animations
209+
(mimetype `application/was`), not raster images — and WhatsApp blocks **non-premium** users from saving
210+
them. When you pass a Lottie / `.was` buffer to `sticker.create()` (or `client.send(jid).sticker(buf)`),
211+
Zaileys detects it and rasterizes the animation into a standard animated WebP sticker that **anyone can
212+
save**, capped at 3 s / 15 fps / 512×512.
213+
214+
This needs the optional **`rlottie`** wasm renderer. Install it only if you want Lottie conversion:
215+
216+
<Tabs items={['npm', 'pnpm', 'yarn', 'bun']}>
217+
<Tabs.Tab>
218+
```bash npm i rlottie ```
219+
</Tabs.Tab>
220+
<Tabs.Tab>
221+
```bash pnpm add rlottie ```
222+
</Tabs.Tab>
223+
<Tabs.Tab>
224+
```bash yarn add rlottie ```
225+
</Tabs.Tab>
226+
<Tabs.Tab>
227+
```bash bun add rlottie ```
228+
</Tabs.Tab>
229+
</Tabs>
230+
231+
Without `rlottie`, passing a Lottie buffer throws a clear, catchable error (`rlottie not installed; run:
232+
pnpm add rlottie`) — wrap the call and fall back (e.g. `client.forward(...)`) if you can't add the dep.
233+
234+
```typescript
235+
// Relay a received premium/Lottie sticker so non-premium users can save it
236+
client.on('sticker', async (ctx) => {
237+
const buf = await ctx.media.buffer()
238+
const to = ctx.roomId ?? ctx.senderId
239+
try {
240+
await client.send(to).sticker(buf) // auto-converted to a savable WebP
241+
} catch {
242+
await client.forward(ctx.message().key, to) // fallback if rlottie is absent
243+
}
244+
})
245+
```
246+
247+
<Callout type="info">
248+
Conversion runs through the bundled ffmpeg, so the same ffmpeg note above applies (Termux needs a
249+
system ffmpeg). Lottie stickers with external image assets are inlined automatically before rendering.
250+
</Callout>
251+
200252
<Callout type="info">
201253
`shape` only affects static stickers. Animated stickers are always padded to a square. Both
202254
static and animated paths require their image backend / ffmpeg — see the requirements callout

docs/public/llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Key facts an LLM should know:
1717
- Commands: set `commandPrefix` in options, then `client.command('name', handler)` (aliases via `name|alias`), with `client.use(middleware)`.
1818
- Plugins: drop files in a folder and load them with `plugins: { dir: './plugins' }`. Author with `export default definePlugin({ name, setup(ctx) { ... }, onUnload? })`; `ctx` can register `command`/`use`/`on`/`once` plus a returned teardown, all auto-reversed on unload. Recursive nested scan, hot-reload on by default (`watch: true`), error-isolated (one bad plugin is skipped). Plugins are trusted in-process code (no sandbox).
1919
- Automation: `client.broadcast(recipients, builderFn, { rateLimitPerSec, onProgress })` and `client.scheduleAt(...)`.
20-
- Storage adapters (auth + message stores): File (default), Memory, SQLite, Postgres, Redis, Convex. Optional peer deps: `better-sqlite3`, `pg`, `redis`, `convex`. Media processing uses bundled ffmpeg and optionally `sharp` (falls back to `jimp`).
20+
- Storage adapters (auth + message stores): File (default), Memory, SQLite, Postgres, Redis, Convex. Optional peer deps: `better-sqlite3`, `pg`, `redis`, `convex`. Media processing uses bundled ffmpeg and optionally `sharp` (falls back to `jimp`). Premium/avatar stickers are Lottie animations (`application/was`); `sticker()` auto-detects and rasterizes them to a savable animated WebP via the optional `rlottie` wasm renderer (install `rlottie` to enable; without it, passing a Lottie buffer throws a clear catchable error).
2121
- Auto-delete: old messages are pruned from the local store on a rolling window — enabled by default with a 1-month `maxAgeMs` (`autoDelete: false` disables; override `maxAgeMs`/`maxPerChat`/`intervalMs`/`chats`). Local store cleanup only — it never deletes messages on WhatsApp. Backed by optional `MessageStore.pruneMessages`/`deleteMessage`, implemented natively by all built-in adapters.
2222
- Utilities exported from `zaileys`: JID helpers (`isJid`, `normalizeJid`, `isLidJid`, `isPnJid`, `jidToPhone`, `phoneToJid`, plus re-exported baileys `jidDecode`/`jidEncode`/`jidNormalizedUser`/`areJidsSameUser`/`isJidGroup`/`isJidNewsletter`/`isLidUser`/`isPnUser`), id hashers (`computeUniqueId`, `computeStaticId`), `extractLinks`, `senderDeviceOf`, `epochSecondsToMs`, `loadMedia`, `detectMimeFromBuffer`, `chunk`.
2323
- Errors are typed classes with `.code`: `ZaileysBuilderError`, `ZaileysCommandError`, `ZaileysDomainError`, `ZaileysAutomationError`, `ZaileysStoreError`.

0 commit comments

Comments
 (0)