@hansaka02/baileys 1.0.0 → 7.3.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 +172 -172
- package/WAProto/AICommon/AICommon.d.ts +7102 -5380
- package/WAProto/AICommon/AICommon.js +13991 -9169
- package/WAProto/AICommon/AICommon.proto +110 -3
- package/WAProto/CompanionReg/CompanionReg.d.ts +27 -0
- package/WAProto/CompanionReg/CompanionReg.js +114 -0
- package/WAProto/CompanionReg/CompanionReg.proto +3 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +244 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.js +652 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +19 -0
- package/WAProto/E2E/E2E.d.ts +7234 -1003
- package/WAProto/E2E/E2E.js +77193 -51248
- package/WAProto/E2E/E2E.proto +68 -12
- package/WAProto/HistorySync/HistorySync.d.ts +1195 -75
- package/WAProto/HistorySync/HistorySync.js +3375 -178
- package/WAProto/HistorySync/HistorySync.proto +3 -3
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +18 -6
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +98 -49
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +2 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +7468 -1051
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +75226 -48422
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +6 -0
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +5 -2
- package/WAProto/StatusAttributions/StatusAttributions.js +21 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +3 -0
- package/WAProto/SyncAction/SyncAction.d.ts +2271 -280
- package/WAProto/SyncAction/SyncAction.js +9423 -2023
- package/WAProto/SyncAction/SyncAction.proto +208 -15
- package/WAProto/Wa6/Wa6.d.ts +20 -1
- package/WAProto/Wa6/Wa6.js +83 -0
- package/WAProto/Wa6/Wa6.proto +3 -0
- package/WAProto/Web/Web.d.ts +8207 -1194
- package/WAProto/Web/Web.js +92664 -63403
- package/WAProto/Web/Web.proto +31 -13
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Socket/messages-recv.js +9 -1
- package/lib/Types/MexUpdates.js +1 -0
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.js +14 -16
- package/lib/Utils/generics.js +63 -16
- package/lib/Utils/messages.js +40 -0
- package/lib/Utils/process-message.js +336 -24
- package/lib/Utils/validate-connection.js +51 -9
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -196,7 +196,7 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
|
|
|
196
196
|
```ts
|
|
197
197
|
import makeWASocket from '@hansaka02/baileys'
|
|
198
198
|
|
|
199
|
-
const
|
|
199
|
+
const AlexaInc = makeWASocket({
|
|
200
200
|
// can provide additional config here
|
|
201
201
|
browser: Browsers.ubuntu('My App'),
|
|
202
202
|
printQRInTerminal: true
|
|
@@ -216,14 +216,14 @@ The phone number can't have `+` or `()` or `-`, only numbers, you must provide c
|
|
|
216
216
|
```ts
|
|
217
217
|
import makeWASocket from '@hansaka02/baileys'
|
|
218
218
|
|
|
219
|
-
const
|
|
219
|
+
const AlexaInc = makeWASocket({
|
|
220
220
|
// can provide additional config here
|
|
221
221
|
printQRInTerminal: false //need to be false
|
|
222
222
|
})
|
|
223
223
|
|
|
224
|
-
if (!
|
|
224
|
+
if (!AlexaInc.authState.creds.registered) {
|
|
225
225
|
const number = 'XXXXXXXXXXX'
|
|
226
|
-
const code = await
|
|
226
|
+
const code = await AlexaInc.requestPairingCode(number) // or await AlexaInc.requestPairingCode(number, 'CODEOTPS') custom your pairing code
|
|
227
227
|
console.log(code)
|
|
228
228
|
}
|
|
229
229
|
```
|
|
@@ -235,7 +235,7 @@ if (!suki.authState.creds.registered) {
|
|
|
235
235
|
- If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
|
|
236
236
|
|
|
237
237
|
```ts
|
|
238
|
-
const
|
|
238
|
+
const AlexaInc = makeWASocket({
|
|
239
239
|
...otherOpts,
|
|
240
240
|
// can use Windows, Ubuntu here too
|
|
241
241
|
browser: Browsers.macOS('Desktop'),
|
|
@@ -251,17 +251,17 @@ const suki = makeWASocket({
|
|
|
251
251
|
```ts
|
|
252
252
|
const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
|
|
253
253
|
|
|
254
|
-
const
|
|
254
|
+
const AlexaInc = makeWASocket({
|
|
255
255
|
cachedGroupMetadata: async (jid) => groupCache.get(jid)
|
|
256
256
|
})
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
const metadata = await
|
|
258
|
+
AlexaInc.ev.on('groups.update', async ([event]) => {
|
|
259
|
+
const metadata = await AlexaInc.groupMetadata(event.id)
|
|
260
260
|
groupCache.set(event.id, metadata)
|
|
261
261
|
})
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
const metadata = await
|
|
263
|
+
AlexaInc.ev.on('group-participants.update', async (event) => {
|
|
264
|
+
const metadata = await AlexaInc.groupMetadata(event.id)
|
|
265
265
|
groupCache.set(event.id, metadata)
|
|
266
266
|
})
|
|
267
267
|
```
|
|
@@ -269,7 +269,7 @@ const suki = makeWASocket({
|
|
|
269
269
|
### Improve Retry System & Decrypt Poll Votes
|
|
270
270
|
- 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:
|
|
271
271
|
```ts
|
|
272
|
-
const
|
|
272
|
+
const AlexaInc = makeWASocket({
|
|
273
273
|
getMessage: async (key) => await getMessageFromStore(key)
|
|
274
274
|
})
|
|
275
275
|
```
|
|
@@ -277,7 +277,7 @@ const suki = makeWASocket({
|
|
|
277
277
|
### Receive Notifications in Whatsapp App
|
|
278
278
|
- If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
|
|
279
279
|
```ts
|
|
280
|
-
const
|
|
280
|
+
const AlexaInc = makeWASocket({
|
|
281
281
|
markOnlineOnConnect: false
|
|
282
282
|
})
|
|
283
283
|
```
|
|
@@ -293,10 +293,10 @@ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
|
|
|
293
293
|
|
|
294
294
|
// will use the given state to connect
|
|
295
295
|
// so if valid credentials are available -- it'll connect without QR
|
|
296
|
-
const
|
|
296
|
+
const AlexaInc = makeWASocket({ auth: state })
|
|
297
297
|
|
|
298
298
|
// this will be called as soon as the credentials are updated
|
|
299
|
-
|
|
299
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
300
300
|
```
|
|
301
301
|
|
|
302
302
|
> [!IMPORTANT]
|
|
@@ -315,8 +315,8 @@ They're all nicely typed up, so you shouldn't have any issues with an Intellisen
|
|
|
315
315
|
|
|
316
316
|
You can listen to these events like this:
|
|
317
317
|
```ts
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
const AlexaInc = makeWASocket()
|
|
319
|
+
AlexaInc.ev.on('messages.upsert', ({ messages }) => {
|
|
320
320
|
console.log('got messages', messages)
|
|
321
321
|
})
|
|
322
322
|
```
|
|
@@ -332,12 +332,12 @@ import { Boom } from '@hapi/boom'
|
|
|
332
332
|
|
|
333
333
|
async function connectToWhatsApp () {
|
|
334
334
|
const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
|
|
335
|
-
const
|
|
335
|
+
const AlexaInc = makeWASocket({
|
|
336
336
|
// can provide additional config here
|
|
337
337
|
auth: state,
|
|
338
338
|
printQRInTerminal: true
|
|
339
339
|
})
|
|
340
|
-
|
|
340
|
+
AlexaInc.ev.on('connection.update', (update) => {
|
|
341
341
|
const { connection, lastDisconnect } = update
|
|
342
342
|
if(connection === 'close') {
|
|
343
343
|
const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
@@ -350,17 +350,17 @@ async function connectToWhatsApp () {
|
|
|
350
350
|
console.log('opened connection')
|
|
351
351
|
}
|
|
352
352
|
})
|
|
353
|
-
|
|
353
|
+
AlexaInc.ev.on('messages.upsert', event => {
|
|
354
354
|
for (const m of event.messages) {
|
|
355
355
|
console.log(JSON.stringify(m, undefined, 2))
|
|
356
356
|
|
|
357
357
|
console.log('replying to', m.key.remoteJid)
|
|
358
|
-
await
|
|
358
|
+
await AlexaInc.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
|
|
359
359
|
}
|
|
360
360
|
})
|
|
361
361
|
|
|
362
362
|
// to storage creds (session info) when it updates
|
|
363
|
-
|
|
363
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
364
364
|
}
|
|
365
365
|
// run in main file
|
|
366
366
|
connectToWhatsApp()
|
|
@@ -372,12 +372,12 @@ import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from '@ha
|
|
|
372
372
|
|
|
373
373
|
// Single Auth
|
|
374
374
|
const { state, saveState } = await useSingleFileAuthState('./auth_info_baileys.json')
|
|
375
|
-
const
|
|
375
|
+
const AlexaInc = makeWASocket({
|
|
376
376
|
auth: state,
|
|
377
377
|
printQRInTerminal: true
|
|
378
378
|
})
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
AlexaInc.ev.on('creds.update', saveState)
|
|
381
381
|
|
|
382
382
|
// Mongo Auth
|
|
383
383
|
import { MongoClient } from "mongodb"
|
|
@@ -399,12 +399,12 @@ const connectAuth = async() => {
|
|
|
399
399
|
|
|
400
400
|
const Authentication = await connectAuth()
|
|
401
401
|
const { state, saveCreds } = await useMongoFileAuthState(Authentication)
|
|
402
|
-
const
|
|
402
|
+
const AlexaInc = makeWASocket({
|
|
403
403
|
auth: state,
|
|
404
404
|
printQRInTerminal: true
|
|
405
405
|
})
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
408
408
|
```
|
|
409
409
|
|
|
410
410
|
> [!IMPORTANT]
|
|
@@ -427,11 +427,11 @@ async function getMessage(key){
|
|
|
427
427
|
return msg?.message
|
|
428
428
|
}
|
|
429
429
|
return {
|
|
430
|
-
conversation: "
|
|
430
|
+
conversation: "ItAlexaInci Kawaiii"
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
AlexaInc.ev.on("messages.update", async (chatUpdate) => {
|
|
435
435
|
for(const { key, update } of chatUpdate) {
|
|
436
436
|
if(update.pollUpdates && key.fromMe) {
|
|
437
437
|
const pollCreation = await getMessage(key)
|
|
@@ -475,18 +475,18 @@ setInterval(() => {
|
|
|
475
475
|
store.writeToFile('./baileys_store.json')
|
|
476
476
|
}, 10_000)
|
|
477
477
|
|
|
478
|
-
const
|
|
478
|
+
const AlexaInc = makeWASocket({ })
|
|
479
479
|
// will listen from this socket
|
|
480
480
|
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
481
|
-
store.bind(
|
|
481
|
+
store.bind(AlexaInc.ev)
|
|
482
482
|
|
|
483
|
-
|
|
483
|
+
AlexaInc.ev.on('chats.upsert', () => {
|
|
484
484
|
// can use 'store.chats' however you want, even after the socket dies out
|
|
485
485
|
// 'chats' => a KeyedDB instance
|
|
486
486
|
console.log('got chats', store.chats.all())
|
|
487
487
|
})
|
|
488
488
|
|
|
489
|
-
|
|
489
|
+
AlexaInc.ev.on('contacts.upsert', () => {
|
|
490
490
|
console.log('got contacts', Object.values(store.contacts))
|
|
491
491
|
})
|
|
492
492
|
|
|
@@ -521,25 +521,25 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
521
521
|
const content: AnyMessageContent
|
|
522
522
|
const options: MiscMessageGenerationOptions
|
|
523
523
|
|
|
524
|
-
|
|
524
|
+
AlexaInc.sendMessage(jid, content, options)
|
|
525
525
|
```
|
|
526
526
|
|
|
527
527
|
### Non-Media Messages
|
|
528
528
|
|
|
529
529
|
#### Text Message
|
|
530
530
|
```ts
|
|
531
|
-
await
|
|
531
|
+
await AlexaInc.sendMessage(jid, { text: 'hello word' })
|
|
532
532
|
```
|
|
533
533
|
|
|
534
534
|
#### Quote Message (works with all types)
|
|
535
535
|
```ts
|
|
536
|
-
await
|
|
536
|
+
await AlexaInc.sendMessage(jid, { text: 'hello word' }, { quoted: message })
|
|
537
537
|
```
|
|
538
538
|
|
|
539
539
|
#### Mention User (works with most types)
|
|
540
540
|
- @number is to mention in text, it's optional
|
|
541
541
|
```ts
|
|
542
|
-
await
|
|
542
|
+
await AlexaInc.sendMessage(
|
|
543
543
|
jid,
|
|
544
544
|
{
|
|
545
545
|
text: '@12345678901',
|
|
@@ -552,12 +552,12 @@ await suki.sendMessage(
|
|
|
552
552
|
- 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
|
|
553
553
|
```ts
|
|
554
554
|
const msg = getMessageFromStore() // implement this on your end
|
|
555
|
-
await
|
|
555
|
+
await AlexaInc.sendMessage(jid, { forward: msg, force: true or number }) // WA forward the message!
|
|
556
556
|
```
|
|
557
557
|
|
|
558
558
|
#### Location Message
|
|
559
559
|
```ts
|
|
560
|
-
await
|
|
560
|
+
await AlexaInc.sendMessage(
|
|
561
561
|
jid,
|
|
562
562
|
{
|
|
563
563
|
location: {
|
|
@@ -570,7 +570,7 @@ await suki.sendMessage(
|
|
|
570
570
|
|
|
571
571
|
#### Live Location Message
|
|
572
572
|
```ts
|
|
573
|
-
await
|
|
573
|
+
await AlexaInc.sendMessage(
|
|
574
574
|
jid,
|
|
575
575
|
{
|
|
576
576
|
location: {
|
|
@@ -590,7 +590,7 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
|
|
|
590
590
|
+ 'TELtype=CELLtype=VOICEwaid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
|
|
591
591
|
+ 'END:VCARD'
|
|
592
592
|
|
|
593
|
-
await
|
|
593
|
+
await AlexaInc.sendMessage(
|
|
594
594
|
id,
|
|
595
595
|
{
|
|
596
596
|
contacts: {
|
|
@@ -604,7 +604,7 @@ await suki.sendMessage(
|
|
|
604
604
|
#### Reaction Message
|
|
605
605
|
- 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
|
|
606
606
|
```ts
|
|
607
|
-
await
|
|
607
|
+
await AlexaInc.sendMessage(
|
|
608
608
|
jid,
|
|
609
609
|
{
|
|
610
610
|
react: {
|
|
@@ -627,7 +627,7 @@ await suki.sendMessage(
|
|
|
627
627
|
| 30d | 2.592.000 |
|
|
628
628
|
|
|
629
629
|
```ts
|
|
630
|
-
await
|
|
630
|
+
await AlexaInc.sendMessage(
|
|
631
631
|
jid,
|
|
632
632
|
{
|
|
633
633
|
pin: {
|
|
@@ -641,7 +641,7 @@ await suki.sendMessage(
|
|
|
641
641
|
|
|
642
642
|
### Keep Message
|
|
643
643
|
```ts
|
|
644
|
-
await
|
|
644
|
+
await AlexaInc.sendMessage(
|
|
645
645
|
jid,
|
|
646
646
|
{
|
|
647
647
|
keep: {
|
|
@@ -654,7 +654,7 @@ await suki.sendMessage(
|
|
|
654
654
|
|
|
655
655
|
#### Poll Message
|
|
656
656
|
```ts
|
|
657
|
-
await
|
|
657
|
+
await AlexaInc.sendMessage(
|
|
658
658
|
jid,
|
|
659
659
|
{
|
|
660
660
|
poll: {
|
|
@@ -669,7 +669,7 @@ await suki.sendMessage(
|
|
|
669
669
|
|
|
670
670
|
#### Poll Result Message
|
|
671
671
|
```ts
|
|
672
|
-
await
|
|
672
|
+
await AlexaInc.sendMessage(
|
|
673
673
|
jid,
|
|
674
674
|
{
|
|
675
675
|
pollResult: {
|
|
@@ -691,7 +691,7 @@ await suki.sendMessage(
|
|
|
691
691
|
|
|
692
692
|
### Call Message
|
|
693
693
|
```ts
|
|
694
|
-
await
|
|
694
|
+
await AlexaInc.sendMessage(
|
|
695
695
|
jid,
|
|
696
696
|
{
|
|
697
697
|
call: {
|
|
@@ -704,7 +704,7 @@ await suki.sendMessage(
|
|
|
704
704
|
|
|
705
705
|
### Event Message
|
|
706
706
|
```ts
|
|
707
|
-
await
|
|
707
|
+
await AlexaInc.sendMessage(
|
|
708
708
|
jid,
|
|
709
709
|
{
|
|
710
710
|
event: {
|
|
@@ -727,7 +727,7 @@ await suki.sendMessage(
|
|
|
727
727
|
|
|
728
728
|
### Order Message
|
|
729
729
|
```ts
|
|
730
|
-
await
|
|
730
|
+
await AlexaInc.sendMessage(
|
|
731
731
|
jid,
|
|
732
732
|
{
|
|
733
733
|
order: {
|
|
@@ -749,7 +749,7 @@ await suki.sendMessage(
|
|
|
749
749
|
|
|
750
750
|
### Product Message
|
|
751
751
|
```ts
|
|
752
|
-
await
|
|
752
|
+
await AlexaInc.sendMessage(
|
|
753
753
|
jid,
|
|
754
754
|
{
|
|
755
755
|
product: {
|
|
@@ -775,7 +775,7 @@ await suki.sendMessage(
|
|
|
775
775
|
|
|
776
776
|
### Payment Message
|
|
777
777
|
```ts
|
|
778
|
-
await
|
|
778
|
+
await AlexaInc.sendMessage(
|
|
779
779
|
jid,
|
|
780
780
|
{
|
|
781
781
|
payment: {
|
|
@@ -797,7 +797,7 @@ await suki.sendMessage(
|
|
|
797
797
|
|
|
798
798
|
#### Payment Invite Message
|
|
799
799
|
```ts
|
|
800
|
-
await
|
|
800
|
+
await AlexaInc.sendMessage(
|
|
801
801
|
id,
|
|
802
802
|
{
|
|
803
803
|
paymentInvite: {
|
|
@@ -810,7 +810,7 @@ await suki.sendMessage(
|
|
|
810
810
|
|
|
811
811
|
### Admin Invite Message
|
|
812
812
|
```ts
|
|
813
|
-
await
|
|
813
|
+
await AlexaInc.sendMessage(
|
|
814
814
|
jid,
|
|
815
815
|
{
|
|
816
816
|
adminInvite: {
|
|
@@ -826,7 +826,7 @@ await suki.sendMessage(
|
|
|
826
826
|
|
|
827
827
|
### Group Invite Message
|
|
828
828
|
```ts
|
|
829
|
-
await
|
|
829
|
+
await AlexaInc.sendMessage(
|
|
830
830
|
jid,
|
|
831
831
|
{
|
|
832
832
|
groupInvite: {
|
|
@@ -844,7 +844,7 @@ await suki.sendMessage(
|
|
|
844
844
|
### Sticker Pack Message
|
|
845
845
|
```ts
|
|
846
846
|
// I don't know why the sticker doesn't appear
|
|
847
|
-
await
|
|
847
|
+
await AlexaInc.sendMessage(
|
|
848
848
|
jid,
|
|
849
849
|
{
|
|
850
850
|
stickerPack: {
|
|
@@ -873,7 +873,7 @@ await suki.sendMessage(
|
|
|
873
873
|
|
|
874
874
|
### Share Phone Number Message
|
|
875
875
|
```ts
|
|
876
|
-
await
|
|
876
|
+
await AlexaInc.sendMessage(
|
|
877
877
|
jid,
|
|
878
878
|
{
|
|
879
879
|
sharePhoneNumber: {
|
|
@@ -884,7 +884,7 @@ await suki.sendMessage(
|
|
|
884
884
|
|
|
885
885
|
### Request Phone Number Message
|
|
886
886
|
```ts
|
|
887
|
-
await
|
|
887
|
+
await AlexaInc.sendMessage(
|
|
888
888
|
jid,
|
|
889
889
|
{
|
|
890
890
|
requestPhoneNumber: {
|
|
@@ -896,7 +896,7 @@ await suki.sendMessage(
|
|
|
896
896
|
### Buttons Reply Message
|
|
897
897
|
```ts
|
|
898
898
|
// List
|
|
899
|
-
await
|
|
899
|
+
await AlexaInc.sendMessage(
|
|
900
900
|
jid,
|
|
901
901
|
{
|
|
902
902
|
buttonReply: {
|
|
@@ -908,7 +908,7 @@ await suki.sendMessage(
|
|
|
908
908
|
}
|
|
909
909
|
)
|
|
910
910
|
// Plain
|
|
911
|
-
await
|
|
911
|
+
await AlexaInc.sendMessage(
|
|
912
912
|
jid,
|
|
913
913
|
{
|
|
914
914
|
buttonReply: {
|
|
@@ -920,7 +920,7 @@ await suki.sendMessage(
|
|
|
920
920
|
)
|
|
921
921
|
|
|
922
922
|
// Template
|
|
923
|
-
await
|
|
923
|
+
await AlexaInc.sendMessage(
|
|
924
924
|
jid,
|
|
925
925
|
{
|
|
926
926
|
buttonReply: {
|
|
@@ -933,7 +933,7 @@ await suki.sendMessage(
|
|
|
933
933
|
)
|
|
934
934
|
|
|
935
935
|
// Interactive
|
|
936
|
-
await
|
|
936
|
+
await AlexaInc.sendMessage(
|
|
937
937
|
jid,
|
|
938
938
|
{
|
|
939
939
|
buttonReply: {
|
|
@@ -951,7 +951,7 @@ await suki.sendMessage(
|
|
|
951
951
|
|
|
952
952
|
### Buttons Message
|
|
953
953
|
```ts
|
|
954
|
-
await
|
|
954
|
+
await AlexaInc.sendMessage(
|
|
955
955
|
jid,
|
|
956
956
|
{
|
|
957
957
|
text: 'This is a button message!', // image: buffer or // image: { url: url } If you want to use images
|
|
@@ -982,7 +982,7 @@ await suki.sendMessage(
|
|
|
982
982
|
### Buttons List Message
|
|
983
983
|
```ts
|
|
984
984
|
// Just working in a private chat
|
|
985
|
-
await
|
|
985
|
+
await AlexaInc.sendMessage(
|
|
986
986
|
jid,
|
|
987
987
|
{
|
|
988
988
|
text: 'This is a list!',
|
|
@@ -1021,7 +1021,7 @@ await suki.sendMessage(
|
|
|
1021
1021
|
### Buttons Product List Message
|
|
1022
1022
|
```ts
|
|
1023
1023
|
// Just working in a private chat
|
|
1024
|
-
await
|
|
1024
|
+
await AlexaInc.sendMessage(
|
|
1025
1025
|
jid,
|
|
1026
1026
|
{
|
|
1027
1027
|
text: 'This is a list!',
|
|
@@ -1047,7 +1047,7 @@ await suki.sendMessage(
|
|
|
1047
1047
|
|
|
1048
1048
|
### Buttons Cards Message
|
|
1049
1049
|
```ts
|
|
1050
|
-
await
|
|
1050
|
+
await AlexaInc.sendMessage(
|
|
1051
1051
|
jid,
|
|
1052
1052
|
{
|
|
1053
1053
|
text: 'Body Message',
|
|
@@ -1107,7 +1107,7 @@ await suki.sendMessage(
|
|
|
1107
1107
|
### Buttons Template Message
|
|
1108
1108
|
```ts
|
|
1109
1109
|
// This no longer works
|
|
1110
|
-
await
|
|
1110
|
+
await AlexaInc.sendMessage(
|
|
1111
1111
|
jid,
|
|
1112
1112
|
{
|
|
1113
1113
|
text: 'This is a template message!',
|
|
@@ -1139,7 +1139,7 @@ await suki.sendMessage(
|
|
|
1139
1139
|
|
|
1140
1140
|
### Buttons Interactive Message
|
|
1141
1141
|
```ts
|
|
1142
|
-
await
|
|
1142
|
+
await AlexaInc.sendMessage(
|
|
1143
1143
|
jid,
|
|
1144
1144
|
{
|
|
1145
1145
|
text: 'This is an Interactive message!',
|
|
@@ -1291,7 +1291,7 @@ await suki.sendMessage(
|
|
|
1291
1291
|
)
|
|
1292
1292
|
|
|
1293
1293
|
// If you want to use an image
|
|
1294
|
-
await
|
|
1294
|
+
await AlexaInc.sendMessage(
|
|
1295
1295
|
jid,
|
|
1296
1296
|
{
|
|
1297
1297
|
image: {
|
|
@@ -1315,7 +1315,7 @@ await suki.sendMessage(
|
|
|
1315
1315
|
)
|
|
1316
1316
|
|
|
1317
1317
|
// If you want to use an video
|
|
1318
|
-
await
|
|
1318
|
+
await AlexaInc.sendMessage(
|
|
1319
1319
|
jid,
|
|
1320
1320
|
{
|
|
1321
1321
|
video: {
|
|
@@ -1339,14 +1339,14 @@ await suki.sendMessage(
|
|
|
1339
1339
|
)
|
|
1340
1340
|
|
|
1341
1341
|
// If you want to use an document
|
|
1342
|
-
await
|
|
1342
|
+
await AlexaInc.sendMessage(
|
|
1343
1343
|
jid,
|
|
1344
1344
|
{
|
|
1345
1345
|
document: {
|
|
1346
1346
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1347
1347
|
},
|
|
1348
1348
|
mimetype: 'image/jpeg',
|
|
1349
|
-
jpegThumbnail: await
|
|
1349
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1350
1350
|
caption: 'Body',
|
|
1351
1351
|
title: 'Title',
|
|
1352
1352
|
subtitle: 'Subtitle',
|
|
@@ -1365,7 +1365,7 @@ await suki.sendMessage(
|
|
|
1365
1365
|
)
|
|
1366
1366
|
|
|
1367
1367
|
// If you want to use an location
|
|
1368
|
-
await
|
|
1368
|
+
await AlexaInc.sendMessage(
|
|
1369
1369
|
jid,
|
|
1370
1370
|
{
|
|
1371
1371
|
location: {
|
|
@@ -1391,7 +1391,7 @@ await suki.sendMessage(
|
|
|
1391
1391
|
)
|
|
1392
1392
|
|
|
1393
1393
|
// if you want to use an product
|
|
1394
|
-
await
|
|
1394
|
+
await AlexaInc.sendMessage(
|
|
1395
1395
|
jid,
|
|
1396
1396
|
{
|
|
1397
1397
|
product: {
|
|
@@ -1428,7 +1428,7 @@ await suki.sendMessage(
|
|
|
1428
1428
|
|
|
1429
1429
|
### Buttons Interactive Message PIX
|
|
1430
1430
|
```ts
|
|
1431
|
-
await
|
|
1431
|
+
await AlexaInc.sendMessage(
|
|
1432
1432
|
jid,
|
|
1433
1433
|
{
|
|
1434
1434
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1453,7 +1453,7 @@ await suki.sendMessage(
|
|
|
1453
1453
|
|
|
1454
1454
|
### Buttons Interactive Message PAY
|
|
1455
1455
|
```ts
|
|
1456
|
-
await
|
|
1456
|
+
await AlexaInc.sendMessage(
|
|
1457
1457
|
jid,
|
|
1458
1458
|
{
|
|
1459
1459
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1511,7 +1511,7 @@ const jidat = [
|
|
|
1511
1511
|
'62xxxxxxx@s.whatsapp.net'
|
|
1512
1512
|
]
|
|
1513
1513
|
// Text
|
|
1514
|
-
await
|
|
1514
|
+
await AlexaInc.sendStatusMentions(
|
|
1515
1515
|
{
|
|
1516
1516
|
text: 'Hello Everyone :3',
|
|
1517
1517
|
font: 2, // optional
|
|
@@ -1522,7 +1522,7 @@ await suki.sendStatusMentions(
|
|
|
1522
1522
|
)
|
|
1523
1523
|
|
|
1524
1524
|
// Image
|
|
1525
|
-
await
|
|
1525
|
+
await AlexaInc.sendStatusMentions(
|
|
1526
1526
|
{
|
|
1527
1527
|
Image: { url: 'https://example.com/ruriooe.jpg' }, or image buffer
|
|
1528
1528
|
caption: 'Hello Everyone :3' // optional
|
|
@@ -1531,7 +1531,7 @@ await suki.sendStatusMentions(
|
|
|
1531
1531
|
)
|
|
1532
1532
|
|
|
1533
1533
|
// Video
|
|
1534
|
-
await
|
|
1534
|
+
await AlexaInc.sendStatusMentions(
|
|
1535
1535
|
{
|
|
1536
1536
|
video: { url: 'https://example.com/ruriooe.mp4' }, or video buffer
|
|
1537
1537
|
caption: 'Hello Everyone :3' // optional
|
|
@@ -1540,7 +1540,7 @@ await suki.sendStatusMentions(
|
|
|
1540
1540
|
)
|
|
1541
1541
|
|
|
1542
1542
|
// Audio
|
|
1543
|
-
await
|
|
1543
|
+
await AlexaInc.sendStatusMentions(
|
|
1544
1544
|
{
|
|
1545
1545
|
audio: { url: 'https://example.com/ruriooe.mp3' }, or audio buffer
|
|
1546
1546
|
backgroundColor: '#000000', // optional
|
|
@@ -1553,7 +1553,7 @@ await suki.sendStatusMentions(
|
|
|
1553
1553
|
|
|
1554
1554
|
### Shop Message
|
|
1555
1555
|
```ts
|
|
1556
|
-
await
|
|
1556
|
+
await AlexaInc.sendMessage(
|
|
1557
1557
|
jid,
|
|
1558
1558
|
{
|
|
1559
1559
|
text: 'Body',
|
|
@@ -1569,7 +1569,7 @@ await suki.sendMessage(
|
|
|
1569
1569
|
)
|
|
1570
1570
|
|
|
1571
1571
|
// Image
|
|
1572
|
-
await
|
|
1572
|
+
await AlexaInc.sendMessage(
|
|
1573
1573
|
jid,
|
|
1574
1574
|
{
|
|
1575
1575
|
image: {
|
|
@@ -1589,7 +1589,7 @@ await suki.sendMessage(
|
|
|
1589
1589
|
)
|
|
1590
1590
|
|
|
1591
1591
|
// Video
|
|
1592
|
-
await
|
|
1592
|
+
await AlexaInc.sendMessage(
|
|
1593
1593
|
jid,
|
|
1594
1594
|
{
|
|
1595
1595
|
video: {
|
|
@@ -1609,14 +1609,14 @@ await suki.sendMessage(
|
|
|
1609
1609
|
)
|
|
1610
1610
|
|
|
1611
1611
|
// Document
|
|
1612
|
-
await
|
|
1612
|
+
await AlexaInc.sendMessage(
|
|
1613
1613
|
jid,
|
|
1614
1614
|
{
|
|
1615
1615
|
document: {
|
|
1616
1616
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1617
1617
|
},
|
|
1618
1618
|
mimetype: 'image/jpeg',
|
|
1619
|
-
jpegThumbnail: await
|
|
1619
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1620
1620
|
caption: 'Body',
|
|
1621
1621
|
title: 'Title',
|
|
1622
1622
|
subtitle: 'Subtitle',
|
|
@@ -1631,7 +1631,7 @@ await suki.sendMessage(
|
|
|
1631
1631
|
)
|
|
1632
1632
|
|
|
1633
1633
|
// Location
|
|
1634
|
-
await
|
|
1634
|
+
await AlexaInc.sendMessage(
|
|
1635
1635
|
jid,
|
|
1636
1636
|
{
|
|
1637
1637
|
location: {
|
|
@@ -1653,7 +1653,7 @@ await suki.sendMessage(
|
|
|
1653
1653
|
)
|
|
1654
1654
|
|
|
1655
1655
|
// Product
|
|
1656
|
-
await
|
|
1656
|
+
await AlexaInc.sendMessage(
|
|
1657
1657
|
jid,
|
|
1658
1658
|
{
|
|
1659
1659
|
product: {
|
|
@@ -1685,7 +1685,7 @@ await suki.sendMessage(
|
|
|
1685
1685
|
```
|
|
1686
1686
|
### Collection Message
|
|
1687
1687
|
```ts
|
|
1688
|
-
await
|
|
1688
|
+
await AlexaInc.sendMessage(
|
|
1689
1689
|
jid,
|
|
1690
1690
|
{
|
|
1691
1691
|
text: 'Body',
|
|
@@ -1702,7 +1702,7 @@ await suki.sendMessage(
|
|
|
1702
1702
|
)
|
|
1703
1703
|
|
|
1704
1704
|
// Image
|
|
1705
|
-
await
|
|
1705
|
+
await AlexaInc.sendMessage(
|
|
1706
1706
|
jid,
|
|
1707
1707
|
{
|
|
1708
1708
|
image: {
|
|
@@ -1723,7 +1723,7 @@ await suki.sendMessage(
|
|
|
1723
1723
|
)
|
|
1724
1724
|
|
|
1725
1725
|
// Video
|
|
1726
|
-
await
|
|
1726
|
+
await AlexaInc.sendMessage(
|
|
1727
1727
|
jid,
|
|
1728
1728
|
{
|
|
1729
1729
|
video: {
|
|
@@ -1744,14 +1744,14 @@ await suki.sendMessage(
|
|
|
1744
1744
|
)
|
|
1745
1745
|
|
|
1746
1746
|
// Document
|
|
1747
|
-
await
|
|
1747
|
+
await AlexaInc.sendMessage(
|
|
1748
1748
|
jid,
|
|
1749
1749
|
{
|
|
1750
1750
|
document: {
|
|
1751
1751
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1752
1752
|
},
|
|
1753
1753
|
mimetype: 'image/jpeg',
|
|
1754
|
-
jpegThumbnail: await
|
|
1754
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1755
1755
|
caption: 'Body',
|
|
1756
1756
|
title: 'Title',
|
|
1757
1757
|
subtitle: 'Subtitle',
|
|
@@ -1767,7 +1767,7 @@ await suki.sendMessage(
|
|
|
1767
1767
|
)
|
|
1768
1768
|
|
|
1769
1769
|
// Location
|
|
1770
|
-
await
|
|
1770
|
+
await AlexaInc.sendMessage(
|
|
1771
1771
|
jid,
|
|
1772
1772
|
{
|
|
1773
1773
|
location: {
|
|
@@ -1790,7 +1790,7 @@ await suki.sendMessage(
|
|
|
1790
1790
|
)
|
|
1791
1791
|
|
|
1792
1792
|
// Product
|
|
1793
|
-
await
|
|
1793
|
+
await AlexaInc.sendMessage(
|
|
1794
1794
|
jid,
|
|
1795
1795
|
{
|
|
1796
1796
|
product: {
|
|
@@ -1824,7 +1824,7 @@ await suki.sendMessage(
|
|
|
1824
1824
|
|
|
1825
1825
|
### AI Icon Feature
|
|
1826
1826
|
```ts
|
|
1827
|
-
await
|
|
1827
|
+
await AlexaInc.sendMessage(
|
|
1828
1828
|
jid,
|
|
1829
1829
|
{
|
|
1830
1830
|
text: 'Hi'
|
|
@@ -1834,7 +1834,7 @@ await suki.sendMessage(
|
|
|
1834
1834
|
)
|
|
1835
1835
|
|
|
1836
1836
|
// If using relay
|
|
1837
|
-
await
|
|
1837
|
+
await AlexaInc.relayMessage(
|
|
1838
1838
|
jid,
|
|
1839
1839
|
{
|
|
1840
1840
|
extendedTextMessage: {
|
|
@@ -1853,7 +1853,7 @@ await suki.relayMessage(
|
|
|
1853
1853
|
3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
|
|
1854
1854
|
4. Send a link:
|
|
1855
1855
|
```ts
|
|
1856
|
-
await
|
|
1856
|
+
await AlexaInc.sendMessage(
|
|
1857
1857
|
jid,
|
|
1858
1858
|
{
|
|
1859
1859
|
text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
|
|
@@ -1876,7 +1876,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
1876
1876
|
#### Gif Message
|
|
1877
1877
|
- Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
|
|
1878
1878
|
```ts
|
|
1879
|
-
await
|
|
1879
|
+
await AlexaInc.sendMessage(
|
|
1880
1880
|
jid,
|
|
1881
1881
|
{
|
|
1882
1882
|
video: fs.readFileSync('Media/ma_gif.mp4'),
|
|
@@ -1888,7 +1888,7 @@ await suki.sendMessage(
|
|
|
1888
1888
|
|
|
1889
1889
|
#### Video Message
|
|
1890
1890
|
```ts
|
|
1891
|
-
await
|
|
1891
|
+
await AlexaInc.sendMessage(
|
|
1892
1892
|
id,
|
|
1893
1893
|
{
|
|
1894
1894
|
video: {
|
|
@@ -1901,7 +1901,7 @@ await suki.sendMessage(
|
|
|
1901
1901
|
|
|
1902
1902
|
#### Video Ptv Message
|
|
1903
1903
|
```ts
|
|
1904
|
-
await
|
|
1904
|
+
await AlexaInc.sendMessage(
|
|
1905
1905
|
id,
|
|
1906
1906
|
{
|
|
1907
1907
|
video: {
|
|
@@ -1925,7 +1925,7 @@ await suki.sendMessage(
|
|
|
1925
1925
|
ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
|
|
1926
1926
|
```
|
|
1927
1927
|
```ts
|
|
1928
|
-
await
|
|
1928
|
+
await AlexaInc.sendMessage(
|
|
1929
1929
|
jid,
|
|
1930
1930
|
{
|
|
1931
1931
|
audio: {
|
|
@@ -1938,7 +1938,7 @@ await suki.sendMessage(
|
|
|
1938
1938
|
|
|
1939
1939
|
#### Image Message
|
|
1940
1940
|
```ts
|
|
1941
|
-
await
|
|
1941
|
+
await AlexaInc.sendMessage(
|
|
1942
1942
|
id,
|
|
1943
1943
|
{
|
|
1944
1944
|
image: {
|
|
@@ -1951,7 +1951,7 @@ await suki.sendMessage(
|
|
|
1951
1951
|
|
|
1952
1952
|
### Album Message
|
|
1953
1953
|
```ts
|
|
1954
|
-
await
|
|
1954
|
+
await AlexaInc.sendMessage(
|
|
1955
1955
|
id,
|
|
1956
1956
|
{
|
|
1957
1957
|
album: [{
|
|
@@ -1980,7 +1980,7 @@ await suki.sendMessage(
|
|
|
1980
1980
|
- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
|
|
1981
1981
|
|
|
1982
1982
|
```ts
|
|
1983
|
-
await
|
|
1983
|
+
await AlexaInc.sendMessage(
|
|
1984
1984
|
id,
|
|
1985
1985
|
{
|
|
1986
1986
|
image: {
|
|
@@ -1997,8 +1997,8 @@ await suki.sendMessage(
|
|
|
1997
1997
|
### Deleting Messages (for everyone)
|
|
1998
1998
|
|
|
1999
1999
|
```ts
|
|
2000
|
-
const msg = await
|
|
2001
|
-
await
|
|
2000
|
+
const msg = await AlexaInc.sendMessage(jid, { text: 'hello word' })
|
|
2001
|
+
await AlexaInc.sendMessage(jid, { delete: msg.key })
|
|
2002
2002
|
```
|
|
2003
2003
|
|
|
2004
2004
|
**Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
|
|
@@ -2007,7 +2007,7 @@ await suki.sendMessage(jid, { delete: msg.key })
|
|
|
2007
2007
|
|
|
2008
2008
|
- You can pass all editable contents here
|
|
2009
2009
|
```ts
|
|
2010
|
-
await
|
|
2010
|
+
await AlexaInc.sendMessage(jid, {
|
|
2011
2011
|
text: 'updated text goes here',
|
|
2012
2012
|
edit: response.key,
|
|
2013
2013
|
})
|
|
@@ -2026,7 +2026,7 @@ If you want to save the media you received
|
|
|
2026
2026
|
import { createWriteStream } from 'fs'
|
|
2027
2027
|
import { downloadMediaMessage, getContentType } from '@hansaka02/baileys'
|
|
2028
2028
|
|
|
2029
|
-
|
|
2029
|
+
AlexaInc.ev.on('messages.upsert', async ({ [m] }) => {
|
|
2030
2030
|
if (!m.message) return // if there is no text or media message
|
|
2031
2031
|
const messageType = getContentType(m) // get what type of message it is (text, image, video...)
|
|
2032
2032
|
|
|
@@ -2041,7 +2041,7 @@ suki.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
2041
2041
|
logger,
|
|
2042
2042
|
// pass this so that baileys can request a reupload of media
|
|
2043
2043
|
// that has been deleted
|
|
2044
|
-
reuploadRequest:
|
|
2044
|
+
reuploadRequest: AlexaInc.updateMediaMessage
|
|
2045
2045
|
}
|
|
2046
2046
|
)
|
|
2047
2047
|
// save to file
|
|
@@ -2055,7 +2055,7 @@ suki.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
2055
2055
|
|
|
2056
2056
|
- 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:
|
|
2057
2057
|
```ts
|
|
2058
|
-
await
|
|
2058
|
+
await AlexaInc.updateMediaMessage(msg)
|
|
2059
2059
|
```
|
|
2060
2060
|
|
|
2061
2061
|
## Reject Call
|
|
@@ -2063,7 +2063,7 @@ await suki.updateMediaMessage(msg)
|
|
|
2063
2063
|
- You can obtain `callId` and `callFrom` from `call` event
|
|
2064
2064
|
|
|
2065
2065
|
```ts
|
|
2066
|
-
await
|
|
2066
|
+
await AlexaInc.rejectCall(callId, callFrom)
|
|
2067
2067
|
```
|
|
2068
2068
|
|
|
2069
2069
|
## Send States in Chat
|
|
@@ -2076,7 +2076,7 @@ This means you have to keep track of unread messages.
|
|
|
2076
2076
|
```ts
|
|
2077
2077
|
const key: WAMessageKey
|
|
2078
2078
|
// can pass multiple keys to read multiple messages as well
|
|
2079
|
-
await
|
|
2079
|
+
await AlexaInc.readMessages([key])
|
|
2080
2080
|
```
|
|
2081
2081
|
|
|
2082
2082
|
The message ID is the unique identifier of the message that you are marking as read.
|
|
@@ -2089,11 +2089,11 @@ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.k
|
|
|
2089
2089
|
- This lets the person/group with `jid` know whether you're online, offline, typing etc.
|
|
2090
2090
|
|
|
2091
2091
|
```ts
|
|
2092
|
-
await
|
|
2092
|
+
await AlexaInc.sendPresenceUpdate('available', jid)
|
|
2093
2093
|
```
|
|
2094
2094
|
|
|
2095
2095
|
> [!NOTE]
|
|
2096
|
-
> 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 `
|
|
2096
|
+
> 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 `AlexaInc.sendPresenceUpdate('unavailable')`
|
|
2097
2097
|
|
|
2098
2098
|
## Modifying Chats
|
|
2099
2099
|
|
|
@@ -2105,7 +2105,7 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
|
|
|
2105
2105
|
### Archive a Chat
|
|
2106
2106
|
```ts
|
|
2107
2107
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2108
|
-
await
|
|
2108
|
+
await AlexaInc.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
2109
2109
|
```
|
|
2110
2110
|
### Mute/Unmute a Chat
|
|
2111
2111
|
|
|
@@ -2119,20 +2119,20 @@ await suki.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
|
2119
2119
|
|
|
2120
2120
|
```ts
|
|
2121
2121
|
// mute for 8 hours
|
|
2122
|
-
await
|
|
2122
|
+
await AlexaInc.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
2123
2123
|
// unmute
|
|
2124
|
-
await
|
|
2124
|
+
await AlexaInc.chatModify({ mute: null }, jid)
|
|
2125
2125
|
```
|
|
2126
2126
|
### Mark a Chat Read/Unread
|
|
2127
2127
|
```ts
|
|
2128
2128
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2129
2129
|
// mark it unread
|
|
2130
|
-
await
|
|
2130
|
+
await AlexaInc.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
|
|
2131
2131
|
```
|
|
2132
2132
|
|
|
2133
2133
|
### Delete a Message for Me
|
|
2134
2134
|
```ts
|
|
2135
|
-
await
|
|
2135
|
+
await AlexaInc.chatModify(
|
|
2136
2136
|
{
|
|
2137
2137
|
clear: {
|
|
2138
2138
|
messages: [
|
|
@@ -2151,7 +2151,7 @@ await suki.chatModify(
|
|
|
2151
2151
|
### Delete a Chat
|
|
2152
2152
|
```ts
|
|
2153
2153
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2154
|
-
await
|
|
2154
|
+
await AlexaInc.chatModify({
|
|
2155
2155
|
delete: true,
|
|
2156
2156
|
lastMessages: [
|
|
2157
2157
|
{
|
|
@@ -2165,7 +2165,7 @@ await suki.chatModify({
|
|
|
2165
2165
|
```
|
|
2166
2166
|
### Pin/Unpin a Chat
|
|
2167
2167
|
```ts
|
|
2168
|
-
await
|
|
2168
|
+
await AlexaInc.chatModify({
|
|
2169
2169
|
pin: true // or `false` to unpin
|
|
2170
2170
|
},
|
|
2171
2171
|
jid
|
|
@@ -2173,7 +2173,7 @@ await suki.chatModify({
|
|
|
2173
2173
|
```
|
|
2174
2174
|
### Star/Unstar a Message
|
|
2175
2175
|
```ts
|
|
2176
|
-
await
|
|
2176
|
+
await AlexaInc.chatModify({
|
|
2177
2177
|
star: {
|
|
2178
2178
|
messages: [
|
|
2179
2179
|
{
|
|
@@ -2203,17 +2203,17 @@ await suki.chatModify({
|
|
|
2203
2203
|
|
|
2204
2204
|
```ts
|
|
2205
2205
|
// turn on disappearing messages
|
|
2206
|
-
await
|
|
2206
|
+
await AlexaInc.sendMessage(
|
|
2207
2207
|
jid,
|
|
2208
2208
|
// this is 1 week in seconds -- how long you want messages to appear for
|
|
2209
2209
|
{ disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
|
|
2210
2210
|
)
|
|
2211
2211
|
|
|
2212
2212
|
// will send as a disappearing message
|
|
2213
|
-
await
|
|
2213
|
+
await AlexaInc.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
|
|
2214
2214
|
|
|
2215
2215
|
// turn off disappearing messages
|
|
2216
|
-
await
|
|
2216
|
+
await AlexaInc.sendMessage(
|
|
2217
2217
|
jid,
|
|
2218
2218
|
{ disappearingMessagesInChat: false }
|
|
2219
2219
|
)
|
|
@@ -2221,14 +2221,14 @@ await suki.sendMessage(
|
|
|
2221
2221
|
|
|
2222
2222
|
### Clear Messages
|
|
2223
2223
|
```ts
|
|
2224
|
-
await
|
|
2224
|
+
await AlexaInc.clearMessage(jid, key, timestamps)
|
|
2225
2225
|
```
|
|
2226
2226
|
|
|
2227
2227
|
## User Querys
|
|
2228
2228
|
|
|
2229
2229
|
### Check If ID Exists in Whatsapp
|
|
2230
2230
|
```ts
|
|
2231
|
-
const [result] = await
|
|
2231
|
+
const [result] = await AlexaInc.onWhatsApp(jid)
|
|
2232
2232
|
if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
|
|
2233
2233
|
```
|
|
2234
2234
|
|
|
@@ -2237,7 +2237,7 @@ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid
|
|
|
2237
2237
|
- You need to have oldest message in chat
|
|
2238
2238
|
```ts
|
|
2239
2239
|
const msg = await getOldestMessageInChat(jid)
|
|
2240
|
-
await
|
|
2240
|
+
await AlexaInc.fetchMessageHistory(
|
|
2241
2241
|
50, //quantity (max: 50 per query)
|
|
2242
2242
|
msg.key,
|
|
2243
2243
|
msg.messageTimestamp
|
|
@@ -2247,7 +2247,7 @@ await suki.fetchMessageHistory(
|
|
|
2247
2247
|
|
|
2248
2248
|
### Fetch Status
|
|
2249
2249
|
```ts
|
|
2250
|
-
const status = await
|
|
2250
|
+
const status = await AlexaInc.fetchStatus(jid)
|
|
2251
2251
|
console.log('status: ' + status)
|
|
2252
2252
|
```
|
|
2253
2253
|
|
|
@@ -2255,34 +2255,34 @@ console.log('status: ' + status)
|
|
|
2255
2255
|
- To get the display picture of some person, group and channel
|
|
2256
2256
|
```ts
|
|
2257
2257
|
// for low res picture
|
|
2258
|
-
const ppUrl = await
|
|
2258
|
+
const ppUrl = await AlexaInc.profilePictureUrl(jid)
|
|
2259
2259
|
console.log(ppUrl)
|
|
2260
2260
|
```
|
|
2261
2261
|
|
|
2262
2262
|
### Fetch Bussines Profile (such as description or category)
|
|
2263
2263
|
```ts
|
|
2264
|
-
const profile = await
|
|
2264
|
+
const profile = await AlexaInc.getBusinessProfile(jid)
|
|
2265
2265
|
console.log('business description: ' + profile.description + ', category: ' + profile.category)
|
|
2266
2266
|
```
|
|
2267
2267
|
|
|
2268
2268
|
### Fetch Someone's Presence (if they're typing or online)
|
|
2269
2269
|
```ts
|
|
2270
2270
|
// the presence update is fetched and called here
|
|
2271
|
-
|
|
2271
|
+
AlexaInc.ev.on('presence.update', console.log)
|
|
2272
2272
|
|
|
2273
2273
|
// request updates for a chat
|
|
2274
|
-
await
|
|
2274
|
+
await AlexaInc.presenceSubscribe(jid)
|
|
2275
2275
|
```
|
|
2276
2276
|
|
|
2277
2277
|
## Change Profile
|
|
2278
2278
|
|
|
2279
2279
|
### Change Profile Status
|
|
2280
2280
|
```ts
|
|
2281
|
-
await
|
|
2281
|
+
await AlexaInc.updateProfileStatus('Hello World!')
|
|
2282
2282
|
```
|
|
2283
2283
|
### Change Profile Name
|
|
2284
2284
|
```ts
|
|
2285
|
-
await
|
|
2285
|
+
await AlexaInc.updateProfileName('My name')
|
|
2286
2286
|
```
|
|
2287
2287
|
### Change Display Picture (groups too)
|
|
2288
2288
|
- To change your display picture or a group's
|
|
@@ -2291,11 +2291,11 @@ await suki.updateProfileName('My name')
|
|
|
2291
2291
|
> 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)
|
|
2292
2292
|
|
|
2293
2293
|
```ts
|
|
2294
|
-
await
|
|
2294
|
+
await AlexaInc.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
|
2295
2295
|
```
|
|
2296
2296
|
### Remove display picture (groups too)
|
|
2297
2297
|
```ts
|
|
2298
|
-
await
|
|
2298
|
+
await AlexaInc.removeProfilePicture(jid)
|
|
2299
2299
|
```
|
|
2300
2300
|
|
|
2301
2301
|
## Groups
|
|
@@ -2305,14 +2305,14 @@ await suki.removeProfilePicture(jid)
|
|
|
2305
2305
|
### Create a Group
|
|
2306
2306
|
```ts
|
|
2307
2307
|
// title & participants
|
|
2308
|
-
const group = await
|
|
2308
|
+
const group = await AlexaInc.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
|
|
2309
2309
|
console.log('created group with id: ' + group.gid)
|
|
2310
|
-
await
|
|
2310
|
+
await AlexaInc.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
|
|
2311
2311
|
```
|
|
2312
2312
|
### Add/Remove or Demote/Promote
|
|
2313
2313
|
```ts
|
|
2314
2314
|
// id & people to add to the group (will throw error if it fails)
|
|
2315
|
-
await
|
|
2315
|
+
await AlexaInc.groupParticipantsUpdate(
|
|
2316
2316
|
jid,
|
|
2317
2317
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2318
2318
|
'add' // replace this parameter with 'remove' or 'demote' or 'promote'
|
|
@@ -2320,68 +2320,68 @@ await suki.groupParticipantsUpdate(
|
|
|
2320
2320
|
```
|
|
2321
2321
|
### Change Subject (name)
|
|
2322
2322
|
```ts
|
|
2323
|
-
await
|
|
2323
|
+
await AlexaInc.groupUpdateSubject(jid, 'New Subject!')
|
|
2324
2324
|
```
|
|
2325
2325
|
### Change Description
|
|
2326
2326
|
```ts
|
|
2327
|
-
await
|
|
2327
|
+
await AlexaInc.groupUpdateDescription(jid, 'New Description!')
|
|
2328
2328
|
```
|
|
2329
2329
|
### Change Settings
|
|
2330
2330
|
```ts
|
|
2331
2331
|
// only allow admins to send messages
|
|
2332
|
-
await
|
|
2332
|
+
await AlexaInc.groupSettingUpdate(jid, 'announcement')
|
|
2333
2333
|
// allow everyone to send messages
|
|
2334
|
-
await
|
|
2334
|
+
await AlexaInc.groupSettingUpdate(jid, 'not_announcement')
|
|
2335
2335
|
// allow everyone to modify the group's settings -- like display picture etc.
|
|
2336
|
-
await
|
|
2336
|
+
await AlexaInc.groupSettingUpdate(jid, 'unlocked')
|
|
2337
2337
|
// only allow admins to modify the group's settings
|
|
2338
|
-
await
|
|
2338
|
+
await AlexaInc.groupSettingUpdate(jid, 'locked')
|
|
2339
2339
|
```
|
|
2340
2340
|
### Leave a Group
|
|
2341
2341
|
```ts
|
|
2342
2342
|
// will throw error if it fails
|
|
2343
|
-
await
|
|
2343
|
+
await AlexaInc.groupLeave(jid)
|
|
2344
2344
|
```
|
|
2345
2345
|
### Get Invite Code
|
|
2346
2346
|
- To create link with code use `'https://chat.whatsapp.com/' + code`
|
|
2347
2347
|
```ts
|
|
2348
|
-
const code = await
|
|
2348
|
+
const code = await AlexaInc.groupInviteCode(jid)
|
|
2349
2349
|
console.log('group code: ' + code)
|
|
2350
2350
|
```
|
|
2351
2351
|
### Revoke Invite Code
|
|
2352
2352
|
```ts
|
|
2353
|
-
const code = await
|
|
2353
|
+
const code = await AlexaInc.groupRevokeInvite(jid)
|
|
2354
2354
|
console.log('New group code: ' + code)
|
|
2355
2355
|
```
|
|
2356
2356
|
### Join Using Invitation Code
|
|
2357
2357
|
- Code can't have `https://chat.whatsapp.com/`, only code
|
|
2358
2358
|
```ts
|
|
2359
|
-
const response = await
|
|
2359
|
+
const response = await AlexaInc.groupAcceptInvite(code)
|
|
2360
2360
|
console.log('joined to: ' + response)
|
|
2361
2361
|
```
|
|
2362
2362
|
### Get Group Info by Invite Code
|
|
2363
2363
|
```ts
|
|
2364
|
-
const response = await
|
|
2364
|
+
const response = await AlexaInc.groupGetInviteInfo(code)
|
|
2365
2365
|
console.log('group information: ' + response)
|
|
2366
2366
|
```
|
|
2367
2367
|
### Query Metadata (participants, name, description...)
|
|
2368
2368
|
```ts
|
|
2369
|
-
const metadata = await
|
|
2369
|
+
const metadata = await AlexaInc.groupMetadata(jid)
|
|
2370
2370
|
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
|
|
2371
2371
|
```
|
|
2372
2372
|
### Join using `groupInviteMessage`
|
|
2373
2373
|
```ts
|
|
2374
|
-
const response = await
|
|
2374
|
+
const response = await AlexaInc.groupAcceptInviteV4(jid, groupInviteMessage)
|
|
2375
2375
|
console.log('joined to: ' + response)
|
|
2376
2376
|
```
|
|
2377
2377
|
### Get Request Join List
|
|
2378
2378
|
```ts
|
|
2379
|
-
const response = await
|
|
2379
|
+
const response = await AlexaInc.groupRequestParticipantsList(jid)
|
|
2380
2380
|
console.log(response)
|
|
2381
2381
|
```
|
|
2382
2382
|
### Approve/Reject Request Join
|
|
2383
2383
|
```ts
|
|
2384
|
-
const response = await
|
|
2384
|
+
const response = await AlexaInc.groupRequestParticipantsUpdate(
|
|
2385
2385
|
jid, // group id
|
|
2386
2386
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2387
2387
|
'approve' // or 'reject'
|
|
@@ -2390,7 +2390,7 @@ console.log(response)
|
|
|
2390
2390
|
```
|
|
2391
2391
|
### Get All Participating Groups Metadata
|
|
2392
2392
|
```ts
|
|
2393
|
-
const response = await
|
|
2393
|
+
const response = await AlexaInc.groupFetchAllParticipating()
|
|
2394
2394
|
console.log(response)
|
|
2395
2395
|
```
|
|
2396
2396
|
### Toggle Ephemeral
|
|
@@ -2405,12 +2405,12 @@ console.log(response)
|
|
|
2405
2405
|
| 90d | 7.776.000 |
|
|
2406
2406
|
|
|
2407
2407
|
```ts
|
|
2408
|
-
await
|
|
2408
|
+
await AlexaInc.groupToggleEphemeral(jid, 86400)
|
|
2409
2409
|
```
|
|
2410
2410
|
|
|
2411
2411
|
### Change Add Mode
|
|
2412
2412
|
```ts
|
|
2413
|
-
await
|
|
2413
|
+
await AlexaInc.groupMemberAddMode(
|
|
2414
2414
|
jid,
|
|
2415
2415
|
'all_member_add' // or 'admin_add'
|
|
2416
2416
|
)
|
|
@@ -2420,48 +2420,48 @@ await suki.groupMemberAddMode(
|
|
|
2420
2420
|
|
|
2421
2421
|
### Block/Unblock User
|
|
2422
2422
|
```ts
|
|
2423
|
-
await
|
|
2424
|
-
await
|
|
2423
|
+
await AlexaInc.updateBlockStatus(jid, 'block') // Block user
|
|
2424
|
+
await AlexaInc.updateBlockStatus(jid, 'unblock') // Unblock user
|
|
2425
2425
|
```
|
|
2426
2426
|
### Get Privacy Settings
|
|
2427
2427
|
```ts
|
|
2428
|
-
const privacySettings = await
|
|
2428
|
+
const privacySettings = await AlexaInc.fetchPrivacySettings(true)
|
|
2429
2429
|
console.log('privacy settings: ' + privacySettings)
|
|
2430
2430
|
```
|
|
2431
2431
|
### Get BlockList
|
|
2432
2432
|
```ts
|
|
2433
|
-
const response = await
|
|
2433
|
+
const response = await AlexaInc.fetchBlocklist()
|
|
2434
2434
|
console.log(response)
|
|
2435
2435
|
```
|
|
2436
2436
|
### Update LastSeen Privacy
|
|
2437
2437
|
```ts
|
|
2438
2438
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2439
|
-
await
|
|
2439
|
+
await AlexaInc.updateLastSeenPrivacy(value)
|
|
2440
2440
|
```
|
|
2441
2441
|
### Update Online Privacy
|
|
2442
2442
|
```ts
|
|
2443
2443
|
const value = 'all' // 'match_last_seen'
|
|
2444
|
-
await
|
|
2444
|
+
await AlexaInc.updateOnlinePrivacy(value)
|
|
2445
2445
|
```
|
|
2446
2446
|
### Update Profile Picture Privacy
|
|
2447
2447
|
```ts
|
|
2448
2448
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2449
|
-
await
|
|
2449
|
+
await AlexaInc.updateProfilePicturePrivacy(value)
|
|
2450
2450
|
```
|
|
2451
2451
|
### Update Status Privacy
|
|
2452
2452
|
```ts
|
|
2453
2453
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2454
|
-
await
|
|
2454
|
+
await AlexaInc.updateStatusPrivacy(value)
|
|
2455
2455
|
```
|
|
2456
2456
|
### Update Read Receipts Privacy
|
|
2457
2457
|
```ts
|
|
2458
2458
|
const value = 'all' // 'none'
|
|
2459
|
-
await
|
|
2459
|
+
await AlexaInc.updateReadReceiptsPrivacy(value)
|
|
2460
2460
|
```
|
|
2461
2461
|
### Update Groups Add Privacy
|
|
2462
2462
|
```ts
|
|
2463
2463
|
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
2464
|
-
await
|
|
2464
|
+
await AlexaInc.updateGroupsAddPrivacy(value)
|
|
2465
2465
|
```
|
|
2466
2466
|
### Update Default Disappearing Mode
|
|
2467
2467
|
|
|
@@ -2476,7 +2476,7 @@ await suki.updateGroupsAddPrivacy(value)
|
|
|
2476
2476
|
|
|
2477
2477
|
```ts
|
|
2478
2478
|
const ephemeral = 86400
|
|
2479
|
-
await
|
|
2479
|
+
await AlexaInc.updateDefaultDisappearingMode(ephemeral)
|
|
2480
2480
|
```
|
|
2481
2481
|
|
|
2482
2482
|
## Broadcast Lists & Stories
|
|
@@ -2484,7 +2484,7 @@ await suki.updateDefaultDisappearingMode(ephemeral)
|
|
|
2484
2484
|
### Send Broadcast & Stories
|
|
2485
2485
|
- Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
|
|
2486
2486
|
```ts
|
|
2487
|
-
await
|
|
2487
|
+
await AlexaInc.sendMessage(
|
|
2488
2488
|
jid,
|
|
2489
2489
|
{
|
|
2490
2490
|
image: {
|
|
@@ -2510,7 +2510,7 @@ await suki.sendMessage(
|
|
|
2510
2510
|
- Broadcast IDs are in the format `12345678@broadcast`
|
|
2511
2511
|
### Query a Broadcast List's Recipients & Name
|
|
2512
2512
|
```ts
|
|
2513
|
-
const bList = await
|
|
2513
|
+
const bList = await AlexaInc.getBroadcastListInfo('1234@broadcast')
|
|
2514
2514
|
console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
|
|
2515
2515
|
```
|
|
2516
2516
|
|
|
@@ -2520,7 +2520,7 @@ Baileys is written with custom functionality in mind. Instead of forking the pro
|
|
|
2520
2520
|
### Enabling Debug Level in Baileys Logs
|
|
2521
2521
|
First, enable the logging of unhandled messages from WhatsApp by setting:
|
|
2522
2522
|
```ts
|
|
2523
|
-
const
|
|
2523
|
+
const AlexaInc = makeWASocket({
|
|
2524
2524
|
logger: P({ level: 'debug' }),
|
|
2525
2525
|
})
|
|
2526
2526
|
```
|
|
@@ -2575,13 +2575,13 @@ The `'frame'` is what the message received is, it has three components:
|
|
|
2575
2575
|
|
|
2576
2576
|
```ts
|
|
2577
2577
|
// for any message with tag 'edge_routing'
|
|
2578
|
-
|
|
2578
|
+
AlexaInc.ws.on('CB:edge_routing', (node: BinaryNode) => { })
|
|
2579
2579
|
|
|
2580
2580
|
// for any message with tag 'edge_routing' and id attribute = abcd
|
|
2581
|
-
|
|
2581
|
+
AlexaInc.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
|
|
2582
2582
|
|
|
2583
2583
|
// for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
|
|
2584
|
-
|
|
2584
|
+
AlexaInc.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
|
|
2585
2585
|
```
|
|
2586
2586
|
|
|
2587
2587
|
> [!NOTE]
|