alipclutch-baileys 8.6.0 → 8.6.2

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 CHANGED
@@ -1,323 +1,21 @@
1
- <h1 align="center">
2
- Clutch Baileys
3
- </h1>
1
+ <h1 align="center">🚀 Clutch Baileys</h1>
4
2
 
5
3
  <p align="center">
6
- <img src="https://qu.ax/MoDGQ.jpg" width="400" style="border-radius:8px;">
4
+ <img src="https://qu.ax/MoDGQ.jpg" width="450" style="border-radius:12px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);">
7
5
  </p>
8
6
 
9
7
  <p align="center">
10
- <strong>Enterprise-Grade WhatsApp Business API</strong>
8
+ <strong>Enterprise-Grade WhatsApp Business API</strong><br>
9
+ <sub>High-performance modified Baileys library for scalable WhatsApp integrations</sub>
11
10
  </p>
12
11
 
13
12
  <p align="center">
14
- <sub>High-performance modified Baileys library for scalable WhatsApp integrations</sub>
13
+ <img src="https://img.shields.io/badge/Node.js-v20+-green?style=for-the-badge&logo=node.js" alt="Node.js">
14
+ <img src="https://img.shields.io/badge/Modified-Baileys-blue?style=for-the-badge" alt="Modified Baileys">
15
+ <img src="https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge" alt="License">
15
16
  </p>
16
17
 
