@queenanya/baileys 9.2.1 → 9.5.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 (149) hide show
  1. package/README.md +531 -445
  2. package/WAProto/fix-imports.js +70 -18
  3. package/WAProto/index.js +197 -160
  4. package/engine-requirements.js +7 -7
  5. package/lib/Defaults/index.d.ts +12 -0
  6. package/lib/Defaults/index.d.ts.map +1 -1
  7. package/lib/Defaults/index.js +17 -5
  8. package/lib/Defaults/index.js.map +1 -1
  9. package/lib/Signal/libsignal.d.ts.map +1 -1
  10. package/lib/Signal/libsignal.js +63 -2
  11. package/lib/Signal/libsignal.js.map +1 -1
  12. package/lib/Signal/lid-mapping.d.ts +5 -9
  13. package/lib/Signal/lid-mapping.d.ts.map +1 -1
  14. package/lib/Signal/lid-mapping.js +170 -70
  15. package/lib/Signal/lid-mapping.js.map +1 -1
  16. package/lib/Socket/Client/websocket.d.ts +1 -1
  17. package/lib/Socket/Client/websocket.d.ts.map +1 -1
  18. package/lib/Socket/Client/websocket.js +5 -1
  19. package/lib/Socket/Client/websocket.js.map +1 -1
  20. package/lib/Socket/business.d.ts +16 -4
  21. package/lib/Socket/business.d.ts.map +1 -1
  22. package/lib/Socket/business.js +11 -8
  23. package/lib/Socket/business.js.map +1 -1
  24. package/lib/Socket/chats.d.ts +14 -3
  25. package/lib/Socket/chats.d.ts.map +1 -1
  26. package/lib/Socket/chats.js +55 -28
  27. package/lib/Socket/chats.js.map +1 -1
  28. package/lib/Socket/communities.d.ts +16 -4
  29. package/lib/Socket/communities.d.ts.map +1 -1
  30. package/lib/Socket/groups.d.ts +14 -3
  31. package/lib/Socket/groups.d.ts.map +1 -1
  32. package/lib/Socket/groups.js +1 -1
  33. package/lib/Socket/groups.js.map +1 -1
  34. package/lib/Socket/index.d.ts +16 -4
  35. package/lib/Socket/index.d.ts.map +1 -1
  36. package/lib/Socket/index.js +0 -6
  37. package/lib/Socket/index.js.map +1 -1
  38. package/lib/Socket/messages-recv.d.ts +16 -4
  39. package/lib/Socket/messages-recv.d.ts.map +1 -1
  40. package/lib/Socket/messages-recv.js +152 -87
  41. package/lib/Socket/messages-recv.js.map +1 -1
  42. package/lib/Socket/messages-send.d.ts +15 -3
  43. package/lib/Socket/messages-send.d.ts.map +1 -1
  44. package/lib/Socket/messages-send.js +117 -48
  45. package/lib/Socket/messages-send.js.map +1 -1
  46. package/lib/Socket/newsletter.d.ts +15 -5
  47. package/lib/Socket/newsletter.d.ts.map +1 -1
  48. package/lib/Socket/newsletter.js +2 -47
  49. package/lib/Socket/newsletter.js.map +1 -1
  50. package/lib/Socket/socket.d.ts +3 -1
  51. package/lib/Socket/socket.d.ts.map +1 -1
  52. package/lib/Socket/socket.js +71 -16
  53. package/lib/Socket/socket.js.map +1 -1
  54. package/lib/Types/Auth.d.ts +1 -0
  55. package/lib/Types/Auth.d.ts.map +1 -1
  56. package/lib/Types/Call.d.ts +1 -0
  57. package/lib/Types/Call.d.ts.map +1 -1
  58. package/lib/Types/Events.d.ts +40 -5
  59. package/lib/Types/Events.d.ts.map +1 -1
  60. package/lib/Types/Message.d.ts +3 -3
  61. package/lib/Types/Message.d.ts.map +1 -1
  62. package/lib/Types/Newsletter.d.ts +0 -17
  63. package/lib/Types/Newsletter.d.ts.map +1 -1
  64. package/lib/Utils/auth-utils.d.ts.map +1 -1
  65. package/lib/Utils/auth-utils.js +53 -20
  66. package/lib/Utils/auth-utils.js.map +1 -1
  67. package/lib/Utils/chat-utils.d.ts.map +1 -1
  68. package/lib/Utils/chat-utils.js +100 -51
  69. package/lib/Utils/chat-utils.js.map +1 -1
  70. package/lib/Utils/crypto.d.ts +4 -8
  71. package/lib/Utils/crypto.d.ts.map +1 -1
  72. package/lib/Utils/crypto.js +2 -26
  73. package/lib/Utils/crypto.js.map +1 -1
  74. package/lib/Utils/event-buffer.d.ts.map +1 -1
  75. package/lib/Utils/event-buffer.js +33 -7
  76. package/lib/Utils/event-buffer.js.map +1 -1
  77. package/lib/Utils/generics.d.ts +1 -0
  78. package/lib/Utils/generics.d.ts.map +1 -1
  79. package/lib/Utils/generics.js +5 -2
  80. package/lib/Utils/generics.js.map +1 -1
  81. package/lib/Utils/history.d.ts +6 -3
  82. package/lib/Utils/history.d.ts.map +1 -1
  83. package/lib/Utils/history.js +46 -5
  84. package/lib/Utils/history.js.map +1 -1
  85. package/lib/Utils/identity-change-handler.d.ts +37 -0
  86. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  87. package/lib/Utils/identity-change-handler.js +49 -0
  88. package/lib/Utils/identity-change-handler.js.map +1 -0
  89. package/lib/Utils/index.d.ts +1 -0
  90. package/lib/Utils/index.d.ts.map +1 -1
  91. package/lib/Utils/index.js +1 -0
  92. package/lib/Utils/index.js.map +1 -1
  93. package/lib/Utils/lt-hash.d.ts +7 -12
  94. package/lib/Utils/lt-hash.d.ts.map +1 -1
  95. package/lib/Utils/lt-hash.js +2 -42
  96. package/lib/Utils/lt-hash.js.map +1 -1
  97. package/lib/Utils/make-mutex.d.ts +1 -0
  98. package/lib/Utils/make-mutex.d.ts.map +1 -1
  99. package/lib/Utils/make-mutex.js +20 -27
  100. package/lib/Utils/make-mutex.js.map +1 -1
  101. package/lib/Utils/message-retry-manager.d.ts +30 -2
  102. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  103. package/lib/Utils/message-retry-manager.js +58 -5
  104. package/lib/Utils/message-retry-manager.js.map +1 -1
  105. package/lib/Utils/messages-media.d.ts +18 -2
  106. package/lib/Utils/messages-media.d.ts.map +1 -1
  107. package/lib/Utils/messages-media.js +150 -39
  108. package/lib/Utils/messages-media.js.map +1 -1
  109. package/lib/Utils/messages.d.ts +2 -0
  110. package/lib/Utils/messages.d.ts.map +1 -1
  111. package/lib/Utils/messages.js +41 -23
  112. package/lib/Utils/messages.js.map +1 -1
  113. package/lib/Utils/noise-handler.d.ts +4 -4
  114. package/lib/Utils/noise-handler.d.ts.map +1 -1
  115. package/lib/Utils/noise-handler.js +139 -85
  116. package/lib/Utils/noise-handler.js.map +1 -1
  117. package/lib/Utils/process-message.d.ts.map +1 -1
  118. package/lib/Utils/process-message.js +57 -14
  119. package/lib/Utils/process-message.js.map +1 -1
  120. package/lib/Utils/reporting-utils.d.ts +11 -0
  121. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  122. package/lib/Utils/reporting-utils.js +258 -0
  123. package/lib/Utils/reporting-utils.js.map +1 -0
  124. package/lib/Utils/sync-action-utils.d.ts +19 -0
  125. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  126. package/lib/Utils/sync-action-utils.js +48 -0
  127. package/lib/Utils/sync-action-utils.js.map +1 -0
  128. package/lib/Utils/tc-token-utils.d.ts +12 -0
  129. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  130. package/lib/Utils/tc-token-utils.js +18 -0
  131. package/lib/Utils/tc-token-utils.js.map +1 -0
  132. package/lib/Utils/use-multi-file-auth-state.js +1 -1
  133. package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
  134. package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -1
  135. package/lib/Utils/use-single-file-auth-state.js.map +1 -1
  136. package/lib/WABinary/decode.d.ts.map +1 -1
  137. package/lib/WABinary/decode.js +24 -0
  138. package/lib/WABinary/decode.js.map +1 -1
  139. package/lib/WABinary/encode.js +5 -1
  140. package/lib/WABinary/encode.js.map +1 -1
  141. package/lib/WABinary/generic-utils.d.ts +1 -1
  142. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  143. package/lib/WABinary/generic-utils.js +19 -8
  144. package/lib/WABinary/generic-utils.js.map +1 -1
  145. package/lib/WABinary/jid-utils.d.ts +0 -3
  146. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  147. package/lib/WABinary/jid-utils.js +0 -4
  148. package/lib/WABinary/jid-utils.js.map +1 -1
  149. package/package.json +4 -2
