@queenanya/baileys 9.1.1 → 9.2.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.
Files changed (91) hide show
  1. package/README.md +1202 -375
  2. package/WAProto/WAProto.proto +1067 -221
  3. package/WAProto/fix-imports.js +1 -1
  4. package/WAProto/index.d.ts +2578 -530
  5. package/WAProto/index.js +36676 -23394
  6. package/lib/Defaults/index.d.ts +1 -1
  7. package/lib/Defaults/index.d.ts.map +1 -1
  8. package/lib/Defaults/index.js +7 -7
  9. package/lib/Defaults/index.js.map +1 -1
  10. package/lib/Signal/libsignal.js +1 -1
  11. package/lib/Signal/lid-mapping.js +2 -2
  12. package/lib/Signal/lid-mapping.js.map +1 -1
  13. package/lib/Socket/Client/types.d.ts +2 -2
  14. package/lib/Socket/Client/types.d.ts.map +1 -1
  15. package/lib/Socket/Client/websocket.d.ts +2 -2
  16. package/lib/Socket/Client/websocket.d.ts.map +1 -1
  17. package/lib/Socket/Client/websocket.js +2 -2
  18. package/lib/Socket/Client/websocket.js.map +1 -1
  19. package/lib/Socket/business.d.ts +3 -1
  20. package/lib/Socket/business.d.ts.map +1 -1
  21. package/lib/Socket/chats.d.ts +2 -0
  22. package/lib/Socket/chats.d.ts.map +1 -1
  23. package/lib/Socket/chats.js +5 -3
  24. package/lib/Socket/chats.js.map +1 -1
  25. package/lib/Socket/communities.d.ts +3 -1
  26. package/lib/Socket/communities.d.ts.map +1 -1
  27. package/lib/Socket/groups.d.ts +2 -0
  28. package/lib/Socket/groups.d.ts.map +1 -1
  29. package/lib/Socket/groups.js +0 -1
  30. package/lib/Socket/groups.js.map +1 -1
  31. package/lib/Socket/index.d.ts +3 -1
  32. package/lib/Socket/index.d.ts.map +1 -1
  33. package/lib/Socket/messages-recv.d.ts +3 -1
  34. package/lib/Socket/messages-recv.d.ts.map +1 -1
  35. package/lib/Socket/messages-recv.js +102 -45
  36. package/lib/Socket/messages-recv.js.map +1 -1
  37. package/lib/Socket/messages-send.d.ts +3 -1
  38. package/lib/Socket/messages-send.d.ts.map +1 -1
  39. package/lib/Socket/messages-send.js +77 -56
  40. package/lib/Socket/messages-send.js.map +1 -1
  41. package/lib/Socket/newsletter.d.ts +2 -0
  42. package/lib/Socket/newsletter.d.ts.map +1 -1
  43. package/lib/Socket/socket.d.ts +2 -0
  44. package/lib/Socket/socket.d.ts.map +1 -1
  45. package/lib/Socket/socket.js +57 -16
  46. package/lib/Socket/socket.js.map +1 -1
  47. package/lib/Types/Auth.d.ts +4 -0
  48. package/lib/Types/Auth.d.ts.map +1 -1
  49. package/lib/Types/Message.d.ts +2 -0
  50. package/lib/Types/Message.d.ts.map +1 -1
  51. package/lib/Types/Message.js.map +1 -1
  52. package/lib/Utils/auth-utils.js +1 -1
  53. package/lib/Utils/auth-utils.js.map +1 -1
  54. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  55. package/lib/Utils/decode-wa-message.js +5 -1
  56. package/lib/Utils/decode-wa-message.js.map +1 -1
  57. package/lib/Utils/event-buffer.js +2 -2
  58. package/lib/Utils/event-buffer.js.map +1 -1
  59. package/lib/Utils/generics.d.ts +1 -1
  60. package/lib/Utils/generics.d.ts.map +1 -1
  61. package/lib/Utils/generics.js +3 -3
  62. package/lib/Utils/generics.js.map +1 -1
  63. package/lib/Utils/history.d.ts.map +1 -1
  64. package/lib/Utils/history.js +7 -1
  65. package/lib/Utils/history.js.map +1 -1
  66. package/lib/Utils/index.d.ts +0 -1
  67. package/lib/Utils/index.d.ts.map +1 -1
  68. package/lib/Utils/index.js +0 -1
  69. package/lib/Utils/index.js.map +1 -1
  70. package/lib/Utils/message-retry-manager.d.ts +3 -3
  71. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  72. package/lib/Utils/message-retry-manager.js +25 -2
  73. package/lib/Utils/message-retry-manager.js.map +1 -1
  74. package/lib/Utils/messages-media.js +1 -1
  75. package/lib/Utils/messages-media.js.map +1 -1
  76. package/lib/Utils/messages.d.ts +13 -0
  77. package/lib/Utils/messages.d.ts.map +1 -1
  78. package/lib/Utils/messages.js +30 -0
  79. package/lib/Utils/messages.js.map +1 -1
  80. package/lib/Utils/process-message.d.ts +20 -2
  81. package/lib/Utils/process-message.d.ts.map +1 -1
  82. package/lib/Utils/process-message.js +75 -3
  83. package/lib/Utils/process-message.js.map +1 -1
  84. package/lib/Utils/validate-connection.d.ts.map +1 -1
  85. package/lib/Utils/validate-connection.js +7 -2
  86. package/lib/Utils/validate-connection.js.map +1 -1
  87. package/package.json +4 -4
  88. package/lib/Utils/baileys-event-stream.d.ts +0 -17
  89. package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
  90. package/lib/Utils/baileys-event-stream.js +0 -56
  91. package/lib/Utils/baileys-event-stream.js.map +0 -1
package/README.md CHANGED
@@ -1,479 +1,1306 @@
1
- # 🚀 BAILEYS-ANYA
1
+ <h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png" height="75"/></h1>
2
2
 
3
- <div align="center">
3
+ <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
4
 
5
- <img src="https://raw.githubusercontent.com/teamolduser/database/refs/heads/main/image/anya.png" width="350px">
6
5
 