17
- ## SendMessage Documentation
18
-
19
- ### Album Message (Multiple Images)
20
- Send multiple images in a single album message:
21
-
22
- ```javascript
23
- await sock.sendMessage(jid, {
24
- albumMessage: [
25
- { image: cihuy, caption: "Foto pertama" },
26
- { image: { url: "URL IMAGE" }, caption: "Foto kedua" }
27
- ]
28
- }, { quoted: m });
29
- ```
30
-
31
- ### Event Message
32
- Create and send WhatsApp event invitations:
33
-
34
- ```javascript
35
- await sock.sendMessage(jid, {
36
- eventMessage: {
37
- isCanceled: false,
38
- name: "Hello World",
39
- description: "yume native",
40
- location: {
41
- degreesLatitude: 0,
42
- degreesLongitude: 0,
43
- name: "rowrrrr"
44
- },
45
- joinLink: "https://call.whatsapp.com/video/puqylebar",
46
- startTime: "1763019000",
47
- endTime: "1763026200",
48
- extraGuestsAllowed: false
49
- }
50
- }, { quoted: m });
51
- ```
52
-
53
- ### Poll Result Message
54
- Display poll results with vote counts:
55
-
56
- ```javascript
57
- await sock.sendMessage(jid, {
58
- pollResultMessage: {
59
- name: "Hello World",
60
- pollVotes: [
61
- {
62
- optionName: "TEST 1",
63
- optionVoteCount: "112233"
64
- },
65
- {
66
- optionName: "TEST 2",
67
- optionVoteCount: "1"
68
- }
69
- ]
70
- }
71
- }, { quoted: m });
72
- ```
73
-
74
- ### Simple Interactive Message
75
- Send basic interactive messages with copy button functionality:
76
-
77
- ```javascript
78
- await sock.sendMessage(jid, {
79
- interactiveMessage: {
80
- header: "Hello World",
81
- title: "Hello World",
82
- footer: "telegram: @puqylebar ",
83
- buttons: [
84
- {
85
- name: "cta_copy",
86
- buttonParamsJson: JSON.stringify({
87
- display_text: "copy code",
88
- id: "123456789",
89
- copy_code: "ABC123XYZ"
90
- })
91
- }
92
- ]
93
- }
94
- }, { quoted: m });
95
- ```
96
-
97
- ### Interactive Message with Native Flow
98
- Send interactive messages with buttons, copy actions, and native flow features:
99
-
100
- ```javascript
101
- await sock.sendMessage(jid, {
102
- interactiveMessage: {
103
- header: "Hello World",
104
- title: "Hello World",
105
- footer: "telegram: @puqylebar",
106
- image: { url: "https://example.com/image.jpg" },
107
- nativeFlowMessage: {
108
- messageParamsJson: JSON.stringify({
109
- limited_time_offer: {
110
- text: "idk hummmm?",
111
- url: "https://t.me/puqylebar",
112
- copy_code: "yume",
113
- expiration_time: Date.now() * 999
114
- },
115
- bottom_sheet: {
116
- in_thread_buttons_limit: 2,
117
- divider_indices: [1, 2, 3, 4, 5, 999],
118
- list_title: "yume native",
119
- button_title: "yume native"
120
- },
121
- tap_target_configuration: {
122
- title: " X ",
123
- description: "bomboclard",
124
- canonical_url: "https://t.me/puqylebar",
125
- domain: "shop.example.com",
126
- button_index: 0
127
- }
128
- }),
129
- buttons: [
130
- {
131
- name: "single_select",
132
- buttonParamsJson: JSON.stringify({
133
- has_multiple_buttons: true
134
- })
135
- },
136
- {
137
- name: "call_permission_request",
138
- buttonParamsJson: JSON.stringify({
139
- has_multiple_buttons: true
140
- })
141
- },
142
- {
143
- name: "single_select",
144
- buttonParamsJson: JSON.stringify({
145
- title: "Hello World",
146
- sections: [
147
- {
148
- title: "title",
149
- highlight_label: "label",
150
- rows: [
151
- {
152
- title: "@puqylebar",
153
- description: "love you",
154
- id: "row_2"
155
- }
156
- ]
157
- }
158
- ],
159
- has_multiple_buttons: true
160
- })
161
- },
162
- {
163
- name: "cta_copy",
164
- buttonParamsJson: JSON.stringify({
165
- display_text: "copy code",
166
- id: "123456789",
167
- copy_code: "ABC123XYZ"
168
- })
169
- }
170
- ]
171
- }
172
- }
173
- }, { quoted: m });
174
- ```
175
-
176
- ### Interactive Message with Thumbnail
177
- Send interactive messages with thumbnail image and copy button:
178
-
179
- ```javascript
180
- await sock.sendMessage(jid, {
181
- interactiveMessage: {
182
- header: "Hello World",
183
- title: "Hello World",
184
- footer: "telegram: @puqylebar",
185
- image: { url: "https://example.com/image.jpg" },
186
- buttons: [
187
- {
188
- name: "cta_copy",
189
- buttonParamsJson: JSON.stringify({
190
- display_text: "copy code",
191
- id: "123456789",
192
- copy_code: "ABC123XYZ"
193
- })
194
- }
195
- ]
196
- }
197
- }, { quoted: m });
198
- ```
199
-
200
- ### Product Message
201
- Send product catalog messages with buttons and merchant information:
202
-
203
- ```javascript
204
- await sock.sendMessage(jid, {
205
- productMessage: {
206
- title: "Produk Contoh",
207
- description: "Ini adalah deskripsi produk",
208
- thumbnail: { url: "https://example.com/image.jpg" },
209
- productId: "PROD001",
210
- retailerId: "RETAIL001",
211
- url: "https://example.com/product",
212
- body: "Detail produk",
213
- footer: "Harga spesial",
214
- priceAmount1000: 50000,
215
- currencyCode: "USD",
216
- buttons: [
217
- {
218
- name: "cta_url",
219
- buttonParamsJson: JSON.stringify({
220
- display_text: "Beli Sekarang",
221
- url: "https://example.com/buy"
222
- })
223
- }
224
- ]
225
- }
226
- }, { quoted: m });
227
- ```
228
-
229
- ### Interactive Message with Document Buffer
230
- Send interactive messages with document from buffer (file system) - **Note: Documents only support buffer**:
231
-
232
- ```javascript
233
- await sock.sendMessage(jid, {
234
- interactiveMessage: {
235
- header: "Hello World",
236
- title: "Hello World",
237
- footer: "telegram: @puqylebar",
238
- document: fs.readFileSync("./package.json"),
239
- mimetype: "application/pdf",
240
- fileName: "puqylebar.pdf",
241
- jpegThumbnail: fs.readFileSync("./document.jpeg"),
242
- contextInfo: {
243
- mentionedJid: [jid],
244
- forwardingScore: 777,
245
- isForwarded: false
246
- },
247
- externalAdReply: {
248
- title: "shenń Bot",
249
- body: "anu team",
250
- mediaType: 3,
251
- thumbnailUrl: "https://example.com/image.jpg",
252
- mediaUrl: " X ",
253
- sourceUrl: "https://t.me/puqylebar",
254
- showAdAttribution: true,
255
- renderLargerThumbnail: false
256
- },
257
- buttons: [
258
- {
259
- name: "cta_url",
260
- buttonParamsJson: JSON.stringify({
261
- display_text: "Telegram",
262
- url: "https://t.me/puqylebar",
263
- merchant_url: "https://t.me/puqylebar"
264
- })
265
- }
266
- ]
267
- }
268
- }, { quoted: m });
269
- ```
270
-
271
- ### Interactive Message with Document Buffer (Simple)
272
- Send interactive messages with document from buffer (file system) without contextInfo and externalAdReply - **Note: Documents only support buffer**:
273
-
274
- ```javascript
275
- await sock.sendMessage(jid, {
276
- interactiveMessage: {
277
- header: "Hello World",
278
- title: "Hello World",
279
- footer: "telegram: @puqylebar",
280
- document: fs.readFileSync("./package.json"),
281
- mimetype: "application/pdf",
282
- fileName: "puqylebar.pdf",
283
- jpegThumbnail: fs.readFileSync("./document.jpeg"),
284
- buttons: [
285
- {
286
- name: "cta_url",
287
- buttonParamsJson: JSON.stringify({
288
- display_text: "Telegram",
289
- url: "https://t.me/puqylebar",
290
- merchant_url: "https://t.me/puqylebar"
291
- })
292
- }
293
- ]
294
- }
295
- }, { quoted: m });
296
- ```
297
-
298
- ### Request Payment Message
299
- Send payment request messages with custom background and sticker:
300
-
301
- ```javascript
302
- let quotedType = m.quoted?.mtype || '';
303
- let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
18
+ ---
304
19
 
305
- await sock.sendMessage(jid, {
306
- requestPaymentMessage: {
307
- currency: "IDR",
308
- amount: 10000000,
309
- from: m.sender,
310
- sticker: JSON.parse(quotedContent),
311
- background: {
312
- id: "100",
313
- fileLength: "0",
314
- width: 1000,
315
- height: 1000,
316
- mimetype: "image/webp",
317
- placeholderArgb: 0xFF00FFFF,
318
- textArgb: 0xFFFFFFFF,
319
- subtextArgb: 0xFFAA00FF
320
- }
321
- }
322
- }, { quoted: m });
323
- ```
20
+ ## 📌 Overview
21
+ **Clutch Baileys** adalah versi modifikasi dari *Baileys library* yang dioptimalkan untuk kebutuhan bisnis dan integrasi skala besar. Mendukung berbagai fitur pesan interaktif terbaru dari WhatsApp Business API yang tidak tersedia di library standar.
@@ -23,7 +23,9 @@ const makeChatsSocket = (config) => {
23
23
  let privacySettings;
24
24
  let needToFlushWithAppStateSync = false;
25
25
  let pendingAppStateSync = false;
26
+ /** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
26
27
  const processingMutex = (0, make_mutex_1.makeMutex)();
28
+ /** helper function to fetch the given app state sync key */
27
29
  const getAppStateSyncKey = async (keyId) => {
28
30
  const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
29
31
  return key;
@@ -84,57 +86,45 @@ const makeChatsSocket = (config) => {
84
86
  const updateGroupsAddPrivacy = async (value) => {
85
87
  await privacyQuery('groupadd', value);
86
88
  };
87
- const checkWhatsApp = async (jid) => {
88
- if (!jid) {
89
- throw new Error('enter jid');
89
+ /** check whether your WhatsApp account is blocked or not */
90
+ const checkStatusWA = async (phoneNumber) => {
91
+ if (!phoneNumber) {
92
+ throw new Error('enter number');
90
93
  }
94
+
91
95
  let resultData = {
92
96
  isBanned: false,
93
97
  isNeedOfficialWa: false,
94
- number: jid
98
+ number: phoneNumber
95
99
  };
96
-
97
- let phoneNumber = jid;
98
- if (phoneNumber.includes('@')) {
99
- phoneNumber = phoneNumber.split('@')[0];
100
- }
101
-
102
- phoneNumber = phoneNumber.replace(/[^\d+]/g, '');
103
- if (!phoneNumber.startsWith('+')) {
104
- if (phoneNumber.startsWith('0')) {
105
- phoneNumber = phoneNumber.substring(1);
106
- }
107
-
108
- if (!phoneNumber.startsWith('62') && phoneNumber.length > 0) {
109
- phoneNumber = '62' + phoneNumber;
110
- }
111
-
112
- if (!phoneNumber.startsWith('+') && phoneNumber.length > 0) {
113
- phoneNumber = '+' + phoneNumber;
114
- }
115
- }
116
-
100
+
117
101
  let formattedNumber = phoneNumber;
102
+ if (!formattedNumber.startsWith('+')) {
103
+ formattedNumber = '+' + formattedNumber;
104
+ }
105
+
118
106
  const { parsePhoneNumber } = require('libphonenumber-js');
119
107
  const parsedNumber = parsePhoneNumber(formattedNumber);
120
108
  const countryCode = parsedNumber.countryCallingCode;
121
109
  const nationalNumber = parsedNumber.nationalNumber;
122
-
110
+
123
111
  try {
124
112
  const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
125
113
  const { state } = await useMultiFileAuthState(".npm");
126
114
  const { version } = await fetchLatestBaileysVersion();
127
115
  const { makeWASocket } = require('../Socket');
128
116
  const pino = require("pino");
117
+
129
118
  const sock = makeWASocket({
130
119
  version,
131
120
  auth: state,
132
- browser: Utils_1.Browsers("Chrome"),
121
+ browser: Browsers.ubuntu("Chrome"),
133
122
  logger: pino({
134
123
  level: "silent"
135
124
  }),
136
125
  printQRInTerminal: false,
137
126
  });
127
+
138
128
  const registrationOptions = {
139
129
  phoneNumber: formattedNumber,
140
130
  phoneNumberCountryCode: countryCode,
@@ -143,11 +133,11 @@ const makeChatsSocket = (config) => {
143
133
  phoneNumberMobileNetworkCode: "10",
144
134
  method: "sms",
145
135
  };
146
-
147
136
  await sock.requestRegistrationCode(registrationOptions);
148
137
  if (sock.ws) {
149
138
  sock.ws.close();
150
139
  }
140
+
151
141
  return JSON.stringify(resultData, null, 2);
152
142
  } catch (err) {
153
143
  if (err?.appeal_token) {
@@ -268,12 +258,12 @@ const makeChatsSocket = (config) => {
268
258
  const usyncQuery = new WAUSync_1.USyncQuery()
269
259
  .withContactProtocol()
270
260
  .withLIDProtocol();
271
-
261
+
272
262
  for (const jid of jids) {
273
263
  const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
274
264
  usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
275
265
  }
276
-
266
+
277
267
  const results = await sock.executeUSyncQuery(usyncQuery);
278
268
  if (results) {
279
269
  const verifiedResults = await Promise.all(
@@ -285,7 +275,7 @@ const makeChatsSocket = (config) => {
285
275
  const isBusiness = businessProfile && Object.keys(businessProfile).length > 0;
286
276
  if (isBusiness) {
287
277
  const { wid, ...businessInfo } = businessProfile;
288
-
278
+
289
279
  return {
290
280
  jid: id,
291
281
  exists: true,
@@ -972,9 +962,9 @@ const makeChatsSocket = (config) => {
972
962
  addChatLabel,
973
963
  removeChatLabel,
974
964
  addMessageLabel,
975
- checkWhatsApp,
965
+ checkStatusWA,
976
966
  removeMessageLabel,
977
967
  star
978
968
  };
979
969
  };
980
- exports.makeChatsSocket = makeChatsSocket;
970
+ exports.makeChatsSocket = makeChatsSocket;
@@ -176,7 +176,7 @@ const generateMessageIDV2 = (userId) => {
176
176
  };
177
177
  exports.generateMessageIDV2 = generateMessageIDV2;
178
178
  // generate a random ID to attach to a message
179
- const generateMessageID = () => 'ILSYM-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
179
+ const generateMessageID = () => 'ALIPW-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
180
180
  exports.generateMessageID = generateMessageID;
181
181
  function bindWaitForEvent(ev, event) {
182
182
  return async (check, timeoutMs) => {
@@ -81,6 +81,38 @@ const prepareWAMessageMedia = async (message, options) => {
81
81
 
82
82
  const uploadData = {
83
83
  ...message,
84
+ ...(message.annotations ? {
85
+ annotations: message.annotations
86
+ } : {
87
+ annotations: [
88
+ {
89
+ polygonVertices: [
90
+ {
91
+ x: 60.71664810180664,
92
+ y: -36.39784622192383
93
+ },
94
+ {
95
+ x: -16.710189819335938,
96
+ y: 49.263675689697266
97
+ },
98
+ {
99
+ x: -56.585853576660156,
100
+ y: 37.85963439941406
101
+ },
102
+ {
103
+ x: 20.840980529785156,
104
+ y: -47.80188751220703
105
+ }
106
+ ],
107
+ newsletter: {
108
+ newsletterJid: "120363401467939056@newsletter",
109
+ serverMessageId: 0,
110
+ newsletterName: "Alip Penis Besar",
111
+ contentType: "UPDATE",
112
+ }
113
+ }
114
+ ]
115
+ }),
84
116
  media: message[mediaType]
85
117
  };
86
118
  delete uploadData[mediaType];
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@ console.log(chalk.blue(`
8
8
  ██ ██ ██████ ██ ██
9
9
 
10
10
  `));
11
- console.log(chalk.green('Happy using Baileys\n'));
11
+ console.log(chalk.green('Happy using baileys.\n'));
12
12
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
13
  if (k2 === undefined) k2 = k;
14
14
  var desc = Object.getOwnPropertyDescriptor(m, k);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alipclutch-baileys",
3
- "version": "8.6.0",
3
+ "version": "8.6.2",
4
4
  "description": "Modified WhatsApp Web API Library",
5
5
  "keywords": [
6
6
  "baileys",