package/README.md CHANGED
@@ -2,23 +2,14 @@
2
2
 
3
3
  <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
4
 
5
-
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.
12
-
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).
15
-
16
5
  New guide link: https://baileys.wiki
17
6
 
18
7
  # Sponsor
8
+
19
9
  If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
20
10
 
21
11
  # Disclaimer
12
+
22
13
  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
14
  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
15
 
@@ -30,11 +21,11 @@ Use at your own discretion. Do not spam people with this. We discourage any stal
30
21
  - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
31
22
  - Not running Selenium or Chromium saves you like **half a gig** of ram :/
32
23
  - 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.
24
+ - 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
25
 
35
26
  > [!IMPORTANT]
36
27
  > 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.
28
+ > This is the only official repository and is maintained by the community.
38
29
  > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
39
30
 
40
31
  ## Example
@@ -42,23 +33,27 @@ This is the only official repository and is maintained by the community.
42
33
  Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
43
34
  The script covers most common use cases.
44
35
  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 ```
36
+
37
+ 1. `cd path/to/Baileys`
38
+ 2. `yarn`
39
+ 3. `yarn example`
48
40
 
49
41
  ## Install
50
42
 
51
43
  Use the stable version:
44
+
52
45
  ```
53
46
  yarn add @whiskeysockets/baileys
54
47
  ```
55
48
 
56
49
  Use the edge version (no guarantee of stability, but latest fixes + features)
50
+
57
51
  ```
58
52
  yarn add github:WhiskeySockets/Baileys
59
53
  ```
60
54
 
61
55
  Then import your code using:
56
+
62
57
  ```ts
63
58
  import makeWASocket from '@whiskeysockets/baileys'
