@alannxd/baileys 6.1.2 → 6.1.4

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,7 +1,7 @@
1
1
  # <div align='center'>Baileys - Typescript/Javascript WhatsApp Web API</div>
2
2
 
3
3
  <p align="center">
4
- <img src="https://i.top4top.io/p_3463no0l00.jpg" alt="Thumbnail" />
4
+ <img src="https://img2.pixhost.to/images/9521/751472173_alan.jpg" alt="Thumbnail" />
5
5
  </p>
6
6
 
7
7
  <div align='center'>
@@ -51,413 +51,327 @@ Simple WhatsApp Web API Library Based On Baileys.
51
51
 
52
52
  ---
53
53
 
54
- # Installation
55
-
56
- ### Install Package
57
-
58
- Install package using npm.
59
-
60
- ```bash
61
- npm install @alannxd/baileys
54
+ ## Usage
55
+ ```json
56
+ "depencies": {
57
+ "@alannxd/baileys": "latest"
58
+ // or "@whiskeysocket/baileys": "npm:@alannxd/baileys"
59
+ }
62
60
  ```
63
-
64
- ---
65
-
66
- # Import
67
-
68
- ### CommonJS
69
-
70
- Import package using require.
71
-
61
+ ## Import
72
62
  ```javascript
73
63
  const {
74
- default: makeWASocket
75
- } = require("@alannxd/baileys");
76
- ```
77
-
78
- ---
79
-
80
- ### ES Module
81
-
82
- Import package using ES Module.
83
-
84
- ```javascript
85
- import makeWASocket from "@alannxd/baileys";
64
+ default: makeWASocket,
65
+ // Other function
66
+ } = require('@alannxd/baileys');
86
67
  ```
87
68
 
88
69
  ---
89
-
90
- # Connection Documentation
91
-
92
- ### Connect With QR Code
93
-
94
- Connect WhatsApp using QR authentication.
95
-
70
+ # How To Connect To Whatsapp
71
+ ## With QR Code
96
72
  ```javascript
97
73
  const {
98
- default: makeWASocket,
99
- Browsers
100
- } = require("@alannxd/baileys");
74
+ default: makeWASocket,
75
+ Browsers
76
+ } = require('@alannxd/baileys');
101
77
 
102
78
  const client = makeWASocket({
103
- browser: Browsers.ubuntu("Chrome"),
104
- printQRInTerminal: true
105
- });
79
+ browser: Browsers.ubuntu('Chrome'),
80
+ printQRInTerminal: true
81
+ })
106
82
  ```
107
83
 
108
- ---
109
-
110
- ### Connect With Pairing Code
111
-
112
- Connect WhatsApp using phone number.
113
-
84
+ ## Connect With Number
114
85
  ```javascript
115
86
  const {
116
- default: makeWASocket,
117
- Browsers,
118
- fetchLatestWAWebVersion
119
- } = require("@alannxd/baileys");
87
+ default: makeWASocket,
88
+ fetchLatestWAWebVersion,
89
+ Browsers
90
+ } = require('@alannxd/baileys');
120
91
 
121
92
  const client = makeWASocket({
122
- browser: Browsers.ubuntu("Chrome"),
123
- printQRInTerminal: false,
124
- version: fetchLatestWAWebVersion(),
125
- aiLabel: false
93
+ browser: Browsers.ubuntu('Chrome'),
94
+ printQRInTerminal: false,
95
+ version: fetchLatestWAWebVersion()
96
+ aiLabel: false // enable for ai label in every message are bot send
97
+ // Other options
126
98
  });
127
99
 
128
- const code = await client.requestPairingCode("628xxxxxxxxxx");
100
+ const number = "628XXXXX";
101
+ const code = await client.requestPairingCode(number.trim) //Use : (number, "YYYYYYYY") for custom-pairing
129
102
 
