zaileys 0.28.93-beta → 0.28.95-beta

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 (2) hide show
  1. package/README.md +307 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
- <p align="center"><img src="https://socialify.git.ci/zeative/zaileys/image?description=1&amp;descriptionEditable=Zaileys%20is%20a%20simplified%20version%20of%20the%20Baileys%20package%20%0Awhich%20is%20easier%20and%20faster.&amp;font=KoHo&amp;forks=1&amp;issues=1&amp;language=1&amp;name=1&amp;owner=1&amp;pattern=Circuit%20Board&amp;pulls=1&amp;stargazers=1&amp;theme=Auto" alt="project-image"></p>
1
+ <div align='center'>
2
+ <img alt="Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API" border='4' src="https://socialify.git.ci/zeative/zaileys/image?description=1&amp;descriptionEditable=Zaileys%20is%20a%20simplified%20version%20of%20the%20Baileys%20package%20%0Awhich%20is%20easier%20and%20faster.&amp;font=KoHo&amp;forks=1&amp;issues=1&amp;language=1&amp;name=1&amp;owner=1&amp;pattern=Circuit%20Board&amp;pulls=1&amp;stargazers=1&amp;theme=Auto">
3
+ </div>
2
4
 
3
- <h1 align="center" id="title">Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API</h1>
5
+ <h1 align="center">Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API</h1>
4
6
 
5
7
  <div align='center'>
6
8
 
@@ -15,51 +17,323 @@
15
17
 
16
18
  </div>
17
19
 
