dct-dula-dev-baileys 1.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 (196) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +511 -0
  3. package/WAProto/index.js +169661 -0
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +3 -0
  6. package/lib/Defaults/constants.js +74 -0
  7. package/lib/Defaults/index.d.ts +53 -0
  8. package/lib/Defaults/index.js +147 -0
  9. package/lib/Defaults/media.js +48 -0
  10. package/lib/Defaults/phonenumber-mcc.json +223 -0
  11. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  12. package/lib/Signal/Group/ciphertext-message.js +15 -0
  13. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  14. package/lib/Signal/Group/group-session-builder.js +64 -0
  15. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  16. package/lib/Signal/Group/group_cipher.js +96 -0
  17. package/lib/Signal/Group/index.d.ts +11 -0
  18. package/lib/Signal/Group/index.js +57 -0
  19. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  20. package/lib/Signal/Group/keyhelper.js +55 -0
  21. package/lib/Signal/Group/queue-job.d.ts +1 -0
  22. package/lib/Signal/Group/queue-job.js +57 -0
  23. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  24. package/lib/Signal/Group/sender-chain-key.js +34 -0
  25. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  27. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  28. package/lib/Signal/Group/sender-key-message.js +69 -0
  29. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  30. package/lib/Signal/Group/sender-key-name.js +51 -0
  31. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  32. package/lib/Signal/Group/sender-key-record.js +53 -0
  33. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  34. package/lib/Signal/Group/sender-key-state.js +99 -0
  35. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  36. package/lib/Signal/Group/sender-message-key.js +29 -0
  37. package/lib/Signal/libsignal.d.ts +3 -0
  38. package/lib/Signal/libsignal.js +174 -0
  39. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  40. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  41. package/lib/Socket/Client/index.d.ts +3 -0
  42. package/lib/Socket/Client/index.js +19 -0
  43. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  44. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  45. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  46. package/lib/Socket/Client/web-socket-client.js +62 -0
  47. package/lib/Socket/business.d.ts +171 -0
  48. package/lib/Socket/business.js +260 -0
  49. package/lib/Socket/chats.d.ts +267 -0
  50. package/lib/Socket/chats.js +970 -0
  51. package/lib/Socket/groups.d.ts +115 -0
  52. package/lib/Socket/groups.js +317 -0
  53. package/lib/Socket/index.d.ts +173 -0
  54. package/lib/Socket/index.js +11 -0
  55. package/lib/Socket/luxu.d.ts +268 -0
  56. package/lib/Socket/luxu.js +591 -0
  57. package/lib/Socket/messages-recv.d.ts +161 -0
  58. package/lib/Socket/messages-recv.js +1110 -0
  59. package/lib/Socket/messages-send.d.ts +149 -0
  60. package/lib/Socket/messages-send.js +913 -0
  61. package/lib/Socket/newsletter.d.ts +134 -0
  62. package/lib/Socket/newsletter.js +356 -0
  63. package/lib/Socket/registration.d.ts +267 -0
  64. package/lib/Socket/registration.js +166 -0
  65. package/lib/Socket/socket.d.ts +43 -0
  66. package/lib/Socket/socket.js +665 -0
  67. package/lib/Socket/usync.d.ts +36 -0
  68. package/lib/Socket/usync.js +70 -0
  69. package/lib/Store/index.d.ts +3 -0
  70. package/lib/Store/index.js +10 -0
  71. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  72. package/lib/Store/make-cache-manager-store.js +83 -0
  73. package/lib/Store/make-in-memory-store.d.ts +118 -0
  74. package/lib/Store/make-in-memory-store.js +427 -0
  75. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  76. package/lib/Store/make-ordered-dictionary.js +81 -0
  77. package/lib/Store/object-repository.d.ts +10 -0
  78. package/lib/Store/object-repository.js +27 -0
  79. package/lib/Types/Auth.d.ts +110 -0
  80. package/lib/Types/Auth.js +2 -0
  81. package/lib/Types/Call.d.ts +13 -0
  82. package/lib/Types/Call.js +2 -0
  83. package/lib/Types/Chat.d.ts +102 -0
  84. package/lib/Types/Chat.js +4 -0
  85. package/lib/Types/Contact.d.ts +19 -0
  86. package/lib/Types/Contact.js +2 -0
  87. package/lib/Types/Events.d.ts +157 -0
  88. package/lib/Types/Events.js +2 -0
  89. package/lib/Types/GroupMetadata.d.ts +55 -0
  90. package/lib/Types/GroupMetadata.js +2 -0
  91. package/lib/Types/Label.d.ts +35 -0
  92. package/lib/Types/Label.js +27 -0
  93. package/lib/Types/LabelAssociation.d.ts +29 -0
  94. package/lib/Types/LabelAssociation.js +9 -0
  95. package/lib/Types/Message.d.ts +273 -0
  96. package/lib/Types/Message.js +9 -0
  97. package/lib/Types/Newsletter.d.ts +103 -0
  98. package/lib/Types/Newsletter.js +38 -0
  99. package/lib/Types/Product.d.ts +78 -0
  100. package/lib/Types/Product.js +2 -0
  101. package/lib/Types/Signal.d.ts +57 -0
  102. package/lib/Types/Signal.js +2 -0
  103. package/lib/Types/Socket.d.ts +111 -0
  104. package/lib/Types/Socket.js +2 -0
  105. package/lib/Types/State.d.ts +27 -0
  106. package/lib/Types/State.js +2 -0
  107. package/lib/Types/USync.d.ts +25 -0
  108. package/lib/Types/USync.js +2 -0
  109. package/lib/Types/index.d.ts +57 -0
  110. package/lib/Types/index.js +42 -0
  111. package/lib/Utils/auth-utils.d.ts +18 -0
  112. package/lib/Utils/auth-utils.js +206 -0
  113. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  114. package/lib/Utils/baileys-event-stream.js +63 -0
  115. package/lib/Utils/business.d.ts +22 -0
  116. package/lib/Utils/business.js +234 -0
  117. package/lib/Utils/chat-utils.d.ts +71 -0
  118. package/lib/Utils/chat-utils.js +729 -0
  119. package/lib/Utils/crypto.d.ts +41 -0
  120. package/lib/Utils/crypto.js +151 -0
  121. package/lib/Utils/decode-wa-message.d.ts +19 -0
  122. package/lib/Utils/decode-wa-message.js +198 -0
  123. package/lib/Utils/event-buffer.d.ts +35 -0
  124. package/lib/Utils/event-buffer.js +514 -0
  125. package/lib/Utils/generics.d.ts +92 -0
  126. package/lib/Utils/generics.js +423 -0
  127. package/lib/Utils/history.d.ts +15 -0
  128. package/lib/Utils/history.js +96 -0
  129. package/lib/Utils/index.d.ts +17 -0
  130. package/lib/Utils/index.js +33 -0
  131. package/lib/Utils/link-preview.d.ts +21 -0
  132. package/lib/Utils/link-preview.js +93 -0
  133. package/lib/Utils/logger.d.ts +4 -0
  134. package/lib/Utils/logger.js +7 -0
  135. package/lib/Utils/lt-hash.d.ts +12 -0
  136. package/lib/Utils/lt-hash.js +51 -0
  137. package/lib/Utils/make-mutex.d.ts +7 -0
  138. package/lib/Utils/make-mutex.js +43 -0
  139. package/lib/Utils/messages-media.d.ts +116 -0
  140. package/lib/Utils/messages-media.js +1109 -0
  141. package/lib/Utils/messages.d.ts +77 -0
  142. package/lib/Utils/messages.js +1858 -0
  143. package/lib/Utils/noise-handler.d.ts +21 -0
  144. package/lib/Utils/noise-handler.js +155 -0
  145. package/lib/Utils/process-message.d.ts +41 -0
  146. package/lib/Utils/process-message.js +321 -0
  147. package/lib/Utils/signal.d.ts +32 -0
  148. package/lib/Utils/signal.js +153 -0
  149. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  150. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  151. package/lib/Utils/validate-connection.d.ts +11 -0
  152. package/lib/Utils/validate-connection.js +229 -0
  153. package/lib/WABinary/constants.d.ts +30 -0
  154. package/lib/WABinary/constants.js +40 -0
  155. package/lib/WABinary/decode.d.ts +7 -0
  156. package/lib/WABinary/decode.js +252 -0
  157. package/lib/WABinary/encode.d.ts +3 -0
  158. package/lib/WABinary/encode.js +265 -0
  159. package/lib/WABinary/generic-utils.d.ts +17 -0
  160. package/lib/WABinary/generic-utils.js +198 -0
  161. package/lib/WABinary/index.d.ts +5 -0
  162. package/lib/WABinary/index.js +21 -0
  163. package/lib/WABinary/jid-utils.d.ts +31 -0
  164. package/lib/WABinary/jid-utils.js +65 -0
  165. package/lib/WABinary/types.d.ts +18 -0
  166. package/lib/WABinary/types.js +2 -0
  167. package/lib/WAM/BinaryInfo.d.ts +17 -0
  168. package/lib/WAM/BinaryInfo.js +13 -0
  169. package/lib/WAM/constants.d.ts +38 -0
  170. package/lib/WAM/constants.js +15350 -0
  171. package/lib/WAM/encode.d.ts +3 -0
  172. package/lib/WAM/encode.js +155 -0
  173. package/lib/WAM/index.d.ts +3 -0
  174. package/lib/WAM/index.js +19 -0
  175. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  176. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  177. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  178. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  179. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  180. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  181. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  182. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  183. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  184. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  185. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  186. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  187. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  188. package/lib/WAUSync/Protocols/index.js +20 -0
  189. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  190. package/lib/WAUSync/USyncQuery.js +89 -0
  191. package/lib/WAUSync/USyncUser.d.ts +12 -0
  192. package/lib/WAUSync/USyncUser.js +26 -0
  193. package/lib/WAUSync/index.js +19 -0
  194. package/lib/index.d.ts +12 -0
  195. package/lib/index.js +71 -0
  196. package/package.json +106 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dew-Coders
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,511 @@
1
+ # 🚀 DCT Dula Baileys - Advanced WhatsApp API
2
+
3
+ <div align="center">
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js](https://img.shields.io/badge/Node.js->=20.0.0-green.svg)](https://nodejs.org/)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](#)
8
+ [![WhatsApp](https://img.shields.io/badge/WhatsApp-API-25D366.svg)](#)
9
+
10
+ **A powerful, feature-rich WhatsApp Web API for Node.js with Desktop App Support**
11
+
12
+ [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [Desktop App](#-desktop-app) • [API Docs](#-api-documentation) • [Support](#-support)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## 📋 Table of Contents
19
+
20
+ - [Features](#-features)
21
+ - [Requirements](#-requirements)
22
+ - [Installation](#-installation)
23
+ - [Quick Start](#-quick-start)
24
+ - [Desktop Application](#-desktop-app)
25
+ - [API Documentation](#-api-documentation)
26
+ - [Newsletter Features](#-newsletter-features)
27
+ - [Button Messages](#-button-messages)
28
+ - [Examples](#-examples)
29
+ - [Troubleshooting](#-troubleshooting)
30
+ - [Contributing](#-contributing)
31
+ - [License](#-license)
32
+ - [Support](#-support)
33
+
34
+ ---
35
+
36
+ ## ✨ Features
37
+
38
+ ### Core Features
39
+ - ✅ **WhatsApp Web Integration** - Connect to WhatsApp Web seamlessly
40
+ - ✅ **Web & PC Support** - Works on browsers and native desktop app
41
+ - ✅ **Desktop Application** - Native Electron-based desktop client
42
+ - ✅ **Multiple Message Types** - Text, Media, Buttons, Lists, Templates
43
+ - ✅ **Group Management** - Create, modify, and manage groups
44
+ - ✅ **Contact Management** - Full contact access and management
45
+ - ✅ **Auto-Reply System** - Automated message responses
46
+ - ✅ **Newsletter Support** - Auto-follow and auto-react features
47
+ - ✅ **QR Code Authentication** - Secure login via QR
48
+ - ✅ **Signal Protocol** - End-to-end encryption support
49
+
50
+ ### Newsletter Features
51
+ - 🔔 Auto-follow newsletters
52
+ - 👍 Auto-react with emojis
53
+ - 📊 View statistics
54
+ - 📈 Track reactions and views
55
+ - 🎯 Manage metadata
56
+
57
+ ### Interactive Messages
58
+ - 🔘 Interactive buttons
59
+ - 📋 List messages
60
+ - 🎨 Rich templates
61
+ - 📱 Media sharing
62
+
63
+ ---
64
+
65
+ ## 📦 Requirements
66
+
67
+ - **Node.js**: >= 20.0.0
68
+ - **npm** or **yarn**
69
+ - **WhatsApp Account**: Active account
70
+ - **Browser**: Modern browser (for Web version)
71
+ - Optional: **Electron** (for Desktop App)
72
+
73
+ ## 📥 Installation
74
+
75
+ ### Via NPM
76
+ ```bash
77
+ npm install @dct-dula/baileys
78
+ ```
79
+
80
+ ### Via Yarn
81
+ ```bash
82
+ yarn add @dct-dula/baileys
83
+ ```
84
+
85
+ ### Clone Repository
86
+ ```bash
87
+ git clone <repository-url>
88
+ cd dtz-baileys
89
+ npm install
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 🚀 Quick Start
95
+
96
+ ### Basic Bot
97
+
98
+ ```javascript
99
+ const { makeWASocket, useMultiFileAuthState, DisconnectReason } = require('@dct-dula/baileys');
100
+ const P = require('pino');
101
+
102
+ async function startBot() {
103
+ // Auth
104
+ const { state, saveCreds } = await useMultiFileAuthState('baileys-creds');
105
+
106
+ // Socket
107
+ const sock = makeWASocket({
108
+ auth: state,
109
+ printQRInTerminal: true,
110
+ logger: P({ level: 'debug' })
111
+ });
112
+
113
+ // Connection update
114
+ sock.ev.on('connection.update', (update) => {
115
+ const { connection, lastDisconnect } = update;
116
+
117
+ if (connection === 'open') {
118
+ console.log('✅ Connected!');
119
+ } else if (connection === 'close') {
120
+ const reason = lastDisconnect?.error?.output?.statusCode;
121
+ if (reason === DisconnectReason.loggedOut) {
122
+ console.log('❌ Logged out');
123
+ }
124
+ }
125
+ });
126
+
127
+ // Save credentials
128
+ sock.ev.on('creds.update', saveCreds);
129
+
130
+ // Listen for messages
131
+ sock.ev.on('messages.upsert', async (m) => {
132
+ const message = m.messages[0];
133
+
134
+ if (!message.key.fromMe && message.message) {
135
+ console.log(`📨 ${message.key.remoteJid}: ${message.message.conversation}`);
136
+
137
+ // Reply
138
+ await sock.sendMessage(message.key.remoteJid, {
139
+ text: 'Thanks for your message!'
140
+ });
141
+ }
142
+ });
143
+ }
144
+
145
+ startBot().catch(console.error);
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 🖥️ Desktop App
151
+
152
+ Complete native WhatsApp PC application built with Electron.
153
+
154
+ ### Setup
155
+
156
+ ```bash
157
+ cd desktop
158
+ npm install
159
+ npm start
160
+ ```
161
+
162
+ ### Features
163
+
164
+ - 📱 Native desktop interface
165
+ - 💬 Chat management
166
+ - 👥 Contacts list
167
+ - ✉️ Send messages & media
168
+ - 🔘 Interactive buttons
169
+ - 📊 Real-time status
170
+ - 🔐 Secure storage
171
+
172
+ ### Structure
173
+
174
+ ```
175
+ desktop/
176
+ ├── main.js # Electron process
177
+ ├── preload.js # IPC bridge
178
+ ├── renderer.js # Frontend logic
179
+ ├── bot-instance.js # Baileys integration
180
+ ├── index.html # UI
181
+ ├── styles.css # Design
182
+ └── package.json
183
+ ```
184
+
185
+ ---
186
+
187
+ ## 📚 API Documentation
188
+
189
+ ### Authentication
190
+
191
+ #### Create Socket
192
+ ```javascript
193
+ const sock = makeWASocket({
194
+ auth: state,
195
+ printQRInTerminal: true,
196
+ logger: P({ level: 'info' })
197
+ });
198
+ ```
199
+
200
+ #### Initialize Auth State
201
+ ```javascript
202
+ const { state, saveCreds } = await useMultiFileAuthState('creds');
203
+ sock.ev.on('creds.update', saveCreds);
204
+ ```
205
+
206
+ ### Messaging
207
+
208
+ #### Send Text
209
+ ```javascript
210
+ await sock.sendMessage(jid, {
211
+ text: 'Hello World!'
212
+ });
213
+ ```
214
+
215
+ #### Send Media
216
+ ```javascript
217
+ const media = require('fs').readFileSync('image.jpg');
218
+ await sock.sendMessage(jid, {
219
+ image: media,
220
+ caption: 'Image caption'
221
+ });
222
+ ```
223
+
224
+ #### Send Buttons
225
+ ```javascript
226
+ await sock.sendMessage(jid, {
227
+ text: 'Choose:',
228
+ buttons: [
229
+ { buttonId: '1', buttonText: { displayText: 'Option 1' }, type: 1 },
230
+ { buttonId: '2', buttonText: { displayText: 'Option 2' }, type: 1 }
231
+ ]
232
+ });
233
+ ```
234
+
235
+ #### Send List
236
+ ```javascript
237
+ await sock.sendMessage(jid, {
238
+ text: 'Select:',
239
+ sections: [{
240
+ title: 'Options',
241
+ rows: [
242
+ { rowId: '1', title: 'Item 1' },
243
+ { rowId: '2', title: 'Item 2' }
244
+ ]
245
+ }]
246
+ });
247
+ ```
248
+
249
+ ### Events
250
+
251
+ #### Message Received
252
+ ```javascript
253
+ sock.ev.on('messages.upsert', (m) => {
254
+ console.log('New message:', m.messages[0]);
255
+ });
256
+ ```
257
+
258
+ #### Message Updated
259
+ ```javascript
260
+ sock.ev.on('messages.update', (m) => {
261
+ console.log('Message updated:', m);
262
+ });
263
+ ```
264
+
265
+ #### Connection Status
266
+ ```javascript
267
+ sock.ev.on('connection.update', (update) => {
268
+ if (update.qr) console.log('Scan QR');
269
+ if (update.connection === 'open') console.log('Connected');
270
+ });
271
+ ```
272
+
273
+ ### Groups
274
+
275
+ #### Create Group
276
+ ```javascript
277
+ const groupId = await sock.groupCreate('Group Name', [
278
+ '1234567890@s.whatsapp.net'
279
+ ]);
280
+ ```
281
+
282
+ #### Add Members
283
+ ```javascript
284
+ await sock.groupParticipantsUpdate(
285
+ groupId,
286
+ ['1234567890@s.whatsapp.net'],
287
+ 'add'
288
+ );
289
+ ```
290
+
291
+ #### Remove Members
292
+ ```javascript
293
+ await sock.groupParticipantsUpdate(
294
+ groupId,
295
+ ['1234567890@s.whatsapp.net'],
296
+ 'remove'
297
+ );
298
+ ```
299
+
300
+ #### Update Subject
301
+ ```javascript
302
+ await sock.groupUpdateSubject(groupId, 'New Name');
303
+ ```
304
+
305
+ ---
306
+
307
+ ## 📰 Newsletter Features
308
+
309
+ ### Follow Newsletter
310
+ ```javascript
311
+ await sock.newsletterFollow('id@newsletter');
312
+ ```
313
+
314
+ ### React to Message
315
+ ```javascript
316
+ await sock.newsletterReactMessage(
317
+ 'id@newsletter',
318
+ 'serverId',
319
+ '👍'
320
+ );
321
+ ```
322
+
323
+ ### Get Metadata
324
+ ```javascript
325
+ const data = await sock.newsletterMetadata(
326
+ 'type', 'key', 'GUEST'
327
+ );
328
+ ```
329
+
330
+ ### Listen to Events
331
+ ```javascript
332
+ sock.ev.on('newsletter.reaction', ({ id, reaction }) => {
333
+ console.log('Reaction:', reaction);
334
+ });
335
+
336
+ sock.ev.on('newsletter.view', ({ id, count }) => {
337
+ console.log('Views:', count);
338
+ });
339
+ ```
340
+
341
+ ---
342
+
343
+ ## 🔘 Button Messages
344
+
345
+ ### Text Buttons
346
+ ```javascript
347
+ const buttons = [
348
+ { buttonId: '1', buttonText: { displayText: 'Yes' }, type: 1 },
349
+ { buttonId: '2', buttonText: { displayText: 'No' }, type: 1 }
350
+ ];
351
+
352
+ await sock.sendMessage(jid, {
353
+ text: 'Your question?',
354
+ buttons,
355
+ footer: 'Choose one'
356
+ });
357
+ ```
358
+
359
+ ### Image Buttons
360
+ ```javascript
361
+ const buttons = [
362
+ { buttonId: '1', buttonText: { displayText: 'View' }, type: 1 }
363
+ ];
364
+
365
+ await sock.sendMessage(jid, {
366
+ image: { url: 'https://example.com/image.jpg' },
367
+ caption: 'Beautiful image',
368
+ buttons
369
+ });
370
+ ```
371
+
372
+ ### Video Buttons
373
+ ```javascript
374
+ const buttons = [
375
+ { buttonId: '1', buttonText: { displayText: 'Play' }, type: 1 }
376
+ ];
377
+
378
+ await sock.sendMessage(jid, {
379
+ video: { url: 'https://example.com/video.mp4' },
380
+ caption: 'Watch this',
381
+ buttons
382
+ });
383
+ ```
384
+
385
+ ---
386
+
387
+ ## 💡 Examples
388
+
389
+ ### Auto-Reply Bot
390
+ ```javascript
391
+ sock.ev.on('messages.upsert', async (m) => {
392
+ const message = m.messages[0];
393
+
394
+ if (!message.key.fromMe && message.message) {
395
+ await sock.sendMessage(message.key.remoteJid, {
396
+ text: '🤖 Thanks! We will reply soon.'
397
+ });
398
+ }
399
+ });
400
+ ```
401
+
402
+ ### Newsletter Auto-Follow
403
+ ```javascript
404
+ setTimeout(async () => {
405
+ try {
406
+ await sock.newsletterFollow('120363408629601473@newsletter');
407
+ console.log('✅ Followed!');
408
+ } catch (error) {
409
+ console.error('Error:', error);
410
+ }
411
+ }, 5000);
412
+ ```
413
+
414
+ ### Chat Statistics
415
+ ```javascript
416
+ async function getStats() {
417
+ const chats = await sock.fetchAllChats();
418
+ console.log(`
419
+ 📊 Stats
420
+ Total: ${chats.length}
421
+ Groups: ${chats.filter(c => c.isGroup).length}
422
+ Contacts: ${chats.filter(c => !c.isGroup).length}
423
+ `);
424
+ }
425
+ ```
426
+
427
+ ---
428
+
429
+ ## 🛠️ Troubleshooting
430
+
431
+ ### QR Code Issues
432
+ - Ensure terminal supports Unicode
433
+ - Use `printQRInTerminal: true`
434
+ - Try desktop app for visual QR
435
+
436
+ ### Connection Problems
437
+ - Check internet
438
+ - Clear credentials folder
439
+ - Update Node.js
440
+ - Restart WhatsApp
441
+
442
+ ### Send Failures
443
+ - Verify JID format
444
+ - Check permissions
445
+ - Ensure phone is online
446
+
447
+ ### Desktop App Issues
448
+ ```bash
449
+ rm -rf node_modules package-lock.json
450
+ npm install
451
+ npm start
452
+ ```
453
+
454
+ ---
455
+
456
+ ## 🤝 Contributing
457
+
458
+ 1. Fork repository
459
+ 2. Create feature branch
460
+ 3. Commit changes
461
+ 4. Push branch
462
+ 5. Open Pull Request
463
+
464
+ ### Development
465
+ ```bash
466
+ npm install
467
+ npm run build:tsc
468
+ npm test
469
+ ```
470
+
471
+ ---
472
+
473
+ ## 📄 License
474
+
475
+ MIT License - See [LICENSE](LICENSE) for details
476
+
477
+ ---
478
+
479
+ ## ⚠️ Disclaimer
480
+
481
+ - Not affiliated with WhatsApp Inc.
482
+ - Use responsibly and follow WhatsApp's ToS
483
+ - No spam or illegal activities
484
+ - Use at your own risk
485
+
486
+ ---
487
+
488
+ ## 🤖 Support
489
+
490
+ - 📖 **Documentation**: Read this README
491
+ - 🐛 **Issues**: Report on GitHub
492
+ - 💬 **Community**: Join discussions
493
+ - 📧 **Contact**: See repository
494
+ - 📱 **WhatsApp**: Join our channel
495
+
496
+ ### Community
497
+
498
+ - ⭐ Star if useful
499
+ - 🔗 Share with others
500
+ - 👥 Contribute
501
+ - 💡 Suggest features
502
+
503
+ ---
504
+
505
+ <div align="center">
506
+
507
+ **Made with ❤️ by DCT Dula Dev**
508
+
509
+ [GitHub](https://github.com) • [WhatsApp Channel](https://whatsapp.com/channel/0029VbCbYpSEquiIsz0brA3D) • [Twitter]()
510
+
511
+ </div>