7
- <br>
8
-
9
- <div style="background: linear-gradient(90deg, #6366F1, #3B82F6, #2DD4BF); padding: 8px; border-radius: 10px; margin: 15px 0;">
10
- <span style="font-size: 18px; font-weight: bold; color: white;">🔥 Ultimate WhatsApp Web API Experience 🥵</span>
11
- </div>
12
-
13
- ![TypeScript](https://img.shields.io/badge/-%F0%9F%94%B7%20TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white&labelColor=0D1117)
14
- ![JavaScript](https://img.shields.io/badge/-%F0%9F%94%B8%20JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=F7DF1E&labelColor=0D1117)
15
- ![WhatsApp](https://img.shields.io/badge/-%F0%9F%92%AC%20WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white&labelColor=0D1117)
16
- ![NPM](https://img.shields.io/badge/-%F0%9F%93%A6%20npm-CB3837?style=for-the-badge&logo=npm&logoColor=white&labelColor=0D1117)
17
- </div>
6
+ > [!CAUTION]
7
+ > NOTICE OF BREAKING CHANGE.
8
+ >
9
+ > As of 7.0.0, multiple breaking changes were introduced into the library.
10
+ >
11
+ > Please check out https://whiskey.so/migrate-latest for more information.
18
12
 
19
- <br>
13
+ # Important Note
14
+ This is a temporary README.md, the new guide is in development and will this file will be replaced with .github/README.md (already a default on GitHub).
20
15
 
21
- <div align="center">
22
- <img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=60&section=header" width="100%">
23
- </div>
16
+ New guide link: https://baileys.wiki
24
17
 
25
- <div style="border-left: 4px solid #3B82F6; padding-left: 15px; margin: 25px 0;">
26
- <h2>⚡️ Supercharged WhatsApp API 🌟</h2>
27
- <p><i>Elevate your messaging experience with the most advanced WhatsApp Web API solution available</i></p>
28
- </div>
18
+ # Sponsor
19
+ If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
29
20
 
30
- ---
21
+ # Disclaimer
22
+ This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates.
23
+ The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
31
24
 
32
- ## 🔮 | WHY BAILEYS-ANYA?
25
+ The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
26
+ Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
33
27
 
34
- <div style="display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin: 20px 0;">
35
- <div style="background: rgba(45, 212, 191, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
36
- <div style="font-weight: bold;">⚡ Lightning Fast</div>
37
- </div>
38
- <div style="background: rgba(99, 102, 241, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
39
- <div style="font-weight: bold;">🛡️ Secure</div>
40
- </div>
41
- <div style="background: rgba(244, 114, 182, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
42
- <div style="font-weight: bold;">🧩 Feature-Rich</div>
43
- </div>
44
- <div style="background: rgba(234, 179, 8, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
45
- <div style="font-weight: bold;">🔄 Active Development</div>
46
- </div>
47
- </div>
28
+ ##
48
29
 
49
- ## 📌 | IMPORTANT NOTE
30
+ - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
31
+ - Not running Selenium or Chromium saves you like **half a gig** of ram :/
32
+ - Baileys supports interacting with the multi-device & web versions of WhatsApp.
33
+ - Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.
50
34
 
51
- <div style="background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05)); border-left: 4px solid #EF4444; padding: 15px; border-radius: 5px; margin: 20px 0;">
52
- <p>⚠️ The original repository was initially removed by its creator and subsequently taken over by <a href="https://github.com/WhiskeySockets" style="color: #60A5FA; text-decoration: none; font-weight: bold;">WhiskeySockets</a>. This enhanced version includes numerous improvements and powerful new features designed to transform your WhatsApp development experience.</p>
53
- </div>
35
+ > [!IMPORTANT]
36
+ > The original repository had to be removed by the original author - we now continue development in this repository here.
37
+ This is the only official repository and is maintained by the community.
38
+ > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
54
39
 
55
- ## 💫 | INSTALLATION
40
+ ## Example
56
41
 
57
- <div style="background: rgba(17, 24, 39, 0.6); border-radius: 8px; padding: 20px; margin: 20px 0;">
42
+ Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
43
+ The script covers most common use cases.
44
+ To run the example script, download or clone the repo and then type the following in a terminal:
45
+ 1. ``` cd path/to/Baileys ```
46
+ 2. ``` yarn ```
47
+ 3. ``` yarn example ```
58
48
 
59
- ### 📂 In package.json:
49
+ ## Install
60
50
 
61
- ```json
62
- "dependencies": {
63
- "baileys-anya": "*"
64
- }
51
+ Use the stable version:
52
+ ```
53
+ yarn add @whiskeysockets/baileys
54
+ ```
55
+
56
+ Use the edge version (no guarantee of stability, but latest fixes + features)
57
+ ```
58
+ yarn add github:WhiskeySockets/Baileys
65
59
  ```
66
60
 
67
- ### ⚙️ Terminal Installation:
61
+ Then import your code using:
62
+ ```ts
63
+ import makeWASocket from '@whiskeysockets/baileys'
64
+ ```
68
65
 
69
- ```bash
70
- npm install baileys-anya
66
+ # Links
67
+
68
+ - [Discord](https://discord.gg/WeJM5FP9GG)
69
+ - [Docs](https://guide.whiskeysockets.io/)
70
+
71
+ # Index
72
+
73
+ - [Connecting Account](#connecting-account)
74
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
75
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
76
+ - [Receive Full History](#receive-full-history)
77
+ - [Important Notes About Socket Config](#important-notes-about-socket-config)
78
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
79
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
80
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
81
+
82
+ - [Save Auth Info](#saving--restoring-sessions)
83
+ - [Handling Events](#handling-events)
84
+ - [Example to Start](#example-to-start)
85
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
86
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
87
+ - [Implementing a Data Store](#implementing-a-data-store)
88
+ - [Whatsapp IDs Explain](#whatsapp-ids-explain)
89
+ - [Utility Functions](#utility-functions)
90
+ - [Sending Messages](#sending-messages)
91
+ - [Non-Media Messages](#non-media-messages)
92
+ - [Text Message](#text-message)
93
+ - [Quote Message](#quote-message-works-with-all-types)
94
+ - [Mention User](#mention-user-works-with-most-types)
95
+ - [Forward Messages](#forward-messages)
96
+ - [Location Message](#location-message)
97
+ - [Contact Message](#contact-message)
98
+ - [Reaction Message](#reaction-message)
99
+ - [Pin Message](#pin-message)
100
+ - [Poll Message](#poll-message)
101
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
102
+ - [Media Messages](#media-messages)
103
+ - [Gif Message](#gif-message)
104
+ - [Video Message](#video-message)
105
+ - [Audio Message](#audio-message)
106
+ - [Image Message](#image-message)
107
+ - [ViewOnce Message](#view-once-message)
108
+ - [Modify Messages](#modify-messages)
109
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
110
+ - [Edit Messages](#editing-messages)
111
+ - [Manipulating Media Messages](#manipulating-media-messages)
112
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
113
+ - [Downloading Media Messages](#downloading-media-messages)
114
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
115
+ - [Reject Call](#reject-call)
116
+ - [Send States in Chat](#send-states-in-chat)
117
+ - [Reading Messages](#reading-messages)
118
+ - [Update Presence](#update-presence)
119
+ - [Modifying Chats](#modifying-chats)
120
+ - [Archive a Chat](#archive-a-chat)
121
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
122
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
123
+ - [Delete a Message for Me](#delete-a-message-for-me)
124
+ - [Delete a Chat](#delete-a-chat)
125
+ - [Star/Unstar a Message](#starunstar-a-message)
126
+ - [Disappearing Messages](#disappearing-messages)
127
+ - [User Querys](#user-querys)
128
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
129
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
130
+ - [Fetch Status](#fetch-status)
131
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
132
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
133
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
134
+ - [Change Profile](#change-profile)
135
+ - [Change Profile Status](#change-profile-status)
136
+ - [Change Profile Name](#change-profile-name)
137
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
138
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
139
+ - [Groups](#groups)
140
+ - [Create a Group](#create-a-group)
141
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
142
+ - [Change Subject (name)](#change-subject-name)
143
+ - [Change Description](#change-description)
144
+ - [Change Settings](#change-settings)
145
+ - [Leave a Group](#leave-a-group)
146
+ - [Get Invite Code](#get-invite-code)
147
+ - [Revoke Invite Code](#revoke-invite-code)
148
+ - [Join Using Invitation Code](#join-using-invitation-code)
149
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
150
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
151
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
152
+ - [Get Request Join List](#get-request-join-list)
153
+ - [Approve/Reject Request Join](#approvereject-request-join)
154
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
155
+ - [Toggle Ephemeral](#toggle-ephemeral)
156
+ - [Change Add Mode](#change-add-mode)
157
+ - [Privacy](#privacy)
158
+ - [Block/Unblock User](#blockunblock-user)
159
+ - [Get Privacy Settings](#get-privacy-settings)
160
+ - [Get BlockList](#get-blocklist)
161
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
162
+ - [Update Online Privacy](#update-online-privacy)
163
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
164
+ - [Update Status Privacy](#update-status-privacy)
165
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
166
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
167
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
168
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
169
+ - [Send Broadcast & Stories](#send-broadcast--stories)
170
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
171
+ - [Writing Custom Functionality](#writing-custom-functionality)
172
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
173
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
174
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
175
+
176
+ ## Connecting Account
177
+
178
+ WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a **QR code** or **Pairing Code** with WhatsApp on your phone.
179
+
180
+ > [!NOTE]
181
+ > **[Here](#example-to-start) is a simple example of event handling**
182
+
183
+ > [!TIP]
184
+ > **You can see all supported socket configs [here](https://baileys.whiskeysockets.io/types/SocketConfig.html) (Recommended)**
185
+
186
+ ### Starting socket with **QR-CODE**
187
+
188
+ > [!TIP]
189
+ > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
190
+
191
+ ```ts
192
+ import makeWASocket from '@whiskeysockets/baileys'
193
+
194
+ const sock = makeWASocket({
195
+ // can provide additional config here
196
+ browser: Browsers.ubuntu('My App'),
197
+ printQRInTerminal: true
198
+ })
71
199
  ```
72
200
 
73
- or
201
+ If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
202
+
203
+ ### Starting socket with **Pairing Code**
204
+
205
+
206
+ > [!IMPORTANT]
207
+ > Pairing Code isn't Mobile API, it's a method to connect Whatsapp Web without QR-CODE, you can connect only with one device, see [here](https://faq.whatsapp.com/1324084875126592/?cms_platform=web)
208
+
209
+ The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
74
210
 
75
- ```bash
76
- yarn add baileys-anya
211
+ ```ts
212
+ import makeWASocket from '@whiskeysockets/baileys'
213
+
214
+ const sock = makeWASocket({
215
+ // can provide additional config here
216
+ printQRInTerminal: false //need to be false
217
+ })
218
+
219
+ if (!sock.authState.creds.registered) {
220
+ const number = 'XXXXXXXXXXX'
221
+ const code = await sock.requestPairingCode(number)
222
+ console.log(code)
223
+ }
77
224
  ```
78
225
 
79
- or
226
+ ### Receive Full History
80
227
 
81
- ```bash
82
- pnpm add baileys-anya
228
+ 1. Set `syncFullHistory` as `true`
229
+ 2. Baileys, by default, use chrome browser config
230
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
231
+
232
+ ```ts
233
+ const sock = makeWASocket({
234
+ ...otherOpts,
235
+ // can use Windows, Ubuntu here too
236
+ browser: Browsers.macOS('Desktop'),
237
+ syncFullHistory: true
238
+ })
83
239
  ```
84
240
 
85
- ### 🔌 Import:
241
+ ## Important Notes About Socket Config
242
+
243
+ ### Caching Group Metadata (Recommended)
244
+ - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
245
+
246
+ ```ts
247
+ const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
248
+
249
+ const sock = makeWASocket({
250
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
251
+ })
252
+
253
+ sock.ev.on('groups.update', async ([event]) => {
254
+ const metadata = await sock.groupMetadata(event.id)
255
+ groupCache.set(event.id, metadata)
256
+ })
257
+
258
+ sock.ev.on('group-participants.update', async (event) => {
259
+ const metadata = await sock.groupMetadata(event.id)
260
+ groupCache.set(event.id, metadata)
261
+ })
262
+ ```
86
263
 
87
- <div style="display: flex; gap: 20px; flex-wrap: wrap;">
88
- <div style="background: rgba(6, 182, 212, 0.1); border-radius: 5px; padding: 10px; flex: 1;">
264
+ ### Improve Retry System & Decrypt Poll Votes
265
+ - If you want to improve sending message, retrying when error occurs and decrypt poll votes, you need to have a store and set `getMessage` config in socket like this:
266
+ ```ts
267
+ const sock = makeWASocket({
268
+ getMessage: async (key) => await getMessageFromStore(key)
269
+ })
270
+ ```
89
271
 
90
- ```typescript
91
- // ESM
92
- import makeWASocket from 'baileys-anya'
272
+ ### Receive Notifications in Whatsapp App
273
+ - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
274
+ ```ts
275
+ const sock = makeWASocket({
276
+ markOnlineOnConnect: false
277
+ })
278
+ ```
279
+ ## Saving & Restoring Sessions
280
+
281
+ You obviously don't want to keep scanning the QR code every time you want to connect.
282
+
283
+ So, you can load the credentials to log back in:
284
+ ```ts
285
+ import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys'
286
+
287
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
288
+
289
+ // will use the given state to connect
290
+ // so if valid credentials are available -- it'll connect without QR
291
+ const sock = makeWASocket({ auth: state })
292
+
293
+ // this will be called as soon as the credentials are updated
294
+ sock.ev.on('creds.update', saveCreds)
295
+ ```
296
+
297
+ > [!IMPORTANT]
298
+ > `useMultiFileAuthState` is a utility function to help save the auth state in a single folder, this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system.
299
+
300
+ > [!NOTE]
301
+ > When a message is received/sent, due to signal sessions needing updating, the auth keys (`authState.keys`) will update. Whenever that happens, you must save the updated keys (`authState.keys.set()` is called). Not doing so will prevent your messages from reaching the recipient & cause other unexpected consequences. The `useMultiFileAuthState` function automatically takes care of that, but for any other serious implementation -- you will need to be very careful with the key state management.
302
+
303
+ ## Handling Events
304
+
305
+ - Baileys uses the EventEmitter syntax for events.
306
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
307
+
308
+ > [!IMPORTANT]
309
+ > **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
310
+
311
+ You can listen to these events like this:
312
+ ```ts
313
+ const sock = makeWASocket()
314
+ sock.ev.on('messages.upsert', ({ messages }) => {
315
+ console.log('got messages', messages)
316
+ })
93
317
  ```
94
318
 
95
- </div>
96
- <div style="background: rgba(234, 179, 8, 0.1); border-radius: 5px; padding: 10px; flex: 1;">
319
+ ### Example to Start
320
+
321
+ > [!NOTE]
322
+ > This example includes basic auth storage too
323
+
324
+ > [!NOTE]
325
+ > For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
326
+
327
+ ```ts
328
+ import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
329
+ import { Boom } from '@hapi/boom'
330
+
331
+ async function connectToWhatsApp () {
332
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
333
+ const sock = makeWASocket({
334
+ // can provide additional config here
335
+ auth: state,
336
+ printQRInTerminal: true
337
+ })
338
+ sock.ev.on('connection.update', (update) => {
339
+ const { connection, lastDisconnect } = update
340
+ if(connection === 'close') {
341
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
342
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
343
+ // reconnect if not logged out
344
+ if(shouldReconnect) {
345
+ connectToWhatsApp()
346
+ }
347
+ } else if(connection === 'open') {
348
+ console.log('opened connection')
349
+ }
350
+ })
351
+ sock.ev.on('messages.upsert', event => {
352
+ for (const m of event.messages) {
353
+ console.log(JSON.stringify(m, undefined, 2))
354
+
355
+ console.log('replying to', m.key.remoteJid)
356
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
357
+ }
358
+ })
359
+
360
+ // to storage creds (session info) when it updates
361
+ sock.ev.on('creds.update', saveCreds)
362
+ }
363
+ // run in main file
364
+ connectToWhatsApp()
365
+ ```
97
366
 
98
- ```javascript
99
- // CommonJS
100
- const { default: makeWASocket } = require('baileys-anya')
367
+ > [!IMPORTANT]
368
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
369
+
370
+ ### Decrypt Poll Votes
371
+
372
+ - By default poll votes are encrypted and handled in `messages.update`
373
+ - That's a simple example
374
+ ```ts
375
+ sock.ev.on('messages.update', event => {
376
+ for(const { key, update } of event) {
377
+ if(update.pollUpdates) {
378
+ const pollCreation = await getMessage(key)
379
+ if(pollCreation) {
380
+ console.log(
381
+ 'got poll update, aggregation: ',
382
+ getAggregateVotesInPollMessage({
383
+ message: pollCreation,
384
+ pollUpdates: update.pollUpdates,
385
+ })
386
+ )
387
+ }
388
+ }
389
+ }
390
+ })
101
391
  ```
102
392
 
103
- </div>
104
- </div>
105
- </div>
393
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
394
+
395
+ ### Summary of Events on First Connection
396
+
397
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
398
+ 2. Then, history messages will be received in `messaging.history-set`
399
+
400
+ ## Implementing a Data Store
401
+
402
+ - Baileys does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.
106
403
 
107
- <div align="center">
108
- <img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&height=2&section=header" width="100%">
109
- </div>
404
+ > [!IMPORTANT]
405
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
110
406
 
111
- ## | FEATURE SHOWCASE
407
+ It can be used as follows:
112
408
 
113
- <div style="background: linear-gradient(45deg, rgba(124, 58, 237, 0.05), rgba(139, 92, 246, 0.05)); border-radius: 10px; padding: 15px; margin: 20px 0;">
409
+ ```ts
410
+ import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
411
+ // the store maintains the data of the WA connection in memory
412
+ // can be written out to a file & read from it
413
+ const store = makeInMemoryStore({ })
414
+ // can be read from a file
415
+ store.readFromFile('./baileys_store.json')
416
+ // saves the state to a file every 10s
417
+ setInterval(() => {
418
+ store.writeToFile('./baileys_store.json')
419
+ }, 10_000)
114
420
 
115
- ### 🎀 Enhanced Features Matrix
421
+ const sock = makeWASocket({ })
422
+ // will listen from this socket
423
+ // the store can listen from a new socket once the current socket outlives its lifetime
424
+ store.bind(sock.ev)
116
425
 
117
- | Feature | Description | Status |
118
- | -------------------------------- | -------------------------------------------- | ------ |
119
- | 🔊 **Channel Messaging** | Send & manage WhatsApp channel content | ✅ |
120
- | 🎛️ **Interactive Messages** | Create rich button-based experiences | ✅ |
121
- | 🤖 **AI Message Icon** | Brand your bot messages with AI icon | ✅ |
122
- | 🖼️ **Enhanced Media** | Uncropped profile pictures & optimized media | ✅ |
123
- | 🔐 **Custom Pairing** | Personalized device pairing codes | ✅ |
124
- | 🔧 **Performance Optimizations** | Cleaner logs & improved signal handling | ✅ |
125
- | 📱 **Cross-Platform** | Works on all NodeJS supported platforms | ✅ |
426
+ sock.ev.on('chats.upsert', () => {
427
+ // can use 'store.chats' however you want, even after the socket dies out
428
+ // 'chats' => a KeyedDB instance
429
+ console.log('got chats', store.chats.all())
430
+ })
126
431
 
127
- </div>
432
+ sock.ev.on('contacts.upsert', () => {
433
+ console.log('got contacts', Object.values(store.contacts))
434
+ })
128
435
 
129
- <br>
436
+ ```
437
+
438
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
439
+
440
+ ## Whatsapp IDs Explain
441
+
442
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
443
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
444
+ - Example for people: ```+19999999999@s.whatsapp.net```.
445
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
446
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
447
+ - For stories, the ID is `status@broadcast`.
448
+
449
+ ## Utility Functions
130
450
 
131
- <div style="display: flex; justify-content: center; margin: 30px 0;">
132
- <div style="background: linear-gradient(135deg, #0EA5E9, #2DD4BF); color: white; padding: 12px 25px; border-radius: 25px; font-weight: bold; font-size: 16px;">🌱 SMALL BUT POWERFUL FEATURES 🎉</div>
133
- </div>
451
+ - `getContentType`, returns the content type for any message
452
+ - `getDevice`, returns the device from message
453
+ - `makeCacheableSignalKeyStore`, make auth store more fast
454
+ - `downloadContentFromMessage`, download content from any message
134
455
 
135
- ## 📰 | NEWSLETTER MANAGEMENT
456
+ ## Sending Messages
136
457
 
137
- <details>
138
- <summary style="background: linear-gradient(90deg, #4F46E5, #7C3AED); color: white; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-weight: bold;">📚 Expand Newsletter Features</summary>
458
+ - Send all types of messages with a single function
459
+ - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
460
+ - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
139
461
 
140
- <div style="padding: 15px; background: rgba(79, 70, 229, 0.05); border-radius: 0 0 10px 10px; margin-top: -5px;">
462
+ ```ts
463
+ const jid: string
464
+ const content: AnyMessageContent
465
+ const options: MiscMessageGenerationOptions
141
466
 
142
- ### 📊 Get Newsletter Info
467
+ sock.sendMessage(jid, content, options)
468
+ ```
143
469
 
144
- ```typescript
145
- // By invite
146
- const metadata = await sock.newsletterMetadata('invite', 'xxxxx')
147
- // By JID
148
- const metadata = await sock.newsletterMetadata('jid', 'abcd@newsletter')
149
- console.log(metadata)
470
+ ### Non-Media Messages
471
+
472
+ #### Text Message
473
+ ```ts
474
+ await sock.sendMessage(jid, { text: 'hello word' })
150
475
  ```
151
476
 
152
- ### 📝 Update Newsletter Content
477
+ #### Quote Message (works with all types)
478
+ ```ts
479
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
480
+ ```
153
481
 
154
- ```typescript
155
- // Update description
156
- await sock.newsletterUpdateDescription('abcd@newsletter', 'New Description')
482
+ #### Mention User (works with most types)
483
+ - @number is to mention in text, it's optional
484
+ ```ts
485
+ await sock.sendMessage(
486
+ jid,
487
+ {
488
+ text: '@12345678901',
489
+ mentions: ['12345678901@s.whatsapp.net']
490
+ }
491
+ )
492
+ ```
157
493
 
158
- // Update name
159
- await sock.newsletterUpdateName('abcd@newsletter', 'New Name')
494
+ #### Forward Messages
495
+ - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object
496
+ ```ts
497
+ const msg = getMessageFromStore() // implement this on your end
498
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
499
+ ```
160
500
 
161
- // Update picture
162
- await sock.newsletterUpdatePicture('abcd@newsletter', buffer)
501
+ #### Location Message
502
+ ```ts
503
+ await sock.sendMessage(
504
+ jid,
505
+ {
506
+ location: {
507
+ degreesLatitude: 24.121231,
508
+ degreesLongitude: 55.1121221
509
+ }
510
+ }
511
+ )
512
+ ```
513
+ #### Contact Message
514
+ ```ts
515
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
516
+ + 'VERSION:3.0\n'
517
+ + 'FN:Jeff Singh\n' // full name
518
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
519
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
520
+ + 'END:VCARD'
521
+
522
+ await sock.sendMessage(
523
+ id,
524
+ {
525
+ contacts: {
526
+ displayName: 'Jeff',
527
+ contacts: [{ vcard }]
528
+ }
529
+ }
530
+ )
531
+ ```
163
532
 
164
- // Remove picture
165
- await sock.newsletterRemovePicture('abcd@newsletter')
533
+ #### Reaction Message
534
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
535
+ ```ts
536
+ await sock.sendMessage(
537
+ jid,
538
+ {
539
+ react: {
540
+ text: '💖', // use an empty string to remove the reaction
541
+ key: message.key
542
+ }
543
+ }
544
+ )
166
545
  ```
167
546
 
168
- ### 🔔 Notification Management
547
+ #### Pin Message
548
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
549
+
550
+ - Time can be:
551
+
552
+ | Time | Seconds |
553
+ |-------|----------------|
554
+ | 24h | 86.400 |
555
+ | 7d | 604.800 |
556
+ | 30d | 2.592.000 |
557
+
558
+ ```ts
559
+ await sock.sendMessage(
560
+ jid,
561
+ {
562
+ pin: {
563
+ type: 1, // 0 to remove
564
+ time: 86400
565
+ key: message.key
566
+ }
567
+ }
568
+ )
569
+ ```
169
570
 
170
- ```typescript
171
- // Unmute newsletter
172
- await sock.newsletterUnmute('abcd@newsletter')
571
+ #### Poll Message
572
+ ```ts
573
+ await sock.sendMessage(
574
+ jid,
575
+ {
576
+ poll: {
577
+ name: 'My Poll',
578
+ values: ['Option 1', 'Option 2', ...],
579
+ selectableCount: 1,
580
+ toAnnouncementGroup: false // or true
581
+ }
582
+ }
583
+ )
584
+ ```
173
585
 
174
- // Mute newsletter
175
- await sock.newsletterMute('abcd@newsletter')
586
+ ### Sending Messages with Link Previews
587
+
588
+ 1. By default, wa does not have link generation when sent from the web
589
+ 2. Baileys has a function to generate the content for these link previews
590
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
591
+ 4. Send a link:
592
+ ```ts
593
+ await sock.sendMessage(
594
+ jid,
595
+ {
596
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
597
+ }
598
+ )
176
599
  ```
177
600
 
178
- ### 🔄 Newsletter Management
601
+ ### Media Messages
179
602
 
180
- ```typescript
181
- // Create new newsletter
182
- const metadata = await sock.newsletterCreate('Newsletter Name', 'Newsletter Description')
183
- console.log(metadata)
603
+ Sending media (video, stickers, images) is easier & more efficient than ever.
184
604
 
185
- // Delete newsletter
186
- await sock.newsletterDelete('abcd@newsletter')
605
+ > [!NOTE]
606
+ > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
187
607
 
188
- // Follow newsletter
189
- await sock.newsletterFollow('abcd@newsletter')
608
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
190
609
 
191
- // Unfollow newsletter
192
- await sock.newsletterUnfollow('abcd@newsletter')
610
+ > [!TIP]
611
+ > It's recommended to use Stream or Url to save memory
612
+
613
+ #### Gif Message
614
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
615
+ ```ts
616
+ await sock.sendMessage(
617
+ jid,
618
+ {
619
+ video: fs.readFileSync('Media/ma_gif.mp4'),
620
+ caption: 'hello word',
621
+ gifPlayback: true
622
+ }
623
+ )
193
624
  ```
194
625
 
195
- ### 😀 Engagement Features
626
+ #### Video Message
627
+ ```ts
628
+ await sock.sendMessage(
629
+ id,
630
+ {
631
+ video: {
632
+ url: './Media/ma_gif.mp4'
633
+ },
634
+ caption: 'hello word',
635
+ ptv: false // if set to true, will send as a `video note`
636
+ }
637
+ )
638
+ ```
196
639
 
197
- ```typescript
198
- // Send reaction to newsletter post
199
- // Get ID from message URL: https://whatsapp.com/channel/xxxxx/175
200
- const id = '175'
201
- await sock.newsletterReactMessage('abcd@newsletter', id, '🥳')
640
+ #### Audio Message
641
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
642
+ ```bash
643
+ codec: libopus //ogg file
644
+ ac: 1 //one channel
645
+ avoid_negative_ts
646
+ make_zero
647
+ ```
648
+ - Example:
649
+ ```bash
650
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
651
+ ```
652
+ ```ts
653
+ await sock.sendMessage(
654
+ jid,
655
+ {
656
+ audio: {
657
+ url: './Media/audio.mp3'
658
+ },
659
+ mimetype: 'audio/mp4'
660
+ }
661
+ )
202
662
  ```
203
663
 
204
- </div>
205
- </details>
664
+ #### Image Message
665
+ ```ts
666
+ await sock.sendMessage(
667
+ id,
668
+ {
669
+ image: {
670
+ url: './Media/ma_img.png'
671
+ },
672
+ caption: 'hello word'
673
+ }
674
+ )
675
+ ```
676
+
677
+ #### View Once Message
678
+
679
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
680
+
681
+ ```ts
682
+ await sock.sendMessage(
683
+ id,
684
+ {
685
+ image: {
686
+ url: './Media/ma_img.png'
687
+ },
688
+ viewOnce: true, //works with video, audio too
689
+ caption: 'hello word'
690
+ }
691
+ )
692
+ ```
206
693
 
207
- ## 🎛️ | INTERACTIVE MESSAGING
694
+ ## Modify Messages
208
695
 
209
- <details>
210
- <summary style="background: linear-gradient(90deg, #EC4899, #F43F5E); color: white; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-weight: bold;">🎯 Expand Button & Interactive Features</summary>
696
+ ### Deleting Messages (for everyone)
211
697
 
212
- <div style="padding: 15px; background: rgba(236, 72, 153, 0.05); border-radius: 0 0 10px 10px; margin-top: -5px;">
698
+ ```ts
699
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
700
+ await sock.sendMessage(jid, { delete: msg.key })
701
+ ```
213
702
 
214
- ### 📝 Text Buttons
703
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
215
704
 
216
- ```typescript
217
- const buttons = [
218
- { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
219
- { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
220
- ]
705
+ ### Editing Messages
221
706
 
222
- const buttonMessage = {
223
- text: "Hi it's button message",
224
- footer: 'Hello World',
225
- buttons,
226
- headerType: 1,
227
- viewOnce: true
707
+ - You can pass all editable contents here
708
+ ```ts
709
+ await sock.sendMessage(jid, {
710
+ text: 'updated text goes here',
711
+ edit: response.key,
712
+ });
713
+ ```
714
+
715
+ ## Manipulating Media Messages
716
+
717
+ ### Thumbnail in Media Messages
718
+ - For media messages, the thumbnail can be generated automatically for images & stickers provided you add `jimp` or `sharp` as a dependency in your project using `yarn add jimp` or `yarn add sharp`.
719
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
720
+
721
+ ### Downloading Media Messages
722
+
723
+ If you want to save the media you received
724
+ ```ts
725
+ import { createWriteStream } from 'fs'
726
+ import { downloadMediaMessage, getContentType } from '@whiskeysockets/baileys'
727
+
728
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
729
+ if (!m.message) return // if there is no text or media message
730
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
731
+
732
+ // if the message is an image
733
+ if (messageType === 'imageMessage') {
734
+ // download the message
735
+ const stream = await downloadMediaMessage(
736
+ m,
737
+ 'stream', // can be 'buffer' too
738
+ { },
739
+ {
740
+ logger,
741
+ // pass this so that baileys can request a reupload of media
742
+ // that has been deleted
743
+ reuploadRequest: sock.updateMediaMessage
744
+ }
745
+ )
746
+ // save to file
747
+ const writeStream = createWriteStream('./my-download.jpeg')
748
+ stream.pipe(writeStream)
749
+ }
228
750
  }
751
+ ```
229
752
 
230
- await sock.sendMessage(id, buttonMessage, { quoted: null })
753
+ ### Re-upload Media Message to Whatsapp
754
+
755
+ - WhatsApp automatically removes old media from their servers. For the device to access said media -- a re-upload is required by another device that has it. This can be accomplished using:
756
+ ```ts
757
+ await sock.updateMediaMessage(msg)
231
758
  ```
232
759
 
233
- ### 🖼️ Image Buttons
760
+ ## Reject Call
234
761
 
235
- ```typescript
236
- const buttons = [
237
- { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
238
- { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
239
- ]
762
+ - You can obtain `callId` and `callFrom` from `call` event
240
763
 
241
- const buttonMessage = {
242
- image: { url: 'https://example.com/abcd.jpg' }, // image: buffer or path
243
- caption: "Hi it's button message with image",
244
- footer: 'Hello World',
245
- buttons,
246
- headerType: 1,
247
- viewOnce: true
248
- }
764
+ ```ts
765
+ await sock.rejectCall(callId, callFrom)
766
+ ```
767
+
768
+ ## Send States in Chat
249
769
 
250
- await sock.sendMessage(id, buttonMessage, { quoted: null })
770
+ ### Reading Messages
771
+ - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
772
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
773
+ This means you have to keep track of unread messages.
774
+
775
+ ```ts
776
+ const key: WAMessageKey
777
+ // can pass multiple keys to read multiple messages as well
778
+ await sock.readMessages([key])
251
779
  ```
252
780
 
253
- ### 🎬 Video Buttons
781
+ The message ID is the unique identifier of the message that you are marking as read.
782
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
254
783
 
255
- ```typescript
256
- const buttons = [
257
- { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
258
- { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
259
- ]
784
+ ### Update Presence
260
785
 
261
- const buttonMessage = {
262
- video: { url: 'https://example.com/abcd.mp4' }, // video: buffer or path
263
- caption: "Hi it's button message with video",
264
- footer: 'Hello World',
265
- buttons,
266
- headerType: 1,
267
- viewOnce: true
268
- }
786
+ - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
787
+ - The presence expires after about 10 seconds.
788
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
269
789
 
270
- await sock.sendMessage(id, buttonMessage, { quoted: null })
271
- ```
272
-
273
- ### 🔄 Advanced Interactive Messages
274
-
275
- ```typescript
276
- const interactiveButtons = [
277
- {
278
- name: 'quick_reply',
279
- buttonParamsJson: JSON.stringify({
280
- display_text: 'Quick Reply',
281
- id: 'ID'
282
- })
283
- },
284
- {
285
- name: 'cta_url',
286
- buttonParamsJson: JSON.stringify({
287
- display_text: 'Tap Here!',
288
- url: 'https://www.example.com/'
289
- })
290
- },
291
- {
292
- name: 'cta_copy',
293
- buttonParamsJson: JSON.stringify({
294
- display_text: 'Copy Code',
295
- id: '12345',
296
- copy_code: '12345'
297
- })
298
- }
299
- ]
300
-
301
- const interactiveMessage = {
302
- text: 'Hello World!',
303
- title: 'this is the title',
304
- footer: 'this is the footer',
305
- interactiveButtons
306
- }
790
+ ```ts
791
+ await sock.sendPresenceUpdate('available', jid)
792
+ ```
307
793
 
308
- await sock.sendMessage(id, interactiveMessage, { quoted: null })
309
- ```
310
-
311
- ### 🖼️ Rich Media Interactive Messages
312
-
313
- ```typescript
314
- const interactiveButtons = [
315
- {
316
- name: 'quick_reply',
317
- buttonParamsJson: JSON.stringify({
318
- display_text: 'Quick Reply',
319
- id: 'ID'
320
- })
321
- },
322
- {
323
- name: 'cta_url',
324
- buttonParamsJson: JSON.stringify({
325
- display_text: 'Visit Website',
326
- url: 'https://www.example.com/'
327
- })
328
- }
329
- ]
330
-
331
- // With Image
332
- const imageInteractiveMessage = {
333
- image: { url: 'https://example.com/abcd.jpg' },
334
- caption: 'Check out this amazing photo!',
335
- title: 'Photo Showcase',
336
- footer: 'Tap a button below',
337
- interactiveButtons
338
- }
794
+ > [!NOTE]
795
+ > If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`
339
796
 
340
- await sock.sendMessage(id, imageInteractiveMessage, { quoted: null })
797
+ ## Modifying Chats
341
798
 
342
- // With Video
343
- const videoInteractiveMessage = {
344
- video: { url: 'https://example.com/abcd.mp4' },
345
- caption: 'Watch this awesome video!',
346
- title: 'Video Showcase',
347
- footer: 'Tap a button below',
348
- interactiveButtons
349
- }
799
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
800
+
801
+ > [!IMPORTANT]
802
+ > If you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.
350
803
 
351
- await sock.sendMessage(id, videoInteractiveMessage, { quoted: null })
804
+ ### Archive a Chat
805
+ ```ts
806
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
807
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
352
808
  ```
809
+ ### Mute/Unmute a Chat
353
810
 
354
- </div>
355
- </details>
811
+ - Supported times:
356
812
 
357
- ## 🤖 | AI MESSAGING
813
+ | Time | Miliseconds |
814
+ |-------|-----------------|
815
+ | Remove | null |
816
+ | 8h | 86.400.000 |
817
+ | 7d | 604.800.000 |
358
818
 
359
- <div style="background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1)); border-radius: 10px; padding: 20px; margin: 20px 0;">
819
+ ```ts
820
+ // mute for 8 hours
821
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
822
+ // unmute
823
+ await sock.chatModify({ mute: null }, jid)
824
+ ```
825
+ ### Mark a Chat Read/Unread
826
+ ```ts
827
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
828
+ // mark it unread
829
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
830
+ ```
360
831
 
361
- ### AI Icon Feature
832
+ ### Delete a Message for Me
833
+ ```ts
834
+ await sock.chatModify(
835
+ {
836
+ clear: {
837
+ messages: [
838
+ {
839
+ id: 'ATWYHDNNWU81732J',
840
+ fromMe: true,
841
+ timestamp: '1654823909'
842
+ }
843
+ ]
844
+ }
845
+ },
846
+ jid
847
+ )
362
848
 
363
- ```typescript
364
- // Simply add "ai: true" to display AI icon with your message
365
- await sock.sendMessage(id, { text: "Hello! I'm your AI assistant.", ai: true })
849
+ ```
850
+ ### Delete a Chat
851
+ ```ts
852
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
853
+ await sock.chatModify({
854
+ delete: true,
855
+ lastMessages: [
856
+ {
857
+ key: lastMsgInChat.key,
858
+ messageTimestamp: lastMsgInChat.messageTimestamp
859
+ }
860
+ ]
861
+ },
862
+ jid
863
+ )
864
+ ```
865
+ ### Pin/Unpin a Chat
866
+ ```ts
867
+ await sock.chatModify({
868
+ pin: true // or `false` to unpin
869
+ },
870
+ jid
871
+ )
872
+ ```
873
+ ### Star/Unstar a Message
874
+ ```ts
875
+ await sock.chatModify({
876
+ star: {
877
+ messages: [
878
+ {
879
+ id: 'messageID',
880
+ fromMe: true // or `false`
881
+ }
882
+ ],
883
+ star: true // - true: Star Message; false: Unstar Message
884
+ }
885
+ },
886
+ jid
887
+ )
366
888
  ```
367
889
 
368
- <div style="background: rgba(16, 185, 129, 0.2); border-radius: 5px; padding: 10px; margin-top: 15px;">
369
- <strong>💡 Pro Tip:</strong> AI icons make your bot messages stand out and indicate automated responses to users.
370
- </div>
890
+ ### Disappearing Messages
371
891
 
372
- </div>
892
+ - Ephemeral can be:
373
893
 
374
- ## 🔐 | CUSTOM PAIRING
894
+ | Time | Seconds |
895
+ |-------|----------------|
896
+ | Remove | 0 |
897
+ | 24h | 86.400 |
898
+ | 7d | 604.800 |
899
+ | 90d | 7.776.000 |
375
900
 
376
- <div style="background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(217, 119, 6, 0.1)); border-radius: 10px; padding: 20px; margin: 20px 0;">
901
+ - You need to pass in **Seconds**, default is 7 days
377
902
 
378
- ### Custom Code Implementation
903
+ ```ts
904
+ // turn on disappearing messages
905
+ await sock.sendMessage(
906
+ jid,
907
+ // this is 1 week in seconds -- how long you want messages to appear for
908
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
909
+ )
379
910
 
380
- ```typescript
381
- if (usePairingCode && !sock.authState.creds.registered) {
382
- const phoneNumber = await question('Please enter your mobile phone number:\n')
383
- const custom = '4NY4P8KA' // must be 8 digits, can be letters or numbers
384
- const code = await sock.requestPairingCode(phoneNumber, custom)
385
- console.log(`Pairing code: ${code?.match(/.{1,4}/g)?.join('-') || code}`)
386
- }
911
+ // will send as a disappearing message
912
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
913
+
914
+ // turn off disappearing messages
915
+ await sock.sendMessage(
916
+ jid,
917
+ { disappearingMessagesInChat: false }
918
+ )
919
+ ```
920
+
921
+ ## User Querys
922
+
923
+ ### Check If ID Exists in Whatsapp
924
+ ```ts
925
+ const [result] = await sock.onWhatsApp(jid)
926
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
927
+ ```
928
+
929
+ ### Query Chat History (groups too)
930
+
931
+ - You need to have oldest message in chat
932
+ ```ts
933
+ const msg = await getOldestMessageInChat(jid) // implement this on your end
934
+ await sock.fetchMessageHistory(
935
+ 50, //quantity (max: 50 per query)
936
+ msg.key,
937
+ msg.messageTimestamp
938
+ )
939
+ ```
940
+ - Messages will be received in `messaging.history-set` event
941
+
942
+ ### Fetch Status
943
+ ```ts
944
+ const status = await sock.fetchStatus(jid)
945
+ console.log('status: ' + status)
946
+ ```
947
+
948
+ ### Fetch Profile Picture (groups too)
949
+ - To get the display picture of some person/group
950
+ ```ts
951
+ // for low res picture
952
+ const ppUrl = await sock.profilePictureUrl(jid)
953
+ console.log(ppUrl)
954
+
955
+ // for high res picture
956
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
957
+ ```
958
+
959
+ ### Fetch Bussines Profile (such as description or category)
960
+ ```ts
961
+ const profile = await sock.getBusinessProfile(jid)
962
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
963
+ ```
964
+
965
+ ### Fetch Someone's Presence (if they're typing or online)
966
+ ```ts
967
+ // the presence update is fetched and called here
968
+ sock.ev.on('presence.update', console.log)
969
+
970
+ // request updates for a chat
971
+ await sock.presenceSubscribe(jid)
972
+ ```
973
+
974
+ ## Change Profile
975
+
976
+ ### Change Profile Status
977
+ ```ts
978
+ await sock.updateProfileStatus('Hello World!')
979
+ ```
980
+ ### Change Profile Name
981
+ ```ts
982
+ await sock.updateProfileName('My name')
983
+ ```
984
+ ### Change Display Picture (groups too)
985
+ - To change your display picture or a group's
986
+
987
+ > [!NOTE]
988
+ > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
989
+
990
+ ```ts
991
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
992
+ ```
993
+ ### Remove display picture (groups too)
994
+ ```ts
995
+ await sock.removeProfilePicture(jid)
996
+ ```
997
+
998
+ ## Groups
999
+
1000
+ - To change group properties you need to be admin
1001
+
1002
+ ### Create a Group
1003
+ ```ts
1004
+ // title & participants
1005
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1006
+ console.log('created group with id: ' + group.gid)
1007
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1008
+ ```
1009
+ ### Add/Remove or Demote/Promote
1010
+ ```ts
1011
+ // id & people to add to the group (will throw error if it fails)
1012
+ await sock.groupParticipantsUpdate(
1013
+ jid,
1014
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1015
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1016
+ )
1017
+ ```
1018
+ ### Change Subject (name)
1019
+ ```ts
1020
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1021
+ ```
1022
+ ### Change Description
1023
+ ```ts
1024
+ await sock.groupUpdateDescription(jid, 'New Description!')
1025
+ ```
1026
+ ### Change Settings
1027
+ ```ts
1028
+ // only allow admins to send messages
1029
+ await sock.groupSettingUpdate(jid, 'announcement')
1030
+ // allow everyone to send messages
1031
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1032
+ // allow everyone to modify the group's settings -- like display picture etc.
1033
+ await sock.groupSettingUpdate(jid, 'unlocked')
1034
+ // only allow admins to modify the group's settings
1035
+ await sock.groupSettingUpdate(jid, 'locked')
1036
+ ```
1037
+ ### Leave a Group
1038
+ ```ts
1039
+ // will throw error if it fails
1040
+ await sock.groupLeave(jid)
1041
+ ```
1042
+ ### Get Invite Code
1043
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1044
+ ```ts
1045
+ const code = await sock.groupInviteCode(jid)
1046
+ console.log('group code: ' + code)
1047
+ ```
1048
+ ### Revoke Invite Code
1049
+ ```ts
1050
+ const code = await sock.groupRevokeInvite(jid)
1051
+ console.log('New group code: ' + code)
1052
+ ```
1053
+ ### Join Using Invitation Code
1054
+ - Code can't have `https://chat.whatsapp.com/`, only code
1055
+ ```ts
1056
+ const response = await sock.groupAcceptInvite(code)
1057
+ console.log('joined to: ' + response)
1058
+ ```
1059
+ ### Get Group Info by Invite Code
1060
+ ```ts
1061
+ const response = await sock.groupGetInviteInfo(code)
1062
+ console.log('group information: ' + response)
1063
+ ```
1064
+ ### Query Metadata (participants, name, description...)
1065
+ ```ts
1066
+ const metadata = await sock.groupMetadata(jid)
1067
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1068
+ ```
1069
+ ### Join using `groupInviteMessage`
1070
+ ```ts
1071
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1072
+ console.log('joined to: ' + response)
1073
+ ```
1074
+ ### Get Request Join List
1075
+ ```ts
1076
+ const response = await sock.groupRequestParticipantsList(jid)
1077
+ console.log(response)
1078
+ ```
1079
+ ### Approve/Reject Request Join
1080
+ ```ts
1081
+ const response = await sock.groupRequestParticipantsUpdate(
1082
+ jid, // group id
1083
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1084
+ 'approve' // or 'reject'
1085
+ )
1086
+ console.log(response)
1087
+ ```
1088
+ ### Get All Participating Groups Metadata
1089
+ ```ts
1090
+ const response = await sock.groupFetchAllParticipating()
1091
+ console.log(response)
1092
+ ```
1093
+ ### Toggle Ephemeral
1094
+
1095
+ - Ephemeral can be:
1096
+
1097
+ | Time | Seconds |
1098
+ |-------|----------------|
1099
+ | Remove | 0 |
1100
+ | 24h | 86.400 |
1101
+ | 7d | 604.800 |
1102
+ | 90d | 7.776.000 |
1103
+
1104
+ ```ts
1105
+ await sock.groupToggleEphemeral(jid, 86400)
1106
+ ```
1107
+
1108
+ ### Change Add Mode
1109
+ ```ts
1110
+ await sock.groupMemberAddMode(
1111
+ jid,
1112
+ 'all_member_add' // or 'admin_add'
1113
+ )
1114
+ ```
1115
+
1116
+ ## Privacy
1117
+
1118
+ ### Block/Unblock User
1119
+ ```ts
1120
+ await sock.updateBlockStatus(jid, 'block') // Block user
1121
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1122
+ ```
1123
+ ### Get Privacy Settings
1124
+ ```ts
1125
+ const privacySettings = await sock.fetchPrivacySettings(true)
1126
+ console.log('privacy settings: ' + privacySettings)
1127
+ ```
1128
+ ### Get BlockList
1129
+ ```ts
1130
+ const response = await sock.fetchBlocklist()
1131
+ console.log(response)
1132
+ ```
1133
+ ### Update LastSeen Privacy
1134
+ ```ts
1135
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1136
+ await sock.updateLastSeenPrivacy(value)
1137
+ ```
1138
+ ### Update Online Privacy
1139
+ ```ts
1140
+ const value = 'all' // 'match_last_seen'
1141
+ await sock.updateOnlinePrivacy(value)
1142
+ ```
1143
+ ### Update Profile Picture Privacy
1144
+ ```ts
1145
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1146
+ await sock.updateProfilePicturePrivacy(value)
1147
+ ```
1148
+ ### Update Status Privacy
1149
+ ```ts
1150
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1151
+ await sock.updateStatusPrivacy(value)
1152
+ ```
1153
+ ### Update Read Receipts Privacy
1154
+ ```ts
1155
+ const value = 'all' // 'none'
1156
+ await sock.updateReadReceiptsPrivacy(value)
1157
+ ```
1158
+ ### Update Groups Add Privacy
1159
+ ```ts
1160
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1161
+ await sock.updateGroupsAddPrivacy(value)
1162
+ ```
1163
+ ### Update Default Disappearing Mode
1164
+
1165
+ - Like [this](#disappearing-messages), ephemeral can be:
1166
+
1167
+ | Time | Seconds |
1168
+ |-------|----------------|
1169
+ | Remove | 0 |
1170
+ | 24h | 86.400 |
1171
+ | 7d | 604.800 |
1172
+ | 90d | 7.776.000 |
1173
+
1174
+ ```ts
1175
+ const ephemeral = 86400
1176
+ await sock.updateDefaultDisappearingMode(ephemeral)
1177
+ ```
1178
+
1179
+ ## Broadcast Lists & Stories
1180
+
1181
+ ### Send Broadcast & Stories
1182
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1183
+ ```ts
1184
+ await sock.sendMessage(
1185
+ jid,
1186
+ {
1187
+ image: {
1188
+ url: url
1189
+ },
1190
+ caption: caption
1191
+ },
1192
+ {
1193
+ backgroundColor: backgroundColor,
1194
+ font: font,
1195
+ statusJidList: statusJidList,
1196
+ broadcast: true
1197
+ }
1198
+ )
1199
+ ```
1200
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1201
+ - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1202
+ - `broadcast: true` enables broadcast mode
1203
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1204
+
1205
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1206
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1207
+ - Broadcast IDs are in the format `12345678@broadcast`
1208
+ ### Query a Broadcast List's Recipients & Name
1209
+ ```ts
1210
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1211
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1212
+ ```
1213
+
1214
+ ## Writing Custom Functionality
1215
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1216
+
1217
+ ### Enabling Debug Level in Baileys Logs
1218
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1219
+ ```ts
1220
+ const sock = makeWASocket({
1221
+ logger: P({ level: 'debug' }),
1222
+ })
1223
+ ```
1224
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1225
+
1226
+ ### How Whatsapp Communicate With Us
1227
+
1228
+ > [!TIP]
1229
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1230
+
1231
+ - **Example:** Functionality to track the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console:
1232
+ ```
1233
+ {
1234
+ "level": 10,
1235
+ "fromMe": false,
1236
+ "frame": {
1237
+ "tag": "ib",
1238
+ "attrs": {
1239
+ "from": "@s.whatsapp.net"
1240
+ },
1241
+ "content": [
1242
+ {
1243
+ "tag": "edge_routing",
1244
+ "attrs": {},
1245
+ "content": [
1246
+ {
1247
+ "tag": "routing_info",
1248
+ "attrs": {},
1249
+ "content": {
1250
+ "type": "Buffer",
1251
+ "data": [8,2,8,5]
1252
+ }
1253
+ }
1254
+ ]
1255
+ }
1256
+ ]
1257
+ },
1258
+ "msg":"communication"
1259
+ }
1260
+ ```
1261
+
1262
+ The `'frame'` is what the message received is, it has three components:
1263
+ - `tag` -- what this frame is about (eg. message will have 'message')
1264
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1265
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1266
+ - read more about this format [here](/src/WABinary/readme.md)
1267
+
1268
+ ### Register a Callback for Websocket Events
1269
+
1270
+ > [!TIP]
1271
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1272
+
1273
+ ```ts
1274
+ // for any message with tag 'edge_routing'
1275
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1276
+
1277
+ // for any message with tag 'edge_routing' and id attribute = abcd
1278
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1279
+
1280
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1281
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
387
1282
  ```
388
1283
 
389
- <div style="background: rgba(245, 158, 11, 0.2); border-radius: 5px; padding: 10px; margin-top: 15px;">
390
- <strong>🔒 Security Note:</strong> Custom pairing codes enhance security while providing a personalized experience.
391
- </div>
392
-
393
- </div>
394
-
395
- <div align="center">
396
- <img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&height=2&section=header" width="100%">
397
- </div>
398
-
399
- ## 🛠️ | QUICK IMPLEMENTATION GUIDE
400
-
401
- <div style="display: flex; flex-wrap: wrap; gap: 15px; margin: 20px 0;">
402
- <div style="flex: 1; min-width: 250px; background: rgba(59, 130, 246, 0.05); border-radius: 10px; padding: 15px;">
403
- <h3>🚀 Step 1: Install</h3>
404
- <p>Add baileys-anya to your project using npm</p>
405
- <div style="background: rgba(0, 0, 0, 0.2); padding: 10px; border-radius: 5px;">
406
- <code>npm install baileys-anya</code>
407
- <p>OR</p>
408
- <code>yarn add baileys-anya</code>
409
- <p>OR</p>
410
- <code>pnpm add baileys-anya</code>
411
- </div>
412
- </div>
413
-
414
- <div style="flex: 1; min-width: 250px; background: rgba(59, 130, 246, 0.05); border-radius: 10px; padding: 15px;">
415
- <h3>🔄 Step 2: Import</h3>
416
- <p>Import the library into your project</p>
417
- <div style="background: rgba(0, 0, 0, 0.2); padding: 10px; border-radius: 5px;">
418
- <code>import makeWASocket from 'baileys-anya'</code>
419
- </div>
420
- </div>
421
-
422
- <div style="flex: 1; min-width: 250px; background: rgba(59, 130, 246, 0.05); border-radius: 10px; padding: 15px;">
423
- <h3>⚙️ Step 3: Configure</h3>
424
- <p>Set up your WhatsApp connection</p>
425
- <div style="background: rgba(0, 0, 0, 0.2); padding: 10px; border-radius: 5px;">
426
- <code>const sock = makeWASocket({...})</code>
427
- </div>
428
- </div>
429
-
430
- <div style="flex: 1; min-width: 250px; background: rgba(59, 130, 246, 0.05); border-radius: 10px; padding: 15px;">
431
- <h3>🚀 Step 4: Implement</h3>
432
- <p>Start using the enhanced features</p>
433
- <div style="background: rgba(0, 0, 0, 0.2); padding: 10px; border-radius: 5px;">
434
- <code>await sock.sendMessage(id, {...})</code>
435
- </div>
436
- </div>
437
- </div>
438
-
439
- ## 🐛 | REPORTING ISSUES
440
-
441
- <div style="background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(220, 38, 38, 0.05)); border-radius: 10px; padding: 20px; margin: 20px 0;">
442
- <h3>Found a bug? Have a suggestion?</h3>
443
- <p>If you encounter any issues while using this repository, please feel free to open a <a href="https://github.com/teamolduser/bail/issues" style="color: #60A5FA; text-decoration: none; font-weight: bold;">new issue</a>.</p>
444
-
445
- <div style="display: flex; align-items: center; gap: 10px; margin-top: 15px; background: rgba(239, 68, 68, 0.1); padding: 10px; border-radius: 5px;">
446
- <span style="font-size: 24px;">👾</span>
447
- <span>Our team actively monitors and responds to all issues.</span>
448
- </div>
449
- </div>
450
-
451
- ## 📝 | NOTES
452
-
453
- <div style="background: linear-gradient(135deg, rgba(107, 114, 128, 0.05), rgba(75, 85, 99, 0.05)); border-radius: 10px; padding: 20px; margin: 20px 0;">
454
- <p>Everything other than the modifications mentioned above remains the same as the original repository. You can check out the original repository at <a href="https://github.com/WhiskeySockets/Baileys" style="color: #60A5FA; text-decoration: none; font-weight: bold;">WhiskeySockets</a>.</p>
455
- </div>
456
-
457
- <div align="center">
458
- <img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=100&section=footer" width="100%">
459
- </div>
460
-
461
- <div align="center" style="margin-top: -40px;">
462
- <div style="background: linear-gradient(90deg, #6366F1, #3B82F6, #2DD4BF); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-size: 24px; font-weight: bold; margin-bottom: 10px;">
463
- ⭐ STAR THIS REPOSITORY ⭐
464
- </div>
465
-
466
- <div style="display: flex; justify-content: center; gap: 10px; margin: 20px 0;">
467
- <div style="background: rgba(6, 182, 212, 0.1); border-radius: 5px; padding: 8px 15px;">
468
- <span style="font-size: 20px;">👨‍💻</span> <span>Developers</span>
469
- </div>
470
- <div style="background: rgba(16, 185, 129, 0.1); border-radius: 5px; padding: 8px 15px;">
471
- <span style="font-size: 20px;">🤖</span> <span>Bot Creators</span>
472
- </div>
473
- <div style="background: rgba(245, 158, 11, 0.1); border-radius: 5px; padding: 8px 15px;">
474
- <span style="font-size: 20px;">🚀</span> <span>Innovators</span>
475
- </div>
476
- </div>
477
-
478
- <p style="font-style: italic; max-width: 600px; margin: 0 auto;">Powered by Baileys-Anya - The Ultimate WhatsApp Web API Experience</p>
479
- </div>
1284
+ # License
1285
+ Copyright (c) 2025 Rajeh Taher/WhiskeySockets
1286
+
1287
+ Licensed under the MIT License:
1288
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1289
+ of this software and associated documentation files (the "Software"), to deal
1290
+ in the Software without restriction, including without limitation the rights
1291
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1292
+ copies of the Software, and to permit persons to whom the Software is
1293
+ furnished to do so, subject to the following conditions:
1294
+
1295
+ The above copyright notice and this permission notice shall be included in all
1296
+ copies or substantial portions of the Software.
1297
+
1298
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1299
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1300
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1301
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1302
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1303
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1304
+ SOFTWARE.
1305
+
1306
+ Thus, the maintainers of the project can't be held liable for any potential misuse of this project.