zaileys 2.1.7 โ 2.1.9
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 +102 -19
- package/dist/index.d.mts +146 -125
- package/dist/index.d.ts +146 -125
- package/dist/index.js +27 -15
- package/dist/index.mjs +27 -15
- package/package.json +6 -5
- package/tsconfig.json +1 -0
package/README.MD
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
|
|
49
49
|
<br>
|
|
50
50
|
|
|
51
|
-
<a href="https://discord.gg/
|
|
51
|
+
<a href="https://discord.gg/KBHhTTVUc5"><img alt="Discord" src="https://discord.com/api/guilds/1105833273415962654/widget.png?style=banner2"></a>
|
|
52
52
|
|
|
53
53
|
</div>
|
|
54
54
|
|
|
@@ -66,19 +66,19 @@ Targeting **Node.js** and **TypeScript** developers, Zaileys integrates essentia
|
|
|
66
66
|
|
|
67
67
|
## ๐ชถ Features
|
|
68
68
|
|
|
69
|
-
- โ
**Auto-Cleanup** - Automatically delete old messages to keep database light
|
|
70
|
-
- โ
**Intelligent Health Manager** - Auto-recovery and connection monitoring
|
|
71
|
-
- โ
**History Filtering** - Smart filtering of old history sync messages
|
|
72
69
|
- โ
**Type-Safe** - Full TypeScript + Zod validation with autocomplete
|
|
73
70
|
- โ
**Middleware** - Intercept and process events globally
|
|
74
|
-
- โ
**Plugin System** - Drop-in file-based plugins
|
|
75
|
-
- โ
**State Management** - Built-in
|
|
76
|
-
- โ
**Event-Driven** - Clean listeners for `connection`, `messages`, `calls`
|
|
71
|
+
- โ
**Plugin System** - Drop-in file-based plugins with on/off controls
|
|
72
|
+
- โ
**State Management** - Built-in [JetDB](https://github.com/zeative/jetdb) for data persistence with **auto chunking**
|
|
77
73
|
- โ
**Rate Limiting** - Anti-spam protection out of the box
|
|
78
|
-
- โ
**Auto-Everything** - Auto-read, auto-reject calls, auto-mentions
|
|
79
74
|
- โ
**Multi-Device** - QR code or Pairing Code authentication
|
|
80
75
|
- โ
**Built-in FFmpeg** - No external dependencies for media processing
|
|
81
76
|
- โ
**Interactive Buttons** - Simple buttons, URL, copy code, call buttons, and lists
|
|
77
|
+
- โ
**Context Injection** - Universal data injection accessible anywhere in ctx
|
|
78
|
+
- โ
**Fancy Logs** - Beautiful, detailed logging with emoji indicators
|
|
79
|
+
- โ
**Fire and Forget** - Background task processing for lightning-fast responses
|
|
80
|
+
- โ
**Auto-Healing** - Intelligent connection monitoring and session repair
|
|
81
|
+
- โ
**Auto Clean Up** - Periodic database maintenance to save space
|
|
82
82
|
|
|
83
83
|
## ๐จ Concepts & Architecture
|
|
84
84
|
|
|
@@ -134,6 +134,9 @@ const wa = new Client({
|
|
|
134
134
|
authType: 'pairing',
|
|
135
135
|
phoneNumber: 6280000000,
|
|
136
136
|
|
|
137
|
+
// for detailed logs
|
|
138
|
+
// fancyLogs: true,
|
|
139
|
+
|
|
137
140
|
// if you want to disable built-in ffmpeg
|
|
138
141
|
// disableFFmpeg: true,
|
|
139
142
|
|
|
@@ -236,9 +239,11 @@ These options apply to both authentication methods:
|
|
|
236
239
|
| `session` | `string` | `'zaileys'` | Name of the session folder. |
|
|
237
240
|
| `prefix` | `string` | `undefined` | Command prefix (e.g., `'/'`). |
|
|
238
241
|
| `showLogs` | `boolean` | `true` | Enable internal logging. |
|
|
242
|
+
| `fancyLogs` | `boolean` | `false` | Enable detailed, fancy log output. |
|
|
239
243
|
| `ignoreMe` | `boolean` | `true` | Ignore messages sent by the bot itself. |
|
|
240
244
|
| `syncFullHistory` | `boolean` | `true` | Sync full chat history on startup. |
|
|
241
245
|
| `cleanupDays` | `number` | `7` | Days to keep messages before auto-deletion. |
|
|
246
|
+
| `autoCleanUp` | `object` | `undefined` | Configuration for periodic database cleanup. |
|
|
242
247
|
| `disableFFmpeg` | `boolean` | `false` | Disable built-in FFmpeg installers. |
|
|
243
248
|
|
|
244
249
|
### Automation Options
|
|
@@ -277,20 +282,14 @@ wa.use(async (ctx, next) => {
|
|
|
277
282
|
});
|
|
278
283
|
````
|
|
279
284
|
|
|
280
|
-
### ๐ ๏ธ Maintenance & Health
|
|
281
|
-
|
|
282
|
-
Zaileys includes built-in tools to keep your bot running smoothly and your database light.
|
|
283
|
-
|
|
284
|
-
- **Auto-Cleanup**: Automatically deletes messages older than `cleanupDays` (default 7) every hour.
|
|
285
|
-
- **Intelligent Recovery**: Automatically detects and repairs session issues or connection drops.
|
|
286
|
-
- **History Filtering**: Prevents database bloat by ignoring extremely old messages during the initial history sync.
|
|
287
|
-
|
|
288
285
|
### ๐งฉ Plugins
|
|
289
286
|
|
|
290
287
|
Zaileys features a built-in file-based plugin system. By default, it looks for plugins in the `plugins` directory of your project root.
|
|
291
288
|
|
|
292
289
|
**1. Create a plugin file** (e.g., `plugins/hello.ts`):
|
|
293
290
|
|
|
291
|
+
also nested file `plugins/nested1/nested2/hello.ts`
|
|
292
|
+
|
|
294
293
|
```typescript
|
|
295
294
|
import { definePlugins } from 'zaileys';
|
|
296
295
|
|
|
@@ -307,9 +306,7 @@ export default definePlugins(
|
|
|
307
306
|
);
|
|
308
307
|
```
|
|
309
308
|
|
|
310
|
-
**2.
|
|
311
|
-
|
|
312
|
-
**3. Extract plugin information** (optional):
|
|
309
|
+
**2. Extract plugin information** (optional):
|
|
313
310
|
|
|
314
311
|
```typescript
|
|
315
312
|
const pluginsInfo = wa.plugins.getPluginsInfo();
|
|
@@ -328,6 +325,31 @@ const pluginsInfo = wa.plugins.getPluginsInfo();
|
|
|
328
325
|
|
|
329
326
|
This returns an array of all loaded plugins with their `matcher` and `metadata`, useful for generating help menus or listing available commands.
|
|
330
327
|
|
|
328
|
+
**3. Plugin Controls:**
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
// Disable all plugins
|
|
332
|
+
wa.plugins.disableAll();
|
|
333
|
+
|
|
334
|
+
// Enable all plugins
|
|
335
|
+
wa.plugins.enableAll();
|
|
336
|
+
|
|
337
|
+
// Disable specific plugin by matcher
|
|
338
|
+
wa.plugins.disable('/hello');
|
|
339
|
+
|
|
340
|
+
// Enable specific plugin
|
|
341
|
+
wa.plugins.enable('/hello');
|
|
342
|
+
|
|
343
|
+
// Disable all plugins in a folder (e.g., plugins/admin/)
|
|
344
|
+
wa.plugins.disableByParent('admin');
|
|
345
|
+
|
|
346
|
+
// Enable all plugins in a folder
|
|
347
|
+
wa.plugins.enableByParent('admin');
|
|
348
|
+
|
|
349
|
+
// Check if plugins are globally enabled
|
|
350
|
+
wa.plugins.isEnabled(); // true/false
|
|
351
|
+
```
|
|
352
|
+
|
|
331
353
|
### ๐ Citation (Custom Authorization)
|
|
332
354
|
|
|
333
355
|
Citation allows you to define custom authorization logic by creating named checkers that verify if a user is in a specific list (e.g., premium users, banned users).
|
|
@@ -376,6 +398,67 @@ Citation functions return an array of phone numbers, group id and lid Internally
|
|
|
376
398
|
|
|
377
399
|
If any of these match a number in your returned array, the citation check returns `true`. This makes it flexible for both individual chats and group scenarios.
|
|
378
400
|
|
|
401
|
+
### ๐ Context Injection
|
|
402
|
+
|
|
403
|
+
Context Injection allows you to inject custom data that is accessible in every message context.
|
|
404
|
+
|
|
405
|
+
**1. Inject data:**
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
// Inject data anywhere in your app
|
|
409
|
+
wa.inject('user', { name: 'Kejaa', role: 'admin' });
|
|
410
|
+
wa.inject('config', { debug: true, version: '1.0.0' });
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**2. Access injected data in handlers:**
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
wa.on('messages', async (ctx) => {
|
|
417
|
+
console.log(ctx.injection.user); // { name: 'John', role: 'admin' }
|
|
418
|
+
console.log(ctx.injection.config); // { debug: true, version: '1.0.0' }
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**3. Manage injections:**
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
// Get injection value
|
|
426
|
+
const user = wa.getInjection('user');
|
|
427
|
+
|
|
428
|
+
// Remove specific injection
|
|
429
|
+
wa.removeInjection('user');
|
|
430
|
+
|
|
431
|
+
// Clear all injections
|
|
432
|
+
wa.clearInjections();
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
This is perfect for sharing database connections, user sessions, or configuration across all handlers.
|
|
436
|
+
|
|
437
|
+
### ๐ก๏ธ Auto-Healing
|
|
438
|
+
|
|
439
|
+
Zaileys includes an intelligent `HealthManager` that monitors your connection and automatically repairs corrupted sessions.
|
|
440
|
+
|
|
441
|
+
- **Bad MAC Repair**: Automatically detects "Bad MAC" errors and repairs the affected session keys without requiring a full logout.
|
|
442
|
+
- **Log Suppression**: Silences noisy stack traces and internal error messages from `libsignal-node` to keep your terminal clean.
|
|
443
|
+
- **Zero Config**: Enabled by default and works silently in the background.
|
|
444
|
+
|
|
445
|
+
### ๐งน Auto Clean Up
|
|
446
|
+
|
|
447
|
+
Keep your database lean and performant by enabling automatic cleanup of old messages.
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
const wa = new Client({
|
|
451
|
+
autoCleanUp: {
|
|
452
|
+
enabled: true,
|
|
453
|
+
intervalMs: 60 * 60 * 1000, // Run every 1 hour
|
|
454
|
+
maxAgeMs: 24 * 60 * 60 * 1000, // Delete messages older than 24 hours
|
|
455
|
+
scopes: ['messages'], // Database scopes to clean
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
The `CleanUpManager` runs in the background and ensures your storage usage stays within limits.
|
|
461
|
+
|
|
379
462
|
## ๐ซ Sending Messages
|
|
380
463
|
|
|
381
464
|
> **Quick Jump:** [Text](#send-text) ยท [Reply](#reply-to-message) ยท [Forward](#forward-message) ยท [Media](#send-media) ยท [Banner](#send-with-banner) ยท [Location](#send-location) ยท [Contact](#send-contact) ยท [Poll](#send-poll) ยท [Reaction](#send-reaction) ยท [Presence](#update-presence) ยท [Mentions](#mentions) ยท [Edit & Delete](#edit--delete-messages) ยท [Buttons](#interactive-buttons) ยท [Member Label](#member-label)
|