64
59
  ```
@@ -71,107 +66,107 @@ import makeWASocket from '@whiskeysockets/baileys'
71
66
  # Index
72
67
 
73
68
  - [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)
69
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
70
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
71
+ - [Receive Full History](#receive-full-history)
77
72
  - [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)
73
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
74
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
75
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
81
76
 
82
77
  - [Save Auth Info](#saving--restoring-sessions)
83
78
  - [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)
79
+ - [Example to Start](#example-to-start)
80
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
81
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
87
82
  - [Implementing a Data Store](#implementing-a-data-store)
88
83
  - [Whatsapp IDs Explain](#whatsapp-ids-explain)
89
84
  - [Utility Functions](#utility-functions)
90
85
  - [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)
86
+ - [Non-Media Messages](#non-media-messages)
87
+ - [Text Message](#text-message)
88
+ - [Quote Message](#quote-message-works-with-all-types)
89
+ - [Mention User](#mention-user-works-with-most-types)
90
+ - [Forward Messages](#forward-messages)
91
+ - [Location Message](#location-message)
92
+ - [Contact Message](#contact-message)
93
+ - [Reaction Message](#reaction-message)
94
+ - [Pin Message](#pin-message)
95
+ - [Poll Message](#poll-message)
96
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
97
+ - [Media Messages](#media-messages)
98
+ - [Gif Message](#gif-message)
99
+ - [Video Message](#video-message)
100
+ - [Audio Message](#audio-message)
101
+ - [Image Message](#image-message)
102
+ - [ViewOnce Message](#view-once-message)
108
103
  - [Modify Messages](#modify-messages)
109
- - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
110
- - [Edit Messages](#editing-messages)
104
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
105
+ - [Edit Messages](#editing-messages)
111
106
  - [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)
107
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
108
+ - [Downloading Media Messages](#downloading-media-messages)
109
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
115
110
  - [Reject Call](#reject-call)
116
111
  - [Send States in Chat](#send-states-in-chat)
117
- - [Reading Messages](#reading-messages)
118
- - [Update Presence](#update-presence)
112
+ - [Reading Messages](#reading-messages)
113
+ - [Update Presence](#update-presence)
119
114
  - [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)
115
+ - [Archive a Chat](#archive-a-chat)
116
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
117
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
118
+ - [Delete a Message for Me](#delete-a-message-for-me)
119
+ - [Delete a Chat](#delete-a-chat)
120
+ - [Star/Unstar a Message](#starunstar-a-message)
121
+ - [Disappearing Messages](#disappearing-messages)
127
122
  - [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)
123
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
124
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
125
+ - [Fetch Status](#fetch-status)
126
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
127
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
128
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
134
129
  - [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)
130
+ - [Change Profile Status](#change-profile-status)
131
+ - [Change Profile Name](#change-profile-name)
132
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
133
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
139
134
  - [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)
135
+ - [Create a Group](#create-a-group)
136
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
137
+ - [Change Subject (name)](#change-subject-name)
138
+ - [Change Description](#change-description)
139
+ - [Change Settings](#change-settings)
140
+ - [Leave a Group](#leave-a-group)
141
+ - [Get Invite Code](#get-invite-code)
142
+ - [Revoke Invite Code](#revoke-invite-code)
143
+ - [Join Using Invitation Code](#join-using-invitation-code)
144
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
145
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
146
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
147
+ - [Get Request Join List](#get-request-join-list)
148
+ - [Approve/Reject Request Join](#approvereject-request-join)
149
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
150
+ - [Toggle Ephemeral](#toggle-ephemeral)
151
+ - [Change Add Mode](#change-add-mode)
157
152
  - [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)
153
+ - [Block/Unblock User](#blockunblock-user)
154
+ - [Get Privacy Settings](#get-privacy-settings)
155
+ - [Get BlockList](#get-blocklist)
156
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
157
+ - [Update Online Privacy](#update-online-privacy)
158
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
159
+ - [Update Status Privacy](#update-status-privacy)
160
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
161
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
162
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
168
163
  - [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)
164
+ - [Send Broadcast & Stories](#send-broadcast--stories)
165
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
171
166
  - [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)
167
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
168
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
169
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
175
170
 
176
171
  ## Connecting Account
177
172
 
@@ -192,9 +187,9 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
192
187
  import makeWASocket from '@whiskeysockets/baileys'
193
188
 
194
189
  const sock = makeWASocket({
195
- // can provide additional config here
196
- browser: Browsers.ubuntu('My App'),
197
- printQRInTerminal: true
190
+ // can provide additional config here
191
+ browser: Browsers.ubuntu('My App'),
192
+ printQRInTerminal: true
198
193
  })
199
194
  ```
200
195
 
@@ -202,7 +197,6 @@ If the connection is successful, you will see a QR code printed on your terminal
202
197
 
203
198
  ### Starting socket with **Pairing Code**
204
199
 
205
-
206
200
  > [!IMPORTANT]
207
201
  > 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
202
 
@@ -212,14 +206,14 @@ The phone number can't have `+` or `()` or `-`, only numbers, you must provide c
212
206
  import makeWASocket from '@whiskeysockets/baileys'
213
207
 
214
208
  const sock = makeWASocket({
215
- // can provide additional config here
216
- printQRInTerminal: false //need to be false
209
+ // can provide additional config here
210
+ printQRInTerminal: false //need to be false
217
211
  })
218
212
 
219
213
  if (!sock.authState.creds.registered) {
220
- const number = 'XXXXXXXXXXX'
221
- const code = await sock.requestPairingCode(number)
222
- console.log(code)
214
+ const number = 'XXXXXXXXXXX'
215
+ const code = await sock.requestPairingCode(number)
216
+ console.log(code)
223
217
  }
224
218
  ```
225
219
 
@@ -227,60 +221,65 @@ if (!sock.authState.creds.registered) {
227
221
 
228
222
  1. Set `syncFullHistory` as `true`
229
223
  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:
224
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
231
225
 
232
226
  ```ts
233
227
  const sock = makeWASocket({
234
- ...otherOpts,
235
- // can use Windows, Ubuntu here too
236
- browser: Browsers.macOS('Desktop'),
237
- syncFullHistory: true
228
+ ...otherOpts,
229
+ // can use Windows, Ubuntu here too
230
+ browser: Browsers.macOS('Desktop'),
231
+ syncFullHistory: true
238
232
  })
239
233
  ```
240
234
 
241
235
  ## Important Notes About Socket Config
242
236
 
243
237
  ### Caching Group Metadata (Recommended)
238
+
244
239
  - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
245
240
 
246
- ```ts
247
- const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
241
+ ```ts
242
+ const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })
248
243
 
249
- const sock = makeWASocket({
250
- cachedGroupMetadata: async (jid) => groupCache.get(jid)
251
- })
244
+ const sock = makeWASocket({
245
+ cachedGroupMetadata: async jid => groupCache.get(jid)
246
+ })
252
247
 
253
- sock.ev.on('groups.update', async ([event]) => {
254
- const metadata = await sock.groupMetadata(event.id)
255
- groupCache.set(event.id, metadata)
256
- })
248
+ sock.ev.on('groups.update', async ([event]) => {
249
+ const metadata = await sock.groupMetadata(event.id)
250
+ groupCache.set(event.id, metadata)
251
+ })
257
252
 
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
- ```
253
+ sock.ev.on('group-participants.update', async event => {
254
+ const metadata = await sock.groupMetadata(event.id)
255
+ groupCache.set(event.id, metadata)
256
+ })
257
+ ```
263
258
 
264
259
  ### Improve Retry System & Decrypt Poll Votes
260
+
265
261
  - 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
- ```
262
+ ```ts
263
+ const sock = makeWASocket({
264
+ getMessage: async key => await getMessageFromStore(key)
265
+ })
266
+ ```
271
267
 
272
268
  ### Receive Notifications in Whatsapp App
269
+
273
270
  - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
274
- ```ts
275
- const sock = makeWASocket({
276
- markOnlineOnConnect: false
277
- })
278
- ```
271
+ ```ts
272
+ const sock = makeWASocket({
273
+ markOnlineOnConnect: false
274
+ })
275
+ ```
276
+
279
277
  ## Saving & Restoring Sessions
280
278
 
281
279
  You obviously don't want to keep scanning the QR code every time you want to connect.
282
280
 
283
281
  So, you can load the credentials to log back in:
