@hansaka02/baileys 7.3.4 → 7.3.6
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 +203 -247
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +1 -1
- package/lib/Defaults/constants.js +13 -1
- package/lib/Defaults/history.js +3 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -14
- package/lib/Signal/Group/sender-key-distribution-message.js +2 -2
- package/lib/Signal/Group/sender-key-record.js +2 -11
- package/lib/Signal/Group/sender-key-state.js +11 -57
- package/lib/Signal/libsignal.js +200 -116
- package/lib/Signal/lid-mapping.js +121 -68
- package/lib/Socket/Client/websocket.js +9 -2
- package/lib/Socket/business.js +5 -1
- package/lib/Socket/chats.js +180 -89
- package/lib/Socket/community.js +169 -41
- package/lib/Socket/groups.js +25 -21
- package/lib/Socket/messages-recv.js +458 -333
- package/lib/Socket/messages-send.js +517 -572
- package/lib/Socket/mex.js +61 -0
- package/lib/Socket/newsletter.js +159 -252
- package/lib/Socket/socket.js +283 -100
- package/lib/Types/Newsletter.js +32 -25
- package/lib/Utils/auth-utils.js +189 -354
- package/lib/Utils/browser-utils.js +43 -0
- package/lib/Utils/chat-utils.js +166 -41
- package/lib/Utils/decode-wa-message.js +77 -35
- package/lib/Utils/event-buffer.js +80 -24
- package/lib/Utils/generics.js +28 -128
- package/lib/Utils/history.js +10 -8
- package/lib/Utils/index.js +1 -1
- package/lib/Utils/link-preview.js +17 -32
- package/lib/Utils/lt-hash.js +28 -22
- package/lib/Utils/make-mutex.js +26 -28
- package/lib/Utils/message-retry-manager.js +51 -3
- package/lib/Utils/messages-media.js +343 -151
- package/lib/Utils/messages.js +806 -792
- package/lib/Utils/noise-handler.js +33 -2
- package/lib/Utils/pre-key-manager.js +126 -0
- package/lib/Utils/process-message.js +115 -55
- package/lib/Utils/signal.js +45 -18
- package/lib/Utils/validate-connection.js +52 -29
- package/lib/WABinary/constants.js +1268 -1268
- package/lib/WABinary/decode.js +58 -4
- package/lib/WABinary/encode.js +54 -7
- package/lib/WABinary/jid-utils.js +58 -11
- package/lib/WAM/constants.js +19064 -11563
- package/lib/WAM/encode.js +57 -8
- package/lib/WAUSync/USyncQuery.js +35 -19
- package/package.json +9 -8
- package/lib/Socket/usync.js +0 -83
package/README.md
CHANGED
|
@@ -2,45 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<img src="
|
|
5
|
+
<img src="./images/image.jpg" alt="Header Image" width="100%"/>
|
|
6
6
|
|
|
7
7
|
<br/>
|
|
8
|
-
|
|
9
|
-
<!-- Badges -->
|
|
10
|
-
<p>
|
|
11
|
-
<img src="https://img.shields.io/npm/dw/%40itsukichan%2Fbaileys?label=npm&color=%23CB3837" alt="NPM Downloads"/>
|
|
12
|
-
<img src="https://img.shields.io/github/v/release/itsukichann/baileys?include_prereleases&sort=semver" alt="Latest Release"/>
|
|
13
|
-
<img src="https://img.shields.io/github/languages/code-size/itsukichann/baileys" alt="Code Size"/>
|
|
14
|
-
<img src="https://img.shields.io/github/license/itsukichann/baileys" alt="License"/>
|
|
15
|
-
<img src="https://img.shields.io/github/stars/itsukichann/baileys" alt="Stars"/>
|
|
16
|
-
<img src="https://img.shields.io/github/forks/itsukichann/baileys" alt="Forks"/>
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
<!-- GitHub Stats -->
|
|
20
|
-
<p>
|
|
21
|
-
<img src="https://github-readme-stats.vercel.app/api?username=itsukichann&show_icons=true&theme=radical" alt="GitHub Stats"/>
|
|
22
|
-
</p>
|
|
23
|
-
|
|
24
8
|
</div>
|
|
25
9
|
|
|
26
|
-
### Important Note
|
|
27
|
-
|
|
28
|
-
This library was originally a project for **CS-2362 at Ashoka University** and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
|
|
29
|
-
|
|
30
|
-
#### Liability and License Notice
|
|
31
|
-
Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/WhiskeySockets/Baileys/blob/master/LICENSE).
|
|
32
|
-
The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
- Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
|
|
36
|
-
- Not running Selenium or Chromimum saves you like **half a gig** of ram :/
|
|
37
|
-
- Baileys supports interacting with the multi-device & web versions of WhatsApp.
|
|
38
|
-
- Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.
|
|
39
|
-
|
|
40
10
|
> [!IMPORTANT]
|
|
41
|
-
> The original repository had to be removed by the original author
|
|
42
|
-
This is
|
|
43
|
-
|
|
11
|
+
> The original repository had to be removed by the original author
|
|
12
|
+
This is a unofficial repository and is maintained by the community.
|
|
13
|
+
|
|
44
14
|
|
|
45
15
|
## Example
|
|
46
16
|
|
|
@@ -55,23 +25,23 @@ To run the example script, download or clone the repo and then type the followin
|
|
|
55
25
|
|
|
56
26
|
Use the stable version:
|
|
57
27
|
```
|
|
58
|
-
yarn add @
|
|
28
|
+
yarn add @hansaka02/baileys
|
|
59
29
|
```
|
|
60
30
|
|
|
61
31
|
Use the edge version (no guarantee of stability, but latest fixes + features)
|
|
62
32
|
```
|
|
63
|
-
yarn add github:
|
|
33
|
+
yarn add github:hansaka02/Baileys
|
|
64
34
|
```
|
|
65
35
|
|
|
66
36
|
Then import your code using:
|
|
67
37
|
```ts
|
|
68
|
-
import makeWASocket from '@
|
|
38
|
+
import makeWASocket from '@hansaka02/baileys'
|
|
69
39
|
```
|
|
70
40
|
|
|
71
41
|
# Links
|
|
72
42
|
|
|
73
|
-
|
|
74
|
-
- [Docs](https://guide.whiskeysockets.io/)
|
|
43
|
+
|
|
44
|
+
- [Docs of original library](https://guide.whiskeysockets.io/)
|
|
75
45
|
|
|
76
46
|
# Index
|
|
77
47
|
|
|
@@ -88,7 +58,6 @@ import makeWASocket from '@itsukichan/baileys'
|
|
|
88
58
|
- [Handling Events](#handling-events)
|
|
89
59
|
- [Example to Start](#example-to-start)
|
|
90
60
|
- [Decrypt Poll Votes](#decrypt-poll-votes)
|
|
91
|
-
- [Decrypt Event Response](#decrypt-event-response)
|
|
92
61
|
- [Summary of Events on First Connection](#summary-of-events-on-first-connection)
|
|
93
62
|
- [Implementing a Data Store](#implementing-a-data-store)
|
|
94
63
|
- [Whatsapp IDs Explain](#whatsapp-ids-explain)
|
|
@@ -225,9 +194,9 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
|
|
|
225
194
|
> 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)**
|
|
226
195
|
|
|
227
196
|
```ts
|
|
228
|
-
import makeWASocket from '@
|
|
197
|
+
import makeWASocket from '@hansaka02/baileys'
|
|
229
198
|
|
|
230
|
-
const
|
|
199
|
+
const AlexaInc = makeWASocket({
|
|
231
200
|
// can provide additional config here
|
|
232
201
|
browser: Browsers.ubuntu('My App'),
|
|
233
202
|
printQRInTerminal: true
|
|
@@ -245,16 +214,16 @@ If the connection is successful, you will see a QR code printed on your terminal
|
|
|
245
214
|
The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
|
|
246
215
|
|
|
247
216
|
```ts
|
|
248
|
-
import makeWASocket from '@
|
|
217
|
+
import makeWASocket from '@hansaka02/baileys'
|
|
249
218
|
|
|
250
|
-
const
|
|
219
|
+
const AlexaInc = makeWASocket({
|
|
251
220
|
// can provide additional config here
|
|
252
221
|
printQRInTerminal: false //need to be false
|
|
253
222
|
})
|
|
254
223
|
|
|
255
|
-
if (!
|
|
224
|
+
if (!AlexaInc.authState.creds.registered) {
|
|
256
225
|
const number = 'XXXXXXXXXXX'
|
|
257
|
-
const code = await
|
|
226
|
+
const code = await AlexaInc.requestPairingCode(number) // or await AlexaInc.requestPairingCode(number, 'CODEOTPS') custom your pairing code
|
|
258
227
|
console.log(code)
|
|
259
228
|
}
|
|
260
229
|
```
|
|
@@ -266,7 +235,7 @@ if (!suki.authState.creds.registered) {
|
|
|
266
235
|
- If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
|
|
267
236
|
|
|
268
237
|
```ts
|
|
269
|
-
const
|
|
238
|
+
const AlexaInc = makeWASocket({
|
|
270
239
|
...otherOpts,
|
|
271
240
|
// can use Windows, Ubuntu here too
|
|
272
241
|
browser: Browsers.macOS('Desktop'),
|
|
@@ -282,17 +251,17 @@ const suki = makeWASocket({
|
|
|
282
251
|
```ts
|
|
283
252
|
const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
|
|
284
253
|
|
|
285
|
-
const
|
|
254
|
+
const AlexaInc = makeWASocket({
|
|
286
255
|
cachedGroupMetadata: async (jid) => groupCache.get(jid)
|
|
287
256
|
})
|
|
288
257
|
|
|
289
|
-
|
|
290
|
-
const metadata = await
|
|
258
|
+
AlexaInc.ev.on('groups.update', async ([event]) => {
|
|
259
|
+
const metadata = await AlexaInc.groupMetadata(event.id)
|
|
291
260
|
groupCache.set(event.id, metadata)
|
|
292
261
|
})
|
|
293
262
|
|
|
294
|
-
|
|
295
|
-
const metadata = await
|
|
263
|
+
AlexaInc.ev.on('group-participants.update', async (event) => {
|
|
264
|
+
const metadata = await AlexaInc.groupMetadata(event.id)
|
|
296
265
|
groupCache.set(event.id, metadata)
|
|
297
266
|
})
|
|
298
267
|
```
|
|
@@ -300,7 +269,7 @@ const suki = makeWASocket({
|
|
|
300
269
|
### Improve Retry System & Decrypt Poll Votes
|
|
301
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:
|
|
302
271
|
```ts
|
|
303
|
-
const
|
|
272
|
+
const AlexaInc = makeWASocket({
|
|
304
273
|
getMessage: async (key) => await getMessageFromStore(key)
|
|
305
274
|
})
|
|
306
275
|
```
|
|
@@ -308,7 +277,7 @@ const suki = makeWASocket({
|
|
|
308
277
|
### Receive Notifications in Whatsapp App
|
|
309
278
|
- If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
|
|
310
279
|
```ts
|
|
311
|
-
const
|
|
280
|
+
const AlexaInc = makeWASocket({
|
|
312
281
|
markOnlineOnConnect: false
|
|
313
282
|
})
|
|
314
283
|
```
|
|
@@ -318,16 +287,16 @@ You obviously don't want to keep scanning the QR code every time you want to con
|
|
|
318
287
|
|
|
319
288
|
So, you can load the credentials to log back in:
|
|
320
289
|
```ts
|
|
321
|
-
import makeWASocket, { useMultiFileAuthState } from '@
|
|
290
|
+
import makeWASocket, { useMultiFileAuthState } from '@hansaka02/baileys'
|
|
322
291
|
|
|
323
292
|
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
|
|
324
293
|
|
|
325
294
|
// will use the given state to connect
|
|
326
295
|
// so if valid credentials are available -- it'll connect without QR
|
|
327
|
-
const
|
|
296
|
+
const AlexaInc = makeWASocket({ auth: state })
|
|
328
297
|
|
|
329
298
|
// this will be called as soon as the credentials are updated
|
|
330
|
-
|
|
299
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
331
300
|
```
|
|
332
301
|
|
|
333
302
|
> [!IMPORTANT]
|
|
@@ -346,8 +315,8 @@ They're all nicely typed up, so you shouldn't have any issues with an Intellisen
|
|
|
346
315
|
|
|
347
316
|
You can listen to these events like this:
|
|
348
317
|
```ts
|
|
349
|
-
const
|
|
350
|
-
|
|
318
|
+
const AlexaInc = makeWASocket()
|
|
319
|
+
AlexaInc.ev.on('messages.upsert', ({ messages }) => {
|
|
351
320
|
console.log('got messages', messages)
|
|
352
321
|
})
|
|
353
322
|
```
|
|
@@ -358,17 +327,17 @@ suki.ev.on('messages.upsert', ({ messages }) => {
|
|
|
358
327
|
> This example includes basic auth storage too
|
|
359
328
|
|
|
360
329
|
```ts
|
|
361
|
-
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@
|
|
330
|
+
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@hansaka02/baileys'
|
|
362
331
|
import { Boom } from '@hapi/boom'
|
|
363
332
|
|
|
364
333
|
async function connectToWhatsApp () {
|
|
365
334
|
const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
|
|
366
|
-
const
|
|
335
|
+
const AlexaInc = makeWASocket({
|
|
367
336
|
// can provide additional config here
|
|
368
337
|
auth: state,
|
|
369
338
|
printQRInTerminal: true
|
|
370
339
|
})
|
|
371
|
-
|
|
340
|
+
AlexaInc.ev.on('connection.update', (update) => {
|
|
372
341
|
const { connection, lastDisconnect } = update
|
|
373
342
|
if(connection === 'close') {
|
|
374
343
|
const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
@@ -381,17 +350,17 @@ async function connectToWhatsApp () {
|
|
|
381
350
|
console.log('opened connection')
|
|
382
351
|
}
|
|
383
352
|
})
|
|
384
|
-
|
|
353
|
+
AlexaInc.ev.on('messages.upsert', event => {
|
|
385
354
|
for (const m of event.messages) {
|
|
386
355
|
console.log(JSON.stringify(m, undefined, 2))
|
|
387
356
|
|
|
388
357
|
console.log('replying to', m.key.remoteJid)
|
|
389
|
-
await
|
|
358
|
+
await AlexaInc.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
|
|
390
359
|
}
|
|
391
360
|
})
|
|
392
361
|
|
|
393
362
|
// to storage creds (session info) when it updates
|
|
394
|
-
|
|
363
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
395
364
|
}
|
|
396
365
|
// run in main file
|
|
397
366
|
connectToWhatsApp()
|
|
@@ -399,16 +368,16 @@ connectToWhatsApp()
|
|
|
399
368
|
|
|
400
369
|
### For example if you use useSingleFileAuthState and useMongoFileAuthState
|
|
401
370
|
```ts
|
|
402
|
-
import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from '@
|
|
371
|
+
import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from '@hansaka02/baileys'
|
|
403
372
|
|
|
404
373
|
// Single Auth
|
|
405
374
|
const { state, saveState } = await useSingleFileAuthState('./auth_info_baileys.json')
|
|
406
|
-
const
|
|
375
|
+
const AlexaInc = makeWASocket({
|
|
407
376
|
auth: state,
|
|
408
377
|
printQRInTerminal: true
|
|
409
378
|
})
|
|
410
379
|
|
|
411
|
-
|
|
380
|
+
AlexaInc.ev.on('creds.update', saveState)
|
|
412
381
|
|
|
413
382
|
// Mongo Auth
|
|
414
383
|
import { MongoClient } from "mongodb"
|
|
@@ -424,18 +393,18 @@ const connectAuth = async() => {
|
|
|
424
393
|
})
|
|
425
394
|
}
|
|
426
395
|
await client.connect()
|
|
427
|
-
const collection = client.db("@
|
|
396
|
+
const collection = client.db("@hansaka02").collection("sessions")
|
|
428
397
|
return collection
|
|
429
398
|
}
|
|
430
399
|
|
|
431
400
|
const Authentication = await connectAuth()
|
|
432
401
|
const { state, saveCreds } = await useMongoFileAuthState(Authentication)
|
|
433
|
-
const
|
|
402
|
+
const AlexaInc = makeWASocket({
|
|
434
403
|
auth: state,
|
|
435
404
|
printQRInTerminal: true
|
|
436
405
|
})
|
|
437
406
|
|
|
438
|
-
|
|
407
|
+
AlexaInc.ev.on('creds.update', saveCreds)
|
|
439
408
|
```
|
|
440
409
|
|
|
441
410
|
> [!IMPORTANT]
|
|
@@ -446,9 +415,9 @@ suki.ev.on('creds.update', saveCreds)
|
|
|
446
415
|
- By default poll votes are encrypted and handled in `messages.update`
|
|
447
416
|
```ts
|
|
448
417
|
import pino from "pino"
|
|
449
|
-
import { makeInMemoryStore, getAggregateVotesInPollMessage } from '@
|
|
418
|
+
import { makeInMemoryStore, getAggregateVotesInPollMessage } from '@hansaka02/baileys'
|
|
450
419
|
|
|
451
|
-
const logger = pino({ timestamp: () => `,"time":"${new Date().toJSON()}"` }).child({ class: "@
|
|
420
|
+
const logger = pino({ timestamp: () => `,"time":"${new Date().toJSON()}"` }).child({ class: "@hansaka02" })
|
|
452
421
|
logger.level = "fatal"
|
|
453
422
|
const store = makeInMemoryStore({ logger })
|
|
454
423
|
|
|
@@ -458,11 +427,11 @@ async function getMessage(key){
|
|
|
458
427
|
return msg?.message
|
|
459
428
|
}
|
|
460
429
|
return {
|
|
461
|
-
conversation: "
|
|
430
|
+
conversation: "ItAlexaInci Kawaiii"
|
|
462
431
|
}
|
|
463
432
|
}
|
|
464
433
|
|
|
465
|
-
|
|
434
|
+
AlexaInc.ev.on("messages.update", async (chatUpdate) => {
|
|
466
435
|
for(const { key, update } of chatUpdate) {
|
|
467
436
|
if(update.pollUpdates && key.fromMe) {
|
|
468
437
|
const pollCreation = await getMessage(key)
|
|
@@ -480,19 +449,6 @@ suki.ev.on("messages.update", async (chatUpdate) => {
|
|
|
480
449
|
})
|
|
481
450
|
```
|
|
482
451
|
|
|
483
|
-
### Decrypt Event Response
|
|
484
|
-
|
|
485
|
-
- By default event response are encrypted and handled in `messages.update`
|
|
486
|
-
```ts
|
|
487
|
-
import { jidNormalizedUser, getAggregateResponsesInEventMessage } from '@itsukichan/baileys'
|
|
488
|
-
|
|
489
|
-
suki.ev.on("messages.update", async ([chatUpdate]) => {
|
|
490
|
-
const eventResponses = chatUpdate.update?.eventResponses
|
|
491
|
-
const agregate = getAggregateResponsesInEventMessage({ eventResponses }, jidNormalizedUser(suki.user.lid))
|
|
492
|
-
console.log(agregate)
|
|
493
|
-
})
|
|
494
|
-
```
|
|
495
|
-
|
|
496
452
|
### Summary of Events on First Connection
|
|
497
453
|
|
|
498
454
|
1. When you connect first time, `connection.update` will be fired requesting you to restart sock
|
|
@@ -508,7 +464,7 @@ suki.ev.on("messages.update", async ([chatUpdate]) => {
|
|
|
508
464
|
It can be used as follows:
|
|
509
465
|
|
|
510
466
|
```ts
|
|
511
|
-
import makeWASocket, { makeInMemoryStore } from '@
|
|
467
|
+
import makeWASocket, { makeInMemoryStore } from '@hansaka02/baileys'
|
|
512
468
|
// the store maintains the data of the WA connection in memory
|
|
513
469
|
// can be written out to a file & read from it
|
|
514
470
|
const store = makeInMemoryStore({ })
|
|
@@ -519,18 +475,18 @@ setInterval(() => {
|
|
|
519
475
|
store.writeToFile('./baileys_store.json')
|
|
520
476
|
}, 10_000)
|
|
521
477
|
|
|
522
|
-
const
|
|
478
|
+
const AlexaInc = makeWASocket({ })
|
|
523
479
|
// will listen from this socket
|
|
524
480
|
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
525
|
-
store.bind(
|
|
481
|
+
store.bind(AlexaInc.ev)
|
|
526
482
|
|
|
527
|
-
|
|
483
|
+
AlexaInc.ev.on('chats.upsert', () => {
|
|
528
484
|
// can use 'store.chats' however you want, even after the socket dies out
|
|
529
485
|
// 'chats' => a KeyedDB instance
|
|
530
486
|
console.log('got chats', store.chats.all())
|
|
531
487
|
})
|
|
532
488
|
|
|
533
|
-
|
|
489
|
+
AlexaInc.ev.on('contacts.upsert', () => {
|
|
534
490
|
console.log('got contacts', Object.values(store.contacts))
|
|
535
491
|
})
|
|
536
492
|
|
|
@@ -565,25 +521,25 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
565
521
|
const content: AnyMessageContent
|
|
566
522
|
const options: MiscMessageGenerationOptions
|
|
567
523
|
|
|
568
|
-
|
|
524
|
+
AlexaInc.sendMessage(jid, content, options)
|
|
569
525
|
```
|
|
570
526
|
|
|
571
527
|
### Non-Media Messages
|
|
572
528
|
|
|
573
529
|
#### Text Message
|
|
574
530
|
```ts
|
|
575
|
-
await
|
|
531
|
+
await AlexaInc.sendMessage(jid, { text: 'hello word' })
|
|
576
532
|
```
|
|
577
533
|
|
|
578
534
|
#### Quote Message (works with all types)
|
|
579
535
|
```ts
|
|
580
|
-
await
|
|
536
|
+
await AlexaInc.sendMessage(jid, { text: 'hello word' }, { quoted: message })
|
|
581
537
|
```
|
|
582
538
|
|
|
583
539
|
#### Mention User (works with most types)
|
|
584
540
|
- @number is to mention in text, it's optional
|
|
585
541
|
```ts
|
|
586
|
-
await
|
|
542
|
+
await AlexaInc.sendMessage(
|
|
587
543
|
jid,
|
|
588
544
|
{
|
|
589
545
|
text: '@12345678901',
|
|
@@ -596,12 +552,12 @@ await suki.sendMessage(
|
|
|
596
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
|
|
597
553
|
```ts
|
|
598
554
|
const msg = getMessageFromStore() // implement this on your end
|
|
599
|
-
await
|
|
555
|
+
await AlexaInc.sendMessage(jid, { forward: msg, force: true or number }) // WA forward the message!
|
|
600
556
|
```
|
|
601
557
|
|
|
602
558
|
#### Location Message
|
|
603
559
|
```ts
|
|
604
|
-
await
|
|
560
|
+
await AlexaInc.sendMessage(
|
|
605
561
|
jid,
|
|
606
562
|
{
|
|
607
563
|
location: {
|
|
@@ -614,7 +570,7 @@ await suki.sendMessage(
|
|
|
614
570
|
|
|
615
571
|
#### Live Location Message
|
|
616
572
|
```ts
|
|
617
|
-
await
|
|
573
|
+
await AlexaInc.sendMessage(
|
|
618
574
|
jid,
|
|
619
575
|
{
|
|
620
576
|
location: {
|
|
@@ -634,11 +590,11 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
|
|
|
634
590
|
+ 'TELtype=CELLtype=VOICEwaid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
|
|
635
591
|
+ 'END:VCARD'
|
|
636
592
|
|
|
637
|
-
await
|
|
593
|
+
await AlexaInc.sendMessage(
|
|
638
594
|
id,
|
|
639
595
|
{
|
|
640
596
|
contacts: {
|
|
641
|
-
displayName: '
|
|
597
|
+
displayName: 'hansaka02',
|
|
642
598
|
contacts: [{ vcard }]
|
|
643
599
|
}
|
|
644
600
|
}
|
|
@@ -648,7 +604,7 @@ await suki.sendMessage(
|
|
|
648
604
|
#### Reaction Message
|
|
649
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
|
|
650
606
|
```ts
|
|
651
|
-
await
|
|
607
|
+
await AlexaInc.sendMessage(
|
|
652
608
|
jid,
|
|
653
609
|
{
|
|
654
610
|
react: {
|
|
@@ -671,7 +627,7 @@ await suki.sendMessage(
|
|
|
671
627
|
| 30d | 2.592.000 |
|
|
672
628
|
|
|
673
629
|
```ts
|
|
674
|
-
await
|
|
630
|
+
await AlexaInc.sendMessage(
|
|
675
631
|
jid,
|
|
676
632
|
{
|
|
677
633
|
pin: {
|
|
@@ -685,7 +641,7 @@ await suki.sendMessage(
|
|
|
685
641
|
|
|
686
642
|
### Keep Message
|
|
687
643
|
```ts
|
|
688
|
-
await
|
|
644
|
+
await AlexaInc.sendMessage(
|
|
689
645
|
jid,
|
|
690
646
|
{
|
|
691
647
|
keep: {
|
|
@@ -698,7 +654,7 @@ await suki.sendMessage(
|
|
|
698
654
|
|
|
699
655
|
#### Poll Message
|
|
700
656
|
```ts
|
|
701
|
-
await
|
|
657
|
+
await AlexaInc.sendMessage(
|
|
702
658
|
jid,
|
|
703
659
|
{
|
|
704
660
|
poll: {
|
|
@@ -713,7 +669,7 @@ await suki.sendMessage(
|
|
|
713
669
|
|
|
714
670
|
#### Poll Result Message
|
|
715
671
|
```ts
|
|
716
|
-
await
|
|
672
|
+
await AlexaInc.sendMessage(
|
|
717
673
|
jid,
|
|
718
674
|
{
|
|
719
675
|
pollResult: {
|
|
@@ -735,7 +691,7 @@ await suki.sendMessage(
|
|
|
735
691
|
|
|
736
692
|
### Call Message
|
|
737
693
|
```ts
|
|
738
|
-
await
|
|
694
|
+
await AlexaInc.sendMessage(
|
|
739
695
|
jid,
|
|
740
696
|
{
|
|
741
697
|
call: {
|
|
@@ -748,7 +704,7 @@ await suki.sendMessage(
|
|
|
748
704
|
|
|
749
705
|
### Event Message
|
|
750
706
|
```ts
|
|
751
|
-
await
|
|
707
|
+
await AlexaInc.sendMessage(
|
|
752
708
|
jid,
|
|
753
709
|
{
|
|
754
710
|
event: {
|
|
@@ -771,7 +727,7 @@ await suki.sendMessage(
|
|
|
771
727
|
|
|
772
728
|
### Order Message
|
|
773
729
|
```ts
|
|
774
|
-
await
|
|
730
|
+
await AlexaInc.sendMessage(
|
|
775
731
|
jid,
|
|
776
732
|
{
|
|
777
733
|
order: {
|
|
@@ -793,7 +749,7 @@ await suki.sendMessage(
|
|
|
793
749
|
|
|
794
750
|
### Product Message
|
|
795
751
|
```ts
|
|
796
|
-
await
|
|
752
|
+
await AlexaInc.sendMessage(
|
|
797
753
|
jid,
|
|
798
754
|
{
|
|
799
755
|
product: {
|
|
@@ -819,7 +775,7 @@ await suki.sendMessage(
|
|
|
819
775
|
|
|
820
776
|
### Payment Message
|
|
821
777
|
```ts
|
|
822
|
-
await
|
|
778
|
+
await AlexaInc.sendMessage(
|
|
823
779
|
jid,
|
|
824
780
|
{
|
|
825
781
|
payment: {
|
|
@@ -841,7 +797,7 @@ await suki.sendMessage(
|
|
|
841
797
|
|
|
842
798
|
#### Payment Invite Message
|
|
843
799
|
```ts
|
|
844
|
-
await
|
|
800
|
+
await AlexaInc.sendMessage(
|
|
845
801
|
id,
|
|
846
802
|
{
|
|
847
803
|
paymentInvite: {
|
|
@@ -854,7 +810,7 @@ await suki.sendMessage(
|
|
|
854
810
|
|
|
855
811
|
### Admin Invite Message
|
|
856
812
|
```ts
|
|
857
|
-
await
|
|
813
|
+
await AlexaInc.sendMessage(
|
|
858
814
|
jid,
|
|
859
815
|
{
|
|
860
816
|
adminInvite: {
|
|
@@ -870,7 +826,7 @@ await suki.sendMessage(
|
|
|
870
826
|
|
|
871
827
|
### Group Invite Message
|
|
872
828
|
```ts
|
|
873
|
-
await
|
|
829
|
+
await AlexaInc.sendMessage(
|
|
874
830
|
jid,
|
|
875
831
|
{
|
|
876
832
|
groupInvite: {
|
|
@@ -888,12 +844,12 @@ await suki.sendMessage(
|
|
|
888
844
|
### Sticker Pack Message
|
|
889
845
|
```ts
|
|
890
846
|
// I don't know why the sticker doesn't appear
|
|
891
|
-
await
|
|
847
|
+
await AlexaInc.sendMessage(
|
|
892
848
|
jid,
|
|
893
849
|
{
|
|
894
850
|
stickerPack: {
|
|
895
851
|
name: 'Hiii',
|
|
896
|
-
publisher: 'By
|
|
852
|
+
publisher: 'By hansaka02',
|
|
897
853
|
description: 'Hello',
|
|
898
854
|
cover: Buffer, // Image buffer
|
|
899
855
|
stickers: [{
|
|
@@ -917,7 +873,7 @@ await suki.sendMessage(
|
|
|
917
873
|
|
|
918
874
|
### Share Phone Number Message
|
|
919
875
|
```ts
|
|
920
|
-
await
|
|
876
|
+
await AlexaInc.sendMessage(
|
|
921
877
|
jid,
|
|
922
878
|
{
|
|
923
879
|
sharePhoneNumber: {
|
|
@@ -928,7 +884,7 @@ await suki.sendMessage(
|
|
|
928
884
|
|
|
929
885
|
### Request Phone Number Message
|
|
930
886
|
```ts
|
|
931
|
-
await
|
|
887
|
+
await AlexaInc.sendMessage(
|
|
932
888
|
jid,
|
|
933
889
|
{
|
|
934
890
|
requestPhoneNumber: {
|
|
@@ -940,7 +896,7 @@ await suki.sendMessage(
|
|
|
940
896
|
### Buttons Reply Message
|
|
941
897
|
```ts
|
|
942
898
|
// List
|
|
943
|
-
await
|
|
899
|
+
await AlexaInc.sendMessage(
|
|
944
900
|
jid,
|
|
945
901
|
{
|
|
946
902
|
buttonReply: {
|
|
@@ -952,7 +908,7 @@ await suki.sendMessage(
|
|
|
952
908
|
}
|
|
953
909
|
)
|
|
954
910
|
// Plain
|
|
955
|
-
await
|
|
911
|
+
await AlexaInc.sendMessage(
|
|
956
912
|
jid,
|
|
957
913
|
{
|
|
958
914
|
buttonReply: {
|
|
@@ -964,7 +920,7 @@ await suki.sendMessage(
|
|
|
964
920
|
)
|
|
965
921
|
|
|
966
922
|
// Template
|
|
967
|
-
await
|
|
923
|
+
await AlexaInc.sendMessage(
|
|
968
924
|
jid,
|
|
969
925
|
{
|
|
970
926
|
buttonReply: {
|
|
@@ -977,7 +933,7 @@ await suki.sendMessage(
|
|
|
977
933
|
)
|
|
978
934
|
|
|
979
935
|
// Interactive
|
|
980
|
-
await
|
|
936
|
+
await AlexaInc.sendMessage(
|
|
981
937
|
jid,
|
|
982
938
|
{
|
|
983
939
|
buttonReply: {
|
|
@@ -995,7 +951,7 @@ await suki.sendMessage(
|
|
|
995
951
|
|
|
996
952
|
### Buttons Message
|
|
997
953
|
```ts
|
|
998
|
-
await
|
|
954
|
+
await AlexaInc.sendMessage(
|
|
999
955
|
jid,
|
|
1000
956
|
{
|
|
1001
957
|
text: 'This is a button message!', // image: buffer or // image: { url: url } If you want to use images
|
|
@@ -1026,7 +982,7 @@ await suki.sendMessage(
|
|
|
1026
982
|
### Buttons List Message
|
|
1027
983
|
```ts
|
|
1028
984
|
// Just working in a private chat
|
|
1029
|
-
await
|
|
985
|
+
await AlexaInc.sendMessage(
|
|
1030
986
|
jid,
|
|
1031
987
|
{
|
|
1032
988
|
text: 'This is a list!',
|
|
@@ -1065,7 +1021,7 @@ await suki.sendMessage(
|
|
|
1065
1021
|
### Buttons Product List Message
|
|
1066
1022
|
```ts
|
|
1067
1023
|
// Just working in a private chat
|
|
1068
|
-
await
|
|
1024
|
+
await AlexaInc.sendMessage(
|
|
1069
1025
|
jid,
|
|
1070
1026
|
{
|
|
1071
1027
|
text: 'This is a list!',
|
|
@@ -1091,7 +1047,7 @@ await suki.sendMessage(
|
|
|
1091
1047
|
|
|
1092
1048
|
### Buttons Cards Message
|
|
1093
1049
|
```ts
|
|
1094
|
-
await
|
|
1050
|
+
await AlexaInc.sendMessage(
|
|
1095
1051
|
jid,
|
|
1096
1052
|
{
|
|
1097
1053
|
text: 'Body Message',
|
|
@@ -1151,7 +1107,7 @@ await suki.sendMessage(
|
|
|
1151
1107
|
### Buttons Template Message
|
|
1152
1108
|
```ts
|
|
1153
1109
|
// This no longer works
|
|
1154
|
-
await
|
|
1110
|
+
await AlexaInc.sendMessage(
|
|
1155
1111
|
jid,
|
|
1156
1112
|
{
|
|
1157
1113
|
text: 'This is a template message!',
|
|
@@ -1183,7 +1139,7 @@ await suki.sendMessage(
|
|
|
1183
1139
|
|
|
1184
1140
|
### Buttons Interactive Message
|
|
1185
1141
|
```ts
|
|
1186
|
-
await
|
|
1142
|
+
await AlexaInc.sendMessage(
|
|
1187
1143
|
jid,
|
|
1188
1144
|
{
|
|
1189
1145
|
text: 'This is an Interactive message!',
|
|
@@ -1286,7 +1242,7 @@ await suki.sendMessage(
|
|
|
1286
1242
|
flow_message_version: '3',
|
|
1287
1243
|
flow_token: '1:1307913409923914:293680f87029f5a13d1ec5e35e718af3',
|
|
1288
1244
|
flow_id: '1307913409923914',
|
|
1289
|
-
flow_cta: '
|
|
1245
|
+
flow_cta: 'hansaka02 kawaii >\\<',
|
|
1290
1246
|
flow_action: 'navigate',
|
|
1291
1247
|
flow_action_payload: {
|
|
1292
1248
|
screen: 'QUESTION_ONE',
|
|
@@ -1335,7 +1291,7 @@ await suki.sendMessage(
|
|
|
1335
1291
|
)
|
|
1336
1292
|
|
|
1337
1293
|
// If you want to use an image
|
|
1338
|
-
await
|
|
1294
|
+
await AlexaInc.sendMessage(
|
|
1339
1295
|
jid,
|
|
1340
1296
|
{
|
|
1341
1297
|
image: {
|
|
@@ -1359,7 +1315,7 @@ await suki.sendMessage(
|
|
|
1359
1315
|
)
|
|
1360
1316
|
|
|
1361
1317
|
// If you want to use an video
|
|
1362
|
-
await
|
|
1318
|
+
await AlexaInc.sendMessage(
|
|
1363
1319
|
jid,
|
|
1364
1320
|
{
|
|
1365
1321
|
video: {
|
|
@@ -1383,14 +1339,14 @@ await suki.sendMessage(
|
|
|
1383
1339
|
)
|
|
1384
1340
|
|
|
1385
1341
|
// If you want to use an document
|
|
1386
|
-
await
|
|
1342
|
+
await AlexaInc.sendMessage(
|
|
1387
1343
|
jid,
|
|
1388
1344
|
{
|
|
1389
1345
|
document: {
|
|
1390
1346
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1391
1347
|
},
|
|
1392
1348
|
mimetype: 'image/jpeg',
|
|
1393
|
-
jpegThumbnail: await
|
|
1349
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1394
1350
|
caption: 'Body',
|
|
1395
1351
|
title: 'Title',
|
|
1396
1352
|
subtitle: 'Subtitle',
|
|
@@ -1409,7 +1365,7 @@ await suki.sendMessage(
|
|
|
1409
1365
|
)
|
|
1410
1366
|
|
|
1411
1367
|
// If you want to use an location
|
|
1412
|
-
await
|
|
1368
|
+
await AlexaInc.sendMessage(
|
|
1413
1369
|
jid,
|
|
1414
1370
|
{
|
|
1415
1371
|
location: {
|
|
@@ -1435,7 +1391,7 @@ await suki.sendMessage(
|
|
|
1435
1391
|
)
|
|
1436
1392
|
|
|
1437
1393
|
// if you want to use an product
|
|
1438
|
-
await
|
|
1394
|
+
await AlexaInc.sendMessage(
|
|
1439
1395
|
jid,
|
|
1440
1396
|
{
|
|
1441
1397
|
product: {
|
|
@@ -1447,7 +1403,7 @@ await suki.sendMessage(
|
|
|
1447
1403
|
description: 'Description',
|
|
1448
1404
|
currencyCode: 'IDR',
|
|
1449
1405
|
priceAmount1000: '283xxx',
|
|
1450
|
-
retailerId: '
|
|
1406
|
+
retailerId: 'hansaka02',
|
|
1451
1407
|
url: 'https://example.com',
|
|
1452
1408
|
productImageCount: 1
|
|
1453
1409
|
},
|
|
@@ -1472,7 +1428,7 @@ await suki.sendMessage(
|
|
|
1472
1428
|
|
|
1473
1429
|
### Buttons Interactive Message PIX
|
|
1474
1430
|
```ts
|
|
1475
|
-
await
|
|
1431
|
+
await AlexaInc.sendMessage(
|
|
1476
1432
|
jid,
|
|
1477
1433
|
{
|
|
1478
1434
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1483,8 +1439,8 @@ await suki.sendMessage(
|
|
|
1483
1439
|
payment_settings: [{
|
|
1484
1440
|
type: "pix_static_code",
|
|
1485
1441
|
pix_static_code: {
|
|
1486
|
-
merchant_name: '
|
|
1487
|
-
key: 'example@
|
|
1442
|
+
merchant_name: 'hansaka02 kawaii >\\\\\\<',
|
|
1443
|
+
key: 'example@hansaka02.com',
|
|
1488
1444
|
key_type: 'EMAIL' // PHONE || EMAIL || CPF || EVP
|
|
1489
1445
|
}
|
|
1490
1446
|
}]
|
|
@@ -1497,7 +1453,7 @@ await suki.sendMessage(
|
|
|
1497
1453
|
|
|
1498
1454
|
### Buttons Interactive Message PAY
|
|
1499
1455
|
```ts
|
|
1500
|
-
await
|
|
1456
|
+
await AlexaInc.sendMessage(
|
|
1501
1457
|
jid,
|
|
1502
1458
|
{
|
|
1503
1459
|
text: '', // This string is required. Even it's empty.
|
|
@@ -1527,7 +1483,7 @@ await suki.sendMessage(
|
|
|
1527
1483
|
order_type: 'PAYMENT_REQUEST',
|
|
1528
1484
|
items: [{
|
|
1529
1485
|
retailer_id: 'your_retailer_id',
|
|
1530
|
-
name: '
|
|
1486
|
+
name: 'hansaka02 Kawaii >\\\<',
|
|
1531
1487
|
amount: {
|
|
1532
1488
|
value: '999999999',
|
|
1533
1489
|
offset: '100'
|
|
@@ -1535,7 +1491,7 @@ await suki.sendMessage(
|
|
|
1535
1491
|
quantity: '1',
|
|
1536
1492
|
}]
|
|
1537
1493
|
},
|
|
1538
|
-
additional_note: '
|
|
1494
|
+
additional_note: 'hansaka02 Kawaii >\\\<',
|
|
1539
1495
|
native_payment_methods: [],
|
|
1540
1496
|
share_payment_status: false
|
|
1541
1497
|
})
|
|
@@ -1555,7 +1511,7 @@ const jidat = [
|
|
|
1555
1511
|
'62xxxxxxx@s.whatsapp.net'
|
|
1556
1512
|
]
|
|
1557
1513
|
// Text
|
|
1558
|
-
await
|
|
1514
|
+
await AlexaInc.sendStatusMentions(
|
|
1559
1515
|
{
|
|
1560
1516
|
text: 'Hello Everyone :3',
|
|
1561
1517
|
font: 2, // optional
|
|
@@ -1566,7 +1522,7 @@ await suki.sendStatusMentions(
|
|
|
1566
1522
|
)
|
|
1567
1523
|
|
|
1568
1524
|
// Image
|
|
1569
|
-
await
|
|
1525
|
+
await AlexaInc.sendStatusMentions(
|
|
1570
1526
|
{
|
|
1571
1527
|
Image: { url: 'https://example.com/ruriooe.jpg' }, or image buffer
|
|
1572
1528
|
caption: 'Hello Everyone :3' // optional
|
|
@@ -1575,7 +1531,7 @@ await suki.sendStatusMentions(
|
|
|
1575
1531
|
)
|
|
1576
1532
|
|
|
1577
1533
|
// Video
|
|
1578
|
-
await
|
|
1534
|
+
await AlexaInc.sendStatusMentions(
|
|
1579
1535
|
{
|
|
1580
1536
|
video: { url: 'https://example.com/ruriooe.mp4' }, or video buffer
|
|
1581
1537
|
caption: 'Hello Everyone :3' // optional
|
|
@@ -1584,7 +1540,7 @@ await suki.sendStatusMentions(
|
|
|
1584
1540
|
)
|
|
1585
1541
|
|
|
1586
1542
|
// Audio
|
|
1587
|
-
await
|
|
1543
|
+
await AlexaInc.sendStatusMentions(
|
|
1588
1544
|
{
|
|
1589
1545
|
audio: { url: 'https://example.com/ruriooe.mp3' }, or audio buffer
|
|
1590
1546
|
backgroundColor: '#000000', // optional
|
|
@@ -1597,7 +1553,7 @@ await suki.sendStatusMentions(
|
|
|
1597
1553
|
|
|
1598
1554
|
### Shop Message
|
|
1599
1555
|
```ts
|
|
1600
|
-
await
|
|
1556
|
+
await AlexaInc.sendMessage(
|
|
1601
1557
|
jid,
|
|
1602
1558
|
{
|
|
1603
1559
|
text: 'Body',
|
|
@@ -1613,7 +1569,7 @@ await suki.sendMessage(
|
|
|
1613
1569
|
)
|
|
1614
1570
|
|
|
1615
1571
|
// Image
|
|
1616
|
-
await
|
|
1572
|
+
await AlexaInc.sendMessage(
|
|
1617
1573
|
jid,
|
|
1618
1574
|
{
|
|
1619
1575
|
image: {
|
|
@@ -1633,7 +1589,7 @@ await suki.sendMessage(
|
|
|
1633
1589
|
)
|
|
1634
1590
|
|
|
1635
1591
|
// Video
|
|
1636
|
-
await
|
|
1592
|
+
await AlexaInc.sendMessage(
|
|
1637
1593
|
jid,
|
|
1638
1594
|
{
|
|
1639
1595
|
video: {
|
|
@@ -1653,14 +1609,14 @@ await suki.sendMessage(
|
|
|
1653
1609
|
)
|
|
1654
1610
|
|
|
1655
1611
|
// Document
|
|
1656
|
-
await
|
|
1612
|
+
await AlexaInc.sendMessage(
|
|
1657
1613
|
jid,
|
|
1658
1614
|
{
|
|
1659
1615
|
document: {
|
|
1660
1616
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1661
1617
|
},
|
|
1662
1618
|
mimetype: 'image/jpeg',
|
|
1663
|
-
jpegThumbnail: await
|
|
1619
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1664
1620
|
caption: 'Body',
|
|
1665
1621
|
title: 'Title',
|
|
1666
1622
|
subtitle: 'Subtitle',
|
|
@@ -1675,7 +1631,7 @@ await suki.sendMessage(
|
|
|
1675
1631
|
)
|
|
1676
1632
|
|
|
1677
1633
|
// Location
|
|
1678
|
-
await
|
|
1634
|
+
await AlexaInc.sendMessage(
|
|
1679
1635
|
jid,
|
|
1680
1636
|
{
|
|
1681
1637
|
location: {
|
|
@@ -1697,7 +1653,7 @@ await suki.sendMessage(
|
|
|
1697
1653
|
)
|
|
1698
1654
|
|
|
1699
1655
|
// Product
|
|
1700
|
-
await
|
|
1656
|
+
await AlexaInc.sendMessage(
|
|
1701
1657
|
jid,
|
|
1702
1658
|
{
|
|
1703
1659
|
product: {
|
|
@@ -1709,7 +1665,7 @@ await suki.sendMessage(
|
|
|
1709
1665
|
description: 'Description',
|
|
1710
1666
|
currencyCode: 'IDR',
|
|
1711
1667
|
priceAmount1000: '283xxx',
|
|
1712
|
-
retailerId: '
|
|
1668
|
+
retailerId: 'hansaka02',
|
|
1713
1669
|
url: 'https://example.com',
|
|
1714
1670
|
productImageCount: 1
|
|
1715
1671
|
},
|
|
@@ -1729,7 +1685,7 @@ await suki.sendMessage(
|
|
|
1729
1685
|
```
|
|
1730
1686
|
### Collection Message
|
|
1731
1687
|
```ts
|
|
1732
|
-
await
|
|
1688
|
+
await AlexaInc.sendMessage(
|
|
1733
1689
|
jid,
|
|
1734
1690
|
{
|
|
1735
1691
|
text: 'Body',
|
|
@@ -1746,7 +1702,7 @@ await suki.sendMessage(
|
|
|
1746
1702
|
)
|
|
1747
1703
|
|
|
1748
1704
|
// Image
|
|
1749
|
-
await
|
|
1705
|
+
await AlexaInc.sendMessage(
|
|
1750
1706
|
jid,
|
|
1751
1707
|
{
|
|
1752
1708
|
image: {
|
|
@@ -1767,7 +1723,7 @@ await suki.sendMessage(
|
|
|
1767
1723
|
)
|
|
1768
1724
|
|
|
1769
1725
|
// Video
|
|
1770
|
-
await
|
|
1726
|
+
await AlexaInc.sendMessage(
|
|
1771
1727
|
jid,
|
|
1772
1728
|
{
|
|
1773
1729
|
video: {
|
|
@@ -1788,14 +1744,14 @@ await suki.sendMessage(
|
|
|
1788
1744
|
)
|
|
1789
1745
|
|
|
1790
1746
|
// Document
|
|
1791
|
-
await
|
|
1747
|
+
await AlexaInc.sendMessage(
|
|
1792
1748
|
jid,
|
|
1793
1749
|
{
|
|
1794
1750
|
document: {
|
|
1795
1751
|
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1796
1752
|
},
|
|
1797
1753
|
mimetype: 'image/jpeg',
|
|
1798
|
-
jpegThumbnail: await
|
|
1754
|
+
jpegThumbnail: await AlexaInc.resize('https://example.com/jdbenkksjs.jpg', 320, 320),
|
|
1799
1755
|
caption: 'Body',
|
|
1800
1756
|
title: 'Title',
|
|
1801
1757
|
subtitle: 'Subtitle',
|
|
@@ -1811,7 +1767,7 @@ await suki.sendMessage(
|
|
|
1811
1767
|
)
|
|
1812
1768
|
|
|
1813
1769
|
// Location
|
|
1814
|
-
await
|
|
1770
|
+
await AlexaInc.sendMessage(
|
|
1815
1771
|
jid,
|
|
1816
1772
|
{
|
|
1817
1773
|
location: {
|
|
@@ -1834,7 +1790,7 @@ await suki.sendMessage(
|
|
|
1834
1790
|
)
|
|
1835
1791
|
|
|
1836
1792
|
// Product
|
|
1837
|
-
await
|
|
1793
|
+
await AlexaInc.sendMessage(
|
|
1838
1794
|
jid,
|
|
1839
1795
|
{
|
|
1840
1796
|
product: {
|
|
@@ -1846,7 +1802,7 @@ await suki.sendMessage(
|
|
|
1846
1802
|
description: 'Description',
|
|
1847
1803
|
currencyCode: 'IDR',
|
|
1848
1804
|
priceAmount1000: '283xxx',
|
|
1849
|
-
retailerId: '
|
|
1805
|
+
retailerId: 'hansaka02',
|
|
1850
1806
|
url: 'https://example.com',
|
|
1851
1807
|
productImageCount: 1
|
|
1852
1808
|
},
|
|
@@ -1868,7 +1824,7 @@ await suki.sendMessage(
|
|
|
1868
1824
|
|
|
1869
1825
|
### AI Icon Feature
|
|
1870
1826
|
```ts
|
|
1871
|
-
await
|
|
1827
|
+
await AlexaInc.sendMessage(
|
|
1872
1828
|
jid,
|
|
1873
1829
|
{
|
|
1874
1830
|
text: 'Hi'
|
|
@@ -1878,7 +1834,7 @@ await suki.sendMessage(
|
|
|
1878
1834
|
)
|
|
1879
1835
|
|
|
1880
1836
|
// If using relay
|
|
1881
|
-
await
|
|
1837
|
+
await AlexaInc.relayMessage(
|
|
1882
1838
|
jid,
|
|
1883
1839
|
{
|
|
1884
1840
|
extendedTextMessage: {
|
|
@@ -1897,7 +1853,7 @@ await suki.relayMessage(
|
|
|
1897
1853
|
3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
|
|
1898
1854
|
4. Send a link:
|
|
1899
1855
|
```ts
|
|
1900
|
-
await
|
|
1856
|
+
await AlexaInc.sendMessage(
|
|
1901
1857
|
jid,
|
|
1902
1858
|
{
|
|
1903
1859
|
text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
|
|
@@ -1920,7 +1876,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
1920
1876
|
#### Gif Message
|
|
1921
1877
|
- Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
|
|
1922
1878
|
```ts
|
|
1923
|
-
await
|
|
1879
|
+
await AlexaInc.sendMessage(
|
|
1924
1880
|
jid,
|
|
1925
1881
|
{
|
|
1926
1882
|
video: fs.readFileSync('Media/ma_gif.mp4'),
|
|
@@ -1932,7 +1888,7 @@ await suki.sendMessage(
|
|
|
1932
1888
|
|
|
1933
1889
|
#### Video Message
|
|
1934
1890
|
```ts
|
|
1935
|
-
await
|
|
1891
|
+
await AlexaInc.sendMessage(
|
|
1936
1892
|
id,
|
|
1937
1893
|
{
|
|
1938
1894
|
video: {
|
|
@@ -1945,7 +1901,7 @@ await suki.sendMessage(
|
|
|
1945
1901
|
|
|
1946
1902
|
#### Video Ptv Message
|
|
1947
1903
|
```ts
|
|
1948
|
-
await
|
|
1904
|
+
await AlexaInc.sendMessage(
|
|
1949
1905
|
id,
|
|
1950
1906
|
{
|
|
1951
1907
|
video: {
|
|
@@ -1969,7 +1925,7 @@ await suki.sendMessage(
|
|
|
1969
1925
|
ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
|
|
1970
1926
|
```
|
|
1971
1927
|
```ts
|
|
1972
|
-
await
|
|
1928
|
+
await AlexaInc.sendMessage(
|
|
1973
1929
|
jid,
|
|
1974
1930
|
{
|
|
1975
1931
|
audio: {
|
|
@@ -1982,7 +1938,7 @@ await suki.sendMessage(
|
|
|
1982
1938
|
|
|
1983
1939
|
#### Image Message
|
|
1984
1940
|
```ts
|
|
1985
|
-
await
|
|
1941
|
+
await AlexaInc.sendMessage(
|
|
1986
1942
|
id,
|
|
1987
1943
|
{
|
|
1988
1944
|
image: {
|
|
@@ -1995,12 +1951,12 @@ await suki.sendMessage(
|
|
|
1995
1951
|
|
|
1996
1952
|
### Album Message
|
|
1997
1953
|
```ts
|
|
1998
|
-
await
|
|
1954
|
+
await AlexaInc.sendMessage(
|
|
1999
1955
|
id,
|
|
2000
1956
|
{
|
|
2001
1957
|
album: [{
|
|
2002
1958
|
image: {
|
|
2003
|
-
url: 'https://example.com/
|
|
1959
|
+
url: 'https://example.com/hansaka02.jpg'
|
|
2004
1960
|
},
|
|
2005
1961
|
caption: 'Hay'
|
|
2006
1962
|
}, {
|
|
@@ -2008,7 +1964,7 @@ await suki.sendMessage(
|
|
|
2008
1964
|
caption: 'Hay'
|
|
2009
1965
|
}, {
|
|
2010
1966
|
video: {
|
|
2011
|
-
url: 'https://example.com/
|
|
1967
|
+
url: 'https://example.com/hansaka02.mp4'
|
|
2012
1968
|
},
|
|
2013
1969
|
caption: 'Hay'
|
|
2014
1970
|
}, {
|
|
@@ -2024,7 +1980,7 @@ await suki.sendMessage(
|
|
|
2024
1980
|
- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
|
|
2025
1981
|
|
|
2026
1982
|
```ts
|
|
2027
|
-
await
|
|
1983
|
+
await AlexaInc.sendMessage(
|
|
2028
1984
|
id,
|
|
2029
1985
|
{
|
|
2030
1986
|
image: {
|
|
@@ -2041,8 +1997,8 @@ await suki.sendMessage(
|
|
|
2041
1997
|
### Deleting Messages (for everyone)
|
|
2042
1998
|
|
|
2043
1999
|
```ts
|
|
2044
|
-
const msg = await
|
|
2045
|
-
await
|
|
2000
|
+
const msg = await AlexaInc.sendMessage(jid, { text: 'hello word' })
|
|
2001
|
+
await AlexaInc.sendMessage(jid, { delete: msg.key })
|
|
2046
2002
|
```
|
|
2047
2003
|
|
|
2048
2004
|
**Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
|
|
@@ -2051,7 +2007,7 @@ await suki.sendMessage(jid, { delete: msg.key })
|
|
|
2051
2007
|
|
|
2052
2008
|
- You can pass all editable contents here
|
|
2053
2009
|
```ts
|
|
2054
|
-
await
|
|
2010
|
+
await AlexaInc.sendMessage(jid, {
|
|
2055
2011
|
text: 'updated text goes here',
|
|
2056
2012
|
edit: response.key,
|
|
2057
2013
|
})
|
|
@@ -2068,9 +2024,9 @@ await suki.sendMessage(jid, {
|
|
|
2068
2024
|
If you want to save the media you received
|
|
2069
2025
|
```ts
|
|
2070
2026
|
import { createWriteStream } from 'fs'
|
|
2071
|
-
import { downloadMediaMessage, getContentType } from '@
|
|
2027
|
+
import { downloadMediaMessage, getContentType } from '@hansaka02/baileys'
|
|
2072
2028
|
|
|
2073
|
-
|
|
2029
|
+
AlexaInc.ev.on('messages.upsert', async ({ [m] }) => {
|
|
2074
2030
|
if (!m.message) return // if there is no text or media message
|
|
2075
2031
|
const messageType = getContentType(m) // get what type of message it is (text, image, video...)
|
|
2076
2032
|
|
|
@@ -2085,7 +2041,7 @@ suki.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
2085
2041
|
logger,
|
|
2086
2042
|
// pass this so that baileys can request a reupload of media
|
|
2087
2043
|
// that has been deleted
|
|
2088
|
-
reuploadRequest:
|
|
2044
|
+
reuploadRequest: AlexaInc.updateMediaMessage
|
|
2089
2045
|
}
|
|
2090
2046
|
)
|
|
2091
2047
|
// save to file
|
|
@@ -2099,7 +2055,7 @@ suki.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
2099
2055
|
|
|
2100
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:
|
|
2101
2057
|
```ts
|
|
2102
|
-
await
|
|
2058
|
+
await AlexaInc.updateMediaMessage(msg)
|
|
2103
2059
|
```
|
|
2104
2060
|
|
|
2105
2061
|
## Reject Call
|
|
@@ -2107,7 +2063,7 @@ await suki.updateMediaMessage(msg)
|
|
|
2107
2063
|
- You can obtain `callId` and `callFrom` from `call` event
|
|
2108
2064
|
|
|
2109
2065
|
```ts
|
|
2110
|
-
await
|
|
2066
|
+
await AlexaInc.rejectCall(callId, callFrom)
|
|
2111
2067
|
```
|
|
2112
2068
|
|
|
2113
2069
|
## Send States in Chat
|
|
@@ -2120,7 +2076,7 @@ This means you have to keep track of unread messages.
|
|
|
2120
2076
|
```ts
|
|
2121
2077
|
const key: WAMessageKey
|
|
2122
2078
|
// can pass multiple keys to read multiple messages as well
|
|
2123
|
-
await
|
|
2079
|
+
await AlexaInc.readMessages([key])
|
|
2124
2080
|
```
|
|
2125
2081
|
|
|
2126
2082
|
The message ID is the unique identifier of the message that you are marking as read.
|
|
@@ -2133,11 +2089,11 @@ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.k
|
|
|
2133
2089
|
- This lets the person/group with `jid` know whether you're online, offline, typing etc.
|
|
2134
2090
|
|
|
2135
2091
|
```ts
|
|
2136
|
-
await
|
|
2092
|
+
await AlexaInc.sendPresenceUpdate('available', jid)
|
|
2137
2093
|
```
|
|
2138
2094
|
|
|
2139
2095
|
> [!NOTE]
|
|
2140
|
-
> 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')`
|
|
2141
2097
|
|
|
2142
2098
|
## Modifying Chats
|
|
2143
2099
|
|
|
@@ -2149,7 +2105,7 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
|
|
|
2149
2105
|
### Archive a Chat
|
|
2150
2106
|
```ts
|
|
2151
2107
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2152
|
-
await
|
|
2108
|
+
await AlexaInc.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
2153
2109
|
```
|
|
2154
2110
|
### Mute/Unmute a Chat
|
|
2155
2111
|
|
|
@@ -2163,20 +2119,20 @@ await suki.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
|
2163
2119
|
|
|
2164
2120
|
```ts
|
|
2165
2121
|
// mute for 8 hours
|
|
2166
|
-
await
|
|
2122
|
+
await AlexaInc.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
2167
2123
|
// unmute
|
|
2168
|
-
await
|
|
2124
|
+
await AlexaInc.chatModify({ mute: null }, jid)
|
|
2169
2125
|
```
|
|
2170
2126
|
### Mark a Chat Read/Unread
|
|
2171
2127
|
```ts
|
|
2172
2128
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2173
2129
|
// mark it unread
|
|
2174
|
-
await
|
|
2130
|
+
await AlexaInc.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
|
|
2175
2131
|
```
|
|
2176
2132
|
|
|
2177
2133
|
### Delete a Message for Me
|
|
2178
2134
|
```ts
|
|
2179
|
-
await
|
|
2135
|
+
await AlexaInc.chatModify(
|
|
2180
2136
|
{
|
|
2181
2137
|
clear: {
|
|
2182
2138
|
messages: [
|
|
@@ -2195,7 +2151,7 @@ await suki.chatModify(
|
|
|
2195
2151
|
### Delete a Chat
|
|
2196
2152
|
```ts
|
|
2197
2153
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
2198
|
-
await
|
|
2154
|
+
await AlexaInc.chatModify({
|
|
2199
2155
|
delete: true,
|
|
2200
2156
|
lastMessages: [
|
|
2201
2157
|
{
|
|
@@ -2209,7 +2165,7 @@ await suki.chatModify({
|
|
|
2209
2165
|
```
|
|
2210
2166
|
### Pin/Unpin a Chat
|
|
2211
2167
|
```ts
|
|
2212
|
-
await
|
|
2168
|
+
await AlexaInc.chatModify({
|
|
2213
2169
|
pin: true // or `false` to unpin
|
|
2214
2170
|
},
|
|
2215
2171
|
jid
|
|
@@ -2217,7 +2173,7 @@ await suki.chatModify({
|
|
|
2217
2173
|
```
|
|
2218
2174
|
### Star/Unstar a Message
|
|
2219
2175
|
```ts
|
|
2220
|
-
await
|
|
2176
|
+
await AlexaInc.chatModify({
|
|
2221
2177
|
star: {
|
|
2222
2178
|
messages: [
|
|
2223
2179
|
{
|
|
@@ -2247,17 +2203,17 @@ await suki.chatModify({
|
|
|
2247
2203
|
|
|
2248
2204
|
```ts
|
|
2249
2205
|
// turn on disappearing messages
|
|
2250
|
-
await
|
|
2206
|
+
await AlexaInc.sendMessage(
|
|
2251
2207
|
jid,
|
|
2252
2208
|
// this is 1 week in seconds -- how long you want messages to appear for
|
|
2253
2209
|
{ disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
|
|
2254
2210
|
)
|
|
2255
2211
|
|
|
2256
2212
|
// will send as a disappearing message
|
|
2257
|
-
await
|
|
2213
|
+
await AlexaInc.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
|
|
2258
2214
|
|
|
2259
2215
|
// turn off disappearing messages
|
|
2260
|
-
await
|
|
2216
|
+
await AlexaInc.sendMessage(
|
|
2261
2217
|
jid,
|
|
2262
2218
|
{ disappearingMessagesInChat: false }
|
|
2263
2219
|
)
|
|
@@ -2265,14 +2221,14 @@ await suki.sendMessage(
|
|
|
2265
2221
|
|
|
2266
2222
|
### Clear Messages
|
|
2267
2223
|
```ts
|
|
2268
|
-
await
|
|
2224
|
+
await AlexaInc.clearMessage(jid, key, timestamps)
|
|
2269
2225
|
```
|
|
2270
2226
|
|
|
2271
2227
|
## User Querys
|
|
2272
2228
|
|
|
2273
2229
|
### Check If ID Exists in Whatsapp
|
|
2274
2230
|
```ts
|
|
2275
|
-
const [result] = await
|
|
2231
|
+
const [result] = await AlexaInc.onWhatsApp(jid)
|
|
2276
2232
|
if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
|
|
2277
2233
|
```
|
|
2278
2234
|
|
|
@@ -2281,7 +2237,7 @@ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid
|
|
|
2281
2237
|
- You need to have oldest message in chat
|
|
2282
2238
|
```ts
|
|
2283
2239
|
const msg = await getOldestMessageInChat(jid)
|
|
2284
|
-
await
|
|
2240
|
+
await AlexaInc.fetchMessageHistory(
|
|
2285
2241
|
50, //quantity (max: 50 per query)
|
|
2286
2242
|
msg.key,
|
|
2287
2243
|
msg.messageTimestamp
|
|
@@ -2291,7 +2247,7 @@ await suki.fetchMessageHistory(
|
|
|
2291
2247
|
|
|
2292
2248
|
### Fetch Status
|
|
2293
2249
|
```ts
|
|
2294
|
-
const status = await
|
|
2250
|
+
const status = await AlexaInc.fetchStatus(jid)
|
|
2295
2251
|
console.log('status: ' + status)
|
|
2296
2252
|
```
|
|
2297
2253
|
|
|
@@ -2299,34 +2255,34 @@ console.log('status: ' + status)
|
|
|
2299
2255
|
- To get the display picture of some person, group and channel
|
|
2300
2256
|
```ts
|
|
2301
2257
|
// for low res picture
|
|
2302
|
-
const ppUrl = await
|
|
2258
|
+
const ppUrl = await AlexaInc.profilePictureUrl(jid)
|
|
2303
2259
|
console.log(ppUrl)
|
|
2304
2260
|
```
|
|
2305
2261
|
|
|
2306
2262
|
### Fetch Bussines Profile (such as description or category)
|
|
2307
2263
|
```ts
|
|
2308
|
-
const profile = await
|
|
2264
|
+
const profile = await AlexaInc.getBusinessProfile(jid)
|
|
2309
2265
|
console.log('business description: ' + profile.description + ', category: ' + profile.category)
|
|
2310
2266
|
```
|
|
2311
2267
|
|
|
2312
2268
|
### Fetch Someone's Presence (if they're typing or online)
|
|
2313
2269
|
```ts
|
|
2314
2270
|
// the presence update is fetched and called here
|
|
2315
|
-
|
|
2271
|
+
AlexaInc.ev.on('presence.update', console.log)
|
|
2316
2272
|
|
|
2317
2273
|
// request updates for a chat
|
|
2318
|
-
await
|
|
2274
|
+
await AlexaInc.presenceSubscribe(jid)
|
|
2319
2275
|
```
|
|
2320
2276
|
|
|
2321
2277
|
## Change Profile
|
|
2322
2278
|
|
|
2323
2279
|
### Change Profile Status
|
|
2324
2280
|
```ts
|
|
2325
|
-
await
|
|
2281
|
+
await AlexaInc.updateProfileStatus('Hello World!')
|
|
2326
2282
|
```
|
|
2327
2283
|
### Change Profile Name
|
|
2328
2284
|
```ts
|
|
2329
|
-
await
|
|
2285
|
+
await AlexaInc.updateProfileName('My name')
|
|
2330
2286
|
```
|
|
2331
2287
|
### Change Display Picture (groups too)
|
|
2332
2288
|
- To change your display picture or a group's
|
|
@@ -2335,11 +2291,11 @@ await suki.updateProfileName('My name')
|
|
|
2335
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)
|
|
2336
2292
|
|
|
2337
2293
|
```ts
|
|
2338
|
-
await
|
|
2294
|
+
await AlexaInc.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
|
2339
2295
|
```
|
|
2340
2296
|
### Remove display picture (groups too)
|
|
2341
2297
|
```ts
|
|
2342
|
-
await
|
|
2298
|
+
await AlexaInc.removeProfilePicture(jid)
|
|
2343
2299
|
```
|
|
2344
2300
|
|
|
2345
2301
|
## Groups
|
|
@@ -2349,14 +2305,14 @@ await suki.removeProfilePicture(jid)
|
|
|
2349
2305
|
### Create a Group
|
|
2350
2306
|
```ts
|
|
2351
2307
|
// title & participants
|
|
2352
|
-
const group = await
|
|
2308
|
+
const group = await AlexaInc.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
|
|
2353
2309
|
console.log('created group with id: ' + group.gid)
|
|
2354
|
-
await
|
|
2310
|
+
await AlexaInc.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
|
|
2355
2311
|
```
|
|
2356
2312
|
### Add/Remove or Demote/Promote
|
|
2357
2313
|
```ts
|
|
2358
2314
|
// id & people to add to the group (will throw error if it fails)
|
|
2359
|
-
await
|
|
2315
|
+
await AlexaInc.groupParticipantsUpdate(
|
|
2360
2316
|
jid,
|
|
2361
2317
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2362
2318
|
'add' // replace this parameter with 'remove' or 'demote' or 'promote'
|
|
@@ -2364,68 +2320,68 @@ await suki.groupParticipantsUpdate(
|
|
|
2364
2320
|
```
|
|
2365
2321
|
### Change Subject (name)
|
|
2366
2322
|
```ts
|
|
2367
|
-
await
|
|
2323
|
+
await AlexaInc.groupUpdateSubject(jid, 'New Subject!')
|
|
2368
2324
|
```
|
|
2369
2325
|
### Change Description
|
|
2370
2326
|
```ts
|
|
2371
|
-
await
|
|
2327
|
+
await AlexaInc.groupUpdateDescription(jid, 'New Description!')
|
|
2372
2328
|
```
|
|
2373
2329
|
### Change Settings
|
|
2374
2330
|
```ts
|
|
2375
2331
|
// only allow admins to send messages
|
|
2376
|
-
await
|
|
2332
|
+
await AlexaInc.groupSettingUpdate(jid, 'announcement')
|
|
2377
2333
|
// allow everyone to send messages
|
|
2378
|
-
await
|
|
2334
|
+
await AlexaInc.groupSettingUpdate(jid, 'not_announcement')
|
|
2379
2335
|
// allow everyone to modify the group's settings -- like display picture etc.
|
|
2380
|
-
await
|
|
2336
|
+
await AlexaInc.groupSettingUpdate(jid, 'unlocked')
|
|
2381
2337
|
// only allow admins to modify the group's settings
|
|
2382
|
-
await
|
|
2338
|
+
await AlexaInc.groupSettingUpdate(jid, 'locked')
|
|
2383
2339
|
```
|
|
2384
2340
|
### Leave a Group
|
|
2385
2341
|
```ts
|
|
2386
2342
|
// will throw error if it fails
|
|
2387
|
-
await
|
|
2343
|
+
await AlexaInc.groupLeave(jid)
|
|
2388
2344
|
```
|
|
2389
2345
|
### Get Invite Code
|
|
2390
2346
|
- To create link with code use `'https://chat.whatsapp.com/' + code`
|
|
2391
2347
|
```ts
|
|
2392
|
-
const code = await
|
|
2348
|
+
const code = await AlexaInc.groupInviteCode(jid)
|
|
2393
2349
|
console.log('group code: ' + code)
|
|
2394
2350
|
```
|
|
2395
2351
|
### Revoke Invite Code
|
|
2396
2352
|
```ts
|
|
2397
|
-
const code = await
|
|
2353
|
+
const code = await AlexaInc.groupRevokeInvite(jid)
|
|
2398
2354
|
console.log('New group code: ' + code)
|
|
2399
2355
|
```
|
|
2400
2356
|
### Join Using Invitation Code
|
|
2401
2357
|
- Code can't have `https://chat.whatsapp.com/`, only code
|
|
2402
2358
|
```ts
|
|
2403
|
-
const response = await
|
|
2359
|
+
const response = await AlexaInc.groupAcceptInvite(code)
|
|
2404
2360
|
console.log('joined to: ' + response)
|
|
2405
2361
|
```
|
|
2406
2362
|
### Get Group Info by Invite Code
|
|
2407
2363
|
```ts
|
|
2408
|
-
const response = await
|
|
2364
|
+
const response = await AlexaInc.groupGetInviteInfo(code)
|
|
2409
2365
|
console.log('group information: ' + response)
|
|
2410
2366
|
```
|
|
2411
2367
|
### Query Metadata (participants, name, description...)
|
|
2412
2368
|
```ts
|
|
2413
|
-
const metadata = await
|
|
2369
|
+
const metadata = await AlexaInc.groupMetadata(jid)
|
|
2414
2370
|
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
|
|
2415
2371
|
```
|
|
2416
2372
|
### Join using `groupInviteMessage`
|
|
2417
2373
|
```ts
|
|
2418
|
-
const response = await
|
|
2374
|
+
const response = await AlexaInc.groupAcceptInviteV4(jid, groupInviteMessage)
|
|
2419
2375
|
console.log('joined to: ' + response)
|
|
2420
2376
|
```
|
|
2421
2377
|
### Get Request Join List
|
|
2422
2378
|
```ts
|
|
2423
|
-
const response = await
|
|
2379
|
+
const response = await AlexaInc.groupRequestParticipantsList(jid)
|
|
2424
2380
|
console.log(response)
|
|
2425
2381
|
```
|
|
2426
2382
|
### Approve/Reject Request Join
|
|
2427
2383
|
```ts
|
|
2428
|
-
const response = await
|
|
2384
|
+
const response = await AlexaInc.groupRequestParticipantsUpdate(
|
|
2429
2385
|
jid, // group id
|
|
2430
2386
|
['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
|
|
2431
2387
|
'approve' // or 'reject'
|
|
@@ -2434,7 +2390,7 @@ console.log(response)
|
|
|
2434
2390
|
```
|
|
2435
2391
|
### Get All Participating Groups Metadata
|
|
2436
2392
|
```ts
|
|
2437
|
-
const response = await
|
|
2393
|
+
const response = await AlexaInc.groupFetchAllParticipating()
|
|
2438
2394
|
console.log(response)
|
|
2439
2395
|
```
|
|
2440
2396
|
### Toggle Ephemeral
|
|
@@ -2449,12 +2405,12 @@ console.log(response)
|
|
|
2449
2405
|
| 90d | 7.776.000 |
|
|
2450
2406
|
|
|
2451
2407
|
```ts
|
|
2452
|
-
await
|
|
2408
|
+
await AlexaInc.groupToggleEphemeral(jid, 86400)
|
|
2453
2409
|
```
|
|
2454
2410
|
|
|
2455
2411
|
### Change Add Mode
|
|
2456
2412
|
```ts
|
|
2457
|
-
await
|
|
2413
|
+
await AlexaInc.groupMemberAddMode(
|
|
2458
2414
|
jid,
|
|
2459
2415
|
'all_member_add' // or 'admin_add'
|
|
2460
2416
|
)
|
|
@@ -2464,48 +2420,48 @@ await suki.groupMemberAddMode(
|
|
|
2464
2420
|
|
|
2465
2421
|
### Block/Unblock User
|
|
2466
2422
|
```ts
|
|
2467
|
-
await
|
|
2468
|
-
await
|
|
2423
|
+
await AlexaInc.updateBlockStatus(jid, 'block') // Block user
|
|
2424
|
+
await AlexaInc.updateBlockStatus(jid, 'unblock') // Unblock user
|
|
2469
2425
|
```
|
|
2470
2426
|
### Get Privacy Settings
|
|
2471
2427
|
```ts
|
|
2472
|
-
const privacySettings = await
|
|
2428
|
+
const privacySettings = await AlexaInc.fetchPrivacySettings(true)
|
|
2473
2429
|
console.log('privacy settings: ' + privacySettings)
|
|
2474
2430
|
```
|
|
2475
2431
|
### Get BlockList
|
|
2476
2432
|
```ts
|
|
2477
|
-
const response = await
|
|
2433
|
+
const response = await AlexaInc.fetchBlocklist()
|
|
2478
2434
|
console.log(response)
|
|
2479
2435
|
```
|
|
2480
2436
|
### Update LastSeen Privacy
|
|
2481
2437
|
```ts
|
|
2482
2438
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2483
|
-
await
|
|
2439
|
+
await AlexaInc.updateLastSeenPrivacy(value)
|
|
2484
2440
|
```
|
|
2485
2441
|
### Update Online Privacy
|
|
2486
2442
|
```ts
|
|
2487
2443
|
const value = 'all' // 'match_last_seen'
|
|
2488
|
-
await
|
|
2444
|
+
await AlexaInc.updateOnlinePrivacy(value)
|
|
2489
2445
|
```
|
|
2490
2446
|
### Update Profile Picture Privacy
|
|
2491
2447
|
```ts
|
|
2492
2448
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2493
|
-
await
|
|
2449
|
+
await AlexaInc.updateProfilePicturePrivacy(value)
|
|
2494
2450
|
```
|
|
2495
2451
|
### Update Status Privacy
|
|
2496
2452
|
```ts
|
|
2497
2453
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
2498
|
-
await
|
|
2454
|
+
await AlexaInc.updateStatusPrivacy(value)
|
|
2499
2455
|
```
|
|
2500
2456
|
### Update Read Receipts Privacy
|
|
2501
2457
|
```ts
|
|
2502
2458
|
const value = 'all' // 'none'
|
|
2503
|
-
await
|
|
2459
|
+
await AlexaInc.updateReadReceiptsPrivacy(value)
|
|
2504
2460
|
```
|
|
2505
2461
|
### Update Groups Add Privacy
|
|
2506
2462
|
```ts
|
|
2507
2463
|
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
2508
|
-
await
|
|
2464
|
+
await AlexaInc.updateGroupsAddPrivacy(value)
|
|
2509
2465
|
```
|
|
2510
2466
|
### Update Default Disappearing Mode
|
|
2511
2467
|
|
|
@@ -2520,7 +2476,7 @@ await suki.updateGroupsAddPrivacy(value)
|
|
|
2520
2476
|
|
|
2521
2477
|
```ts
|
|
2522
2478
|
const ephemeral = 86400
|
|
2523
|
-
await
|
|
2479
|
+
await AlexaInc.updateDefaultDisappearingMode(ephemeral)
|
|
2524
2480
|
```
|
|
2525
2481
|
|
|
2526
2482
|
## Broadcast Lists & Stories
|
|
@@ -2528,7 +2484,7 @@ await suki.updateDefaultDisappearingMode(ephemeral)
|
|
|
2528
2484
|
### Send Broadcast & Stories
|
|
2529
2485
|
- Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
|
|
2530
2486
|
```ts
|
|
2531
|
-
await
|
|
2487
|
+
await AlexaInc.sendMessage(
|
|
2532
2488
|
jid,
|
|
2533
2489
|
{
|
|
2534
2490
|
image: {
|
|
@@ -2554,7 +2510,7 @@ await suki.sendMessage(
|
|
|
2554
2510
|
- Broadcast IDs are in the format `12345678@broadcast`
|
|
2555
2511
|
### Query a Broadcast List's Recipients & Name
|
|
2556
2512
|
```ts
|
|
2557
|
-
const bList = await
|
|
2513
|
+
const bList = await AlexaInc.getBroadcastListInfo('1234@broadcast')
|
|
2558
2514
|
console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
|
|
2559
2515
|
```
|
|
2560
2516
|
|
|
@@ -2564,7 +2520,7 @@ Baileys is written with custom functionality in mind. Instead of forking the pro
|
|
|
2564
2520
|
### Enabling Debug Level in Baileys Logs
|
|
2565
2521
|
First, enable the logging of unhandled messages from WhatsApp by setting:
|
|
2566
2522
|
```ts
|
|
2567
|
-
const
|
|
2523
|
+
const AlexaInc = makeWASocket({
|
|
2568
2524
|
logger: P({ level: 'debug' }),
|
|
2569
2525
|
})
|
|
2570
2526
|
```
|
|
@@ -2619,13 +2575,13 @@ The `'frame'` is what the message received is, it has three components:
|
|
|
2619
2575
|
|
|
2620
2576
|
```ts
|
|
2621
2577
|
// for any message with tag 'edge_routing'
|
|
2622
|
-
|
|
2578
|
+
AlexaInc.ws.on('CB:edge_routing', (node: BinaryNode) => { })
|
|
2623
2579
|
|
|
2624
2580
|
// for any message with tag 'edge_routing' and id attribute = abcd
|
|
2625
|
-
|
|
2581
|
+
AlexaInc.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
|
|
2626
2582
|
|
|
2627
2583
|
// for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
|
|
2628
|
-
|
|
2584
|
+
AlexaInc.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
|
|
2629
2585
|
```
|
|
2630
2586
|
|
|
2631
2587
|
> [!NOTE]
|