18
- Zaileys is a powerful and flexible WhatsApp API library for Node.js, built on top of Baileys. It simplifies the process of integrating WhatsApp functionalities into your applications, providing a comprehensive set of features for building robust and scalable WhatsApp-based solutions.
20
+ > [!WARNING]
21
+ > This is beta version, not recomended to use in production. Join whatsapp community for latest info [WhatsApp Channel](https://whatsapp.com/channel/0029VazENbmInlqHIWzgn33h)
22
+
23
+ Zaileys is a powerful and flexible WhatsApp API library for Node.js, built on top of [Baileys](https://github.com/WhiskeySockets/Baileys). It simplifies the process of integrating WhatsApp functionalities into your applications, providing a comprehensive set of features for building robust and scalable WhatsApp-based solutions.
19
24
 
20
- **Key Features:**
25
+ ## # Features
21
26
 
22
- * **Multi-Device Support:** Leverage the latest WhatsApp multi-device features for enhanced reliability and performance.
23
- * **Comprehensive API:** Access a wide range of WhatsApp functionalities, including sending and receiving messages, media handling, group management, and more.
24
- * **Easy to Use:** Designed with developer experience in mind, Zaileys offers a clean and intuitive API that is easy to learn and use.
25
- * **Highly Customizable:** Adapt the library to your specific needs with flexible configuration options and modular design.
27
+ - **Multi-Device Support:** Leverage the latest WhatsApp multi-device features for enhanced reliability and performance.
28
+ - **Customizable:** Adapt the library to your specific needs with flexible configuration options and modular design.
26
29
 
27
- ## Installation
30
+ ## # Installation
28
31
 
29
32
  ```bash
30
- npm install zaileys
33
+ npm add zaileys
34
+
35
+ pnpm add zaileys
36
+
37
+ yarn add zaileys
38
+
39
+ bun add zaileys
40
+
41
+ deno add npm:zaileys
42
+ ```
43
+
44
+ ## # Example Code
45
+
46
+ > [!TIP]
47
+ > If you don't want to take time for setup and configuration, use the [example.ts](https://github.com/zeative/zaileys/blob/main/test/example.ts) file that I have provided.
48
+
49
+ ## # Usage & Configuration
50
+
51
+ ### 📦 Import Library
52
+
53
+ ```js
54
+ // ESM
55
+ import { Client } from "zaileys";
56
+
57
+ // CJS
58
+ const { Client } = require("zaileys");
31
59
  ```
32
60
 
33
- ## Usage
61
+ ### ⚙️ Configuration
62
+
63
+ > [!WARNING]
64
+ > Warning! in beta version this library uses built-in Baileys [`makeInMemoryStore`](https://github.com/WhiskeySockets/Baileys?tab=readme-ov-file#implementing-a-data-store) function which will most likely use quite a lot of RAM.
65
+ > If you experience this, you can delete the `.zaileys/memory.json` file then restart the server.
66
+
67
+ ```ts
68
+ const wa = new Client({
69
+ prefix: "/", // for command message, example '/'
70
+ ignoreMe: true, // ignore messages from bot (bot phone number)
71
+ phoneNumber: 628xxx, // fill bot phone number if auth type is 'pairing'
72
+ authPath: ".zaileys", // auth directory path for session and chat store
73
+ authType: "pairing", // auth type 'pairing' or 'qr'
74
+ showLogs: true, // show logs of any chats
75
+ autoMentions: true, // bot will be auto mentioned if text contains sender number with '@' prefix
76
+ autoOnline: true, // bot status will be mark online
77
+ autoRead: true, // auto read message from any chats
78
+ autoRejectCall: true, // auto reject call if someone call you
79
+ citation: {
80
+ // your citation will be boolean object based on validate with your value
81
+ // system will be validate your value with 'senderId' and 'roomId'
82
+ // if one is valid then the key will return 'boolean'
83
+ // sample output: { isAuthors: boolean }
84
+
85
+ // just sample, you can rename with any key
86
+ authors: () => ["628xxxx"], // key 'authors' will be 'isAuthors'
87
+ myGroups: () => ["1203633xxxxx"], // key 'myGroups' will be 'isMyGroups'
88
+ ...otherKey // key 'otherKey' will be 'isOtherKey'
89
+ },
90
+ });
91
+ ```
92
+
93
+ <hr>
94
+
95
+ > [!NOTE]
96
+ > The functions and parameters below may change at any time considering that this library is a beta version. So when you update a library to the latest version but an error occurs, there may be changes to certain functions and parameters.
97
+
98
+ ### 🛎️ Event Handler
99
+
100
+ You can find out the output type of each object in the listener below:
34
101
 
35
- ### Import Client
102
+ - ctx for [`connection`]()
103
+ - ctx for [`message`]()
104
+ - ctx for [`command`]()
105
+ - ctx for [`call`]()
36
106
 
37
- ```typescript
38
- import { Client } from 'zaileys';
107
+ ```ts
108
+ wa.on("connection", (ctx) => {}); // listener for current connection
109
+ wa.on("message", (ctx) => {}); // listener for message from any chats
110
+ wa.on("command", (ctx) => {}); // listener for message that starts with prefix at beginning of word
111
+ wa.on("call", (ctx) => {}); // listener for someone call to bot
39
112
  ```
40
113
 
41
- ### Basic Example
114
+ <hr>
42
115
 
43
- ```typescript
44
- import { Client } from 'zaileys';
116
+ ### 🔹 Connection Handler
45
117
 
118
+ ```ts
119
+ wa.on("connection", (ctx) => {
120
+ if (ctx.status == "open") {
121
+ // do something
122
+ }
123
+ });
46
124
  ```
47
125
 
48
- ## Features
126
+ <hr>
49
127
 
50
- - **Simple Client Initialization**: Easy setup with the `Client` class.
51
- - **Effortless Connection Management**: Connect and reconnect to WhatsApp with built-in functions.
52
- - **Versatile Message Handling**: Send and receive text, media, and interactive messages.
53
- - **Group Management**: Create, join, and manage WhatsApp groups.
54
- - **Contact Management**: Interact with contacts, block/unblock, and manage your contact list.
55
- - **Real-time Event Handling**: Get notified of events in real-time using a simple event listener system.
56
- - **Advanced Media Support**: Send and receive various types of media messages, including images, videos, audio, documents, and stickers.
57
- - **Location and Live Location Sharing**: Share and receive locations and live locations.
58
- - **Interactive Messages**: Send and receive interactive messages like buttons, lists, and quick reply buttons.
59
- - **Presence Management**: Manage your online presence with presence features.
60
- - **Device Synchronization**: Leverage multi-device features for seamless device synchronization.
128
+ ### 🔹 Send Text Message
129
+
130
+ [Here](#) you can find out the complete parameters for the `.sendText()` function
131
+
132
+ ```ts
133
+ wa.on("message", (ctx) => {
134
+ if (ctx.text == "ping") {
135
+ ctx.sendText("Hello! " + ctx.senderName);
136
+ }
137
+
138
+ // text from reply message
139
+ if (ctx.reply?.text == "ping") {
140
+ ctx.sendText("Pong from reply!");
141
+ }
142
+
143
+ // text from nested reply message
144
+ // you can retrieve reply messages of any depth
145
+ if (ctx.reply?.reply?.reply?.text == "ping") {
146
+ ctx.sendText("Pong from nested reply!");
147
+ }
148
+
149
+ // text with footer message (doesn't work on whatsapp desktop)
150
+ if (ctx.text == "pong") {
151
+ ctx.sendText("Ping!", { footer: "Footer message" });
152
+ }
153
+ });
154
+ ```
155
+
156
+ <hr>
157
+
158
+ ### 🔹 Send Reply Message
159
+
160
+ [Here](#) you can find out the complete parameters for the `.sendReply()` function
161
+
162
+ ```ts
163
+ wa.on("message", (ctx) => {
164
+ if (ctx.text == "ping") {
165
+ ctx.sendReply("Pong!");
166
+ }
167
+
168
+ // reply with footer message (doesn't work on whatsapp desktop)
169
+ if (ctx.text == "pong") {
170
+ ctx.sendReply("Ping!", { footer: "Footer message" });
171
+ }
172
+
173
+ // reply with fake verified badge
174
+ if (ctx.text == "fake") {
175
+ ctx.sendReply("Fake Verified!", { fakeVerified: "whatsapp" });
176
+ }
177
+ });
178
+ ```
179
+
180
+ [Here](#) you can find out all the **verified** platforms provided
181
+
182
+ <hr>
183
+
184
+ ### 🔹 Send Sticker Message
185
+
186
+ [Here](#) you can find out the complete parameters for the `.sendSticker()` function
187
+
188
+ ```ts
189
+ wa.on("message", async (ctx) => {
190
+ if (ctx.chatType == "sticker") {
191
+ const sticker = await ctx.media?.buffer!();
192
+
193
+ ctx.sendSticker(sticker);
194
+ }
195
+
196
+ if (ctx.text == "sticker") {
197
+ ctx.sendSticker("https://gtihub.com/zeative.png");
198
+ }
199
+ });
200
+ ```
201
+
202
+ <hr>
203
+
204
+ ### 🔹 Send Image Message
205
+
206
+ [Here](#) you can find out the complete parameters for the `.sendImage()` function
207
+
208
+ ```ts
209
+ wa.on("message", async (ctx) => {
210
+ if (ctx.chatType == "image") {
211
+ const image = await ctx.media?.buffer!();
212
+
213
+ ctx.sendImage(image);
214
+ }
215
+
216
+ if (ctx.text == "image") {
217
+ ctx.sendImage("https://gtihub.com/zeative.png");
218
+ }
219
+
220
+ if (ctx.text == "mypp") {
221
+ const picture = await ctx.senderImage();
222
+
223
+ ctx.sendImage(picture);
224
+ }
225
+ });
226
+ ```
227
+
228
+ <hr>
229
+
230
+ ### 🔹 Send Video Message
231
+
232
+ [Here](#) you can find out the complete parameters for the `.sendVideo()` function
233
+
234
+ ```ts
235
+ wa.on("message", async (ctx) => {
236
+ if (ctx.chatType == "video") {
237
+ const video = await ctx.media?.buffer!();
238
+
239
+ ctx.sendVideo(video);
240
+ }
241
+
242
+ if (ctx.text == "video") {
243
+ ctx.sendVideo("https://gtihub.com/zeative.png");
244
+ }
245
+ });
246
+ ```
247
+
248
+ <hr>
249
+
250
+ ### 🔹 Send Audio Message
251
+
252
+ [Here](#) you can find out the complete parameters for the `.sendAudio()` function
253
+
254
+ ```ts
255
+ wa.on("message", async (ctx) => {
256
+ if (ctx.chatType == "audio") {
257
+ const audio = await ctx.media?.buffer!();
258
+
259
+ ctx.sendAudio(audio);
260
+ }
261
+
262
+ if (ctx.text == "audio") {
263
+ ctx.sendAudio("https://gtihub.com/zeative.png");
264
+ }
265
+ });
266
+ ```
267
+
268
+ <hr>
269
+
270
+ ### 🔹 With Prefix Message
271
+
272
+ > [!NOTE]
273
+ > You must set `prefix` option to anything character
274
+
275
+ ```ts
276
+ wa.on("message", async (ctx) => {
277
+ // for example set prefix to "/"
278
+ // and user text "/test"
279
+ if (ctx.command == "test") {
280
+ ctx.sendText("From command message!");
281
+ }
282
+ });
283
+ ```
284
+
285
+ <hr>
286
+
287
+ ### 🔹 Mentioned User
288
+
289
+ > [!NOTE]
290
+ > You must set `autoMentions` option to `true` and bot will send text as mentions
291
+
292
+ ```ts
293
+ wa.on("message", async (ctx) => {
294
+ if (ctx.text == "mentions") {
295
+ ctx.sendText("Here user mentioned: @0 @18002428478");
296
+ // example output: "Here user mentioned: @WhatsApp @ChatGPT"
297
+
298
+ // if `autoMentions` is inactive or `false`
299
+ // output can be plain text: "Here user mentioned: @0 @18002428478"
300
+ }
301
+ });
302
+ ```
303
+
304
+ <hr>
305
+
306
+ ### 🔹 Citation Handler
307
+
308
+ > [!NOTE]
309
+ > You must set `citation` like [example](https://github.com/zeative/zaileys?tab=readme-ov-file#%EF%B8%8F-configuration) above before
310
+
311
+ ```ts
312
+ const wa = new Client({
313
+ ...,
314
+
315
+ // just example you can edit with your own
316
+ citation: {
317
+ authors: ["628xxxx"],
318
+ myPrivateGroups: ["1203633xxxxx"]
319
+ }
320
+ })
321
+
322
+ wa.on("message", async (ctx) => {
323
+ const isAuthors = ctx.citation?.isAuthors;
324
+ const isMyPrivateGroups = ctx.citation?.isMyPrivateGroups;
325
+
326
+ if (isAuthors && ctx.text == "ping") {
327
+ ctx.sendText("Message for my author: kejaa");
328
+ }
329
+
330
+ if (isMyPrivateGroups && ctx.text == "pong") {
331
+ ctx.sendText("Message for my private group!");
332
+ }
333
+ });
334
+ ```
61
335
 
62
- ## Contributing
336
+ ## # Contributing
63
337
 
64
338
  Contributions are welcome! Please follow these steps to contribute:
65
339
 
@@ -71,10 +345,10 @@ Contributions are welcome! Please follow these steps to contribute:
71
345
 
72
346
  Please ensure your code follows the project's coding standards and includes appropriate tests.
73
347
 
74
- ## License
348
+ ## # License
75
349
 
76
350
  This project is licensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.
77
351
 
78
- ## Acknowledgements
352
+ ## # Acknowledgements
79
353
 
80
- - [Baileys](https://github.com/WhiskeySockets/Baileys) - The WhatsApp Web API library this project is based on.
354
+ - [Baileys](https://github.com/WhiskeySockets/Baileys) - The WhatsApp Web API library this project is based on.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zaileys",
3
- "version": "0.28.93-beta",
3
+ "version": "0.28.95-beta",
4
4
  "description": "Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API",
5
5
  "keywords": [
6
6
  "zaileys",