282
+
284
283
  ```ts
285
284
  import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys'
286
285
 
@@ -303,16 +302,17 @@ sock.ev.on('creds.update', saveCreds)
303
302
  ## Handling Events
304
303
 
305
304
  - 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.
305
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
307
306
 
308
307
  > [!IMPORTANT]
309
308
  > **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
310
309
 
311
310
  You can listen to these events like this:
311
+
312
312
  ```ts
313
313
  const sock = makeWASocket()
314
314
  sock.ev.on('messages.upsert', ({ messages }) => {
315
- console.log('got messages', messages)
315
+ console.log('got messages', messages)
316
316
  })
317
317
  ```
318
318
 
@@ -328,37 +328,37 @@ sock.ev.on('messages.upsert', ({ messages }) => {
328
328
  import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
329
329
  import { Boom } from '@hapi/boom'
330
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)
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
362
  }
363
363
  // run in main file
364
364
  connectToWhatsApp()
@@ -371,22 +371,23 @@ connectToWhatsApp()
371
371
 
372
372
  - By default poll votes are encrypted and handled in `messages.update`
373
373
  - That's a simple example
374
+
374
375
  ```ts
375
376
  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
- }
377
+ for (const { key, update } of event) {
378
+ if (update.pollUpdates) {
379
+ const pollCreation = await getMessage(key)
380
+ if (pollCreation) {
381
+ console.log(
382
+ 'got poll update, aggregation: ',
383
+ getAggregateVotesInPollMessage({
384
+ message: pollCreation,
385
+ pollUpdates: update.pollUpdates
386
+ })
387
+ )
388
+ }
389
+ }
390
+ }
390
391
  })
391
392
  ```
392
393
 
@@ -410,29 +411,28 @@ It can be used as follows:
410
411
  import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
411
412
  // the store maintains the data of the WA connection in memory
412
413
  // can be written out to a file & read from it
413
- const store = makeInMemoryStore({ })
414
+ const store = makeInMemoryStore({})
414
415
  // can be read from a file
415
416
  store.readFromFile('./baileys_store.json')
416
417
  // saves the state to a file every 10s
417
418
  setInterval(() => {
418
- store.writeToFile('./baileys_store.json')
419
+ store.writeToFile('./baileys_store.json')
419
420
  }, 10_000)
420
421
 
421
- const sock = makeWASocket({ })
422
+ const sock = makeWASocket({})
422
423
  // will listen from this socket
423
424
  // the store can listen from a new socket once the current socket outlives its lifetime
424
425
  store.bind(sock.ev)
425
426
 
426
427
  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())
428
+ // can use 'store.chats' however you want, even after the socket dies out
429
+ // 'chats' => a KeyedDB instance
430
+ console.log('got chats', store.chats.all())
430
431
  })
431
432
 
432
433
  sock.ev.on('contacts.upsert', () => {
433
- console.log('got contacts', Object.values(store.contacts))
434
+ console.log('got contacts', Object.values(store.contacts))
434
435
  })
435
-
436
436
  ```
437
437
 
438
438
  The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
@@ -440,11 +440,11 @@ The store also provides some simple functions such as `loadMessages` that utiliz
440
440
  ## Whatsapp IDs Explain
441
441
 
442
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`.
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
448
 
449
449
  ## Utility Functions
450
450
 
@@ -456,104 +456,105 @@ The store also provides some simple functions such as `loadMessages` that utiliz
456
456
  ## Sending Messages
457
457
 
458
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**
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**
461
461
 
462
- ```ts
463
- const jid: string
464
- const content: AnyMessageContent
465
- const options: MiscMessageGenerationOptions
462
+ ```ts
463
+ const jid: string
464
+ const content: AnyMessageContent
465
+ const options: MiscMessageGenerationOptions
466
466
 
467
- sock.sendMessage(jid, content, options)
468
- ```
467
+ sock.sendMessage(jid, content, options)
468
+ ```
469
469
 
470
470
  ### Non-Media Messages
471
471
 
472
472
  #### Text Message
473
+
473
474
  ```ts
474
475
  await sock.sendMessage(jid, { text: 'hello word' })
475
476
  ```
476
477
 
477
478
  #### Quote Message (works with all types)
479
+
478
480
  ```ts
479
481
  await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
480
482
  ```
481
483
 
482
484
  #### Mention User (works with most types)
485
+
483
486
  - @number is to mention in text, it's optional
487
+
484
488
  ```ts
485
- await sock.sendMessage(
486
- jid,
487
- {
488
- text: '@12345678901',
489
- mentions: ['12345678901@s.whatsapp.net']
490
- }
491
- )
489
+ await sock.sendMessage(jid, {
490
+ text: '@12345678901',
491
+ mentions: ['12345678901@s.whatsapp.net']
492
+ })
492
493
  ```
493
494
 
494
495
  #### Forward Messages
496
+
495
497
  - 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
498
+
496
499
  ```ts
497
500
  const msg = getMessageFromStore() // implement this on your end
498
501
  await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
499
502
  ```
500
503
 
501
504
  #### Location Message
505
+
502
506
  ```ts
503
- await sock.sendMessage(
504
- jid,
505
- {
506
- location: {
507
- degreesLatitude: 24.121231,
508
- degreesLongitude: 55.1121221
509
- }
510
- }
511
- )
507
+ await sock.sendMessage(jid, {
508
+ location: {
509
+ degreesLatitude: 24.121231,
510
+ degreesLongitude: 55.1121221
511
+ }
512
+ })
512
513
  ```
514
+
513
515
  #### Contact Message
516
+
514
517
  ```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'
518
+ const vcard =
519
+ 'BEGIN:VCARD\n' + // metadata of the contact card
520
+ 'VERSION:3.0\n' +
521
+ 'FN:Jeff Singh\n' + // full name
522
+ 'ORG:Ashoka Uni;\n' + // the organization of the contact
523
+ 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' + // WhatsApp ID + phone number
524
+ 'END:VCARD'
521
525
 
522
- await sock.sendMessage(
523
- id,
524
- {
525
- contacts: {
526
- displayName: 'Jeff',
527
- contacts: [{ vcard }]
528
- }
529
- }
530
- )
526
+ await sock.sendMessage(id, {
527
+ contacts: {
528
+ displayName: 'Jeff',
529
+ contacts: [{ vcard }]
530
+ }
531
+ })
531
532
  ```
532
533
 
533
534
  #### Reaction Message
535
+
534
536
  - 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
537
+
535
538
  ```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
