@lzif/zaileys 1.0.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/LICENSE +21 -0
- package/QWEN.md +135 -0
- package/README.MD +1230 -0
- package/dist/index.d.mts +1184 -0
- package/dist/index.d.ts +1184 -0
- package/dist/index.js +34 -0
- package/dist/index.mjs +34 -0
- package/package.json +84 -0
- package/tsconfig.json +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zaadevofc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/QWEN.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Zaileys - WhatsApp Node.js TypeScript/JavaScript API
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
Zaileys is a powerful, type-safe wrapper around Baileys, designed to simplify the development of WhatsApp bots. It provides a robust architecture with built-in state management, middleware support, and easy-to-use event handlers, making it perfect for building scalable and maintainable WhatsApp applications.
|
|
6
|
+
|
|
7
|
+
This library targets Node.js and TypeScript developers, providing an opinionated API that handles the complexity of managing raw WhatsApp socket connections. It includes essential features like rate limiting, session management, and input validation out of the box.
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
- ✅ **Auto-Cleanup** - Automatically delete old messages to keep database light
|
|
11
|
+
- ✅ **Intelligent Health Manager** - Auto-recovery and connection monitoring
|
|
12
|
+
- ✅ **History Filtering** - Smart filtering of old history sync messages
|
|
13
|
+
- ✅ **Type-Safe** - Full TypeScript + Zod validation with autocomplete
|
|
14
|
+
- ✅ **Middleware** - Intercept and process events globally
|
|
15
|
+
- ✅ **Plugin System** - Drop-in file-based plugins
|
|
16
|
+
- ✅ **State Management** - Built-in `JetDB` for data persistence with **auto chunking**
|
|
17
|
+
- ✅ **Event-Driven** - Clean listeners for `connection`, `messages`, `calls`
|
|
18
|
+
- ✅ **Rate Limiting** - Anti-spam protection out of the box
|
|
19
|
+
- ✅ **Auto-Everything** - Auto-read, auto-reject calls, auto-mentions
|
|
20
|
+
- ✅ **Multi-Device** - QR code or Pairing Code authentication
|
|
21
|
+
- ✅ **Built-in FFmpeg** - No external dependencies for media processing
|
|
22
|
+
- ✅ **Interactive Buttons** - Simple buttons, URL, copy code, call buttons, and lists
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
### Core Concepts
|
|
27
|
+
- **Client** - Your bot's brain. Manages connections, events, and the entire lifecycle.
|
|
28
|
+
- **Context** - Rich event objects with all the data and helpers you need.
|
|
29
|
+
- **Middleware** - Pre-process events for logging, auth, spam filtering, or custom logic.
|
|
30
|
+
- **Plugins** - Drop files in `plugins/` directory. Auto-loaded, zero config.
|
|
31
|
+
- **Store** - JSON database (`JetDB`) that auto-syncs chats, contacts, and messages.
|
|
32
|
+
|
|
33
|
+
### Project Structure
|
|
34
|
+
```
|
|
35
|
+
src/
|
|
36
|
+
├── Auth/ # Authentication related modules
|
|
37
|
+
├── Classes/ # Core class implementations (Client, Middleware, etc.)
|
|
38
|
+
├── Config/ # Configuration modules
|
|
39
|
+
├── Listener/ # Event listeners
|
|
40
|
+
├── Modules/ # Core functionality modules (store, limiter, zod)
|
|
41
|
+
├── Signal/ # Signal handling for different features (groups, privacy, etc.)
|
|
42
|
+
├── Types/ # Type definitions
|
|
43
|
+
└── Utils/ # Utility functions
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Building and Running
|
|
47
|
+
|
|
48
|
+
### Prerequisites
|
|
49
|
+
- Node.js v20+
|
|
50
|
+
- TypeScript (for best experience)
|
|
51
|
+
|
|
52
|
+
### Installation
|
|
53
|
+
```bash
|
|
54
|
+
npm install zaileys
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Build Commands
|
|
58
|
+
From the `package.json`:
|
|
59
|
+
- `npm run build` - Build the project using tsup
|
|
60
|
+
- `npm run test` - Run tests with tsx
|
|
61
|
+
- `npm run r:patch` - Build and publish a patch version
|
|
62
|
+
- `npm run r:minor` - Build and publish a minor version
|
|
63
|
+
- `npm run r:major` - Build and publish a major version
|
|
64
|
+
|
|
65
|
+
### Quick Start Example
|
|
66
|
+
```typescript
|
|
67
|
+
import { Client } from 'zaileys';
|
|
68
|
+
|
|
69
|
+
const wa = new Client({
|
|
70
|
+
// dynamic session you can change
|
|
71
|
+
session: 'zaileys', // default
|
|
72
|
+
|
|
73
|
+
// qr code
|
|
74
|
+
authType: 'qr',
|
|
75
|
+
|
|
76
|
+
// pairing code
|
|
77
|
+
authType: 'pairing',
|
|
78
|
+
phoneNumber: 6280000000,
|
|
79
|
+
|
|
80
|
+
// if you want to disable built-in ffmpeg
|
|
81
|
+
// disableFFmpeg: true,
|
|
82
|
+
|
|
83
|
+
sticker: {
|
|
84
|
+
authorName: 'your name',
|
|
85
|
+
packageName: 'package name',
|
|
86
|
+
quality: 80,
|
|
87
|
+
shape: 'circle', // output sticker must be circle
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
wa.on('messages', async (ctx) => {
|
|
92
|
+
if (ctx.text == 'ping') {
|
|
93
|
+
await wa.send(ctx.roomId, 'Pong! 🏓');
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Development Conventions
|
|
99
|
+
|
|
100
|
+
### TypeScript Configuration
|
|
101
|
+
- Target: ES2022
|
|
102
|
+
- Module: ESNext
|
|
103
|
+
- Strict mode: disabled (for compatibility)
|
|
104
|
+
- Module resolution: bundler
|
|
105
|
+
|
|
106
|
+
### Dependencies
|
|
107
|
+
- **Core**: `baileys` (WhatsApp Web API), `jetdb` (JSON database)
|
|
108
|
+
- **Validation**: `zod` (type validation)
|
|
109
|
+
- **Media**: `@ffmpeg-installer/ffmpeg`, `@ffprobe-installer/ffprobe`, `sharp`
|
|
110
|
+
- **Utilities**: `lodash`, `pino` (logger), `nanospinner`, `rate-limiter-flexible`
|
|
111
|
+
|
|
112
|
+
### Architecture Patterns
|
|
113
|
+
- Event-driven architecture with EventEmitter
|
|
114
|
+
- Proxy-based class injection for modular functionality
|
|
115
|
+
- Plugin system with auto-loading capabilities
|
|
116
|
+
- Middleware pattern for request processing
|
|
117
|
+
- Health management with auto-recovery
|
|
118
|
+
|
|
119
|
+
### Code Structure
|
|
120
|
+
- Main client class combines functionality through interface merging
|
|
121
|
+
- Signal classes handle specific WhatsApp features (groups, privacy, etc.)
|
|
122
|
+
- Store module manages data persistence and caching
|
|
123
|
+
- Utility functions provide common operations
|
|
124
|
+
- Type definitions ensure type safety throughout the codebase
|
|
125
|
+
|
|
126
|
+
## Testing
|
|
127
|
+
The project uses a test script that can be run with `npm run test`, which executes examples/test.ts with tsx in watch mode.
|
|
128
|
+
|
|
129
|
+
## Contributing
|
|
130
|
+
Based on the README, contributions are welcome following the standard GitHub workflow:
|
|
131
|
+
1. Fork the repository
|
|
132
|
+
2. Create a new branch for your feature
|
|
133
|
+
3. Commit your changes
|
|
134
|
+
4. Push to your branch
|
|
135
|
+
5. Open a Pull Request
|