130
- console.log(code);
103
+ console.log("Ur pairing code : " + code)
131
104
  ```
132
105
 
133
- ---
134
-
135
- # Store Documentation
136
-
137
- ### In Memory Store
138
-
139
- Store contacts, chats and messages in memory.
140
-
106
+ # Store Data
141
107
  ```javascript
142
108
  const {
143
- default: makeWASocket,
144
- makeInMemoryStore
145
- } = require("@alannxd/baileys");
146
-
147
- const pino = require("pino");
109
+ default: makeWASocket,
110
+ makeInMemoryStore
111
+ } = require('@alannxd/baileys');
112
+ const pino = require('pino');
148
113
 
149
114
  const store = makeInMemoryStore({
150
- logger: pino().child({
151
- level: "silent",
152
- stream: "store"
153
- })
115
+ logger: pino().child({ level: 'silent', stream: 'store' })
154
116
  });
155
-
156
- store.bind(client.ev);
157
- ```
158
-
159
- ---
160
-
161
- # Group Documentation
162
-
163
- ### Member Label
164
-
165
- Send member label inside group.
166
-
167
- ```javascript
168
- await client.sendMessage(jid, {
169
- groupLabel: {
170
- labelText: "Premium Member"
171
- }
117
+ const client = makeWASocket({
118
+ // option
172
119
  });
173
- ```
174
-
175
- ---
120
+ store.bind(client.ev)
176
121
 
177
- ### Message Members
178
-
179
- Send message to all group members.
180
-
181
- ```javascript
182
- await client.sendMessageMembers(
183
- jid,
184
- {
185
- extendedTextMessage: {
186
- text: "Hello Members"
187
- }
188
- },
189
- {}
190
- );
122
+ client.ev.on('contacts.upsert', () => {
123
+ console.log('Get new contact: ' + Object.values(store.contacts()));
124
+ })
191
125
  ```
126
+ # Sending messages
192
127
 
193
- ---
194
-
195
- # Utility Documentation
196
-
197
- ### Check Channel Information
198
-
199
- Get newsletter information from URL.
200
-
128
+ ## send/relay message with participant
201
129
  ```javascript
202
- client.newsletterFromUrl(url);
130
+ await client.relayMessage(m.chat, {
131
+ conversation: "Alann Winter's"
132
+ }, {
133
+ participant: true
134
+ })
135
+ // or
136
+ await client.sendMessage(m.chat, {
137
+ text: "Alann Winter's"
138
+ }, {
139
+ participant: true
140
+ })
203
141
  ```
204
-
205
- Result:
206
-
207
- ```json
208
- {
209
- "name": "Channel Name",
210
- "id": "123456789",
211
- "state": "ACTIVE",
212
- "subscribers": "1000",
213
- "verification": "UNVERIFIED",
214
- "creation_time": 1728547155,
215
- "description": "Channel Description"
216
- }
142
+ ## send orderMessage
143
+ ```javascript
144
+ const fs = require('fs');
145
+ const AlannXd = fs.readFileSync('./AlannXd');
146
+
147
+ await client.sendMessage(m.chat, {
148
+ thumbnail: AlannXd,
149
+ message: "Gotta get a grip",
150
+ orderTitle: "Alann-Winters",
151
+ totalAmount1000: 72502,
152
+ totalCurrencyCode: "IDR"
153
+ }, { quoted:m })
217
154
  ```
218
155
 
219
- ---
220
-
221
- ### Check WhatsApp Number
222
-
223
- Check whether number exists on WhatsApp.
224
-
156
+ ## send pollResultSnapshotMessage
225
157
  ```javascript
226
- client.checkWhatsApp(jid);
158
+ await client.sendMessage(m.chat, {
159
+ pollResultMessage: {
160
+ name: "Alann-Winters",
161
+ options: [
162
+ {
163
+ optionName: "poll 1"
164
+ },
165
+ {
166
+ optionName: "poll 2"
167
+ }
168
+ ],
169
+ newsletter: {
170
+ newsletterName: "ALANNXD | HOLOW",
171
+ newsletterJid: "1@newsletter"
172
+ }
173
+ }
174
+ })
227
175
  ```
228
176
 
229
- ---
230
-
231
- # SendMessage Documentation
232
-
233
- ### Send Text
234
-
235
- Send text message.
236
-
177
+ ## send productMessage
237
178
  ```javascript
238
- await client.sendText(
239
- jid,
240
- "Hello World"
241
- );
179
+ await client.relayMessage(m.chat, {
180
+ productMessage {
181
+ title: "AlannWinter's",
182
+ description: "zazaza...",
183
+ thumbnail: { url: "./AlannXd" },
184
+ productId: "EXAMPLE_TOKEN",
185
+ retailerId: "EXAMPLE_RETAILER_ID",
186
+ url: "https://t.me/alannxd",
187
+ body: "Apalah ya",
188
+ footer: "Footer",
189
+ buttons: [
190
+ {
191
+ name: "cta_url",
192
+ buttonParamsJson: "{\"display_text\":\"AlannWinters\",\"url\":\"https://t.me/alannxd\"}"
193
+ }
194
+ ],
195
+ priceAmount1000: 72502,
196
+ currencyCode: "IDR"
197
+ }
198
+ })
242
199
  ```
243
200
 
244
- ---
245
-
246
- ### Send Image
247
-
248
- Send image message.
249
-
201
+ ## send interactiveMessage
250
202
  ```javascript
251
- await client.sendImage(
252
- jid,
203
+ await client.sendMessage(m.chat, {
204
+ image: { url: "./alxd.jpg" },
205
+ text: "body",
206
+ title: "title", // if media, should put title in
207
+ footer: "footer",
208
+ interactiveButtons: [
253
209
  {
254
- url: "./image.jpg"
255
- },
256
- "Caption Here"
257
- );
210
+ name: "single_select",
211
+ buttonParamsJson: JSON.stringify({
212
+ title: "\0"
213
+ })
214
+ }
215
+ ],
216
+ messageParams: JSON.stringify({
217
+ bottom_sheet: {
218
+ /** ot params **/
219
+ }
220
+ })
221
+ })
258
222
  ```
259
223
 
260
- ---
261
-
262
- ### Send Video
263
-
264
- Send video message.
265
-
224
+ ## send member label
266
225
  ```javascript
267
- await client.sendVideo(
268
- jid,
269
- {
270
- url: "./video.mp4"
271
- },
272
- "Caption Here"
273
- );
226
+ await client.sendMessage(m.chat, {
227
+ groupLabel: {
228
+ labelText: "Tag anggota tercantum di sini"
229
+ }
230
+ })
274
231
  ```
275
232
 
276
- ---
277
-
278
- ### Send Audio
279
-
280
- Send audio message.
281
-
233
+ ## send message to members in group
282
234
  ```javascript
283
- await client.sendAudio(
284
- jid,
285
- {
286
- url: "./audio.mp3"
287
- }
288
- );
235
+ await client.sendMessageMembers(m.chat, {
236
+ extendedTextMessage: {
237
+ text: "woik sialan"
238
+ }
239
+ }, {})
289
240
  ```
241
+ # Simple sendMessage
290
242
 
291
- ---
292
-
293
- ### Send Location
294
-
295
- Send location message.
296
-
243
+ ## send text
297
244
  ```javascript
298
- await client.sendLocation(
299
- jid,
300
- "AlannXD",
301
- -6.2,
302
- 106.8,
303
- "https://example.com",
304
- "123456789"
305
- );
245
+ await client.sendText(m.chat, "AlannWinters", {
246
+ contextInfo: {
247
+ mentionedJid: [m.chat]
248
+ }
249
+ }, {
250
+ key: {
251
+ remoteJid: "status@broadcast",
252
+ participant: m.sender,
253
+ fromMe: true
254
+ },
255
+ message: {
256
+ conversation: "\0"
257
+ }
258
+ })
306
259
  ```
307
-
308
- ---
309
-
310
- ### Send Poll
311
-
312
- Create poll message.
313
-
260
+ ## send image
314
261
  ```javascript
315
- await client.sendPoll(
316
- jid,
317
- "Choose One",
318
- [
319
- "Option 1",
320
- "Option 2",
321
- "Option 3"
322
- ],
323
- true
324
- );
262
+ await client.sendImage(m.chat, { url: "./alxd.jpg" }, "AlannWinters", {
263
+ contextInfo: {
264
+ mentionedJid: [m.chat]
265
+ }
266
+ }, {
267
+ key: {
268
+ remoteJid: "status@broadcast",
269
+ participant: m.sender,
270
+ fromMe: true
271
+ },
272
+ message: {
273
+ conversation: "\0"
274
+ }
275
+ })
325
276
  ```
326
277
 
327
- ---
328
-
329
- ### Send Quiz
330
-
331
- Create quiz poll message.
332
-
278
+ ## send video
333
279
  ```javascript
334
- await client.sendQuiz(
335
- jid,
336
- "Question Here",
337
- [
338
- "A",
339
- "B",
340
- "C"
341
- ],
342
- "B"
343
- );
280
+ await client.sendVideo(m.chat, { url: "./alanxd.mp4" }, "AlannWinters", {
281
+ contextInfo: {
282
+ mentionedJid: [m.chat]
283
+ }
284
+ }, {
285
+ key: {
286
+ remoteJid: "status@broadcast",
287
+ participant: m.sender,
288
+ fromMe: true
289
+ },
290
+ message: {
291
+ conversation: "\0"
292
+ }
293
+ })
344
294
  ```
345
295
 
346
- ---
347
-
348
- ### Status Mention
349
-
350
- Mention users through status.
351
-
296
+ ## send audio
352
297
  ```javascript
353
- await client.statusMention(
354
- jid,
355
- {
356
- extendedTextMessage: {
357
- text: "Hello World"
358
- }
359
- }
360
- );
298
+ await client.sendAudio(m.chat, { url: "./alanxd.mp3" }, {
299
+ contextInfo: {
300
+ mentionedJid: [m.chat]
301
+ }
302
+ }, {
303
+ key: {
304
+ remoteJid: "status@broadcast",
305
+ participant: m.sender,
306
+ fromMe: true
307
+ },
308
+ message: {
309
+ conversation: "\0"
310
+ }
311
+ })
361
312
  ```
362
313
 
363
- ---
364
-
365
- ### Interactive Message
366
-
367
- Send interactive message.
368
-
314
+ ## send location
369
315
  ```javascript
370
- await client.sendMessage(
371
- jid,
372
- {
373
- image: {
374
- url: "./image.jpg"
375
- },
376
- text: "Body Message",
377
- title: "Hello World",
378
- footer: "AlannXD",
379
- interactiveButtons: [
380
- {
381
- name: "single_select",
382
- buttonParamsJson: JSON.stringify({
383
- title: "Menu"
384
- })
385
- }
386
- ]
387
- }
388
- );
316
+ await client.sendLocation(m.chat, "AlannWinters", 90.0, 90.0, "https://t.me/alannxd", "1234567890", {
317
+ contextInfo: {
318
+ mentionedJid: [m.chat]
319
+ }
320
+ }, {
321
+ key: {
322
+ remoteJid: "status@broadcast",
323
+ participant: m.sender,
324
+ fromMe: true
325
+ },
326
+ message: {
327
+ conversation: "\0"
328
+ }
329
+ })
389
330
  ```
390
331
 
391
- ---
392
-
393
- ### Product Message
394
-
395
- Send product catalog message.
396
-
332
+ ## send polling
397
333
  ```javascript
398
- await client.sendMessage(
399
- jid,
400
- {
401
- productMessage: {
402
- title: "AlannXD Product",
403
- description: "Product Description",
404
- thumbnail: {
405
- url: "./thumbnail.jpg"
406
- },
407
- productId: "PRODUCT_ID",
408
- retailerId: "RETAILER_ID",
409
- url: "https://example.com",
410
- body: "Product Body",
411
- footer: "Footer Product",
412
- priceAmount1000: 50000,
413
- currencyCode: "IDR"
414
- }
415
- }
416
- );
334
+ await client.sendPoll(m.chat, "AlannWinters", ["1", "2", "3"], true, {
335
+ contextInfo: {
336
+ mentionedJid: [m.chat]
337
+ }
338
+ }, {
339
+ key: {
340
+ remoteJid: "status@broadcast",
341
+ participant: m.sender,
342
+ fromMe: true
343
+ },
344
+ message: {
345
+ conversation: "\0"
346
+ }
347
+ })
417
348
  ```
418
349
 
419
- ---
420
-
421
- ### Order Message
422
-
423
- Send order message.
424
-
350
+ ## send quiz
425
351
  ```javascript
426
- await client.sendMessage(
427
- jid,
428
- {
429
- thumbnail: thumbnailBuffer,
430
- message: "Order Example",
431
- orderTitle: "AlannXD Store",
432
- totalAmount1000: 50000,
433
- totalCurrencyCode: "IDR"
434
- }
435
- );
352
+ await client.sendQuiz(m.chat, "AlannWinters", ["1", "2", "3"], "2", {
353
+ contextInfo: {
354
+ mentionedJid: [m.chat]
355
+ }
356
+ }, {
357
+ key: {
358
+ remoteJid: "status@broadcast",
359
+ participant: m.sender,
360
+ fromMe: true
361
+ },
362
+ message: {
363
+ conversation: "\0"
364
+ }
365
+ })
436
366
  ```
437
367
 
438
- ---
439
-
440
- ### Poll Result Snapshot
441
-
442
- Display poll result snapshot.
443
-
368
+ ## send status mention
444
369
  ```javascript
445
- await client.sendMessage(
446
- jid,
447
- {
448
- pollResultMessage: {
449
- name: "Example Poll",
450
- options: [
451
- {
452
- optionName: "Option 1"
453
- },
454
- {
455
- optionName: "Option 2"
456
- }
457
- ]
458
- }
459
- }
460
- );
370
+ await client.statusMention(m.chat, {
371
+ extendedTextMessage: {
372
+ text: "AlannWinters"
373
+ }
374
+ })
461
375
  ```
462
376
 
463
377
  ---
@@ -496,9 +410,9 @@ For questions, support, or collaboration, feel free to contact the developer:
496
410
  - **Telegram**: [Telegram Contact](https://t.me/alannxd)
497
411
  - **Channel WhatsApp**: [Channel WhatsApp](https://whatsapp.com/channel/0029Vb3IiqTL7UVP9A9n0w1x)
498
412
 
499
- ### 🙌 Contributors outside the Baileys code
413
+ ### Contributors outside the Baileys code
500
414
 
501
- Thanks to the following awesome contributors who help improve this project 💖
415
+ Thanks to the following awesome contributors who help improve this project
502
416
 
503
417
  <table>
504
418
  <tr>
@@ -524,11 +438,12 @@ Thanks to the following awesome contributors who help improve this project 💖
524
438
  </a>
525
439
  </td>
526
440
  <td align="center">
527
- <a href="https://github.com/RexxHayanasi">
528
- <img src="https://github.com/RexxHayanasi.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
441
+ <a href="https://github.com/Xcoursed">
442
+ <img src="https://github.com/Xcoursed.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
529
443
  <br />
530
- <sub><b>RexxHayanasi</b></sub>
444
+ <sub><b>Xcoursed</b></sub>
531
445
  </a>
532
446
  </td>
533
447
  </tr>
534
448
  </table>
449
+