- )
539
+ await sock.sendMessage(jid, {
540
+ react: {
541
+ text: '💖', // use an empty string to remove the reaction
542
+ key: message.key
543
+ }
544
+ })
545
545
  ```
546
546
 
547
547
  #### Pin Message
548
+
548
549
  - 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
 
550
551
  - Time can be:
551
552
 
552
- | Time | Seconds |
553
- |-------|----------------|
554
- | 24h | 86.400 |
555
- | 7d | 604.800 |
556
- | 30d | 2.592.000 |
553
+ | Time | Seconds |
554
+ | ---- | --------- |
555
+ | 24h | 86.400 |
556
+ | 7d | 604.800 |
557
+ | 30d | 2.592.000 |
557
558
 
558
559
  ```ts
559
560
  await sock.sendMessage(
@@ -569,6 +570,7 @@ await sock.sendMessage(
569
570
  ```
570
571
 
571
572
  #### Poll Message
573
+
572
574
  ```ts
573
575
  await sock.sendMessage(
574
576
  jid,
@@ -589,13 +591,11 @@ await sock.sendMessage(
589
591
  2. Baileys has a function to generate the content for these link previews
590
592
  3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
591
593
  4. Send a link:
594
+
592
595
  ```ts
593
- await sock.sendMessage(
594
- jid,
595
- {
596
- text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
597
- }
598
- )
596
+ await sock.sendMessage(jid, {
597
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
598
+ })
599
599
  ```
600
600
 
601
601
  ### Media Messages
@@ -611,67 +611,64 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
611
611
  > It's recommended to use Stream or Url to save memory
612
612
 
613
613
  #### Gif Message
614
+
614
615
  - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
616
+
615
617
  ```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
- )
618
+ await sock.sendMessage(jid, {
619
+ video: fs.readFileSync('Media/ma_gif.mp4'),
620
+ caption: 'hello word',
621
+ gifPlayback: true
622
+ })
624
623
  ```
625
624
 
626
625
  #### Video Message
626
+
627
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
- )
628
+ await sock.sendMessage(id, {
629
+ video: {
630
+ url: './Media/ma_gif.mp4'
631
+ },
632
+ caption: 'hello word',
633
+ ptv: false // if set to true, will send as a `video note`
634
+ })
638
635
  ```
639
636
 
640
637
  #### Audio Message
638
+
641
639
  - 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
- ```
640
+
641
+ ```bash
642
+ codec: libopus //ogg file
643
+ ac: 1 //one channel
644
+ avoid_negative_ts
645
+ make_zero
646
+ ```
647
+
648
+ - Example:
649
+
650
+ ```bash
651
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
652
+ ```
653
+
652
654
  ```ts
653
- await sock.sendMessage(
654
- jid,
655
- {
656
- audio: {
657
- url: './Media/audio.mp3'
658
- },
659
- mimetype: 'audio/mp4'
660
- }
661
- )
655
+ await sock.sendMessage(jid, {
656
+ audio: {
657
+ url: './Media/audio.mp3'
658
+ },
659
+ mimetype: 'audio/mp4'
660
+ })
662
661
  ```
663
662
 
664
663
  #### Image Message
664
+
665
665
  ```ts
666
- await sock.sendMessage(
667
- id,
668
- {
669
- image: {
670
- url: './Media/ma_img.png'
671
- },
672
- caption: 'hello word'
673
- }
674
- )
666
+ await sock.sendMessage(id, {
667
+ image: {
668
+ url: './Media/ma_img.png'
669
+ },
670
+ caption: 'hello word'
671
+ })
675
672
  ```
676
673
 
677
674
  #### View Once Message
@@ -679,16 +676,13 @@ await sock.sendMessage(
679
676
  - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
680
677
 
681
678
  ```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
- )
679
+ await sock.sendMessage(id, {
680
+ image: {
681
+ url: './Media/ma_img.png'
682
+ },
683
+ viewOnce: true, //works with video, audio too
684
+ caption: 'hello word'
685
+ })
692
686
  ```
693
687
 
694
688
  ## Modify Messages
@@ -705,22 +699,25 @@ await sock.sendMessage(jid, { delete: msg.key })
705
699
  ### Editing Messages
706
700
 
707
701
  - You can pass all editable contents here
702
+
708
703
  ```ts
709
704
  await sock.sendMessage(jid, {
710
- text: 'updated text goes here',
711
- edit: response.key,
712
- });
705
+ text: 'updated text goes here',
706
+ edit: response.key
707
+ })
713
708
  ```
714
709
 
715
710
  ## Manipulating Media Messages
716
711
 
717
712
  ### Thumbnail in Media Messages
713
+
718
714
  - 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
715
  - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
720
716
 
721
717
  ### Downloading Media Messages
722
718
 
723
719
  If you want to save the media you received
720
+
724
721
  ```ts
725
722
  import { createWriteStream } from 'fs'
726
723
  import { downloadMediaMessage, getContentType } from '@whiskeysockets/baileys'
@@ -753,6 +750,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
753
750
  ### Re-upload Media Message to Whatsapp
754
751
 
755
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
+
756
754
  ```ts
757
755
  await sock.updateMediaMessage(msg)
758
756
  ```
@@ -768,9 +766,10 @@ await sock.rejectCall(callId, callFrom)
768
766
  ## Send States in Chat
769
767
 
770
768
  ### Reading Messages
769
+
771
770
  - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
772
771
  - You cannot mark an entire 'chat' read as it were with Baileys Web.
773
- This means you have to keep track of unread messages.
772
+ This means you have to keep track of unread messages.
774
773
 
775
774
  ```ts
776
775
  const key: WAMessageKey
@@ -779,11 +778,11 @@ await sock.readMessages([key])
779
778
  ```
780
779
 
781
780
  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```.
781
+ On a `WAMessage`, the `messageID` can be accessed using `messageID = message.key.id`.
783
782
 
784
783
  ### Update Presence
785
784
 
786
- - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
785
+ - `presence` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
787
786
  - The presence expires after about 10 seconds.
788
787
  - This lets the person/group with `jid` know whether you're online, offline, typing etc.
789
788
 
@@ -802,19 +801,21 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
802
801
  > 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.
803
802
 
804
803
  ### Archive a Chat
804
+
805
805
  ```ts
806
806
  const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
807
807
  await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
808
808
  ```
809
+
809
810
  ### Mute/Unmute a Chat
810
811
 
811
812
  - Supported times:
812
813
 
813
- | Time | Miliseconds |
814
- |-------|-----------------|
815
- | Remove | null |
816
- | 8h | 86.400.000 |
817
- | 7d | 604.800.000 |
814
+ | Time | Miliseconds |
815
+ | ------ | ----------- |
816
+ | Remove | null |
817
+ | 8h | 86.400.000 |
818
+ | 7d | 604.800.000 |
818
819
 
819
820
  ```ts
820
821
  // mute for 8 hours
@@ -822,7 +823,9 @@ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
822
823
  // unmute
823
824
  await sock.chatModify({ mute: null }, jid)
824
825
  ```
826
+
825
827
  ### Mark a Chat Read/Unread
828
+
826
829
  ```ts
827
830
  const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
828
831
  // mark it unread
@@ -830,60 +833,69 @@ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
830
833
  ```
831
834
 
832
835
  ### Delete a Message for Me
836
+
833
837
  ```ts
834
838
  await sock.chatModify(
835
- {
836
- clear: {
837
- messages: [
838
- {
839
- id: 'ATWYHDNNWU81732J',
840
- fromMe: true,
841
- timestamp: '1654823909'
842
- }
843
- ]
844
- }
845
- },
846
- jid
839
+ {
840
+ clear: {
841
+ messages: [
842
+ {
843
+ id: 'ATWYHDNNWU81732J',
844
+ fromMe: true,
845
+ timestamp: '1654823909'
846
+ }
847
+ ]
848
+ }
849
+ },
850
+ jid
847
851
  )
848
-
849
852
  ```
853
+
850
854
  ### Delete a Chat
855
+
851
856
  ```ts
852
857
  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
858
+ await sock.chatModify(
859
+ {
860
+ delete: true,
861
+ lastMessages: [
862
+ {
863
+ key: lastMsgInChat.key,
864
+ messageTimestamp: lastMsgInChat.messageTimestamp
865
+ }
866
+ ]
867
+ },
868
+ jid
863
869
  )
864
870
  ```
871
+
865
872
  ### Pin/Unpin a Chat
873
+
866
874
  ```ts
867
- await sock.chatModify({
868
- pin: true // or `false` to unpin
869
- },
870
- jid
875
+ await sock.chatModify(
876
+ {
877
+ pin: true // or `false` to unpin
878
+ },
879
+ jid
871
880
  )
872
881
  ```
882
+
873
883
  ### Star/Unstar a Message
884
+
874
885
  ```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
886
+ await sock.chatModify(
887
+ {
888
+ star: {
889
+ messages: [
890
+ {
891
+ id: 'messageID',
892
+ fromMe: true // or `false`
893
+ }
894
+ ],
895
+ star: true // - true: Star Message; false: Unstar Message
896
+ }
897
+ },
898
+ jid
887
899
  )
888
900
  ```
889
901
 
@@ -891,62 +903,65 @@ await sock.chatModify({
891
903
 
892
904
  - Ephemeral can be:
893
905
 
894
- | Time | Seconds |
895
- |-------|----------------|
896
- | Remove | 0 |
897
- | 24h | 86.400 |
898
- | 7d | 604.800 |
899
- | 90d | 7.776.000 |
906
+ | Time | Seconds |
907
+ | ------ | --------- |
908
+ | Remove | 0 |
909
+ | 24h | 86.400 |
910
+ | 7d | 604.800 |
911
+ | 90d | 7.776.000 |
900
912
 
901
913
  - You need to pass in **Seconds**, default is 7 days
902
914
 
903
915
  ```ts
904
916
  // turn on disappearing messages
905
917
  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 }
918
+ jid,
919
+ // this is 1 week in seconds -- how long you want messages to appear for
920
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
909
921
  )
910
922
 
911
923
  // will send as a disappearing message
912
924
  await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
913
925
 
914
926
  // turn off disappearing messages
915
- await sock.sendMessage(
916
- jid,
917
- { disappearingMessagesInChat: false }
918
- )
927
+ await sock.sendMessage(jid, { disappearingMessagesInChat: false })
919
928
  ```
920
929
 
921
930
  ## User Querys
922
931
 
923
932
  ### Check If ID Exists in Whatsapp
933
+
924
934
  ```ts
925
935
  const [result] = await sock.onWhatsApp(jid)
926
- if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
936
+ if (result.exists) console.log(`${jid} exists on WhatsApp, as jid: ${result.jid}`)
927
937
  ```
928
938
 
929
939
  ### Query Chat History (groups too)
930
940
 
931
941
  - You need to have oldest message in chat
942
+
932
943
  ```ts
933
944
  const msg = await getOldestMessageInChat(jid) // implement this on your end
934
945
  await sock.fetchMessageHistory(
935
- 50, //quantity (max: 50 per query)
936
- msg.key,
937
- msg.messageTimestamp
946
+ 50, //quantity (max: 50 per query)
947
+ msg.key,
948
+ msg.messageTimestamp
938
949
  )
939
950
  ```
951
+
940
952
  - Messages will be received in `messaging.history-set` event
941
953
 
942
954
  ### Fetch Status
955
+
943
956
  ```ts
944
957
  const status = await sock.fetchStatus(jid)
945
958
  console.log('status: ' + status)
946
959
  ```
947
960
 
948
961
  ### Fetch Profile Picture (groups too)
962
+
949
963
  - To get the display picture of some person/group
964
+
950
965
  ```ts
951
966
  // for low res picture
952
967
  const ppUrl = await sock.profilePictureUrl(jid)
@@ -957,12 +972,14 @@ const ppUrl = await sock.profilePictureUrl(jid, 'image')
957
972
  ```
958
973
 
959
974
  ### Fetch Bussines Profile (such as description or category)
975
+
960
976
  ```ts
961
977
  const profile = await sock.getBusinessProfile(jid)
962
978
  console.log('business description: ' + profile.description + ', category: ' + profile.category)
963
979
  ```
964
980
 
965
981
  ### Fetch Someone's Presence (if they're typing or online)
982
+
966
983
  ```ts
967
984
  // the presence update is fetched and called here
968
985
  sock.ev.on('presence.update', console.log)
@@ -974,14 +991,19 @@ await sock.presenceSubscribe(jid)
974
991
  ## Change Profile
975
992
 
976
993
  ### Change Profile Status
994
+
977
995
  ```ts
978
996
  await sock.updateProfileStatus('Hello World!')
979
997
  ```
998
+
980
999
  ### Change Profile Name
1000
+
981
1001
  ```ts
982
1002
  await sock.updateProfileName('My name')
983
1003
  ```
1004
+
984
1005
  ### Change Display Picture (groups too)
1006
+
985
1007
  - To change your display picture or a group's
986
1008
 
987
1009
  > [!NOTE]
@@ -990,7 +1012,9 @@ await sock.updateProfileName('My name')
990
1012
  ```ts
991
1013
  await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
992
1014
  ```
1015
+
993
1016
  ### Remove display picture (groups too)
1017
+
994
1018
  ```ts
995
1019
  await sock.removeProfilePicture(jid)
996
1020
  ```
@@ -1000,30 +1024,39 @@ await sock.removeProfilePicture(jid)
1000
1024
  - To change group properties you need to be admin
1001
1025
 
1002
1026
  ### Create a Group
1027
+
1003
1028
  ```ts
1004
1029
  // title & participants
1005
1030
  const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1006
1031
  console.log('created group with id: ' + group.gid)
1007
1032
  await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1008
1033
  ```
1034
+
1009
1035
  ### Add/Remove or Demote/Promote
1036
+
1010
1037
  ```ts
1011
1038
  // id & people to add to the group (will throw error if it fails)
1012
1039
  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'
1040
+ jid,
1041
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1042
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1016
1043
  )
1017
1044
  ```
1045
+
1018
1046
  ### Change Subject (name)
1047
+
1019
1048
  ```ts
1020
1049
  await sock.groupUpdateSubject(jid, 'New Subject!')
1021
1050
  ```
1051
+
1022
1052
  ### Change Description
1053
+
1023
1054
  ```ts
1024
1055
  await sock.groupUpdateDescription(jid, 'New Description!')
1025
1056
  ```
1057
+
1026
1058
  ### Change Settings
1059
+
1027
1060
  ```ts
1028
1061
  // only allow admins to send messages
1029
1062
  await sock.groupSettingUpdate(jid, 'announcement')
@@ -1034,142 +1067,184 @@ await sock.groupSettingUpdate(jid, 'unlocked')
1034
1067
  // only allow admins to modify the group's settings
1035
1068
  await sock.groupSettingUpdate(jid, 'locked')
1036
1069
  ```
1070
+
1037
1071
  ### Leave a Group
1072
+
1038
1073
  ```ts
1039
1074
  // will throw error if it fails
1040
1075
  await sock.groupLeave(jid)
1041
1076
  ```
1077
+
1042
1078
  ### Get Invite Code
1079
+
1043
1080
  - To create link with code use `'https://chat.whatsapp.com/' + code`
1081
+
1044
1082
  ```ts
1045
1083
  const code = await sock.groupInviteCode(jid)
1046
1084
  console.log('group code: ' + code)
1047
1085
  ```
1086
+
1048
1087
  ### Revoke Invite Code
1088
+
1049
1089
  ```ts
1050
1090
  const code = await sock.groupRevokeInvite(jid)
1051
1091
  console.log('New group code: ' + code)
1052
1092
  ```
1093
+
1053
1094
  ### Join Using Invitation Code
1095
+
1054
1096
  - Code can't have `https://chat.whatsapp.com/`, only code
1097
+
1055
1098
  ```ts
1056
1099
  const response = await sock.groupAcceptInvite(code)
1057
1100
  console.log('joined to: ' + response)
1058
1101
  ```
1102
+
1059
1103
  ### Get Group Info by Invite Code
1104
+
1060
1105
  ```ts
1061
1106
  const response = await sock.groupGetInviteInfo(code)
1062
1107
  console.log('group information: ' + response)
1063
1108
  ```
1109
+
1064
1110
  ### Query Metadata (participants, name, description...)
1111
+
1065
1112
  ```ts
1066
1113
  const metadata = await sock.groupMetadata(jid)
1067
1114
  console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1068
1115
  ```
1116
+
1069
1117
  ### Join using `groupInviteMessage`
1118
+
1070
1119
  ```ts
1071
1120
  const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1072
1121
  console.log('joined to: ' + response)
1073
1122
  ```
1123
+
1074
1124
  ### Get Request Join List
1125
+
1075
1126
  ```ts
1076
1127
  const response = await sock.groupRequestParticipantsList(jid)
1077
1128
  console.log(response)
1078
1129
  ```
1130
+
1079
1131
  ### Approve/Reject Request Join
1132
+
1080
1133
  ```ts
1081
1134
  const response = await sock.groupRequestParticipantsUpdate(
1082
- jid, // group id
1083
- ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1084
- 'approve' // or 'reject'
1135
+ jid, // group id
1136
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1137
+ 'approve' // or 'reject'
1085
1138
  )
1086
1139
  console.log(response)
1087
1140
  ```
1141
+
1088
1142
  ### Get All Participating Groups Metadata
1143
+
1089
1144
  ```ts
1090
1145
  const response = await sock.groupFetchAllParticipating()
1091
1146
  console.log(response)
1092
1147
  ```
1148
+
1093
1149
  ### Toggle Ephemeral
1094
1150
 
1095
1151
  - Ephemeral can be:
1096
1152
 
1097
- | Time | Seconds |
1098
- |-------|----------------|
1099
- | Remove | 0 |
1100
- | 24h | 86.400 |
1101
- | 7d | 604.800 |
1102
- | 90d | 7.776.000 |
1153
+ | Time | Seconds |
1154
+ | ------ | --------- |
1155
+ | Remove | 0 |
1156
+ | 24h | 86.400 |
1157
+ | 7d | 604.800 |
1158
+ | 90d | 7.776.000 |
1103
1159
 
1104
1160
  ```ts
1105
1161
  await sock.groupToggleEphemeral(jid, 86400)
1106
1162
  ```
1107
1163
 
1108
1164
  ### Change Add Mode
1165
+
1109
1166
  ```ts
1110
1167
  await sock.groupMemberAddMode(
1111
- jid,
1112
- 'all_member_add' // or 'admin_add'
1168
+ jid,
1169
+ 'all_member_add' // or 'admin_add'
1113
1170
  )
1114
1171
  ```
1115
1172
 
1116
1173
  ## Privacy
1117
1174
 
1118
1175
  ### Block/Unblock User
1176
+
1119
1177
  ```ts
1120
1178
  await sock.updateBlockStatus(jid, 'block') // Block user
1121
1179
  await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1122
1180
  ```
1181
+
1123
1182
  ### Get Privacy Settings
1183
+
1124
1184
  ```ts
1125
1185
  const privacySettings = await sock.fetchPrivacySettings(true)
1126
1186
  console.log('privacy settings: ' + privacySettings)
1127
1187
  ```
1188
+
1128
1189
  ### Get BlockList
1190
+
1129
1191
  ```ts
1130
1192
  const response = await sock.fetchBlocklist()
1131
1193
  console.log(response)
1132
1194
  ```
1195
+
1133
1196
  ### Update LastSeen Privacy
1197
+
1134
1198
  ```ts
1135
1199
  const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1136
1200
  await sock.updateLastSeenPrivacy(value)
1137
1201
  ```
1202
+
1138
1203
  ### Update Online Privacy
1204
+
1139
1205
  ```ts
1140
1206
  const value = 'all' // 'match_last_seen'
1141
1207
  await sock.updateOnlinePrivacy(value)
1142
1208
  ```
1209
+
1143
1210
  ### Update Profile Picture Privacy
1211
+
1144
1212
  ```ts
1145
1213
  const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1146
1214
  await sock.updateProfilePicturePrivacy(value)
1147
1215
  ```
1216
+
1148
1217
  ### Update Status Privacy
1218
+
1149
1219
  ```ts
1150
1220
  const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1151
1221
  await sock.updateStatusPrivacy(value)
1152
1222
  ```
1223
+
1153
1224
  ### Update Read Receipts Privacy
1225
+
1154
1226
  ```ts
1155
1227
  const value = 'all' // 'none'
1156
1228
  await sock.updateReadReceiptsPrivacy(value)
1157
1229
  ```
1230
+
1158
1231
  ### Update Groups Add Privacy
1232
+
1159
1233
  ```ts
1160
1234
  const value = 'all' // 'contacts' | 'contact_blacklist'
1161
1235
  await sock.updateGroupsAddPrivacy(value)
1162
1236
  ```
1237
+
1163
1238
  ### Update Default Disappearing Mode
1164
1239
 
1165
1240
  - Like [this](#disappearing-messages), ephemeral can be:
1166
1241
 
1167
- | Time | Seconds |
1168
- |-------|----------------|
1169
- | Remove | 0 |
1170
- | 24h | 86.400 |
1171
- | 7d | 604.800 |
1172
- | 90d | 7.776.000 |
1242
+ | Time | Seconds |
1243
+ | ------ | --------- |
1244
+ | Remove | 0 |
1245
+ | 24h | 86.400 |
1246
+ | 7d | 604.800 |
1247
+ | 90d | 7.776.000 |
1173
1248
 
1174
1249
  ```ts
1175
1250
  const ephemeral = 86400
@@ -1179,24 +1254,27 @@ await sock.updateDefaultDisappearingMode(ephemeral)
1179
1254
  ## Broadcast Lists & Stories
1180
1255
 
1181
1256
  ### Send Broadcast & Stories
1257
+
1182
1258
  - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1259
+
1183
1260
  ```ts
1184
1261
  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
- }
1262
+ jid,
1263
+ {
1264
+ image: {
1265
+ url: url
1266
+ },
1267
+ caption: caption
1268
+ },
1269
+ {
1270
+ backgroundColor: backgroundColor,
1271
+ font: font,
1272
+ statusJidList: statusJidList,
1273
+ broadcast: true
1274
+ }
1198
1275
  )
1199
1276
  ```
1277
+
1200
1278
  - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1201
1279
  - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1202
1280
  - `broadcast: true` enables broadcast mode
@@ -1205,22 +1283,28 @@ await sock.sendMessage(
1205
1283
  - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1206
1284
  - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1207
1285
  - Broadcast IDs are in the format `12345678@broadcast`
1286
+
1208
1287
  ### Query a Broadcast List's Recipients & Name
1288
+
1209
1289
  ```ts
1210
1290
  const bList = await sock.getBroadcastListInfo('1234@broadcast')
1211
- console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1291
+ console.log(`list name: ${bList.name}, recps: ${bList.recipients}`)
1212
1292
  ```
1213
1293
 
1214
1294
  ## Writing Custom Functionality
1295
+
1215
1296
  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
1297
 
1217
1298
  ### Enabling Debug Level in Baileys Logs
1299
+
1218
1300
  First, enable the logging of unhandled messages from WhatsApp by setting:
1301
+
1219
1302
  ```ts
1220
1303
  const sock = makeWASocket({
1221
- logger: P({ level: 'debug' }),
1304
+ logger: P({ level: 'debug' })
1222
1305
  })
1223
1306
  ```
1307
+
1224
1308
  This will enable you to see all sorts of messages WhatsApp sends in the console.
1225
1309
 
1226
1310
  ### How Whatsapp Communicate With Us
@@ -1229,37 +1313,38 @@ This will enable you to see all sorts of messages WhatsApp sends in the console.
1229
1313
  > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1230
1314
 
1231
1315
  - **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
- ```
1316
+ ```
1317
+ {
1318
+ "level": 10,
1319
+ "fromMe": false,
1320
+ "frame": {
1321
+ "tag": "ib",
1322
+ "attrs": {
1323
+ "from": "@s.whatsapp.net"
1324
+ },
1325
+ "content": [
1326
+ {
1327
+ "tag": "edge_routing",
1328
+ "attrs": {},
1329
+ "content": [
1330
+ {
1331
+ "tag": "routing_info",
1332
+ "attrs": {},
1333
+ "content": {
1334
+ "type": "Buffer",
1335
+ "data": [8,2,8,5]
1336
+ }
1337
+ }
1338
+ ]
1339
+ }
1340
+ ]
1341
+ },
1342
+ "msg":"communication"
1343
+ }
1344
+ ```
1261
1345
 
1262
1346
  The `'frame'` is what the message received is, it has three components:
1347
+
1263
1348
  - `tag` -- what this frame is about (eg. message will have 'message')
1264
1349
  - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1265
1350
  - `content` -- the actual data (eg. a message node will have the actual message content in it)
@@ -1272,16 +1357,17 @@ The `'frame'` is what the message received is, it has three components:
1272
1357
 
1273
1358
  ```ts
1274
1359
  // for any message with tag 'edge_routing'
1275
- sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1360
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => {})
1276
1361
 
1277
1362
  // for any message with tag 'edge_routing' and id attribute = abcd
1278
- sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1363
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => {})
1279
1364
 
1280
1365
  // 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) => { })
1366
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => {})
1282
1367
  ```
1283
1368
 
1284
1369
  # License
1370
+
1285
1371
  Copyright (c) 2025 Rajeh Taher/WhiskeySockets
1286
1372
 
1287
1373
  Licensed under the MIT License: