zaileys 0.29.8-beta → 0.29.10-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.
package/README.md CHANGED
@@ -19,345 +19,3 @@
19
19
  > This is beta version, not recomended to use in production. Join whatsapp community for latest info [WhatsApp Channel](https://whatsapp.com/channel/0029VazENbmInlqHIWzgn33h)
20
20
 
21
21
  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.
22
-
23
- ## # Features
24
-
25
- - **Multi-Device Support:** Leverage the latest WhatsApp multi-device features for enhanced reliability and performance.
26
- - **Customizable:** Adapt the library to your specific needs with flexible configuration options and modular design.
27
-
28
- ## # Installation
29
-
30
- ```bash
31
- npm add zaileys
32
-
33
- pnpm add zaileys
34
-
35
- yarn add zaileys
36
-
37
- bun add zaileys
38
-
39
- deno add npm:zaileys
40
- ```
41
-
42
- ## # Example Code
43
-
44
- > [!TIP]
45
- > 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.
46
-
47
- ## # Usage & Configuration
48
-
49
- ### 📦 Import Library
50
-
51
- ```js
52
- // ESM
53
- import { Client } from "zaileys";
54
-
55
- // CJS
56
- const { Client } = require("zaileys");
57
- ```
58
-
59
- ### ⚙️ Configuration
60
-
61
- > [!WARNING]
62
- > 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.
63
- > If you experience this, you can delete the `.zaileys/memory.json` file then restart the server.
64
-
65
- ```ts
66
- const wa = new Client({
67
- prefix: "/", // for command message, example '/'
68
- ignoreMe: true, // ignore messages from bot (bot phone number)
69
- phoneNumber: 628xxx, // fill bot phone number if auth type is 'pairing'
70
- authPath: ".zaileys", // auth directory path for session and chat store
71
- authType: "pairing", // auth type 'pairing' or 'qr'
72
- showLogs: true, // show logs of any chats
73
- autoMentions: true, // bot will be auto mentioned if text contains sender number with '@' prefix
74
- autoOnline: true, // bot status will be mark online
75
- autoRead: true, // auto read message from any chats
76
- autoRejectCall: true, // auto reject call if someone call you
77
- citation: {
78
- // your citation will be boolean object based on validate with your value
79
- // system will be validate your value with 'senderId' and 'roomId'
80
- // if one is valid then the key will return 'boolean'
81
- // sample output: { isAuthors: boolean }
82
-
83
- // just sample, you can rename with any key
84
- authors: () => ["628xxxx"], // key 'authors' will be 'isAuthors'
85
- myGroups: () => ["1203633xxxxx"], // key 'myGroups' will be 'isMyGroups'
86
- ...otherKey // key 'otherKey' will be 'isOtherKey'
87
- },
88
- });
89
- ```
90
-
91
- <hr>
92
-
93
- > [!NOTE]
94
- > 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.
95
-
96
- ### 🛎️ Event Handler
97
-
98
- You can find out the output type of each object in the listener below:
99
-
100
- - ctx for [`connection`]()
101
- - ctx for [`message`]()
102
- - ctx for [`command`]()
103
- - ctx for [`call`]()
104
-
105
- ```ts
106
- wa.on("connection", (ctx) => {}); // listener for current connection
107
- wa.on("message", (ctx) => {}); // listener for message from any chats
108
- wa.on("command", (ctx) => {}); // listener for message that starts with prefix at beginning of word
109
- wa.on("call", (ctx) => {}); // listener for someone call to bot
110
- ```
111
-
112
- <hr>
113
-
114
- ### 🔹 Connection Handler
115
-
116
- ```ts
117
- wa.on("connection", (ctx) => {
118
- if (ctx.status == "open") {
119
- // do something
120
- }
121
- });
122
- ```
123
-
124
- <hr>
125
-
126
- ### 🔹 Send Text Message
127
-
128
- [Here](#) you can find out the complete parameters for the `.sendText()` function
129
-
130
- ```ts
131
- wa.on("message", (ctx) => {
132
- if (ctx.text == "ping") {
133
- wa.sendText("Hello! " + ctx.senderName);
134
- }
135
-
136
- // text from reply message
137
- if (ctx.reply?.text == "ping") {
138
- wa.sendText("Pong from reply!");
139
- }
140
-
141
- // text from nested reply message
142
- // you can retrieve reply messages of any depth
143
- if (ctx.reply?.reply?.reply?.text == "ping") {
144
- wa.sendText("Pong from nested reply!");
145
- }
146
-
147
- // text with footer message (doesn't work on whatsapp desktop)
148
- if (ctx.text == "pong") {
149
- wa.sendText("Ping!", { footer: "Footer message" });
150
- }
151
- });
152
- ```
153
-
154
- <hr>
155
-
156
- ### 🔹 Send Reply Message
157
-
158
- [Here](#) you can find out the complete parameters for the `.sendReply()` function
159
-
160
- ```ts
161
- wa.on("message", (ctx) => {
162
- if (ctx.text == "ping") {
163
- wa.sendReply("Pong!");
164
- }
165
-
166
- // reply with footer message (doesn't work on whatsapp desktop)
167
- if (ctx.text == "pong") {
168
- wa.sendReply("Ping!", { footer: "Footer message" });
169
- }
170
-
171
- // reply with fake verified badge
172
- if (ctx.text == "fake") {
173
- wa.sendReply("Fake Verified!", { fakeVerified: "whatsapp" });
174
- }
175
- });
176
- ```
177
-
178
- [Here](#) you can find out all the **verified** platforms provided
179
-
180
- <hr>
181
-
182
- ### 🔹 Send Sticker Message
183
-
184
- [Here](#) you can find out the complete parameters for the `.sendSticker()` function
185
-
186
- ```ts
187
- wa.on("message", async (ctx) => {
188
- if (ctx.chatType == "sticker") {
189
- const sticker = await ctx.media?.buffer!();
190
-
191
- wa.sendSticker(sticker);
192
- }
193
-
194
- if (ctx.text == "sticker") {
195
- wa.sendSticker("https://gtihub.com/zeative.png");
196
- }
197
- });
198
- ```
199
-
200
- <hr>
201
-
202
- ### 🔹 Send Image Message
203
-
204
- [Here](#) you can find out the complete parameters for the `.sendImage()` function
205
-
206
- ```ts
207
- wa.on("message", async (ctx) => {
208
- if (ctx.chatType == "image") {
209
- const image = await ctx.media?.buffer!();
210
-
211
- wa.sendImage(image);
212
- }
213
-
214
- if (ctx.text == "image") {
215
- wa.sendImage("https://gtihub.com/zeative.png");
216
- }
217
-
218
- if (ctx.text == "mypp") {
219
- const picture = await ctx.senderImage();
220
-
221
- wa.sendImage(picture);
222
- }
223
- });
224
- ```
225
-
226
- <hr>
227
-
228
- ### 🔹 Send Video Message
229
-
230
- [Here](#) you can find out the complete parameters for the `.sendVideo()` function
231
-
232
- ```ts
233
- wa.on("message", async (ctx) => {
234
- if (ctx.chatType == "video") {
235
- const video = await ctx.media?.buffer!();
236
-
237
- wa.sendVideo(video);
238
- }
239
-
240
- if (ctx.text == "video") {
241
- wa.sendVideo("https://gtihub.com/zeative.png");
242
- }
243
- });
244
- ```
245
-
246
- <hr>
247
-
248
- ### 🔹 Send Audio Message
249
-
250
- [Here](#) you can find out the complete parameters for the `.sendAudio()` function
251
-
252
- ```ts
253
- wa.on("message", async (ctx) => {
254
- if (ctx.chatType == "audio") {
255
- const audio = await ctx.media?.buffer!();
256
-
257
- wa.sendAudio(audio);
258
- }
259
-
260
- if (ctx.text == "audio") {
261
- wa.sendAudio("https://gtihub.com/zeative.png");
262
- }
263
- });
264
- ```
265
-
266
- <hr>
267
-
268
- ### 🔹 With Prefix Message
269
-
270
- > [!NOTE]
271
- > You must set `prefix` option to anything character
272
-
273
- ```ts
274
- wa.on("message", async (ctx) => {
275
- // for example set prefix to "/"
276
- // and user text "/test"
277
- if (ctx.command == "test") {
278
- wa.sendText("From command message!");
279
- }
280
- });
281
- ```
282
-
283
- <hr>
284
-
285
- ### 🔹 Mentioned User
286
-
287
- > [!NOTE]
288
- > You must set `autoMentions` option to `true` and bot will send text as mentions
289
-
290
- ```ts
291
- wa.on("message", async (ctx) => {
292
- if (ctx.text == "mentions") {
293
- wa.sendText("Here user mentioned: @0 @18002428478");
294
- // example output: "Here user mentioned: @WhatsApp @ChatGPT"
295
-
296
- // if `autoMentions` is inactive or `false`
297
- // output can be plain text: "Here user mentioned: @0 @18002428478"
298
- }
299
- });
300
- ```
301
-
302
- <hr>
303
-
304
- ### 🔹 Citation Handler
305
-
306
- > [!NOTE]
307
- > You must set `citation` like [example](https://github.com/zeative/zaileys?tab=readme-ov-file#%EF%B8%8F-configuration) above before
308
-
309
- ```ts
310
- const wa = new Client({
311
- ...,
312
-
313
- // just example you can edit with your own
314
- citation: {
315
- authors: () => ["628xxxx"],
316
- myPrivateGroups: () => ["1203633xxxxx"],
317
- bannedUsers: async () => {
318
- const res = await fetch("/get/user/banned")
319
- const users = await res.json()
320
-
321
- return users // ["628xx", "628xx", "628xx"]
322
- }
323
- }
324
- })
325
-
326
- wa.on("message", async (ctx) => {
327
- const isAuthors = ctx.citation?.isAuthors;
328
- const isMyPrivateGroups = ctx.citation?.isMyPrivateGroups;
329
- const isBannedUsers = ctx.citation?.isBannedUsers;
330
-
331
- if (isAuthors && ctx.text == "test1") {
332
- wa.sendText("Message for my author: kejaa");
333
- }
334
-
335
- if (isMyPrivateGroups && ctx.text == "test2") {
336
- wa.sendText("Message for my private group!");
337
- }
338
-
339
- if (isBannedUsers && ctx.text) {
340
- wa.sendText("Your number is banned!");
341
- }
342
- });
343
- ```
344
-
345
- ## # Contributing
346
-
347
- Contributions are welcome! Please follow these steps to contribute:
348
-
349
- 1. Fork the repository.
350
- 2. Create a new branch for your feature or bug fix (`git checkout -b feature/your-feature-name` or `git checkout -b fix/bug-description`).
351
- 3. Make your changes and commit them (`git commit -m 'Add some AmazingFeature'`).
352
- 4. Push your changes to your forked repository (`git push origin feature/your-feature-name`).
353
- 5. Submit a pull request to the main repository.
354
-
355
- Please ensure your code follows the project's coding standards and includes appropriate tests.
356
-
357
- ## # License
358
-
359
- This project is licensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.
360
-
361
- ## # Acknowledgements
362
-
363
- - [Baileys](https://github.com/WhiskeySockets/Baileys) - The WhatsApp Web API library this project is based on.