zaileys 1.1.40 β†’ 2.0.1

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 DELETED
@@ -1,718 +0,0 @@
1
- <div align="center">
2
- <img alt="Zaileys - Simplified WhatsApp Node.js API" src="https://socialify.git.ci/zeative/zaileys/image?description=1&descriptionEditable=Zaileys%20is%20a%20simplified%20version%20of%20the%20Baileys%20package%20%0Awhich%20is%20easier%20and%20faster.&font=KoHo&forks=1&issues=1&language=1&name=1&owner=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Auto">
3
-
4
- <h1 align="center">Zaileys - Simplified WhatsApp Node.js API</h1>
5
-
6
- <a href="https://www.npmjs.com/package/zaileys"><img src="https://img.shields.io/npm/v/zaileys.svg" alt="NPM Version"></a>
7
- <a href="https://www.npmjs.com/package/zaileys"><img src="https://img.shields.io/npm/dw/zaileys?label=npm&color=%23CB3837" alt="NPM Downloads"></a>
8
- <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/languages/code-size/zeative/zaileys" alt="GitHub Code Size"></a>
9
- <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/license/zeative/zaileys" alt="GitHub License"></a>
10
- <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/stars/zeative/zaileys" alt="GitHub Stars"></a>
11
- <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/forks/zeative/zaileys" alt="GitHub Forks"></a>
12
-
13
- </div>
14
-
15
- **Zaileys** is a lightweight, user-friendly wrapper around the [Baileys](https://github.com/WhiskeySockets/Baileys) library, designed to simplify building WhatsApp bots and integrations with TypeScript or ESM JavaScript. It offers a streamlined API, robust multi-device support, and seamless database integration for session management.
16
-
17
- > [!TIP]
18
- > Stay updated and get support by joining our [WhatsApp Channel](https://whatsapp.com/channel/0029VazENbmInlqHIWzgn33h).
19
-
20
- > [!IMPORTANT]
21
- > There is no assurance that you won’t get blocked when using this approach. WhatsApp does not permit bots or unofficial clients, so use it at your own risk.
22
-
23
- ### πŸ’  Table of Contents
24
-
25
- - [Features](#-features)
26
- - [Installation](#-installation)
27
- - [Example Projects](#-example-projects)
28
- - [Connecting Methods](#-connecting-methods)
29
- - [QR Code](#qr-code)
30
- - [Pairing Code](#pairing-code)
31
- - [Quick Start](#-quick-start)
32
- - [Core Concepts](#-core-concepts)
33
- - [Citation](#citation)
34
- - [Limiter](#limiter)
35
- - [Fake Reply](#fake-reply)
36
- - [Event Handling](#-event-handling)
37
- - [Relay Handling](#-relay-handling)
38
- - [General](#general)
39
- - [Text Message](#text-message)
40
- - [Reply Message](#reply-message)
41
- - [Forward Message](#forward-message)
42
- - [Edit Message](#edit-message)
43
- - [Delete Message](#delete-message)
44
- - [Reaction Message](#reaction-message)
45
- - [Presence](#presence)
46
- - [Reject Call](#reject-call)
47
- - [Media](#media)
48
- - [Document Message](#document-message)
49
- - [Image Message](#image-message)
50
- - [Sticker Message](#sticker-message)
51
- - [Video Message](#video-message)
52
- - [Audio Message](#audio-message)
53
- - [Voice Message](#voice-message)
54
- - [View Once Message](#view-once-message)
55
- - [Note Message](#note-message)
56
- - [Gif Message](#gif-message)
57
- - [Location Message](#location-message)
58
- - [Contacts Message](#contacts-message)
59
- - [Polling Message](#polling-message)
60
- - [Button Message](#button-message)
61
- - [Group Control](#group-control)
62
- - [Group Create](#group-create)
63
- - [Group Action](#group-action)
64
- - [Group Invite](#group-invite)
65
- - [Group Update](#group-update)
66
- - [Group Settings](#group-settings)
67
- - [Group Leave](#group-leave)
68
- - [Group Links](#group-links)
69
- - [Group Invite](#group-invite)
70
- - [Group Metadata](#group-metadata)
71
- - [Group Requests](#group-requests)
72
- - [Privacy Control](#privacy-control)
73
- - [Privacy Update](#privacy-update)
74
- - [Privacy Fetch](#privacy-fetch)
75
- - [Profile Control](#profile-control)
76
- - [Profile Bio](#profile-bio)
77
- - [Profile Avatar](#profile-avatar)
78
- - [Profile Business](#profile-business)
79
- - [Profile Update](#profile-update)
80
- - [Profile Check](#profile-check)
81
- - [Issues & Feedback](#-issues---feedback)
82
-
83
- ### πŸ’  Features
84
-
85
- - 🎯 **Simplified API**: Minimal boilerplate get up and running in minutes.
86
- - πŸ”’ **Secure Multi-Device**: Full multi-device support via Baileys.
87
- - βš™οΈ **Modular & Extensible**: Plug-and-play middleware, transports, and storage layers.
88
- - πŸ“Ÿ **Multi Auth (QR and Pairing Code)**: Connect to whatsapp with QR code or Pairing Code.
89
- - πŸ› οΈ **TypeScript First**: Full type definitions and zero-config TS support.
90
- - ~~πŸ“ˆ **Built-in Logging**: Integrated with Pino for structured logs.~~
91
-
92
- ### πŸ’  Installation
93
-
94
- > [!WARNING]
95
- > Ensure you are running [Node.js](https://nodejs.org/) **>= 20** as specified in `package.json`.
96
-
97
- Install with your preferred package manager:
98
-
99
- ```bash
100
- npm install zaileys
101
- # or
102
- yarn add zaileys
103
- # or
104
- pnpm add zaileys
105
- # or
106
- bun add zaileys
107
- deno add npm:zaileys
108
- ```
109
-
110
- Then import your code using:
111
-
112
- ```js
113
- import { Client } from "zaileys";
114
- // or
115
- const { Client } = require("zaileys");
116
- ```
117
-
118
- ### πŸ’  Example Projects
119
-
120
- Explore the `examples` for practical use cases:
121
-
122
- - [Simple Setup](https://github.com/zeative/zaileys/blob/main/examples/simple.ts): A minimal setup for quick prototyping.
123
- - [Citation Example](https://github.com/zeative/zaileys/blob/main/examples/citation.ts): Demonstrates custom metadata with the citation mechanism.
124
- - [Rate Limiting Example](https://github.com/zeative/zaileys/blob/main/examples/limiter.ts): Shows how to implement spam detection.
125
- - [AI Integration with Groq](https://github.com/zeative/zaileys/blob/main/examples/llms.ts): Integrates AI capabilities using Groq.
126
- - [Voice Note with AI](https://github.com/zeative/zaileys/blob/main/examples/speech.ts): Interacts with AI using voice notes.
127
-
128
- ### πŸ’  Connecting Methods
129
-
130
- > [!TIP]
131
- > You can connect to WhatsApp using either a QR code or a pairing code.
132
-
133
- ### `QR Code`
134
-
135
- ```js
136
- const wa = new Client({
137
- authType: "qr",
138
- });
139
- ```
140
-
141
- ### `Pairing Code`
142
-
143
- ```js
144
- const wa = new Client({
145
- authType: "pairing",
146
- phoneNumber: 628123456789,
147
- });
148
- ```
149
-
150
- ### πŸ’  Quick Start
151
-
152
- here is minimal example of how to run:
153
-
154
- ```js
155
- const wa = new Client({ authType: "qr" });
156
-
157
- wa.on("messages", (ctx) => {
158
- if (ctx.text == "ping") {
159
- wa.text("pong");
160
- }
161
- });
162
- ```
163
-
164
- ### πŸ’  Core Concepts
165
-
166
- ### `Citation`
167
-
168
- Define custom metadata providers for dynamic boolean flags in `ctx.citation`. See `citation.ts`.
169
-
170
- ```js
171
- const wa = new Client({
172
- ...,
173
- citation: {
174
- admins: [628123456789]
175
- }
176
- })
177
-
178
- wa.on("messages", (ctx) => {
179
- // from 'admins' to 'isAdmins'
180
- // from 'test' to 'isTest'
181
- if (ctx.citation?.isAdmins) {
182
- wa.text("Admin access granted")
183
- }
184
- })
185
- ```
186
-
187
- ### `Limiter`
188
-
189
- Detect and prevent spam with the built-in limiter. See limiter.ts.
190
-
191
- ```js
192
- const wa = new Client({
193
- ...,
194
- // max 5 messages on 10 seconds
195
- limiter: {
196
- durationMs: 10000,
197
- maxMessages: 5
198
- }
199
- })
200
-
201
- wa.on("messages", (ctx) => {
202
- if (ctx.isSpam) {
203
- wa.text("You're spamming!!");
204
- }
205
- })
206
- ```
207
-
208
- ### `Fake Reply`
209
-
210
- Make it look like the number verified by manipulation.
211
-
212
- ```js
213
- const wa = new Client({
214
- ...,
215
- fakeReply: {
216
- provider: "whatsapp", // meta | chatgpt | copilot | instagram | tiktok
217
- }
218
- })
219
-
220
- wa.on("messages", (ctx) => {
221
- if (ctx.text == "test") {
222
- wa.reply("Test reply...");
223
- }
224
- })
225
- ```
226
-
227
- ### πŸ’  Event Handling
228
-
229
- Types of events handled.
230
-
231
- ```js
232
- /* Monitor connection status */
233
- wa.on("connection", (ctx) => {});
234
-
235
- /* Handle incoming messages */
236
- wa.on("messages", (ctx) => {});
237
-
238
- /* Handle incoming calls */
239
- wa.on("calls", (ctx) => {});
240
- ```
241
-
242
- ### πŸ’  Relay Handling
243
-
244
- ### `General`
245
-
246
- #### *Text Message*
247
-
248
- ```js
249
- wa.text("Hello World!")
250
- // or
251
- wa.text({ text: "Hello World!" })
252
-
253
- /* custom roomId */
254
- wa.text({ text: "Hello World!", roomId: "12345@xxx" })
255
- ```
256
-
257
- auto mentions user/group (works for both):
258
-
259
- ```js
260
- wa.text("Hello @628123456789 @0")
261
- ```
262
-
263
- external ads preview (works for both):
264
-
265
- ```js
266
- wa.text({
267
- text: "Test ads text",
268
- externalAdReply: {
269
- title: "Test ads title",
270
- body: "Test ads body",
271
- thumbnailUrl: "https://github.com/zeative.png",
272
- mediaUrl: "https://zpi.my.id",
273
- }
274
- })
275
- ```
276
-
277
- #### *Reply Message*
278
-
279
- ```js
280
- wa.reply("Test reply message...")
281
- ```
282
-
283
- #### *Forward Message*
284
-
285
- ```js
286
- wa.forward("Test forward message...")
287
- ```
288
-
289
- #### *Edit Message*
290
-
291
- ```js
292
- const msg = await wa.text("Test edit message...")
293
- await wa.edit({ text: "Edit success!", message: msg.message })
294
- ```
295
-
296
- #### *Delete Message*
297
-
298
- ```js
299
- const msg = await wa.text("Test delete message...")
300
- await wa.delete({ message: msg.message })
301
- ```
302
-
303
- #### *Reaction Message*
304
-
305
- ```js
306
- wa.reaction("🎯")
307
- // or
308
- wa.reaction({ emoticon: "🎯" });
309
- ```
310
-
311
- #### *Presence*
312
-
313
- ```js
314
- wa.presence("typing") // online | offline | recording | paused
315
- ```
316
-
317
- #### *Reject Call*
318
-
319
- ```js
320
- wa.on("calls", (ctx) => {
321
- wa.reject(ctx);
322
- // or
323
- wa.reject({ callId: ctx.callId, callerId: ctx.callerId });
324
- })
325
- ```
326
-
327
- ### `Media`
328
-
329
- #### *Document Message*
330
-
331
- ```js
332
- wa.document("text", {
333
- document: "https://github.com/zeative.png",
334
- mimetype: "image/png",
335
- fileName: "zaadevofc logo.png",
336
- text: "Here your logo",
337
- })
338
-
339
- // others method: text | reply | forward
340
- // example as reply
341
- wa.document("reply" { ... })
342
- ```
343
-
344
- #### *Image Message*
345
-
346
- ```js
347
- wa.image("text", {
348
- image: "https://github.com/zeative.png",
349
- text: "Here your logo",
350
- })
351
- ```
352
-
353
- #### *Sticker Message*
354
-
355
- ```js
356
- wa.sticker("text", {
357
- sticker: "https://example.com/file.webp"
358
- })
359
- ```
360
-
361
- #### *Video Message*
362
-
363
- ```js
364
- wa.video("text", {
365
- video: "https://example.com/file.mp4",
366
- text: "Here your logo",
367
- })
368
- ```
369
-
370
- #### *Audio Message*
371
-
372
- ```js
373
- wa.audio("text", {
374
- audio: "https://example.com/file.mp3",
375
- text: "Here your logo",
376
- })
377
- ```
378
-
379
- #### *Voice Message*
380
-
381
- ```js
382
- wa.voice("text", {
383
- audio: "https://example.com/file.ogg"
384
- })
385
- ```
386
-
387
- #### *View Once Message*
388
-
389
- ```js
390
- wa.image("text", {
391
- image: "https://github.com/zeative.png",
392
- text: "Here your logo",
393
- viewOnce: true
394
- })
395
-
396
- wa.video("text", {
397
- ...,
398
- viewOnce: true
399
- })
400
-
401
- wa.voice("text", {
402
- ...,
403
- viewOnce: true
404
- })
405
- ```
406
-
407
- #### *Note Message*
408
-
409
- ```js
410
- wa.note("text", {
411
- video: "https://example.com/file.mp4"
412
- })
413
- ```
414
-
415
- #### *Gif Message*
416
-
417
- ```js
418
- wa.gif("text", {
419
- video: "https://example.com/file.gif"
420
- })
421
- ```
422
-
423
- #### *Location Message*
424
-
425
- ```js
426
- wa.location('text', {
427
- latitude: 1115,
428
- longitude: -2225,
429
- title: "Test location title",
430
- footer: "Test location footer",
431
- })
432
- ```
433
-
434
- #### *Contacts Message*
435
-
436
- ```js
437
- wa.contacts('text', {
438
- title: "Test contacts title",
439
- contacts: [
440
- {
441
- fullname: "zaadevofc",
442
- nickname: "kejaa",
443
- phoneNumber: 628123456789,
444
- website: "https://github.com/zaadevofc",
445
- },
446
- ],
447
- })
448
- ```
449
-
450
- #### *Polling Message*
451
-
452
- ```js
453
- wa.poll('text', {
454
- action: "create",
455
- name: "Test poll",
456
- answers: [
457
- "Option 1",
458
- "Option 2",
459
- ],
460
- })
461
- ```
462
-
463
- #### *Button Message*
464
-
465
- simple button schema:
466
-
467
- ```js
468
- wa.button("text", {
469
- type: "simple",
470
- text: "Test button",
471
- footer: "Test button footer",
472
- buttons: [
473
- {
474
- id: "1",
475
- text: "Test button 1",
476
- },
477
- {
478
- id: "2",
479
- text: "Test button 2",
480
- }
481
- ]
482
- })
483
- ```
484
-
485
- interactive button schema:
486
-
487
- ```js
488
- wa.button("text", {
489
- type: "interactive",
490
- text: "Test button",
491
- footer: "Test button footer",
492
- buttons: [
493
- {
494
- id: "1",
495
- type: "quick_reply",
496
- text: "Reply button",
497
- },
498
- {
499
- id: "2",
500
- type: "cta_copy",
501
- text: "Copy button",
502
- copy: "this is form copy",
503
- },
504
- {
505
- id: "3",
506
- type: "cta_call",
507
- text: "Test Call",
508
- phoneNumber: "628123456789",
509
- },
510
- {
511
- id: "4",
512
- type: "cta_url",
513
- text: "Visit Url",
514
- url: "https://github.com/zeative",
515
- }
516
- ]
517
- })
518
- ```
519
-
520
- ### `Group Control`
521
-
522
- #### *Group Create*
523
-
524
- ```js
525
- wa.group().create({
526
- title: "Test New Group",
527
- members: ["628123456789@s.whatsapp.net"],
528
- })
529
- ```
530
-
531
- #### *Group Action*
532
-
533
- add new member to group:
534
-
535
- ```js
536
- wa.group().action({
537
- action: "add",
538
- roomId: "123456789@g.us",
539
- members: ["628123456789@s.whatsapp.net"],
540
- })
541
- ```
542
-
543
- checkout others action: `add` | `kick` | `promote` | `demote`
544
-
545
- #### *Group Update*
546
-
547
- update group subject:
548
-
549
- ```js
550
- wa.group().update({
551
- action: "subject",
552
- roomId: "123456789@g.us",
553
- text: "Test New Group Title",
554
- })
555
- ```
556
-
557
- checkout others action: `subject` | `description`
558
-
559
- #### *Group Settings*
560
-
561
- setting group only admin can send message:
562
-
563
- ```js
564
- wa.group().settings({
565
- action: "close",
566
- roomId: "123456789@g.us"
567
- })
568
- ```
569
-
570
- checkout others action: `open` | `close` | `lock` | `unlock`
571
-
572
- #### *Group Leave*
573
-
574
- leave group:
575
-
576
- ```js
577
- wa.group().leave({
578
- roomId: "123456789@g.us"
579
- })
580
- ```
581
-
582
- #### *Group Invite*
583
-
584
- join group chat by url:
585
-
586
- ```js
587
- wa.group().invite({
588
- url: "https://chat.whatsapp.com/xxxxxx",
589
- action: "join",
590
- })
591
- ```
592
-
593
- checkout others action: `join` | `info`
594
-
595
- #### *Group Metadata*
596
-
597
- get group metadata:
598
-
599
- ```js
600
- wa.group().metadata({
601
- roomId: "123456789@g.us",
602
- })
603
- ```
604
-
605
- #### *Group Requests*
606
-
607
- get request join list:
608
-
609
- ```js
610
- wa.group().requests.list({
611
- roomId: "123456789@g.us",
612
- })
613
- ```
614
-
615
- approve request join:
616
-
617
- ```js
618
- wa.group().requests.approve({
619
- roomId: "123456789@g.us",
620
- members: ["628123456789@s.whatsapp.net"],
621
- })
622
- ```
623
-
624
- reject request join:
625
-
626
- ```js
627
- wa.group().requests.reject({
628
- roomId: "123456789@g.us",
629
- members: ["628123456789@s.whatsapp.net"],
630
- })
631
- ```
632
-
633
- ### `Privacy Control`
634
-
635
- #### *Privacy Update*
636
-
637
- update profile picture privacy:
638
-
639
- ```js
640
- wa.privacy().update({
641
- action: "avatar",
642
- type: "all"
643
- })
644
- ```
645
-
646
- checkout others type: `avatar` | `groupsAdd` | `lastSeen` | `online` | `read` | `story`
647
-
648
- #### *Privacy Fetch*
649
-
650
- get blocklists user:
651
-
652
- ```js
653
- wa.privacy().fetch.blocklists()
654
- ```
655
-
656
- get my settings:
657
-
658
- ```js
659
- wa.privacy().fetch.settings()
660
- ```
661
-
662
- ### `Profile Control`
663
-
664
- #### *Profile Bio*
665
-
666
- get user bio:
667
-
668
- ```js
669
- wa.profile().bio({ senderId: ctx.senderId })
670
- ```
671
-
672
- #### *Profile Avatar*
673
-
674
- get user/group avatar:
675
-
676
- ```js
677
- wa.profile().avatar({ senderId: ctx.senderId })
678
- // or group
679
- wa.profile().avatar({ senderId: ctx.roomId })
680
- ```
681
-
682
- #### *Profile Business*
683
-
684
- get user business:
685
-
686
- ```js
687
- wa.profile().business({ senderId: ctx.senderId })
688
- ```
689
-
690
- #### *Profile Update*
691
-
692
- ```js
693
- wa.profile().update({
694
- type: 'avatar',
695
- avatar: 'https://github.com/zeative.png',
696
- })
697
- ```
698
-
699
- checkout others type: `avatar` | `bio` | `name`
700
-
701
- #### *Profile Check*
702
-
703
- ```js
704
- wa.profile().check({ senderId: ctx.senderId })
705
- ```
706
-
707
- ### πŸ’  Issues & Feedback
708
-
709
- **If you encounter any problems or have feature requests, please open an [issue](https://github.com/zeative/zaileys/issues)**
710
-
711
- - [Buy me a coffee β˜•](https://saweria.co/zaadevofc)
712
- - [Ko-Fi](https://ko-fi.com/zaadevofc)
713
- - [Trakteer](https://trakteer.id/zaadevofc)
714
- - ⭐ Star the repo on GitHub
715
-
716
- ### πŸ’  License
717
-
718
- Distributed under the **MIT License**. See [`LICENSE`](https://github.com/zeative/zaileys/blob/main/LICENSE) for details.