dcodeindra-baileyspro 2.3.9 → 2.3.10
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 +182 -182
- package/lib/Socket/socket.js +2 -2
- package/lib/index.js +11 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,31 +50,31 @@ To run the example script, download or clone the repo and then type the followin
|
|
|
50
50
|
|
|
51
51
|
Use the stable version:
|
|
52
52
|
```
|
|
53
|
-
yarn add
|
|
53
|
+
yarn add Dcodeindra-Baileyspro
|
|
54
54
|
```
|
|
55
55
|
```
|
|
56
|
-
npm install
|
|
56
|
+
npm install Dcodeindra-Baileyspro
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Use package.json
|
|
60
60
|
```
|
|
61
|
-
"@whiskeysockets/baileys": "npm:
|
|
61
|
+
"@whiskeysockets/baileys": "npm:Dcodeindra-Baileyspro@latest"
|
|
62
62
|
```
|
|
63
63
|
```
|
|
64
|
-
"@adiwajshing/baileys": "npm:
|
|
64
|
+
"@adiwajshing/baileys": "npm:Dcodeindra-Baileyspro@latest"
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Use the edge version (no guarantee of stability, but latest fixes + features)
|
|
68
68
|
```
|
|
69
|
-
yarn add github:
|
|
69
|
+
yarn add github:indraVollereii/indra-Baileys
|
|
70
70
|
```
|
|
71
71
|
```
|
|
72
|
-
yarn add npm:
|
|
72
|
+
yarn add npm:Dcodeindra-Baileyspro@latest
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Then import your code using:
|
|
76
76
|
```ts
|
|
77
|
-
import makeWASocket from '
|
|
77
|
+
import makeWASocket from 'Dcodeindra-Baileyspro'
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
# Links
|
|
@@ -231,9 +231,9 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
|
|
|
231
231
|
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
|
|
232
232
|
|
|
233
233
|
```ts
|
|
234
|
-
import makeWASocket from '
|
|
234
|
+
import makeWASocket from 'Dcodeindra-Baileyspro'
|
|
235
235
|
|
|
236
|
-
const
|
|
236
|
+
const indra = makeWASocket({
|
|
237
237
|
// can provide additional config here
|
|
238
238
|
browser: Browsers.ubuntu('My App'),
|
|
239
239
|
printQRInTerminal: true
|
|
@@ -251,16 +251,16 @@ If the connection is successful, you will see a QR code printed on your terminal
|
|
|
251
251
|
The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
|
|
252
252
|
|
|
253
253
|
```ts
|
|
254
|
-
import makeWASocket from '
|
|
254
|
+
import makeWASocket from 'Dcodeindra-Baileyspro'
|
|
255
255
|
|
|
256
|
-
const
|
|
256
|
+
const indra = makeWASocket({
|
|
257
257
|
// can provide additional config here
|
|
258
258
|
printQRInTerminal: false //need to be false
|
|
259
259
|
})
|
|
260
260
|
|
|
261
|
-
if (!
|
|
261
|
+
if (!indra.authState.creds.registered) {
|
|
262
262
|
const number = 'XXXXXXXXXXX'
|
|
263
|
-
const code = await
|
|
263
|
+
const code = await indra.requestPairingCode(number) // or await indra.requestPairingCode(number, 'CODEOTPS') custom your pairing code
|
|
264
264
|
console.log(code)
|
|
265
265
|
}
|
|
266
266
|
```
|
|
@@ -272,7 +272,7 @@ if (!sanka.authState.creds.registered) {
|
|
|
272
272
|
- If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
|
|
273
273
|
|
|
274
274
|
```ts
|
|
275
|
-
const
|
|
275
|
+
const indra = makeWASocket({
|
|
276
276
|
...otherOpts,
|
|
277
277
|
// can use Windows, Ubuntu here too
|
|
278
278
|
browser: Browsers.macOS('Desktop'),
|
|
@@ -288,17 +288,17 @@ const sanka = makeWASocket({
|
|
|
288
288
|
```ts
|
|
289
289
|
const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
|
|
290
290
|
|
|
291
|
-
const
|
|
291
|
+
const indra = makeWASocket({
|
|
292
292
|
cachedGroupMetadata: async (jid) => groupCache.get(jid)
|
|
293
293
|
})
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
const metadata = await
|
|
295
|
+
indra.ev.on('groups.update', async ([event]) => {
|
|
296
|
+
const metadata = await indra.groupMetadata(event.id)
|
|
297
297
|
groupCache.set(event.id, metadata)
|
|
298
298
|
})
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
const metadata = await
|
|
300
|
+
indra.ev.on('group-participants.update', async (event) => {
|
|
301
|
+
const metadata = await indra.groupMetadata(event.id)
|
|
302
302
|
groupCache.set(event.id, metadata)
|
|
303
303
|
})
|
|
304
304
|
```
|
|
@@ -306,7 +306,7 @@ const sanka = makeWASocket({
|
|
|
306
306
|
### Improve Retry System & Decrypt Poll Votes
|
|
307
307
|
- 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:
|
|
308
308
|
```ts
|
|
309
|
-
const
|
|
309
|
+
const indra = makeWASocket({
|
|
310
310
|
getMessage: async (key) => await getMessageFromStore(key)
|
|
311
311
|
})
|
|
312
312
|
```
|
|
@@ -314,7 +314,7 @@ const sanka = makeWASocket({
|
|
|
314
314
|
### Receive Notifications in Whatsapp App
|
|
315
315
|
- If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
|
|
316
316
|
```ts
|
|
317
|
-
const
|
|
317
|
+
const indra = makeWASocket({
|
|
318
318
|
markOnlineOnConnect: false
|
|
319
319
|
})
|
|
320
320
|
```
|
|
@@ -324,16 +324,16 @@ You obviously don't want to keep scanning the QR code every time you want to con
|
|
|
324
324
|
|
|
325
325
|
So, you can load the credentials to log back in:
|
|
326
326
|
```ts
|
|
327
|
-
import makeWASocket, { useMultiFileAuthState } from '
|
|
327
|
+
import makeWASocket, { useMultiFileAuthState } from 'Dcodeindra-Baileyspro'
|
|
328
328
|
|
|
329
329
|
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
|
|
330
330
|
|
|
331
331
|
// will use the given state to connect
|
|
332
332
|
// so if valid credentials are available -- it'll connect without QR
|
|
333
|
-
const
|
|
333
|
+
const indra = makeWASocket({ auth: state })
|
|
334
334
|
|
|
335
335
|
// this will be called as soon as the credentials are updated
|
|
336
|
-
|
|
336
|
+
indra.ev.on('creds.update', saveCreds)
|
|
337
337
|
```
|
|
338
338
|
|
|
339
339
|
> [!IMPORTANT]
|
|
@@ -352,8 +352,8 @@ They're all nicely typed up, so you shouldn't have any issues with an Intellisen
|
|
|
352
352
|
|
|
353
353
|
You can listen to these events like this:
|
|
354
354
|
```ts
|
|
355
|
-
const
|
|
356
|
-
|
|
355
|
+
const indra = makeWASocket()
|
|
356
|
+
indra.ev.on('messages.upsert', ({ messages }) => {
|
|
357
357
|
console.log('got messages', messages)
|
|
358
358
|
})
|
|
359
359
|
```
|
|
@@ -364,17 +364,17 @@ sanka.ev.on('messages.upsert', ({ messages }) => {
|
|
|
364
364
|
> This example includes basic auth storage too
|
|
365
365
|
|
|
366
366
|
```ts
|
|
367
|
-
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '
|
|
367
|
+
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from 'Dcodeindra-Baileyspro'
|
|
368
368
|
import { Boom } from '@hapi/boom'
|
|
369
369
|
|
|
370
370
|
async function connectToWhatsApp () {
|
|
371
371
|
const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
|
|
372
|
-
const
|
|
372
|
+
const indra = makeWASocket({
|
|
373
373
|
// can provide additional config here
|
|
374
374
|
auth: state,
|
|
375
375
|
printQRInTerminal: true
|
|
376
376
|
})
|
|
377
|
-
|
|
377
|
+
indra.ev.on('connection.update', (update) => {
|
|
378
378
|
const { connection, lastDisconnect } = update
|
|
379
379
|
if(connection === 'close') {
|
|
380
380
|
const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
@@ -387,17 +387,17 @@ async function connectToWhatsApp () {
|
|
|
387
387
|
console.log('opened connection')
|
|
388
388
|
}
|
|
389
389
|
})
|
|
390
|
-
|
|
390
|
+
indra.ev.on('messages.upsert', event => {
|
|
391
391
|
for (const m of event.messages) {
|
|
392
392
|
console.log(JSON.stringify(m, undefined, 2))
|
|
393
393
|
|
|
394
394
|
console.log('replying to', m.key.remoteJid)
|
|
395
|
-
await
|
|
395
|
+
await indra.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
|
|
396
396
|
}
|
|
397
397
|
})
|
|
398
398
|
|
|
399
399
|
// to storage creds (session info) when it updates
|
|
400
|
-
|
|
400
|
+
indra.ev.on('creds.update', saveCreds)
|
|
401
401
|
}
|
|
402
402
|
// run in main file
|
|
403
403
|
connectToWhatsApp()
|
|
@@ -405,16 +405,16 @@ connectToWhatsApp()
|
|
|
405
405
|
|
|
406
406
|
### For example if you use useSingleFileAuthState and useMongoFileAuthState
|
|
407
407
|
```ts
|
|
408
|
-
import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from '
|
|
408
|
+
import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from 'Dcodeindra-Baileyspro'
|
|
409
409
|
|
|
410
410
|
// Single Auth
|
|
411
411
|
const { state, saveState } = await useSingleFileAuthState('./auth_info_baileys.json')
|
|
412
|
-
const
|
|
412
|
+
const indra = makeWASocket({
|
|
413
413
|
auth: state,
|
|
414
414
|
printQRInTerminal: true
|
|
415
415
|
})
|
|
416
416
|
|
|
417
|
-
|
|
417
|
+
indra.ev.on('creds.update', saveState)
|
|
418
418
|
|
|
419
419
|
// Mongo Auth
|
|
420
420
|
import { MongoClient } from "mongodb"
|
|
@@ -430,18 +430,18 @@ const connectAuth = async() => {
|
|
|
430
430
|
})
|
|
431
431
|
}
|
|
432
432
|
await client.connect()
|
|
433
|
-
const collection = client.db("@
|
|
433
|
+
const collection = client.db("@indraVollereii").collection("sessions")
|
|
434
434
|
return collection
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
const Authentication = await connectAuth()
|
|
438
438
|
const { state, saveCreds } = await useMongoFileAuthState(Authentication)
|
|
439
|
-
const
|
|
439
|
+
const indra = makeWASocket({
|
|
440
440
|
auth: state,
|
|
441
441
|
printQRInTerminal: true
|
|
442
442
|
})
|
|
443
443
|
|
|
444
|
-
|
|
444
|
+
indra.ev.on('creds.update', saveCreds)
|
|
445
445
|
```
|
|
446
446
|
|
|
447
447
|
> [!IMPORTANT]
|
|
@@ -452,9 +452,9 @@ sanka.ev.on('creds.update', saveCreds)
|
|
|
452
452
|
- By default poll votes are encrypted and handled in `messages.update`
|
|
453
453
|
```ts
|
|
454
454
|
import pino from "pino"
|
|
455
|
-
import { makeInMemoryStore, getAggregateVotesInPollMessage } from '
|
|
455
|
+
import { makeInMemoryStore, getAggregateVotesInPollMessage } from 'Dcodeindra-Baileyspro'
|
|
456
456
|
|
|
457
|
-
const logger = pino({ timestamp: () => `,"time":"${new Date().toJSON()}"` }).child({ class: "
|
|
457
|
+
const logger = pino({ timestamp: () => `,"time":"${new Date().toJSON()}"` }).child({ class: "Dcodeindra-Baileyspro" })
|
|
458
458
|
logger.level = "fatal"
|
|
459
459
|
const store = makeInMemoryStore({ logger })
|
|
460
460
|
|
|
@@ -468,7 +468,7 @@ async function getMessage(key){
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
|
|
471
|
+
indra.ev.on("messages.update", async (chatUpdate) => {
|
|
472
472
|
for(const { key, update } of chatUpdate) {
|
|
473
473
|
if(update.pollUpdates && key.fromMe) {
|
|
474
474
|
const pollCreation = await getMessage(key)
|
|
@@ -501,7 +501,7 @@ sanka.ev.on("messages.update", async (chatUpdate) => {
|
|
|
501
501
|
It can be used as follows:
|
|
502
502
|
|
|
503
503
|
```ts
|
|
504
|
-
import makeWASocket, { makeInMemoryStore } from '
|
|
504
|
+
import makeWASocket, { makeInMemoryStore } from 'Dcodeindra-Baileyspro'
|
|
505
505
|
// the store maintains the data of the WA connection in memory
|
|
506
506
|
// can be written out to a file & read from it
|
|
507
507
|
const store = makeInMemoryStore({ })
|
|
@@ -512,18 +512,18 @@ setInterval(() => {
|
|
|
512
512
|
store.writeToFile('./baileys_store.json')
|
|
513
513
|
}, 10_000)
|
|
514
514
|
|
|
515
|
-
const
|
|
515
|
+
const indra = makeWASocket({ })
|
|
516
516
|
// will listen from this socket
|
|
517
517
|
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
518
|
-
store.bind(
|
|
518
|
+
store.bind(indra.ev)
|
|
519
519
|
|
|
520
|
-
|
|
520
|
+
indra.ev.on('chats.upsert', () => {
|
|
521
521
|
// can use 'store.chats' however you want, even after the socket dies out
|
|
522
522
|
// 'chats' => a KeyedDB instance
|
|
523
523
|
console.log('got chats', store.chats.all())
|
|
524
524
|
})
|
|
525
525
|
|
|
526
|
-
|
|
526
|
+
indra.ev.on('contacts.upsert', () => {
|
|
527
527
|
console.log('got contacts', Object.values(store.contacts))
|
|
528
528
|
})
|
|
529
529
|
|
|
@@ -558,25 +558,25 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
558
558
|
const content: AnyMessageContent
|
|
559
559
|
const options: MiscMessageGenerationOptions
|
|
560
560
|
|
|
561
|
-
|
|
561
|
+
indra.sendMessage(jid, content, options)
|
|
562
562
|
```
|
|
563
563
|
|
|
564
564
|
### Non-Media Messages
|
|
565
565
|
|
|
566
566
|
#### Text Message
|
|
567
567
|
```ts
|
|
568
|
-
await
|
|
568
|
+
await indra.sendMessage(jid, { text: 'hello word' })
|
|
569
569
|
```
|
|
570
570
|
|
|
571
571
|
#### Quote Message (works with all types)
|
|
572
572
|
```ts
|
|
573
|
-
await
|
|
573
|
+
await indra.sendMessage(jid, { text: 'hello word' }, { quoted: message })
|
|
574
574
|
```
|
|
575
575
|
|
|
576
576
|
#### Mention User (works with most types)
|
|
577
577
|
- @number is to mention in text, it's optional
|
|
578
578
|
```ts
|
|
579
|
-
await
|
|
579
|
+
await indra.sendMessage(
|
|
580
580
|
jid,
|
|
581
581
|
{
|
|
582
582
|
text: '@12345678901',
|
|
@@ -589,12 +589,12 @@ await sanka.sendMessage(
|
|
|
589
589
|
- 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
|
|
590
590
|
```ts
|
|
591
591
|
const msg = getMessageFromStore() // implement this on your end
|
|
592
|
-
await
|
|
592
|
+
await indra.sendMessage(jid, { forward: msg, force: true or number }) // WA forward the message!
|
|
593
593
|
```
|
|
594
594
|
|
|
595
595
|
#### Location Message
|
|
596
596
|
```ts
|
|
597
|
-
await
|
|
597
|
+
await indra.sendMessage(
|
|
598
598
|
jid,
|
|
599
599
|
{
|
|
600
600
|
location: {
|
|
@@ -607,7 +607,7 @@ await sanka.sendMessage(
|
|
|
607
607
|
|
|
608
608
|
#### Live Location Message
|
|
609
609
|
```ts
|
|
610
|
-
await
|
|
610
|
+
await indra.sendMessage(
|
|
611
611
|
jid,
|
|
612
612
|
{
|
|
613
613
|
location: {
|
|
@@ -627,7 +627,7 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
|
|
|
627
627
|
+ 'TELtype=CELLtype=VOICEwaid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
|
|
628
628
|
+ 'END:VCARD'
|
|
629
629
|
|
|
630
|
-
await
|
|
630
|
+
await indra.sendMessage(
|
|
631
631
|
id,
|
|
632
632
|
{
|
|
633
633
|
contacts: {
|
|
@@ -641,7 +641,7 @@ await sanka.sendMessage(
|
|
|
641
641
|
#### Reaction Message
|
|
642
642
|
- 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
|
|
643
643
|
```ts
|
|
644
|
-
await
|
|
644
|
+
await indra.sendMessage(
|
|
645
645
|
jid,
|
|
646
646
|
{
|
|
647
647
|
react: {
|
|
@@ -664,7 +664,7 @@ await sanka.sendMessage(
|
|
|
664
664
|
| 30d | 2.592.000 |
|
|
665
665
|
|
|
666
666
|
```ts
|
|
667
|
-
await
|
|
667
|
+
await indra.sendMessage(
|
|
668
668
|
jid,
|
|
669
669
|
{
|
|
670
670
|
pin: {
|
|
@@ -678,7 +678,7 @@ await sanka.sendMessage(
|
|
|
678
678
|
|
|
679
679
|
### Keep Message
|
|
680
680
|
```ts
|
|
681
|
-
await
|
|
681
|
+
await indra.sendMessage(
|
|
682
682
|
jid,
|
|
683
683
|
{
|
|
684
684
|
keep: {
|
|
@@ -691,7 +691,7 @@ await sanka.sendMessage(
|
|
|
691
691
|
|
|
692
692
|
#### Poll Message
|
|
693
693
|
```ts
|
|
694
|
-
await
|
|
694
|
+
await indra.sendMessage(
|
|
695
695
|
jid,
|
|
696
696
|
{
|
|
697
697
|
poll: {
|
|
@@ -706,7 +706,7 @@ await sanka.sendMessage(
|
|
|
706
706
|
|
|
707
707
|
#### Poll Result Message
|
|
708
708
|
```ts
|
|
709
|
-
await
|
|
709
|
+
await indra.sendMessage(
|
|
710
710
|
jid,
|
|
711
711
|
{
|
|
712
712
|
pollResult: {
|
|
@@ -728,7 +728,7 @@ await sanka.sendMessage(
|
|
|
728
728
|
|
|
729
729
|
### Call Message
|
|
730
730
|
```ts
|
|
731
|
-
await
|
|
731
|
+
await indra.sendMessage(
|
|
732
732
|
jid,
|
|
733
733
|
{
|
|
734
734
|
call: {
|
|
@@ -741,7 +741,7 @@ await sanka.sendMessage(
|
|
|
741
741
|
|
|
742
742
|
### Event Message
|
|
743
743
|
```ts
|
|
744
|
-
await
|
|
744
|
+
await indra.sendMessage(
|
|
745
745
|
jid,
|
|
746
746
|
{
|
|
747
747
|
event: {
|
|
@@ -763,7 +763,7 @@ await sanka.sendMessage(
|
|
|
763
763
|
|
|
764
764
|
### Order Message
|
|
765
765
|
```ts
|
|
766
|
-
await
|
|
766
|
+
await indra.sendMessage(
|
|
767
767
|
jid,
|
|
768
768
|
{
|
|
769
769
|
order: {
|
|
@@ -785,7 +785,7 @@ await sanka.sendMessage(
|
|
|
785
785
|
|
|
786
786
|
### Product Message
|
|
787
787
|
```ts
|
|
788
|
-
await
|
|
788
|
+
await indra.sendMessage(
|
|
789
789
|
jid,
|
|
790
790
|
{
|
|
791
791
|
product: {
|
|
@@ -811,7 +811,7 @@ await sanka.sendMessage(
|
|
|
811
811
|
|
|
812
812
|
### Payment Message
|
|
813
813
|
```ts
|
|
814
|
-
await
|
|
814
|
+
await indra.sendMessage(
|
|
815
815
|
jid,
|
|
816
816
|
{
|
|
817
817
|
payment: {
|
|
@@ -833,7 +833,7 @@ await sanka.sendMessage(
|
|
|
833
833
|
|
|
834
834
|
#### Payment Invite Message
|
|
835
835
|
```ts
|
|
836
|
-
await
|
|
836
|
+
await indra.sendMessage(
|
|
837
837
|
id,
|
|
838
838
|
{
|
|
839
839
|
paymentInvite: {
|
|
@@ -846,7 +846,7 @@ await sanka.sendMessage(
|
|
|
846
846
|
|
|
847
847
|
### Admin Invite Message
|
|
848
848
|
```ts
|
|
849
|
-
await
|
|
849
|
+
await indra.sendMessage(
|
|
850
850
|
jid,
|
|
851
851
|
{
|
|
852
852
|
adminInvite: {
|
|
@@ -862,7 +862,7 @@ await sanka.sendMessage(
|
|
|
862
862
|
|
|
863
863
|
### Group Invite Message
|
|
864
864
|
```ts
|
|
865
|
-
await
|
|
865
|
+
await indra.sendMessage(
|
|
866
866
|
jid,
|
|
867
867
|
{
|
|
868
868
|
groupInvite: {
|
|
@@ -879,7 +879,7 @@ await sanka.sendMessage(
|
|
|
879
879
|
|
|
880
880
|
### Share Phone Number Message
|
|
881
881
|
```ts
|
|
882
|
-
await
|
|
882
|
+
await indra.sendMessage(
|
|
883
883
|
jid,
|
|
884
884
|
{
|
|
885
885
|
sharePhoneNumber: {
|
|
@@ -890,7 +890,7 @@ await sanka.sendMessage(
|
|
|
890
890
|
|
|
891
891
|
### Request Phone Number Message
|
|
892
892
|
```ts
|
|
893
|
-
await
|
|
893
|
+
await indra.sendMessage(
|
|
894
894
|
jid,
|
|
895
895
|
{
|
|
896
896
|
requestPhoneNumber: {
|
|
@@ -902,7 +902,7 @@ await sanka.sendMessage(
|
|
|
902
902
|
### Buttons Reply Message
|
|
903
903
|
```ts
|
|
904
904
|
// List
|
|
905
|
-
await
|
|
905
|
+
await indra.sendMessage(
|
|
906
906
|
jid,
|
|
907
907
|
{
|
|
908
908
|
buttonReply: {
|
|
@@ -914,7 +914,7 @@ await sanka.sendMessage(
|
|
|
914
914
|
}
|
|
915
915
|
)
|
|
916
916
|
// Plain
|
|
917
|
-
await
|
|
917
|
+
await indra.sendMessage(
|
|
918
918
|
jid,
|
|
919
919
|
{
|
|
920
920
|
buttonReply: {
|
|
@@ -926,7 +926,7 @@ await sanka.sendMessage(
|
|
|
926
926
|
)
|
|
927
927
|
|
|
928
928
|
// Template
|
|
929
|
-
await
|
|
929
|
+
await indra.sendMessage(
|
|
930
930
|
jid,
|
|
931
931
|
{
|
|
932
932
|
buttonReply: {
|
|
@@ -939,7 +939,7 @@ await sanka.sendMessage(
|
|
|
939
939
|
)
|
|
940
940
|
|
|
941
941
|
// Interactive
|
|
942
|
-
await
|
|
942
|
+
await indra.sendMessage(
|
|
943
943
|
jid,
|
|
944
944
|
{
|
|
945
945
|
buttonReply: {
|
|
@@ -957,7 +957,7 @@ await sanka.sendMessage(
|
|
|
957
957
|
|
|
958
958
|
### Buttons Message
|
|
959
959
|
```ts
|
|
960
|
-
await
|
|
960
|
+
await indra.sendMessage(
|
|
961
961
|
jid,
|
|
962
962
|
{
|
|
963
963
|
text: 'This is a button message!', // image: buffer or // image: { url: url } If you want to use images
|
|
@@ -988,7 +988,7 @@ await sanka.sendMessage(
|
|
|
988
988
|
### Buttons List Message
|
|
989
989
|
```ts
|
|
990
990
|
// Just working in a private chat
|
|
991
|
-
await
|
|
991
|
+
await indra.sendMessage(
|
|
992
992
|
jid,
|
|
993
993
|
{
|
|
994
994
|
text: 'This is a list!',
|
|
@@ -1027,7 +1027,7 @@ await sanka.sendMessage(
|
|
|
1027
1027
|
### Buttons Product List Message
|
|
1028
1028
|
```ts
|
|
1029
1029
|
// Just working in a private chat
|
|
1030
|
-
await
|
|
1030
|
+
await indra.sendMessage(
|
|
1031
1031
|
jid,
|
|
1032
1032
|
{
|
|
1033
1033
|
text: 'This is a list!',
|
|
@@ -1053,7 +1053,7 @@ await sanka.sendMessage(
|
|
|
1053
1053
|
|
|
1054
1054
|
### Buttons Cards Message
|
|
1055
1055
|
```ts
|
|
1056
|
-
await
|
|
1056
|
+
await indra.sendMessage(
|
|
1057
1057
|
jid,
|
|
1058
1058
|
{
|
|
1059
1059
|
text: 'Body Message',
|
|
@@ -1112,7 +1112,7 @@ await sanka.sendMessage(
|
|
|
1112
1112
|
|
|
1113
1113
|
### Buttons Template Message
|
|
1114
1114
|
```ts
|
|
1115
|
-
await
|
|
1115
|
+
await indra.sendMessage(
|
|
1116
1116
|
jid,
|
|
1117
1117
|
{
|
|
1118
1118
|
text: 'This is a template message!',
|
|
@@ -1144,7 +1144,7 @@ await sanka.sendMessage(
|
|
|
1144
1144
|
|
|
1145
1145
|
### Buttons Interactive Message
|
|
1146
1146
|
```ts
|
|
1147
|
-
await
|
|
1147
|
+
await indra.sendMessage(
|
|
1148
1148
|
jid,
|
|
1149
1149
|
{
|
|
1150
1150
|
text: 'This is an Interactive message!',
|
|
@@ -1296,7 +1296,7 @@ await sanka.sendMessage(
|
|
|
1296
1296
|
)
|
|
1297
1297
|
|
|
1298
1298
|
// If you want to use an image
|
|
1299
|
-
await
|
|
1299
|
+
await indra.sendMessage(
|
|
1300
1300
|
jid,
|
|
1301
1301
|
{
|
|
1302
1302
|
image: {
|
|
@@ -1320,7 +1320,7 @@ await sanka.sendMessage(
|
|
|
1320
1320
|
)
|
|
1321
1321
|
|
|
1322
1322
|
// If you want to use an video
|
|
1323
|
-
await
|
|
1323
|
+
await indra.sendMessage(
|
|
1324
1324
|
jid,
|
|
1325
1325
|
{
|
|
1326
1326
|
video: {
|
|
@@ -1344,14 +1344,14 @@ await sanka.sendMessage(
|
|
|
1344
1344
|
)
|
|
1345
1345
|
|
|
1346
1346
|
// If you want to use an document
|
|
1347
|
-
await
|
|
1347
|
+
await indra.sendMessage(
|
|
1348
1348
|
jid,
|
|
1349
1349
|
{
|
|
1350
1350
|
document: {
|
|
1351
1351
|
url: 'https://example.jpg'
|
|
1352
1352
|
},
|
|
1353
1353
|
mimetype: 'image/jpeg',
|
|
1354
|
-
jpegThumbnail: await
|
|
1354
|
+
jpegThumbnail: await indra.resize('https://example.jpg', 320, 320),
|
|
1355
1355
|
caption: 'Body',
|
|
1356
1356
|
title: 'Title',
|
|
1357
1357
|
subtitle: 'Subtitle',
|
|
@@ -1370,7 +1370,7 @@ await sanka.sendMessage(
|
|
|
1370
1370
|
)
|
|
1371
1371
|
|
|
1372
1372
|
// If you want to use an location
|
|
1373
|
-
await
|
|
1373
|
+
await indra.sendMessage(
|
|
1374
1374
|
jid,
|
|
1375
1375
|
{
|
|
1376
1376
|
location: {
|
|
@@ -1396,7 +1396,7 @@ await sanka.sendMessage(
|
|
|
1396
1396
|
)
|
|
1397
1397
|
|
|
1398
1398
|
// if you want to use an product
|
|
1399
|
-
await
|
|
1399
|
+
await indra.sendMessage(
|
|
1400
1400
|
jid,
|
|
1401
1401
|
{
|
|
1402
1402
|
product: {
|
|
@@ -1433,7 +1433,7 @@ await sanka.sendMessage(
|
|
|
1433
1433
|
|
|
1434
1434
|
### Buttons Interactive Message PIX
|
|
1435
1435
|
```ts
|
|
1436
|
-
await
|
|
1436
|
+
await indra.sendMessage(
|
|
1437
1437
|
jid,
|
|
1438
1438
|
{
|
|
1439
1439
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1458,7 +1458,7 @@ await sanka.sendMessage(
|
|
|
1458
1458
|
|
|
1459
1459
|
### Buttons Interactive Message PAY
|
|
1460
1460
|
```ts
|
|
1461
|
-
await
|
|
1461
|
+
await indra.sendMessage(
|
|
1462
1462
|
jid,
|
|
1463
1463
|
{
|
|
1464
1464
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1508,7 +1508,7 @@ await sanka.sendMessage(
|
|
|
1508
1508
|
|
|
1509
1509
|
### Status Mentions Message
|
|
1510
1510
|
```ts
|
|
1511
|
-
await
|
|
1511
|
+
await indra.sendStatusMentions(
|
|
1512
1512
|
jid,
|
|
1513
1513
|
{
|
|
1514
1514
|
image: {
|
|
@@ -1521,7 +1521,7 @@ await sanka.sendStatusMentions(
|
|
|
1521
1521
|
|
|
1522
1522
|
### Send Album Message
|
|
1523
1523
|
```ts
|
|
1524
|
-
await
|
|
1524
|
+
await indra.sendAlbumMessage(
|
|
1525
1525
|
jid,
|
|
1526
1526
|
[
|
|
1527
1527
|
{
|
|
@@ -1549,7 +1549,7 @@ await sanka.sendAlbumMessage(
|
|
|
1549
1549
|
```
|
|
1550
1550
|
### Shop Message
|
|
1551
1551
|
```ts
|
|
1552
|
-
await
|
|
1552
|
+
await indra.sendMessage(
|
|
1553
1553
|
jid,
|
|
1554
1554
|
{
|
|
1555
1555
|
text: 'Body',
|
|
@@ -1565,7 +1565,7 @@ await sanka.sendMessage(
|
|
|
1565
1565
|
)
|
|
1566
1566
|
|
|
1567
1567
|
// Image
|
|
1568
|
-
await
|
|
1568
|
+
await indra.sendMessage(
|
|
1569
1569
|
jid,
|
|
1570
1570
|
{
|
|
1571
1571
|
image: {
|
|
@@ -1585,7 +1585,7 @@ await sanka.sendMessage(
|
|
|
1585
1585
|
)
|
|
1586
1586
|
|
|
1587
1587
|
// Video
|
|
1588
|
-
await
|
|
1588
|
+
await indra.sendMessage(
|
|
1589
1589
|
jid,
|
|
1590
1590
|
{
|
|
1591
1591
|
video: {
|
|
@@ -1605,14 +1605,14 @@ await sanka.sendMessage(
|
|
|
1605
1605
|
)
|
|
1606
1606
|
|
|
1607
1607
|
// Document
|
|
1608
|
-
await
|
|
1608
|
+
await indra.sendMessage(
|
|
1609
1609
|
jid,
|
|
1610
1610
|
{
|
|
1611
1611
|
document: {
|
|
1612
1612
|
url: 'https://example.jpg'
|
|
1613
1613
|
},
|
|
1614
1614
|
mimetype: 'image/jpeg',
|
|
1615
|
-
jpegThumbnail: await
|
|
1615
|
+
jpegThumbnail: await indra.resize('https://example.jpg', 320, 320),
|
|
1616
1616
|
caption: 'Body',
|
|
1617
1617
|
title: 'Title',
|
|
1618
1618
|
subtitle: 'Subtitle',
|
|
@@ -1627,7 +1627,7 @@ await sanka.sendMessage(
|
|
|
1627
1627
|
)
|
|
1628
1628
|
|
|
1629
1629
|
// Location
|
|
1630
|
-
await
|
|
1630
|
+
await indra.sendMessage(
|
|
1631
1631
|
jid,
|
|
1632
1632
|
{
|
|
1633
1633
|
location: {
|
|
@@ -1649,7 +1649,7 @@ await sanka.sendMessage(
|
|
|
1649
1649
|
)
|
|
1650
1650
|
|
|
1651
1651
|
// Product
|
|
1652
|
-
await
|
|
1652
|
+
await indra.sendMessage(
|
|
1653
1653
|
jid,
|
|
1654
1654
|
{
|
|
1655
1655
|
product: {
|
|
@@ -1681,7 +1681,7 @@ await sanka.sendMessage(
|
|
|
1681
1681
|
```
|
|
1682
1682
|
### Collection Message
|
|
1683
1683
|
```ts
|
|
1684
|
-
await
|
|
1684
|
+
await indra.sendMessage(
|
|
1685
1685
|
jid,
|
|
1686
1686
|
{
|
|
1687
1687
|
text: 'Body',
|
|
@@ -1698,7 +1698,7 @@ await sanka.sendMessage(
|
|
|
1698
1698
|
)
|
|
1699
1699
|
|
|
1700
1700
|
// Image
|
|
1701
|
-
await
|
|
1701
|
+
await indra.sendMessage(
|
|
1702
1702
|
jid,
|
|
1703
1703
|
{
|
|
1704
1704
|
image: {
|
|
@@ -1719,7 +1719,7 @@ await sanka.sendMessage(
|
|
|
1719
1719
|
)
|
|
1720
1720
|
|
|
1721
1721
|
// Video
|
|
1722
|
-
await
|
|
1722
|
+
await indra.sendMessage(
|
|
1723
1723
|
jid,
|
|
1724
1724
|
{
|
|
1725
1725
|
video: {
|
|
@@ -1740,14 +1740,14 @@ await sanka.sendMessage(
|
|
|
1740
1740
|
)
|
|
1741
1741
|
|
|
1742
1742
|
// Document
|
|
1743
|
-
await
|
|
1743
|
+
await indra.sendMessage(
|
|
1744
1744
|
jid,
|
|
1745
1745
|
{
|
|
1746
1746
|
document: {
|
|
1747
1747
|
url: 'https://example.jpg'
|
|
1748
1748
|
},
|
|
1749
1749
|
mimetype: 'image/jpeg',
|
|
1750
|
-
jpegThumbnail: await
|
|
1750
|
+
jpegThumbnail: await indra.resize('https://example.jpg', 320, 320),
|
|
1751
1751
|
caption: 'Body',
|
|
1752
1752
|
title: 'Title',
|
|
1753
1753
|
subtitle: 'Subtitle',
|
|
@@ -1763,7 +1763,7 @@ await sanka.sendMessage(
|
|
|
1763
1763
|
)
|
|
1764
1764
|
|
|
1765
1765
|
// Location
|
|
1766
|
-
await
|
|
1766
|
+
await indra.sendMessage(
|
|
1767
1767
|
jid,
|
|
1768
1768
|
{
|
|
1769
1769
|
location: {
|
|
@@ -1786,7 +1786,7 @@ await sanka.sendMessage(
|
|
|
1786
1786
|
)
|
|
1787
1787
|
|
|
1788
1788
|
// Product
|
|
1789
|
-
await
|
|
1789
|
+
await indra.sendMessage(
|
|
1790
1790
|
jid,
|
|
1791
1791
|
{
|
|
1792
1792
|
product: {
|
|
@@ -1825,7 +1825,7 @@ await sanka.sendMessage(
|
|
|
1825
1825
|
3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
|
|
1826
1826
|
4. Send a link:
|
|
1827
1827
|
```ts
|
|
1828
|
-
await
|
|
1828
|
+
await indra.sendMessage(
|
|
1829
1829
|
jid,
|
|
1830
1830
|
{
|
|
1831
1831
|
text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
|
|
@@ -1848,7 +1848,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
1848
1848
|
#### Gif Message
|
|
1849
1849
|
- Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
|
|
1850
1850
|
```ts
|
|
1851
|
-
await
|
|
1851
|
+
await indra.sendMessage(
|
|
1852
1852
|
jid,
|
|
1853
1853
|
{
|
|
1854
1854
|
video: fs.readFileSync('Media/ma_gif.mp4'),
|
|
@@ -1860,7 +1860,7 @@ await sanka.sendMessage(
|
|
|
1860
1860
|
|
|
1861
1861
|
#### Video Message
|
|
1862
1862
|
```ts
|
|
1863
|
-
await
|
|
1863
|
+
await indra.sendMessage(
|
|
1864
1864
|
id,
|
|
1865
1865
|
{
|
|
1866
1866
|
video: {
|
|
@@ -1873,7 +1873,7 @@ await sanka.sendMessage(
|
|
|
1873
1873
|
|
|
1874
1874
|
#### Video Ptv Message
|
|
1875
1875
|
```ts
|
|
1876
|
-
await
|
|
1876
|
+
await indra.sendMessage(
|
|
1877
1877
|
id,
|
|
1878
1878
|
{
|
|
1879
1879
|
video: {
|
|
@@ -1897,7 +1897,7 @@ await sanka.sendMessage(
|
|
|
1897
1897
|
ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
|
|
1898
1898
|
```
|
|
1899
1899
|
```ts
|
|
1900
|
-
await
|
|
1900
|
+
await indra.sendMessage(
|
|
1901
1901
|
jid,
|
|
1902
1902
|
{
|
|
1903
1903
|
audio: {
|
|
@@ -1910,7 +1910,7 @@ await sanka.sendMessage(
|
|
|
1910
1910
|
|
|
1911
1911
|
#### Image Message
|
|
1912
1912
|
```ts
|
|
1913
|
-
await
|
|
1913
|
+
await indra.sendMessage(
|
|
1914
1914
|
id,
|
|
1915
1915
|
{
|
|
1916
1916
|
image: {
|
|
@@ -1926,7 +1926,7 @@ await sanka.sendMessage(
|
|
|
1926
1926
|
- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
|
|
1927
1927
|
|
|
1928
1928
|
```ts
|
|
1929
|
-
await
|
|
1929
|
+
await indra.sendMessage(
|
|
1930
1930
|
id,
|
|
1931
1931
|
{
|
|
1932
1932
|
image: {
|
|
@@ -1943,8 +1943,8 @@ await sanka.sendMessage(
|
|
|
1943
1943
|
### Deleting Messages (for everyone)
|
|
1944
1944
|
|
|
1945
1945
|
```ts
|
|
1946
|
-
const msg = await
|
|
1947
|
-
await
|
|
1946
|
+
const msg = await indra.sendMessage(jid, { text: 'hello word' })
|
|
1947
|
+
await indra.sendMessage(jid, { delete: msg.key })
|
|
1948
1948
|
```
|
|
1949
1949
|
|
|
1950
1950
|
**Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
|
|
@@ -1953,7 +1953,7 @@ await sanka.sendMessage(jid, { delete: msg.key })
|
|
|
1953
1953
|
|
|
1954
1954
|
- You can pass all editable contents here
|
|
1955
1955
|
```ts
|
|
1956
|
-
await
|
|
1956
|
+
await indra.sendMessage(jid, {
|
|
1957
1957
|
text: 'updated text goes here',
|
|
1958
1958
|
edit: response.key,
|
|
1959
1959
|
})
|
|
@@ -1970,9 +1970,9 @@ await sanka.sendMessage(jid, {
|
|
|
1970
1970
|
If you want to save the media you received
|
|
1971
1971
|
```ts
|
|
1972
1972
|
import { createWriteStream } from 'fs'
|
|
1973
|
-
import { downloadMediaMessage, getContentType } from '
|
|
1973
|
+
import { downloadMediaMessage, getContentType } from 'Dcodeindra-Baileyspro'
|
|
1974
1974
|
|
|
1975
|
-
|
|
1975
|
+
indra.ev.on('messages.upsert', async ({ [m] }) => {
|
|
1976
1976
|
if (!m.message) return // if there is no text or media message
|
|
1977
1977
|
const messageType = getContentType(m) // get what type of message it is (text, image, video...)
|
|
1978
1978
|
|
|
@@ -1987,7 +1987,7 @@ sanka.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
1987
1987
|
logger,
|
|
1988
1988
|
// pass this so that baileys can request a reupload of media
|
|
1989
1989
|
// that has been deleted
|
|
1990
|
-
reuploadRequest:
|
|
1990
|
+
reuploadRequest: indra.updateMediaMessage
|
|
1991
1991
|
}
|
|
1992
1992
|
)
|
|
1993
1993
|
// save to file
|
|
@@ -2001,7 +2001,7 @@ sanka.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
2001
2001
|
|
|
2002
2002
|
- 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:
|
|
2003
2003
|
```ts
|
|
2004
|
-
await
|
|
2004
|
+
await indra.updateMediaMessage(msg)
|
|
2005
2005
|
```
|
|
2006
2006
|
|
|
2007
2007
|
## Reject Call
|
|
@@ -2009,7 +2009,7 @@ await sanka.updateMediaMessage(msg)
|
|
|
2009
2009
|
- You can obtain `callId` and `callFrom` from `call` event
|
|
2010
2010
|
|
|
2011
2011
|
```ts
|
|
2012
|
-
await
|
|
2012
|
+
await indra.rejectCall(callId, callFrom)
|
|
2013
2013
|
```
|
|
2014
2014
|
|
|
2015
2015
|
## Send States in Chat
|
|
@@ -2022,7 +2022,7 @@ This means you have to keep track of unread messages.
|
|
|
2022
2022
|
```ts
|
|
2023
2023
|
const key: WAMessageKey
|
|
2024
2024
|
// can pass multiple keys to read multiple messages as well
|
|
2025
|
-
await
|
|
2025
|
+
await indra.readMessages([key])
|
|
2026
2026
|
```
|
|
2027
2027
|
|
|
2028
2028
|
The message ID is the unique identifier of the message that you are marking as read.
|
|
@@ -2035,11 +2035,11 @@ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.k
|
|
|
2035
2035
|
- This lets the person/group with `jid` know whether you're online, offline, typing etc.
|
|
2036
2036
|
|
|
2037
2037
|
```ts
|
|
2038
|
-
await
|
|
2038
|
+
await indra.sendPresenceUpdate('available', jid)
|
|
2039
2039
|
```
|
|
2040
2040
|
|
|
2041
2041
|
> [!NOTE]
|
|
2042
|
-
> If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `
|
|
2042
|
+
> If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `indra.sendPresenceUpdate('unavailable')`
|
|
2043
2043
|
|
|
2044
2044
|
## Modifying Chats
|
|
2045
2045
|
|
|
@@ -2051,7 +2051,7 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
|
|
|
2051
2051
|
### Archive a Chat
|
|
2052
2052
|
```ts
|
|
2053
2053
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2054
|
-
await
|
|
2054
|
+
await indra.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
2055
2055
|
```
|
|
2056
2056
|
### Mute/Unmute a Chat
|
|
2057
2057
|
|
|
@@ -2065,20 +2065,20 @@ await sanka.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
|
2065
2065
|
|
|
2066
2066
|
```ts
|
|
2067
2067
|
// mute for 8 hours
|
|
2068
|
-
await
|
|
2068
|
+
await indra.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
2069
2069
|
// unmute
|
|
2070
|
-
await
|
|
2070
|
+
await indra.chatModify({ mute: null }, jid)
|
|
2071
2071
|
```
|
|
2072
2072
|
### Mark a Chat Read/Unread
|
|
2073
2073
|
```ts
|
|
2074
2074
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2075
2075
|
// mark it unread
|
|
2076
|
-
await
|
|
2076
|
+
await indra.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
|
|
2077
2077
|
```
|
|
2078
2078
|
|
|
2079
2079
|
### Delete a Message for Me
|
|
2080
2080
|
```ts
|
|
2081
|
-
await
|
|
2081
|
+
await indra.chatModify(
|
|
2082
2082
|
{
|
|
2083
2083
|
clear: {
|
|
2084
2084
|
messages: [
|
|
@@ -2097,7 +2097,7 @@ await sanka.chatModify(
|
|
|
2097
2097
|
### Delete a Chat
|
|
2098
2098
|
```ts
|
|
2099
2099
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2100
|
-
await
|
|
2100
|
+
await indra.chatModify({
|
|
2101
2101
|
delete: true,
|
|
2102
2102
|
lastMessages: [
|
|
2103
2103
|
{
|
|
@@ -2111,7 +2111,7 @@ await sanka.chatModify({
|
|
|
2111
2111
|
```
|
|
2112
2112
|
### Pin/Unpin a Chat
|
|
2113
2113
|
```ts
|
|
2114
|
-
await
|
|
2114
|
+
await indra.chatModify({
|
|
2115
2115
|
pin: true // or `false` to unpin
|
|
2116
2116
|
},
|
|
2117
2117
|
jid
|
|
@@ -2119,7 +2119,7 @@ await sanka.chatModify({
|
|
|
2119
2119
|
```
|
|
2120
2120
|
### Star/Unstar a Message
|
|
2121
2121
|
```ts
|
|
2122
|
-
await
|
|
2122
|
+
await indra.chatModify({
|
|
2123
2123
|
star: {
|
|
2124
2124
|
messages: [
|
|
2125
2125
|
{
|
|
@@ -2149,17 +2149,17 @@ await sanka.chatModify({
|
|
|
2149
2149
|
|
|
2150
2150
|
```ts
|
|
2151
2151
|
// turn on disappearing messages
|
|
2152
|
-
await
|
|
2152
|
+
await indra.sendMessage(
|
|
2153
2153
|
jid,
|
|
2154
2154
|
// this is 1 week in seconds -- how long you want messages to appear for
|
|
2155
2155
|
{ disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
|
|
2156
2156
|
)
|
|
2157
2157
|
|
|
2158
2158
|
// will send as a disappearing message
|
|
2159
|
-
await
|
|
2159
|
+
await indra.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
|
|
2160
2160
|
|
|
2161
2161
|
// turn off disappearing messages
|
|
2162
|
-
await
|
|
2162
|
+
await indra.sendMessage(
|
|
2163
2163
|
jid,
|
|
2164
2164
|
{ disappearingMessagesInChat: false }
|
|
2165
2165
|
)
|
|
@@ -2167,14 +2167,14 @@ await sanka.sendMessage(
|
|
|
2167
2167
|
|
|
2168
2168
|
### Clear Messages
|
|
2169
2169
|
```ts
|
|
2170
|
-
await
|
|
2170
|
+
await indra.clearMessage(jid, key, timestamps)
|
|
2171
2171
|
```
|
|
2172
2172
|
|
|
2173
2173
|
## User Querys
|
|
2174
2174
|
|
|
2175
2175
|
### Check If ID Exists in Whatsapp
|
|
2176
2176
|
```ts
|
|
2177
|
-
const [result] = await
|
|
2177
|
+
const [result] = await indra.onWhatsApp(jid)
|
|
2178
2178
|
if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
|
|
2179
2179
|
```
|
|
2180
2180
|
|
|
@@ -2183,7 +2183,7 @@ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid
|
|
|
2183
2183
|
- You need to have oldest message in chat
|
|
2184
2184
|
```ts
|
|
2185
2185
|
const msg = await getOldestMessageInChat(jid)
|
|
2186
|
-
await
|
|
2186
|
+
await indra.fetchMessageHistory(
|
|
2187
2187
|
50, //quantity (max: 50 per query)
|
|
2188
2188
|
msg.key,
|
|
2189
2189
|
msg.messageTimestamp
|
|
@@ -2193,7 +2193,7 @@ await sanka.fetchMessageHistory(
|
|
|
2193
2193
|
|
|
2194
2194
|
### Fetch Status
|
|
2195
2195
|
```ts
|
|
2196
|
-
const status = await
|
|
2196
|
+
const status = await indra.fetchStatus(jid)
|
|
2197
2197
|
console.log('status: ' + status)
|
|
2198
2198
|
```
|
|
2199
2199
|
|
|
@@ -2201,34 +2201,34 @@ console.log('status: ' + status)
|
|
|
2201
2201
|
- To get the display picture of some person, group and channel
|
|
2202
2202
|
```ts
|
|
2203
2203
|
// for low res picture
|
|
2204
|
-
const ppUrl = await
|
|
2204
|
+
const ppUrl = await indra.profilePictureUrl(jid)
|
|
2205
2205
|
console.log(ppUrl)
|
|
2206
2206
|
```
|
|
2207
2207
|
|
|
2208
2208
|
### Fetch Bussines Profile (such as description or category)
|
|
2209
2209
|
```ts
|
|
2210
|
-
const profile = await
|
|
2210
|
+
const profile = await indra.getBusinessProfile(jid)
|
|
2211
2211
|
console.log('business description: ' + profile.description + ', category: ' + profile.category)
|
|
2212
2212
|
```
|
|
2213
2213
|
|
|
2214
2214
|
### Fetch Someone's Presence (if they're typing or online)
|
|
2215
2215
|
```ts
|
|
2216
2216
|
// the presence update is fetched and called here
|
|
2217
|
-
|
|
2217
|
+
indra.ev.on('presence.update', console.log)
|
|
2218
2218
|
|
|
2219
2219
|
// request updates for a chat
|
|
2220
|
-
await
|
|
2220
|
+
await indra.presenceSubscribe(jid)
|
|
2221
2221
|
```
|
|
2222
2222
|
|
|
2223
2223
|
## Change Profile
|
|
2224
2224
|
|
|
2225
2225
|
### Change Profile Status
|
|
2226
2226
|
```ts
|
|
2227
|
-
await
|
|
2227
|
+
await indra.updateProfileStatus('Hello World!')
|
|
2228
2228
|
```
|
|
2229
2229
|
### Change Profile Name
|
|
2230
2230
|
```ts
|
|
2231
|
-
await
|
|
2231
|
+
await indra.updateProfileName('My name')
|
|
2232
2232
|
```
|
|
2233
2233
|
### Change Display Picture (groups too)
|
|
2234
2234
|
- To change your display picture or a group's
|
|
@@ -2237,11 +2237,11 @@ await sanka.updateProfileName('My name')
|
|
|
2237
2237
|
> Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
|
|
2238
2238
|
|
|
2239
2239
|
```ts
|
|
2240
|
-
await
|
|
2240
|
+
await indra.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
|
2241
2241
|
```
|
|
2242
2242
|
### Remove display picture (groups too)
|
|
2243
2243
|
```ts
|
|
2244
|
-
await
|
|
2244
|
+
await indra.removeProfilePicture(jid)
|
|
2245
2245
|
```
|
|
2246
2246
|
|
|
2247
2247
|
## Groups
|
|
@@ -2251,14 +2251,14 @@ await sanka.removeProfilePicture(jid)
|
|
|
2251
2251
|
### Create a Group
|
|
2252
2252
|
```ts
|
|
2253
2253
|
// title & participants
|
|
2254
|
-
const group = await
|
|
2254
|
+
const group = await indra.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
|
|
2255
2255
|
console.log('created group with id: ' + group.gid)
|
|
2256
|
-
await
|
|
2256
|
+
await indra.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
|
|
2257
2257
|
```
|
|
2258
2258
|
### Add/Remove or Demote/Promote
|
|
2259
2259
|
```ts
|
|
2260
2260
|
// id & people to add to the group (will throw error if it fails)
|
|
2261
|
-
await
|
|
2261
|
+
await indra.groupParticipantsUpdate(
|
|
2262
2262
|
jid,
|
|
2263
2263
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2264
2264
|
'add' // replace this parameter with 'remove' or 'demote' or 'promote'
|
|
@@ -2266,68 +2266,68 @@ await sanka.groupParticipantsUpdate(
|
|
|
2266
2266
|
```
|
|
2267
2267
|
### Change Subject (name)
|
|
2268
2268
|
```ts
|
|
2269
|
-
await
|
|
2269
|
+
await indra.groupUpdateSubject(jid, 'New Subject!')
|
|
2270
2270
|
```
|
|
2271
2271
|
### Change Description
|
|
2272
2272
|
```ts
|
|
2273
|
-
await
|
|
2273
|
+
await indra.groupUpdateDescription(jid, 'New Description!')
|
|
2274
2274
|
```
|
|
2275
2275
|
### Change Settings
|
|
2276
2276
|
```ts
|
|
2277
2277
|
// only allow admins to send messages
|
|
2278
|
-
await
|
|
2278
|
+
await indra.groupSettingUpdate(jid, 'announcement')
|
|
2279
2279
|
// allow everyone to send messages
|
|
2280
|
-
await
|
|
2280
|
+
await indra.groupSettingUpdate(jid, 'not_announcement')
|
|
2281
2281
|
// allow everyone to modify the group's settings -- like display picture etc.
|
|
2282
|
-
await
|
|
2282
|
+
await indra.groupSettingUpdate(jid, 'unlocked')
|
|
2283
2283
|
// only allow admins to modify the group's settings
|
|
2284
|
-
await
|
|
2284
|
+
await indra.groupSettingUpdate(jid, 'locked')
|
|
2285
2285
|
```
|
|
2286
2286
|
### Leave a Group
|
|
2287
2287
|
```ts
|
|
2288
2288
|
// will throw error if it fails
|
|
2289
|
-
await
|
|
2289
|
+
await indra.groupLeave(jid)
|
|
2290
2290
|
```
|
|
2291
2291
|
### Get Invite Code
|
|
2292
2292
|
- To create link with code use `'https://chat.whatsapp.com/' + code`
|
|
2293
2293
|
```ts
|
|
2294
|
-
const code = await
|
|
2294
|
+
const code = await indra.groupInviteCode(jid)
|
|
2295
2295
|
console.log('group code: ' + code)
|
|
2296
2296
|
```
|
|
2297
2297
|
### Revoke Invite Code
|
|
2298
2298
|
```ts
|
|
2299
|
-
const code = await
|
|
2299
|
+
const code = await indra.groupRevokeInvite(jid)
|
|
2300
2300
|
console.log('New group code: ' + code)
|
|
2301
2301
|
```
|
|
2302
2302
|
### Join Using Invitation Code
|
|
2303
2303
|
- Code can't have `https://chat.whatsapp.com/`, only code
|
|
2304
2304
|
```ts
|
|
2305
|
-
const response = await
|
|
2305
|
+
const response = await indra.groupAcceptInvite(code)
|
|
2306
2306
|
console.log('joined to: ' + response)
|
|
2307
2307
|
```
|
|
2308
2308
|
### Get Group Info by Invite Code
|
|
2309
2309
|
```ts
|
|
2310
|
-
const response = await
|
|
2310
|
+
const response = await indra.groupGetInviteInfo(code)
|
|
2311
2311
|
console.log('group information: ' + response)
|
|
2312
2312
|
```
|
|
2313
2313
|
### Query Metadata (participants, name, description...)
|
|
2314
2314
|
```ts
|
|
2315
|
-
const metadata = await
|
|
2315
|
+
const metadata = await indra.groupMetadata(jid)
|
|
2316
2316
|
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
|
|
2317
2317
|
```
|
|
2318
2318
|
### Join using `groupInviteMessage`
|
|
2319
2319
|
```ts
|
|
2320
|
-
const response = await
|
|
2320
|
+
const response = await indra.groupAcceptInviteV4(jid, groupInviteMessage)
|
|
2321
2321
|
console.log('joined to: ' + response)
|
|
2322
2322
|
```
|
|
2323
2323
|
### Get Request Join List
|
|
2324
2324
|
```ts
|
|
2325
|
-
const response = await
|
|
2325
|
+
const response = await indra.groupRequestParticipantsList(jid)
|
|
2326
2326
|
console.log(response)
|
|
2327
2327
|
```
|
|
2328
2328
|
### Approve/Reject Request Join
|
|
2329
2329
|
```ts
|
|
2330
|
-
const response = await
|
|
2330
|
+
const response = await indra.groupRequestParticipantsUpdate(
|
|
2331
2331
|
jid, // group id
|
|
2332
2332
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2333
2333
|
'approve' // or 'reject'
|
|
@@ -2336,7 +2336,7 @@ console.log(response)
|
|
|
2336
2336
|
```
|
|
2337
2337
|
### Get All Participating Groups Metadata
|
|
2338
2338
|
```ts
|
|
2339
|
-
const response = await
|
|
2339
|
+
const response = await indra.groupFetchAllParticipating()
|
|
2340
2340
|
console.log(response)
|
|
2341
2341
|
```
|
|
2342
2342
|
### Toggle Ephemeral
|
|
@@ -2351,12 +2351,12 @@ console.log(response)
|
|
|
2351
2351
|
| 90d | 7.776.000 |
|
|
2352
2352
|
|
|
2353
2353
|
```ts
|
|
2354
|
-
await
|
|
2354
|
+
await indra.groupToggleEphemeral(jid, 86400)
|
|
2355
2355
|
```
|
|
2356
2356
|
|
|
2357
2357
|
### Change Add Mode
|
|
2358
2358
|
```ts
|
|
2359
|
-
await
|
|
2359
|
+
await indra.groupMemberAddMode(
|
|
2360
2360
|
jid,
|
|
2361
2361
|
'all_member_add' // or 'admin_add'
|
|
2362
2362
|
)
|
|
@@ -2366,48 +2366,48 @@ await sanka.groupMemberAddMode(
|
|
|
2366
2366
|
|
|
2367
2367
|
### Block/Unblock User
|
|
2368
2368
|
```ts
|
|
2369
|
-
await
|
|
2370
|
-
await
|
|
2369
|
+
await indra.updateBlockStatus(jid, 'block') // Block user
|
|
2370
|
+
await indra.updateBlockStatus(jid, 'unblock') // Unblock user
|
|
2371
2371
|
```
|
|
2372
2372
|
### Get Privacy Settings
|
|
2373
2373
|
```ts
|
|
2374
|
-
const privacySettings = await
|
|
2374
|
+
const privacySettings = await indra.fetchPrivacySettings(true)
|
|
2375
2375
|
console.log('privacy settings: ' + privacySettings)
|
|
2376
2376
|
```
|
|
2377
2377
|
### Get BlockList
|
|
2378
2378
|
```ts
|
|
2379
|
-
const response = await
|
|
2379
|
+
const response = await indra.fetchBlocklist()
|
|
2380
2380
|
console.log(response)
|
|
2381
2381
|
```
|
|
2382
2382
|
### Update LastSeen Privacy
|
|
2383
2383
|
```ts
|
|
2384
2384
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2385
|
-
await
|
|
2385
|
+
await indra.updateLastSeenPrivacy(value)
|
|
2386
2386
|
```
|
|
2387
2387
|
### Update Online Privacy
|
|
2388
2388
|
```ts
|
|
2389
2389
|
const value = 'all' // 'match_last_seen'
|
|
2390
|
-
await
|
|
2390
|
+
await indra.updateOnlinePrivacy(value)
|
|
2391
2391
|
```
|
|
2392
2392
|
### Update Profile Picture Privacy
|
|
2393
2393
|
```ts
|
|
2394
2394
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2395
|
-
await
|
|
2395
|
+
await indra.updateProfilePicturePrivacy(value)
|
|
2396
2396
|
```
|
|
2397
2397
|
### Update Status Privacy
|
|
2398
2398
|
```ts
|
|
2399
2399
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2400
|
-
await
|
|
2400
|
+
await indra.updateStatusPrivacy(value)
|
|
2401
2401
|
```
|
|
2402
2402
|
### Update Read Receipts Privacy
|
|
2403
2403
|
```ts
|
|
2404
2404
|
const value = 'all' // 'none'
|
|
2405
|
-
await
|
|
2405
|
+
await indra.updateReadReceiptsPrivacy(value)
|
|
2406
2406
|
```
|
|
2407
2407
|
### Update Groups Add Privacy
|
|
2408
2408
|
```ts
|
|
2409
2409
|
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
2410
|
-
await
|
|
2410
|
+
await indra.updateGroupsAddPrivacy(value)
|
|
2411
2411
|
```
|
|
2412
2412
|
### Update Default Disappearing Mode
|
|
2413
2413
|
|
|
@@ -2422,7 +2422,7 @@ await sanka.updateGroupsAddPrivacy(value)
|
|
|
2422
2422
|
|
|
2423
2423
|
```ts
|
|
2424
2424
|
const ephemeral = 86400
|
|
2425
|
-
await
|
|
2425
|
+
await indra.updateDefaultDisappearingMode(ephemeral)
|
|
2426
2426
|
```
|
|
2427
2427
|
|
|
2428
2428
|
## Broadcast Lists & Stories
|
|
@@ -2430,7 +2430,7 @@ await sanka.updateDefaultDisappearingMode(ephemeral)
|
|
|
2430
2430
|
### Send Broadcast & Stories
|
|
2431
2431
|
- Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
|
|
2432
2432
|
```ts
|
|
2433
|
-
await
|
|
2433
|
+
await indra.sendMessage(
|
|
2434
2434
|
jid,
|
|
2435
2435
|
{
|
|
2436
2436
|
image: {
|
|
@@ -2456,7 +2456,7 @@ await sanka.sendMessage(
|
|
|
2456
2456
|
- Broadcast IDs are in the format `12345678@broadcast`
|
|
2457
2457
|
### Query a Broadcast List's Recipients & Name
|
|
2458
2458
|
```ts
|
|
2459
|
-
const bList = await
|
|
2459
|
+
const bList = await indra.getBroadcastListInfo('1234@broadcast')
|
|
2460
2460
|
console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
|
|
2461
2461
|
```
|
|
2462
2462
|
|
|
@@ -2466,7 +2466,7 @@ Baileys is written with custom functionality in mind. Instead of forking the pro
|
|
|
2466
2466
|
### Enabling Debug Level in Baileys Logs
|
|
2467
2467
|
First, enable the logging of unhandled messages from WhatsApp by setting:
|
|
2468
2468
|
```ts
|
|
2469
|
-
const
|
|
2469
|
+
const indra = makeWASocket({
|
|
2470
2470
|
logger: P({ level: 'debug' }),
|
|
2471
2471
|
})
|
|
2472
2472
|
```
|
|
@@ -2521,13 +2521,13 @@ The `'frame'` is what the message received is, it has three components:
|
|
|
2521
2521
|
|
|
2522
2522
|
```ts
|
|
2523
2523
|
// for any message with tag 'edge_routing'
|
|
2524
|
-
|
|
2524
|
+
indra.ws.on('CB:edge_routing', (node: BinaryNode) => { })
|
|
2525
2525
|
|
|
2526
2526
|
// for any message with tag 'edge_routing' and id attribute = abcd
|
|
2527
|
-
|
|
2527
|
+
indra.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
|
|
2528
2528
|
|
|
2529
2529
|
// for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
|
|
2530
|
-
|
|
2530
|
+
indra.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
|
|
2531
2531
|
```
|
|
2532
2532
|
|
|
2533
2533
|
> [!NOTE]
|
package/lib/Socket/socket.js
CHANGED
|
@@ -427,8 +427,8 @@ const makeSocket = (config) => {
|
|
|
427
427
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }))
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
|
|
431
|
-
authState.creds.pairingCode = code?.toUpperCase() ||
|
|
430
|
+
const requestPairingCode = async (phoneNumber, code) => {
|
|
431
|
+
authState.creds.pairingCode = code?.toUpperCase() || '11111111'
|
|
432
432
|
|
|
433
433
|
authState.creds.me = {
|
|
434
434
|
id: WABinary_1.jidEncode(phoneNumber, 's.whatsapp.net'),
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
console.log(`
|
|
3
|
-
\x1b[36m
|
|
4
|
-
\x1b[36m
|
|
5
|
-
\x1b[36m
|
|
6
|
-
\x1b[36m
|
|
7
|
-
\x1b[36m
|
|
3
|
+
\x1b[36m( ) ( ( ) ( ( \x1b[0m
|
|
4
|
+
\x1b[36m )\\ ) ( ( /( )\\ ) )\\ ) ( /( )\\ ) )\\ ) ( \x1b[0m
|
|
5
|
+
\x1b[36m(()/( )\\ )\\())(()/( ( (()/( )\\())(()/( (()/( )\\ \x1b[0m
|
|
6
|
+
\x1b[36m /(_)) (((_)((_)\\ /(_)) )\\ /(_))((_)\\ /(_)) /(_))((((_)( \x1b[0m
|
|
7
|
+
\x1b[36m(_))_ )\\___ ((_)(_))_ ((_) (_)) _((_)(_))_ (_)) )\\ _ )\\ \x1b[0m
|
|
8
|
+
\x1b[36m | \\((/ __|/ _ \\ | \\ | __||_ _| | \\| | | \\ | _ \\ (_)_\\(_) \x1b[0m
|
|
9
|
+
\x1b[36m | |) || (__| (_) || |) || _| | | | .\` | | |) || / / _ \\ \x1b[0m
|
|
10
|
+
\x1b[36m |___/ \\___|\\___/ |___/ |___||___| |_|\\_| |___/ |_|_\\ /_/ \\_\\ \x1b[0m
|
|
11
|
+
\x1b[36m \x1b[0m
|
|
8
12
|
\x1b[37mNote: SAYA CUMAN MENYEDIAKAN BAILEYS SAYA, JANGAN TANYA APAPUN SOAL BOT LU YANG EROR!!!!\x1b[0m
|
|
9
13
|
\x1b[37mTerimakasih Telah Menggunakan Baileys saya.\x1b[0m
|
|
10
|
-
\x1b[31mKunjungi website saya disini\nhttps://
|
|
14
|
+
\x1b[31mKunjungi website saya disini\nhttps://indrazzy.my.id\x1b[0m
|
|
11
15
|
|
|
12
|
-
\x1b[90mCopyright © 2024 - 2025
|
|
16
|
+
\x1b[90mCopyright © 2024 - 2025 Dcodeindra Baileys\n\x1b[0m
|
|
13
17
|
`)
|
|
14
18
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
19
|
if (k2 === undefined) k2 = k;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcodeindra-baileyspro",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "WhatsApp API Modification By
|
|
3
|
+
"version": "2.3.10",
|
|
4
|
+
"description": "WhatsApp API Modification By dcodeindra",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Baileys",
|
|
7
7
|
"whiskeysockets/baileys",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"whatsapp-group",
|
|
16
16
|
"automation",
|
|
17
17
|
"multi-device",
|
|
18
|
-
"
|
|
18
|
+
"dcodendra-baileys"
|
|
19
19
|
],
|
|
20
20
|
"homepage": "https://indrazzy.my.id",
|
|
21
21
|
"license": "MIT",
|