@skycodee/baileys 8.0.9 → 8.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,290 @@
1
+ <div align="center">
2
+
3
+ <img src="https://camo.githubusercontent.com/c1f3b7dcf8145e1a0d91e90aae2b7080e761e88b7d770e0e8429c369d7311425/68747470733a2f2f66696c65732e636174626f782e6d6f652f6335733967302e6a7067" alt="WhatsApp Baileys" width="100%" />
4
+
5
+ <br/>
6
+ <br/>
7
+
8
+ # @skycodee/baileys
9
+
10
+ <p>
11
+ <img src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" />
12
+ <img src="https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" />
13
+ <img src="https://img.shields.io/badge/WebSocket-010101?style=for-the-badge&logo=socketdotio&logoColor=white" />
14
+ <img src="https://img.shields.io/badge/Open%20Source-FF4500?style=for-the-badge&logo=github&logoColor=white" />
15
+ <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" />
16
+ </p>
17
+
18
+ **Open-source WhatsApp automation library 2014 no browser required.**
19
+ Built on WebSocket for speed, stability, and full multi-device support.
20
+
21
+ <br/>
22
+
23
+ [Installation](#getting-started) [Documentation](#sendmessage-documentation) [Features](#main-features) [Telegram](https://t.me/Xskycode)
24
+
25
+ </div>
26
+
27
+ ---
28
+
29
+ ## What is @skycodee/baileys?
30
+
31
+ **@skycodee/baileys** is a powerful, open-source library for developers who need reliable WhatsApp automation without the overhead of a browser. Powered by **WebSocket technology**, it supports message management, group administration, interactive messages, and action buttons all in a lightweight and modular package.
32
+
33
+ Actively maintained with continuous improvements to **pairing stability**, **session management**, and **WhatsApp multi-device compatibility**.
34
+
35
+ Perfect for:
36
+ - Business bots & chat automation
37
+ - Customer service systems
38
+ - Broadcast & notification tools
39
+ - E-commerce integrations
40
+
41
+ ---
42
+
43
+ ## Main Features
44
+
45
+ | Feature | Description |
46
+ |---|---|
47
+ | **Custom Pairing** | Stable pairing with your own codes no disconnection issues |
48
+ | **Interactive Messages** | Buttons, menus, native flows, and more |
49
+ | **Session Management** | Automatic, efficient, and long-term stable |
50
+ | **Multi-Device Support** | Fully compatible with WhatsApp's latest multi-device API |
51
+ | **Lightweight & Modular** | Easy to integrate into any Node.js project |
52
+ | **Rich Documentation** | Comprehensive guides and example code included |
53
+ | **Secure Auth** | Improved authentication flow with fixed prior vulnerabilities |
54
+
55
+ ---
56
+
57
+ ## Getting Started
58
+
59
+ Install via npm or yarn:
60
+
61
+ ```bash
62
+ npm install @whiskeysockets/baileys
63
+ # or
64
+ yarn add @whiskeysockets/baileys
65
+ ```
66
+
67
+ Then import and initialize:
68
+
69
+ ```javascript
70
+ const { makeWASocket, useMultiFileAuthState } = require("@whiskeysockets/baileys");
71
+
72
+ const { state, saveCreds } = await useMultiFileAuthState("auth_info");
73
+ const sock = makeWASocket({ auth: state });
74
+
75
+ sock.ev.on("creds.update", saveCreds);
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Additional Functions
81
+
82
+ ### Get Channel ID
83
+ ```javascript
84
+ await sock.newsletterId(url);
85
+ ```
86
+
87
+ ### Check Banned Number
88
+ ```javascript
89
+ await sock.checkWhatsApp(target);
90
+ ```
91
+
92
+ ---
93
+
94
+ ## SendMessage Documentation
95
+
96
+ <details>
97
+ <summary><b>Group Status Message (V2)</b></summary>
98
+ <br/>
99
+
100
+ ```javascript
101
+ await sock.sendMessage(target, {
102
+ groupStatusMessage: {
103
+ text: "Hello World"
104
+ }
105
+ });
106
+ ```
107
+ </details>
108
+
109
+ <details>
110
+ <summary><b>Album Message (Multiple Images)</b></summary>
111
+ <br/>
112
+
113
+ ```javascript
114
+ await sock.sendMessage(target, {
115
+ albumMessage: [
116
+ { image: cihuy, caption: "First photo" },
117
+ { image: { url: "IMAGE_URL" }, caption: "Second photo" }
118
+ ]
119
+ }, { quoted: m });
120
+ ```
121
+ </details>
122
+
123
+ <details>
124
+ <summary><b>Event Message</b></summary>
125
+ <br/>
126
+
127
+ ```javascript
128
+ await sock.sendMessage(target, {
129
+ eventMessage: {
130
+ isCanceled: false,
131
+ name: "Event Name",
132
+ description: "Event description here",
133
+ location: {
134
+ degreesLatitude: 0,
135
+ degreesLongitude: 0,
136
+ name: "Location Name"
137
+ },
138
+ joinLink: "https://call.whatsapp.com/video/example",
139
+ startTime: "1763019000",
140
+ endTime: "1763026200",
141
+ extraGuestsAllowed: false
142
+ }
143
+ }, { quoted: m });
144
+ ```
145
+ </details>
146
+
147
+ <details>
148
+ <summary><b>Poll Result Message</b></summary>
149
+ <br/>
150
+
151
+ ```javascript
152
+ await sock.sendMessage(target, {
153
+ pollResultMessage: {
154
+ name: "Poll Title",
155
+ pollVotes: [
156
+ { optionName: "Option A", optionVoteCount: "112233" },
157
+ { optionName: "Option B", optionVoteCount: "1" }
158
+ ]
159
+ }
160
+ }, { quoted: m });
161
+ ```
162
+ </details>
163
+
164
+ <details>
165
+ <summary><b>Simple Interactive Message</b></summary>
166
+ <br/>
167
+
168
+ ```javascript
169
+ await sock.sendMessage(target, {
170
+ interactiveMessage: {
171
+ header: "Hello World",
172
+ title: "Hello World",
173
+ footer: "telegram: @Xskycode",
174
+ buttons: [
175
+ {
176
+ name: "cta_copy",
177
+ buttonParamsJson: JSON.stringify({
178
+ display_text: "Copy Code",
179
+ id: "123456789",
180
+ copy_code: "ABC123XYZ"
181
+ })
182
+ }
183
+ ]
184
+ }
185
+ }, { quoted: m });
186
+ ```
187
+ </details>
188
+
189
+ <details>
190
+ <summary><b>Interactive Message with Native Flow</b></summary>
191
+ <br/>
192
+
193
+ ```javascript
194
+ await sock.sendMessage(target, {
195
+ interactiveMessage: {
196
+ header: "Hello World",
197
+ title: "Hello World",
198
+ footer: "telegram: @Xskycode",
199
+ image: { url: "https://example.com/image.jpg" },
200
+ nativeFlowMessage: {
201
+ messageParamsJson: JSON.stringify({
202
+ limited_time_offer: {
203
+ text: "Limited offer text",
204
+ url: "https://t.me/Xskycode",
205
+ copy_code: "PROMO2024",
206
+ expiration_time: Date.now() * 999
207
+ },
208
+ bottom_sheet: {
209
+ in_thread_buttons_limit: 2,
210
+ divider_indices: [1, 2, 3, 4, 5, 999],
211
+ list_title: "List Title",
212
+ button_title: "Button Title"
213
+ },
214
+ tap_target_configuration: {
215
+ title: "Title",
216
+ description: "Description text",
217
+ canonical_url: "https://t.me/Xskycode",
218
+ domain: "shop.example.com",
219
+ button_index: 0
220
+ }
221
+ }),
222
+ buttons: [
223
+ {
224
+ name: "single_select",
225
+ buttonParamsJson: JSON.stringify({ has_multiple_buttons: true })
226
+ },
227
+ {
228
+ name: "call_permission_request",
229
+ buttonParamsJson: JSON.stringify({ has_multiple_buttons: true })
230
+ },
231
+ {
232
+ name: "single_select",
233
+ buttonParamsJson: JSON.stringify({
234
+ title: "Select an Option",
235
+ sections: [
236
+ {
237
+ title: "Section Title",
238
+ highlight_label: "Label",
239
+ rows: [
240
+ {
241
+ title: "Row Title",
242
+ description: "Row description",
243
+ id: "row_1"
244
+ }
245
+ ]
246
+ }
247
+ ],
248
+ has_multiple_buttons: true
249
+ })
250
+ },
251
+ {
252
+ name: "cta_copy",
253
+ buttonParamsJson: JSON.stringify({
254
+ display_text: "Copy Code",
255
+ id: "123456789",
256
+ copy_code: "ABC123XYZ"
257
+ })
258
+ }
259
+ ]
260
+ }
261
+ }
262
+ }, { quoted: m });
263
+ ```
264
+ </details>
265
+
266
+ <details>
267
+ <summary><b>Interactive Message with Thumbnail</b></summary>
268
+ <br/>
269
+
270
+ ```javascript
271
+ await sock.sendMessage(target, {
272
+ interactiveMessage: {
273
+ header: "Hello World",
274
+ title: "Hello World",
275
+ footer: "telegram: @Xskycode",
276
+ image: { url: "https://example.com/image.jpg" },
277
+ buttons: [
278
+ {
279
+ name: "cta_copy",
280
+ buttonParamsJson: JSON.stringify({
281
+ display_text: "Copy Code",
282
+ id: "123456789",
283
+ copy_code: "ABC123XYZ"
284
+ })
285
+ }
286
+ ]
287
+ }
288
+ }, { quoted: m });
289
+ ```
290
+ </details>
@@ -245,25 +245,64 @@ export const makeChatsSocket = (config) => {
245
245
  const listNode = getBinaryNodeChild(result, "list");
246
246
  return getBinaryNodeChildren(listNode, "item").map(n => n.attrs.jid);
247
247
  };
248
- const updateBlockStatus = async (jid, action) => {
249
- await query({
250
- tag: "iq",
251
- attrs: {
252
- xmlns: "blocklist",
253
- to: S_WHATSAPP_NET,
254
- type: "set"
255
- },
256
- content: [
257
- {
258
- tag: "item",
259
- attrs: {
260
- action,
261
- jid
262
- }
248
+ const updateBlockStatus = async (jid, action) => {
249
+ let lid;
250
+ let pn_jid;
251
+ let isLidUser = (jid) => /@lid/.test(jid)
252
+ let isPnUser = (jid) => /@s.whatsapp.net/.test(jid)
253
+
254
+ if (isLidUser(jid)) {
255
+ lid = jid;
256
+
257
+ if (action === 'block') {
258
+ const pn = await signalRepository.lidMapping.getPNForLID(jid);
259
+ if (!pn) {
260
+ throw new Boom(`Unable to resolve PN JID for LID: ${jid}`);
261
+ }
262
+
263
+ pn_jid = jidNormalizedUser(pn);
263
264
  }
264
- ]
265
+
266
+ } else if (isPnUser(jid)) {
267
+ const mapped = await signalRepository.lidMapping.getLIDForPN(jid);
268
+ if (!mapped) {
269
+ throw new Boom(`Unable to resolve LID for PN JID: ${jid}`);
270
+ }
271
+
272
+ lid = mapped;
273
+
274
+ if (action === 'block') {
275
+ pn_jid = jidNormalizedUser(jid);
276
+ }
277
+
278
+ } else {
279
+ throw new Boom(`Invalid jid for block/unblock: ${jid}`);
280
+ }
281
+
282
+ const itemAttrs = {
283
+ action: action,
284
+ jid: lid
285
+ };
286
+
287
+ if (action === 'block' && pn_jid) {
288
+ itemAttrs.pn_jid = pn_jid;
289
+ }
290
+
291
+ await query({
292
+ tag: 'iq',
293
+ attrs: {
294
+ xmlns: 'blocklist',
295
+ to: S_WHATSAPP_NET,
296
+ type: 'set'
297
+ },
298
+ content: [
299
+ {
300
+ tag: 'item',
301
+ attrs: itemAttrs
302
+ }
303
+ ]
265
304
  });
266
- };
305
+ };
267
306
  const getBusinessProfile = async (jid) => {
268
307
  const results = await query({
269
308
  tag: "iq",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skycodee/baileys",
3
- "version": "8.0.9",
3
+ "version": "8.0.11",
4
4
  "description": "Websocket Whatsapp API for Node.js",
5
5
  "keywords": [
6
6
  "whatsapp",