gifted-baileys 1.5.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +4 -1298
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,1303 +1,9 @@
1
- <h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png" height="75"/></h1>
1
+ # <div align='center'>Gifted-Baileys WhatsApp Web API</div>
2
2
 
3
- <div align='center'>
3
+ Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.
4
4
 
5
- ![NPM Downloads](https://img.shields.io/npm/dw/%40whiskeysockets%2Fbaileys?label=npm&color=%23CB3837)
6
- ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/whiskeysockets/baileys)
7
- ![Discord](https://img.shields.io/discord/725839806084546610?label=discord&color=%235865F2)
8
-
9
- </div>
10
-
11
- <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
12
-
13
- # Important Note
14
- This is a temporally README, the new guide is at development and will be fully released when it's finished.
15
-
16
- New Guide: https://baileys.wiki
17
-
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).
5
+ ### Visit **[DOCS SITE](https://baileys.giftedtech.web.id)** for more details.
20
6
 
21
7
  # Disclaimer
22
8
  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.
24
-
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.
27
-
28
- ##
29
-
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.
34
-
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)**
39
-
40
- ## Example
41
-
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 ```
48
-
49
- ## Install
50
-
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
59
- ```
60
-
61
- Then import your code using:
62
- ```ts
63
- import makeWASocket from '@whiskeysockets/baileys'
64
- ```
65
-
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
- })
199
- ```
200
-
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
210
-
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
- }
224
- ```
225
-
226
- ### Receive Full History
227
-
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
- })
239
- ```
240
-
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
- ```
263
-
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
- ```
271
-
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
- })
317
- ```
318
-
319
- ### Example to Start
320
-
321
- > [!NOTE]
322
- > This example includes basic auth storage too
323
-
324
- ```ts
325
- import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
326
- import { Boom } from '@hapi/boom'
327
-
328
- async function connectToWhatsApp () {
329
- const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
330
- const sock = makeWASocket({
331
- // can provide additional config here
332
- auth: state,
333
- printQRInTerminal: true
334
- })
335
- sock.ev.on('connection.update', (update) => {
336
- const { connection, lastDisconnect } = update
337
- if(connection === 'close') {
338
- const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
339
- console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
340
- // reconnect if not logged out
341
- if(shouldReconnect) {
342
- connectToWhatsApp()
343
- }
344
- } else if(connection === 'open') {
345
- console.log('opened connection')
346
- }
347
- })
348
- sock.ev.on('messages.upsert', event => {
349
- for (const m of event.messages) {
350
- console.log(JSON.stringify(m, undefined, 2))
351
-
352
- console.log('replying to', m.key.remoteJid)
353
- await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
354
- }
355
- })
356
-
357
- // to storage creds (session info) when it updates
358
- sock.ev.on('creds.update', saveCreds)
359
- }
360
- // run in main file
361
- connectToWhatsApp()
362
- ```
363
-
364
- > [!IMPORTANT]
365
- > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
366
-
367
- ### Decrypt Poll Votes
368
-
369
- - By default poll votes are encrypted and handled in `messages.update`
370
- - That's a simple example
371
- ```ts
372
- sock.ev.on('messages.update', event => {
373
- for(const { key, update } of event) {
374
- if(update.pollUpdates) {
375
- const pollCreation = await getMessage(key)
376
- if(pollCreation) {
377
- console.log(
378
- 'got poll update, aggregation: ',
379
- getAggregateVotesInPollMessage({
380
- message: pollCreation,
381
- pollUpdates: update.pollUpdates,
382
- })
383
- )
384
- }
385
- }
386
- }
387
- })
388
- ```
389
-
390
- - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
391
-
392
- ### Summary of Events on First Connection
393
-
394
- 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
395
- 2. Then, history messages will be received in `messaging.history-set`
396
-
397
- ## Implementing a Data Store
398
-
399
- - 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.
400
-
401
- > [!IMPORTANT]
402
- > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
403
-
404
- It can be used as follows:
405
-
406
- ```ts
407
- import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
408
- // the store maintains the data of the WA connection in memory
409
- // can be written out to a file & read from it
410
- const store = makeInMemoryStore({ })
411
- // can be read from a file
412
- store.readFromFile('./baileys_store.json')
413
- // saves the state to a file every 10s
414
- setInterval(() => {
415
- store.writeToFile('./baileys_store.json')
416
- }, 10_000)
417
-
418
- const sock = makeWASocket({ })
419
- // will listen from this socket
420
- // the store can listen from a new socket once the current socket outlives its lifetime
421
- store.bind(sock.ev)
422
-
423
- sock.ev.on('chats.upsert', () => {
424
- // can use 'store.chats' however you want, even after the socket dies out
425
- // 'chats' => a KeyedDB instance
426
- console.log('got chats', store.chats.all())
427
- })
428
-
429
- sock.ev.on('contacts.upsert', () => {
430
- console.log('got contacts', Object.values(store.contacts))
431
- })
432
-
433
- ```
434
-
435
- The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
436
-
437
- ## Whatsapp IDs Explain
438
-
439
- - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
440
- - It must be in the format ```[country code][phone number]@s.whatsapp.net```
441
- - Example for people: ```+19999999999@s.whatsapp.net```.
442
- - For groups, it must be in the format ``` 123456789-123345@g.us ```.
443
- - For broadcast lists, it's `[timestamp of creation]@broadcast`.
444
- - For stories, the ID is `status@broadcast`.
445
-
446
- ## Utility Functions
447
-
448
- - `getContentType`, returns the content type for any message
449
- - `getDevice`, returns the device from message
450
- - `makeCacheableSignalKeyStore`, make auth store more fast
451
- - `downloadContentFromMessage`, download content from any message
452
-
453
- ## Sending Messages
454
-
455
- - Send all types of messages with a single function
456
- - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
457
- - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
458
-
459
- ```ts
460
- const jid: string
461
- const content: AnyMessageContent
462
- const options: MiscMessageGenerationOptions
463
-
464
- sock.sendMessage(jid, content, options)
465
- ```
466
-
467
- ### Non-Media Messages
468
-
469
- #### Text Message
470
- ```ts
471
- await sock.sendMessage(jid, { text: 'hello word' })
472
- ```
473
-
474
- #### Quote Message (works with all types)
475
- ```ts
476
- await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
477
- ```
478
-
479
- #### Mention User (works with most types)
480
- - @number is to mention in text, it's optional
481
- ```ts
482
- await sock.sendMessage(
483
- jid,
484
- {
485
- text: '@12345678901',
486
- mentions: ['12345678901@s.whatsapp.net']
487
- }
488
- )
489
- ```
490
-
491
- #### Forward Messages
492
- - 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
493
- ```ts
494
- const msg = getMessageFromStore() // implement this on your end
495
- await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
496
- ```
497
-
498
- #### Location Message
499
- ```ts
500
- await sock.sendMessage(
501
- jid,
502
- {
503
- location: {
504
- degreesLatitude: 24.121231,
505
- degreesLongitude: 55.1121221
506
- }
507
- }
508
- )
509
- ```
510
- #### Contact Message
511
- ```ts
512
- const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
513
- + 'VERSION:3.0\n'
514
- + 'FN:Jeff Singh\n' // full name
515
- + 'ORG:Ashoka Uni;\n' // the organization of the contact
516
- + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
517
- + 'END:VCARD'
518
-
519
- await sock.sendMessage(
520
- id,
521
- {
522
- contacts: {
523
- displayName: 'Jeff',
524
- contacts: [{ vcard }]
525
- }
526
- }
527
- )
528
- ```
529
-
530
- #### Reaction Message
531
- - 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
532
- ```ts
533
- await sock.sendMessage(
534
- jid,
535
- {
536
- react: {
537
- text: '💖', // use an empty string to remove the reaction
538
- key: message.key
539
- }
540
- }
541
- )
542
- ```
543
-
544
- #### Pin Message
545
- - 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
546
-
547
- - Time can be:
548
-
549
- | Time | Seconds |
550
- |-------|----------------|
551
- | 24h | 86.400 |
552
- | 7d | 604.800 |
553
- | 30d | 2.592.000 |
554
-
555
- ```ts
556
- await sock.sendMessage(
557
- jid,
558
- {
559
- pin: {
560
- type: 1, // 0 to remove
561
- time: 86400
562
- key: message.key
563
- }
564
- }
565
- )
566
- ```
567
-
568
- #### Poll Message
569
- ```ts
570
- await sock.sendMessage(
571
- jid,
572
- {
573
- poll: {
574
- name: 'My Poll',
575
- values: ['Option 1', 'Option 2', ...],
576
- selectableCount: 1,
577
- toAnnouncementGroup: false // or true
578
- }
579
- }
580
- )
581
- ```
582
-
583
- ### Sending Messages with Link Previews
584
-
585
- 1. By default, wa does not have link generation when sent from the web
586
- 2. Baileys has a function to generate the content for these link previews
587
- 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
588
- 4. Send a link:
589
- ```ts
590
- await sock.sendMessage(
591
- jid,
592
- {
593
- text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
594
- }
595
- )
596
- ```
597
-
598
- ### Media Messages
599
-
600
- Sending media (video, stickers, images) is easier & more efficient than ever.
601
-
602
- > [!NOTE]
603
- > 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)
604
-
605
- - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
606
-
607
- > [!TIP]
608
- > It's recommended to use Stream or Url to save memory
609
-
610
- #### Gif Message
611
- - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
612
- ```ts
613
- await sock.sendMessage(
614
- jid,
615
- {
616
- video: fs.readFileSync('Media/ma_gif.mp4'),
617
- caption: 'hello word',
618
- gifPlayback: true
619
- }
620
- )
621
- ```
622
-
623
- #### Video Message
624
- ```ts
625
- await sock.sendMessage(
626
- id,
627
- {
628
- video: {
629
- url: './Media/ma_gif.mp4'
630
- },
631
- caption: 'hello word',
632
- ptv: false // if set to true, will send as a `video note`
633
- }
634
- )
635
- ```
636
-
637
- #### Audio Message
638
- - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
639
- ```bash
640
- codec: libopus //ogg file
641
- ac: 1 //one channel
642
- avoid_negative_ts
643
- make_zero
644
- ```
645
- - Example:
646
- ```bash
647
- ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
648
- ```
649
- ```ts
650
- await sock.sendMessage(
651
- jid,
652
- {
653
- audio: {
654
- url: './Media/audio.mp3'
655
- },
656
- mimetype: 'audio/mp4'
657
- }
658
- )
659
- ```
660
-
661
- #### Image Message
662
- ```ts
663
- await sock.sendMessage(
664
- id,
665
- {
666
- image: {
667
- url: './Media/ma_img.png'
668
- },
669
- caption: 'hello word'
670
- }
671
- )
672
- ```
673
-
674
- #### View Once Message
675
-
676
- - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
677
-
678
- ```ts
679
- await sock.sendMessage(
680
- id,
681
- {
682
- image: {
683
- url: './Media/ma_img.png'
684
- },
685
- viewOnce: true, //works with video, audio too
686
- caption: 'hello word'
687
- }
688
- )
689
- ```
690
-
691
- ## Modify Messages
692
-
693
- ### Deleting Messages (for everyone)
694
-
695
- ```ts
696
- const msg = await sock.sendMessage(jid, { text: 'hello word' })
697
- await sock.sendMessage(jid, { delete: msg.key })
698
- ```
699
-
700
- **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
701
-
702
- ### Editing Messages
703
-
704
- - You can pass all editable contents here
705
- ```ts
706
- await sock.sendMessage(jid, {
707
- text: 'updated text goes here',
708
- edit: response.key,
709
- });
710
- ```
711
-
712
- ## Manipulating Media Messages
713
-
714
- ### Thumbnail in Media Messages
715
- - 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`.
716
- - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
717
-
718
- ### Downloading Media Messages
719
-
720
- If you want to save the media you received
721
- ```ts
722
- import { createWriteStream } from 'fs'
723
- import { downloadMediaMessage, getContentType } from '@whiskeysockets/baileys'
724
-
725
- sock.ev.on('messages.upsert', async ({ [m] }) => {
726
- if (!m.message) return // if there is no text or media message
727
- const messageType = getContentType(m) // get what type of message it is (text, image, video...)
728
-
729
- // if the message is an image
730
- if (messageType === 'imageMessage') {
731
- // download the message
732
- const stream = await downloadMediaMessage(
733
- m,
734
- 'stream', // can be 'buffer' too
735
- { },
736
- {
737
- logger,
738
- // pass this so that baileys can request a reupload of media
739
- // that has been deleted
740
- reuploadRequest: sock.updateMediaMessage
741
- }
742
- )
743
- // save to file
744
- const writeStream = createWriteStream('./my-download.jpeg')
745
- stream.pipe(writeStream)
746
- }
747
- }
748
- ```
749
-
750
- ### Re-upload Media Message to Whatsapp
751
-
752
- - 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:
753
- ```ts
754
- await sock.updateMediaMessage(msg)
755
- ```
756
-
757
- ## Reject Call
758
-
759
- - You can obtain `callId` and `callFrom` from `call` event
760
-
761
- ```ts
762
- await sock.rejectCall(callId, callFrom)
763
- ```
764
-
765
- ## Send States in Chat
766
-
767
- ### Reading Messages
768
- - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
769
- - You cannot mark an entire 'chat' read as it were with Baileys Web.
770
- This means you have to keep track of unread messages.
771
-
772
- ```ts
773
- const key: WAMessageKey
774
- // can pass multiple keys to read multiple messages as well
775
- await sock.readMessages([key])
776
- ```
777
-
778
- The message ID is the unique identifier of the message that you are marking as read.
779
- On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
780
-
781
- ### Update Presence
782
-
783
- - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
784
- - The presence expires after about 10 seconds.
785
- - This lets the person/group with `jid` know whether you're online, offline, typing etc.
786
-
787
- ```ts
788
- await sock.sendPresenceUpdate('available', jid)
789
- ```
790
-
791
- > [!NOTE]
792
- > 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')`
793
-
794
- ## Modifying Chats
795
-
796
- WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
797
-
798
- > [!IMPORTANT]
799
- > 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.
800
-
801
- ### Archive a Chat
802
- ```ts
803
- const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
804
- await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
805
- ```
806
- ### Mute/Unmute a Chat
807
-
808
- - Supported times:
809
-
810
- | Time | Miliseconds |
811
- |-------|-----------------|
812
- | Remove | null |
813
- | 8h | 86.400.000 |
814
- | 7d | 604.800.000 |
815
-
816
- ```ts
817
- // mute for 8 hours
818
- await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
819
- // unmute
820
- await sock.chatModify({ mute: null }, jid)
821
- ```
822
- ### Mark a Chat Read/Unread
823
- ```ts
824
- const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
825
- // mark it unread
826
- await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
827
- ```
828
-
829
- ### Delete a Message for Me
830
- ```ts
831
- await sock.chatModify(
832
- {
833
- clear: {
834
- messages: [
835
- {
836
- id: 'ATWYHDNNWU81732J',
837
- fromMe: true,
838
- timestamp: '1654823909'
839
- }
840
- ]
841
- }
842
- },
843
- jid
844
- )
845
-
846
- ```
847
- ### Delete a Chat
848
- ```ts
849
- const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
850
- await sock.chatModify({
851
- delete: true,
852
- lastMessages: [
853
- {
854
- key: lastMsgInChat.key,
855
- messageTimestamp: lastMsgInChat.messageTimestamp
856
- }
857
- ]
858
- },
859
- jid
860
- )
861
- ```
862
- ### Pin/Unpin a Chat
863
- ```ts
864
- await sock.chatModify({
865
- pin: true // or `false` to unpin
866
- },
867
- jid
868
- )
869
- ```
870
- ### Star/Unstar a Message
871
- ```ts
872
- await sock.chatModify({
873
- star: {
874
- messages: [
875
- {
876
- id: 'messageID',
877
- fromMe: true // or `false`
878
- }
879
- ],
880
- star: true // - true: Star Message; false: Unstar Message
881
- }
882
- },
883
- jid
884
- )
885
- ```
886
-
887
- ### Disappearing Messages
888
-
889
- - Ephemeral can be:
890
-
891
- | Time | Seconds |
892
- |-------|----------------|
893
- | Remove | 0 |
894
- | 24h | 86.400 |
895
- | 7d | 604.800 |
896
- | 90d | 7.776.000 |
897
-
898
- - You need to pass in **Seconds**, default is 7 days
899
-
900
- ```ts
901
- // turn on disappearing messages
902
- await sock.sendMessage(
903
- jid,
904
- // this is 1 week in seconds -- how long you want messages to appear for
905
- { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
906
- )
907
-
908
- // will send as a disappearing message
909
- await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
910
-
911
- // turn off disappearing messages
912
- await sock.sendMessage(
913
- jid,
914
- { disappearingMessagesInChat: false }
915
- )
916
- ```
917
-
918
- ## User Querys
919
-
920
- ### Check If ID Exists in Whatsapp
921
- ```ts
922
- const [result] = await sock.onWhatsApp(jid)
923
- if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
924
- ```
925
-
926
- ### Query Chat History (groups too)
927
-
928
- - You need to have oldest message in chat
929
- ```ts
930
- const msg = await getOldestMessageInChat(jid) // implement this on your end
931
- await sock.fetchMessageHistory(
932
- 50, //quantity (max: 50 per query)
933
- msg.key,
934
- msg.messageTimestamp
935
- )
936
- ```
937
- - Messages will be received in `messaging.history-set` event
938
-
939
- ### Fetch Status
940
- ```ts
941
- const status = await sock.fetchStatus(jid)
942
- console.log('status: ' + status)
943
- ```
944
-
945
- ### Fetch Profile Picture (groups too)
946
- - To get the display picture of some person/group
947
- ```ts
948
- // for low res picture
949
- const ppUrl = await sock.profilePictureUrl(jid)
950
- console.log(ppUrl)
951
-
952
- // for high res picture
953
- const ppUrl = await sock.profilePictureUrl(jid, 'image')
954
- ```
955
-
956
- ### Fetch Bussines Profile (such as description or category)
957
- ```ts
958
- const profile = await sock.getBusinessProfile(jid)
959
- console.log('business description: ' + profile.description + ', category: ' + profile.category)
960
- ```
961
-
962
- ### Fetch Someone's Presence (if they're typing or online)
963
- ```ts
964
- // the presence update is fetched and called here
965
- sock.ev.on('presence.update', console.log)
966
-
967
- // request updates for a chat
968
- await sock.presenceSubscribe(jid)
969
- ```
970
-
971
- ## Change Profile
972
-
973
- ### Change Profile Status
974
- ```ts
975
- await sock.updateProfileStatus('Hello World!')
976
- ```
977
- ### Change Profile Name
978
- ```ts
979
- await sock.updateProfileName('My name')
980
- ```
981
- ### Change Display Picture (groups too)
982
- - To change your display picture or a group's
983
-
984
- > [!NOTE]
985
- > 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)
986
-
987
- ```ts
988
- await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
989
- ```
990
- ### Remove display picture (groups too)
991
- ```ts
992
- await sock.removeProfilePicture(jid)
993
- ```
994
-
995
- ## Groups
996
-
997
- - To change group properties you need to be admin
998
-
999
- ### Create a Group
1000
- ```ts
1001
- // title & participants
1002
- const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1003
- console.log('created group with id: ' + group.gid)
1004
- await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1005
- ```
1006
- ### Add/Remove or Demote/Promote
1007
- ```ts
1008
- // id & people to add to the group (will throw error if it fails)
1009
- await sock.groupParticipantsUpdate(
1010
- jid,
1011
- ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1012
- 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1013
- )
1014
- ```
1015
- ### Change Subject (name)
1016
- ```ts
1017
- await sock.groupUpdateSubject(jid, 'New Subject!')
1018
- ```
1019
- ### Change Description
1020
- ```ts
1021
- await sock.groupUpdateDescription(jid, 'New Description!')
1022
- ```
1023
- ### Change Settings
1024
- ```ts
1025
- // only allow admins to send messages
1026
- await sock.groupSettingUpdate(jid, 'announcement')
1027
- // allow everyone to send messages
1028
- await sock.groupSettingUpdate(jid, 'not_announcement')
1029
- // allow everyone to modify the group's settings -- like display picture etc.
1030
- await sock.groupSettingUpdate(jid, 'unlocked')
1031
- // only allow admins to modify the group's settings
1032
- await sock.groupSettingUpdate(jid, 'locked')
1033
- ```
1034
- ### Leave a Group
1035
- ```ts
1036
- // will throw error if it fails
1037
- await sock.groupLeave(jid)
1038
- ```
1039
- ### Get Invite Code
1040
- - To create link with code use `'https://chat.whatsapp.com/' + code`
1041
- ```ts
1042
- const code = await sock.groupInviteCode(jid)
1043
- console.log('group code: ' + code)
1044
- ```
1045
- ### Revoke Invite Code
1046
- ```ts
1047
- const code = await sock.groupRevokeInvite(jid)
1048
- console.log('New group code: ' + code)
1049
- ```
1050
- ### Join Using Invitation Code
1051
- - Code can't have `https://chat.whatsapp.com/`, only code
1052
- ```ts
1053
- const response = await sock.groupAcceptInvite(code)
1054
- console.log('joined to: ' + response)
1055
- ```
1056
- ### Get Group Info by Invite Code
1057
- ```ts
1058
- const response = await sock.groupGetInviteInfo(code)
1059
- console.log('group information: ' + response)
1060
- ```
1061
- ### Query Metadata (participants, name, description...)
1062
- ```ts
1063
- const metadata = await sock.groupMetadata(jid)
1064
- console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1065
- ```
1066
- ### Join using `groupInviteMessage`
1067
- ```ts
1068
- const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1069
- console.log('joined to: ' + response)
1070
- ```
1071
- ### Get Request Join List
1072
- ```ts
1073
- const response = await sock.groupRequestParticipantsList(jid)
1074
- console.log(response)
1075
- ```
1076
- ### Approve/Reject Request Join
1077
- ```ts
1078
- const response = await sock.groupRequestParticipantsUpdate(
1079
- jid, // group id
1080
- ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1081
- 'approve' // or 'reject'
1082
- )
1083
- console.log(response)
1084
- ```
1085
- ### Get All Participating Groups Metadata
1086
- ```ts
1087
- const response = await sock.groupFetchAllParticipating()
1088
- console.log(response)
1089
- ```
1090
- ### Toggle Ephemeral
1091
-
1092
- - Ephemeral can be:
1093
-
1094
- | Time | Seconds |
1095
- |-------|----------------|
1096
- | Remove | 0 |
1097
- | 24h | 86.400 |
1098
- | 7d | 604.800 |
1099
- | 90d | 7.776.000 |
1100
-
1101
- ```ts
1102
- await sock.groupToggleEphemeral(jid, 86400)
1103
- ```
1104
-
1105
- ### Change Add Mode
1106
- ```ts
1107
- await sock.groupMemberAddMode(
1108
- jid,
1109
- 'all_member_add' // or 'admin_add'
1110
- )
1111
- ```
1112
-
1113
- ## Privacy
1114
-
1115
- ### Block/Unblock User
1116
- ```ts
1117
- await sock.updateBlockStatus(jid, 'block') // Block user
1118
- await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1119
- ```
1120
- ### Get Privacy Settings
1121
- ```ts
1122
- const privacySettings = await sock.fetchPrivacySettings(true)
1123
- console.log('privacy settings: ' + privacySettings)
1124
- ```
1125
- ### Get BlockList
1126
- ```ts
1127
- const response = await sock.fetchBlocklist()
1128
- console.log(response)
1129
- ```
1130
- ### Update LastSeen Privacy
1131
- ```ts
1132
- const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1133
- await sock.updateLastSeenPrivacy(value)
1134
- ```
1135
- ### Update Online Privacy
1136
- ```ts
1137
- const value = 'all' // 'match_last_seen'
1138
- await sock.updateOnlinePrivacy(value)
1139
- ```
1140
- ### Update Profile Picture Privacy
1141
- ```ts
1142
- const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1143
- await sock.updateProfilePicturePrivacy(value)
1144
- ```
1145
- ### Update Status Privacy
1146
- ```ts
1147
- const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1148
- await sock.updateStatusPrivacy(value)
1149
- ```
1150
- ### Update Read Receipts Privacy
1151
- ```ts
1152
- const value = 'all' // 'none'
1153
- await sock.updateReadReceiptsPrivacy(value)
1154
- ```
1155
- ### Update Groups Add Privacy
1156
- ```ts
1157
- const value = 'all' // 'contacts' | 'contact_blacklist'
1158
- await sock.updateGroupsAddPrivacy(value)
1159
- ```
1160
- ### Update Default Disappearing Mode
1161
-
1162
- - Like [this](#disappearing-messages), ephemeral can be:
1163
-
1164
- | Time | Seconds |
1165
- |-------|----------------|
1166
- | Remove | 0 |
1167
- | 24h | 86.400 |
1168
- | 7d | 604.800 |
1169
- | 90d | 7.776.000 |
1170
-
1171
- ```ts
1172
- const ephemeral = 86400
1173
- await sock.updateDefaultDisappearingMode(ephemeral)
1174
- ```
1175
-
1176
- ## Broadcast Lists & Stories
1177
-
1178
- ### Send Broadcast & Stories
1179
- - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1180
- ```ts
1181
- await sock.sendMessage(
1182
- jid,
1183
- {
1184
- image: {
1185
- url: url
1186
- },
1187
- caption: caption
1188
- },
1189
- {
1190
- backgroundColor: backgroundColor,
1191
- font: font,
1192
- statusJidList: statusJidList,
1193
- broadcast: true
1194
- }
1195
- )
1196
- ```
1197
- - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1198
- - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1199
- - `broadcast: true` enables broadcast mode
1200
- - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1201
-
1202
- - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1203
- - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1204
- - Broadcast IDs are in the format `12345678@broadcast`
1205
- ### Query a Broadcast List's Recipients & Name
1206
- ```ts
1207
- const bList = await sock.getBroadcastListInfo('1234@broadcast')
1208
- console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1209
- ```
1210
-
1211
- ## Writing Custom Functionality
1212
- Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1213
-
1214
- ### Enabling Debug Level in Baileys Logs
1215
- First, enable the logging of unhandled messages from WhatsApp by setting:
1216
- ```ts
1217
- const sock = makeWASocket({
1218
- logger: P({ level: 'debug' }),
1219
- })
1220
- ```
1221
- This will enable you to see all sorts of messages WhatsApp sends in the console.
1222
-
1223
- ### How Whatsapp Communicate With Us
1224
-
1225
- > [!TIP]
1226
- > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1227
-
1228
- - **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:
1229
- ```
1230
- {
1231
- "level": 10,
1232
- "fromMe": false,
1233
- "frame": {
1234
- "tag": "ib",
1235
- "attrs": {
1236
- "from": "@s.whatsapp.net"
1237
- },
1238
- "content": [
1239
- {
1240
- "tag": "edge_routing",
1241
- "attrs": {},
1242
- "content": [
1243
- {
1244
- "tag": "routing_info",
1245
- "attrs": {},
1246
- "content": {
1247
- "type": "Buffer",
1248
- "data": [8,2,8,5]
1249
- }
1250
- }
1251
- ]
1252
- }
1253
- ]
1254
- },
1255
- "msg":"communication"
1256
- }
1257
- ```
1258
-
1259
- The `'frame'` is what the message received is, it has three components:
1260
- - `tag` -- what this frame is about (eg. message will have 'message')
1261
- - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1262
- - `content` -- the actual data (eg. a message node will have the actual message content in it)
1263
- - read more about this format [here](/src/WABinary/readme.md)
1264
-
1265
- ### Register a Callback for Websocket Events
1266
-
1267
- > [!TIP]
1268
- > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1269
-
1270
- ```ts
1271
- // for any message with tag 'edge_routing'
1272
- sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1273
-
1274
- // for any message with tag 'edge_routing' and id attribute = abcd
1275
- sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1276
-
1277
- // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1278
- sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1279
- ```
1280
-
1281
- # License
1282
- Copyright (c) 2025 Rajeh Taher/WhiskeySockets
1283
-
1284
- Licensed under the MIT License:
1285
- Permission is hereby granted, free of charge, to any person obtaining a copy
1286
- of this software and associated documentation files (the "Software"), to deal
1287
- in the Software without restriction, including without limitation the rights
1288
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1289
- copies of the Software, and to permit persons to whom the Software is
1290
- furnished to do so, subject to the following conditions:
1291
-
1292
- The above copyright notice and this permission notice shall be included in all
1293
- copies or substantial portions of the Software.
1294
-
1295
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1296
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1297
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1298
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1299
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1300
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1301
- SOFTWARE.
1302
-
1303
- Thus, the maintainers of the project can't be held liable for any potential misuse of this project.
9
+ Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-baileys",
3
- "version": "1.5.8",
3
+ "version": "2.0.0",
4
4
  "description": "Typescript/Javascript WhatsApp Web API",
5
5
  "keywords": [
6
6
  "whatsapp",