@alannxd/baileys 6.1.4 → 6.1.7
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/LICENSE +4 -1
- package/README.md +205 -281
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/chats.js +5 -0
- package/lib/Socket/graphql.js +716 -0
- package/lib/Socket/index.js +9 -1
- package/lib/Socket/interop.js +463 -0
- package/lib/Socket/message-builder.js +475 -0
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +106 -30
- package/lib/Socket/mex.js +51 -39
- package/lib/Socket/newsletter.js +729 -242
- package/lib/Socket/privacy.js +318 -0
- package/lib/Socket/socket.js +163 -16
- package/lib/Socket/username.js +225 -136
- package/lib/Store/make-in-memory-store.js +47 -1
- package/lib/Types/Mex.js +76 -2
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/messages-media.js +82 -0
- package/lib/Utils/messages.js +143 -2
- package/lib/Utils/sticker.js +133 -0
- package/lib/Utils/use-sqlite-auth-state.js +162 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -50
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +55 -52
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -25
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +58 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -36
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -23
- package/lib/WAUSync/Protocols/index.js +12 -6
- package/lib/WAUSync/USyncQuery.js +149 -96
- package/lib/WAUSync/USyncUser.js +54 -29
- package/lib/WAUSync/index.js +3 -4
- package/lib/index.js +2 -3
- package/package.json +20 -21
- package/WAProto/fix-import.js +0 -29
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/community.js +0 -392
- package/lib/Socket/dugong.js +0 -637
- package/lib/Socket/registration.js +0 -167
- package/lib/Socket/usync.js +0 -69
- package/lib/Types/Newsletter.js +0 -38
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
package/LICENSE
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 alannxd (AlannXD) and contributors
|
|
4
|
+
|
|
5
|
+
Based on Baileys (https://github.com/WhiskeySockets/Baileys), originally
|
|
6
|
+
created by Adhiraj Singh and the WhiskeySockets community, also MIT licensed.
|
|
4
7
|
|
|
5
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
9
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -43,338 +43,264 @@ Begin by installing the library via your preferred package manager, then follow
|
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
#
|
|
46
|
+
## Table of Contents
|
|
47
|
+
|
|
48
|
+
- [Requirements](#requirements)
|
|
49
|
+
- [Install](#install)
|
|
50
|
+
- [Quick Start](#quick-start)
|
|
51
|
+
- [QR Code login](#login-with-qr-code)
|
|
52
|
+
- [Pairing Code login](#login-with-pairing-code)
|
|
53
|
+
- [Store](#store)
|
|
54
|
+
- [Sending Messages](#sending-messages)
|
|
55
|
+
- [Generic send / relay](#generic-send--relay)
|
|
56
|
+
- [Simple senders](#simple-senders)
|
|
57
|
+
- [Special message types](#special-message-types)
|
|
58
|
+
- [Events](#events)
|
|
59
|
+
- [Examples](#examples)
|
|
60
|
+
- [Known Limitations](#known-limitations)
|
|
61
|
+
- [Why Choose WhatsApp Baileys?](#why-choose-whatsapp-baileys?)
|
|
62
|
+
- [Technical Notes](#technical-notes)
|
|
63
|
+
- [Contact Developer](#contact-developer)
|
|
64
|
+
- [Contributors](#contributors-outside-the-baileys-code)
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- Node.js **>= 20**
|
|
69
|
+
- Optional peer deps depending on the features you use: `sharp` or `jimp` (image processing), `link-preview-js` (link previews), `audio-decode` (audio waveform)
|
|
70
|
+
|
|
71
|
+
## Install
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install @alannxd/baileys
|
|
75
|
+
```
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
Or alias it as `baileys` / `@whiskeysockets/baileys` in your `package.json`:
|
|
51
78
|
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Usage
|
|
55
79
|
```json
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
80
|
+
{
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"@alannxd/baileys": "latest"
|
|
83
|
+
}
|
|
59
84
|
}
|
|
60
85
|
```
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} = require('@alannxd/baileys');
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import makeWASocket from '@alannxd/baileys'
|
|
89
|
+
// or, CommonJS:
|
|
90
|
+
const { default: makeWASocket } = require('@alannxd/baileys')
|
|
67
91
|
```
|
|
68
92
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} =
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
### Login with QR Code
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import makeWASocket, { Browsers, useMultiFileAuthState } from '@alannxd/baileys'
|
|
99
|
+
|
|
100
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
|
|
77
101
|
|
|
78
102
|
const client = makeWASocket({
|
|
79
103
|
browser: Browsers.ubuntu('Chrome'),
|
|
80
|
-
printQRInTerminal: true
|
|
104
|
+
printQRInTerminal: true,
|
|
105
|
+
auth: state
|
|
81
106
|
})
|
|
107
|
+
|
|
108
|
+
client.ev.on('creds.update', saveCreds)
|
|
82
109
|
```
|
|
83
110
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} =
|
|
111
|
+
### Login with Pairing Code
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import makeWASocket, { Browsers, fetchLatestWAWebVersion, useMultiFileAuthState } from '@alannxd/baileys'
|
|
115
|
+
|
|
116
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
|
|
117
|
+
const { version } = await fetchLatestWAWebVersion()
|
|
91
118
|
|
|
92
119
|
const client = makeWASocket({
|
|
93
120
|
browser: Browsers.ubuntu('Chrome'),
|
|
94
121
|
printQRInTerminal: false,
|
|
95
|
-
version
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
122
|
+
version,
|
|
123
|
+
auth: state
|
|
124
|
+
})
|
|
99
125
|
|
|
100
|
-
|
|
101
|
-
const code = await client.requestPairingCode(number.trim) //Use : (number, "YYYYYYYY") for custom-pairing
|
|
126
|
+
client.ev.on('creds.update', saveCreds)
|
|
102
127
|
|
|
103
|
-
|
|
128
|
+
if (!client.authState?.creds?.registered) {
|
|
129
|
+
const phoneNumber = '628XXXXXXXXXX' // international format, no '+'
|
|
130
|
+
const code = await client.requestPairingCode(phoneNumber)
|
|
131
|
+
// custom pairing code (8 characters):
|
|
132
|
+
// const code = await client.requestPairingCode(phoneNumber, 'YYYYYYYY')
|
|
133
|
+
console.log('Pairing code:', code)
|
|
134
|
+
}
|
|
104
135
|
```
|
|
105
136
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
137
|
+
## Store
|
|
138
|
+
|
|
139
|
+
`makeInMemoryStore` builds a local cache of chats/contacts/messages, which
|
|
140
|
+
Baileys does not persist automatically by default.
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
import makeWASocket, { makeInMemoryStore } from '@alannxd/baileys'
|
|
144
|
+
import pino from 'pino'
|
|
113
145
|
|
|
114
146
|
const store = makeInMemoryStore({
|
|
115
147
|
logger: pino().child({ level: 'silent', stream: 'store' })
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const client = makeWASocket({ /* ...other options */ })
|
|
120
151
|
store.bind(client.ev)
|
|
121
152
|
|
|
122
153
|
client.ev.on('contacts.upsert', () => {
|
|
123
|
-
console.log('
|
|
154
|
+
console.log('New contact:', Object.values(store.contacts))
|
|
124
155
|
})
|
|
125
156
|
```
|
|
126
|
-
# Sending messages
|
|
127
|
-
|
|
128
|
-
## send/relay message with participant
|
|
129
|
-
```javascript
|
|
130
|
-
await client.relayMessage(m.chat, {
|
|
131
|
-
conversation: "Alann Winter's"
|
|
132
|
-
}, {
|
|
133
|
-
participant: true
|
|
134
|
-
})
|
|
135
|
-
// or
|
|
136
|
-
await client.sendMessage(m.chat, {
|
|
137
|
-
text: "Alann Winter's"
|
|
138
|
-
}, {
|
|
139
|
-
participant: true
|
|
140
|
-
})
|
|
141
|
-
```
|
|
142
|
-
## send orderMessage
|
|
143
|
-
```javascript
|
|
144
|
-
const fs = require('fs');
|
|
145
|
-
const AlannXd = fs.readFileSync('./AlannXd');
|
|
146
|
-
|
|
147
|
-
await client.sendMessage(m.chat, {
|
|
148
|
-
thumbnail: AlannXd,
|
|
149
|
-
message: "Gotta get a grip",
|
|
150
|
-
orderTitle: "Alann-Winters",
|
|
151
|
-
totalAmount1000: 72502,
|
|
152
|
-
totalCurrencyCode: "IDR"
|
|
153
|
-
}, { quoted:m })
|
|
154
|
-
```
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
await client.sendMessage(m.chat, {
|
|
159
|
-
pollResultMessage: {
|
|
160
|
-
name: "Alann-Winters",
|
|
161
|
-
options: [
|
|
162
|
-
{
|
|
163
|
-
optionName: "poll 1"
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
optionName: "poll 2"
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
newsletter: {
|
|
170
|
-
newsletterName: "ALANNXD | HOLOW",
|
|
171
|
-
newsletterJid: "1@newsletter"
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
```
|
|
158
|
+
Need a persistent store (Redis, etc.)? Use `makeCacheManagerStore` — see [API Reference](docs/API.md#store-libstore).
|
|
176
159
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
name: "cta_url",
|
|
192
|
-
buttonParamsJson: "{\"display_text\":\"AlannWinters\",\"url\":\"https://t.me/alannxd\"}"
|
|
193
|
-
}
|
|
194
|
-
],
|
|
195
|
-
priceAmount1000: 72502,
|
|
196
|
-
currencyCode: "IDR"
|
|
197
|
-
}
|
|
160
|
+
### Saving the store to a file
|
|
161
|
+
|
|
162
|
+
`makeInMemoryStore` can read/write its state to a local JSON file, so it
|
|
163
|
+
survives restarts without needing an external database:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
const store = makeInMemoryStore({ /* ... */ })
|
|
167
|
+
|
|
168
|
+
// load once on startup, then auto-save every 10s
|
|
169
|
+
const stopAutoSave = store.writeToFileInterval('./store.json')
|
|
170
|
+
|
|
171
|
+
process.on('SIGINT', () => {
|
|
172
|
+
stopAutoSave()
|
|
173
|
+
process.exit(0)
|
|
198
174
|
})
|
|
199
175
|
```
|
|
200
176
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
messageParams: JSON.stringify({
|
|
217
|
-
bottom_sheet: {
|
|
218
|
-
/** ot params **/
|
|
219
|
-
}
|
|
220
|
-
})
|
|
221
|
-
})
|
|
177
|
+
Or handle it manually with `store.readFromFile(path)` / `store.writeToFile(path)` — see [API Reference](docs/API.md#file-persistence-makeinmemorystore) for details.
|
|
178
|
+
|
|
179
|
+
## Sending Messages
|
|
180
|
+
|
|
181
|
+
### Generic send / relay
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
// relayMessage — send a raw message object, bypassing the sendMessage pipeline
|
|
185
|
+
await client.relayMessage(jid, { conversation: 'Hello from Baileys' }, {})
|
|
186
|
+
|
|
187
|
+
// sendMessage — the common way to send a message
|
|
188
|
+
await client.sendMessage(jid, { text: 'Hello from Baileys' })
|
|
222
189
|
```
|
|
223
190
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
})
|
|
191
|
+
### Simple senders
|
|
192
|
+
|
|
193
|
+
All the `sendX` functions below are shortcuts on top of `sendMessage`.
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
await client.sendText(jid, 'Hi!', { contextInfo: { mentionedJid: [jid] } })
|
|
197
|
+
await client.sendImage(jid, { url: './photo.jpg' }, 'image caption')
|
|
198
|
+
await client.sendVideo(jid, { url: './clip.mp4' }, 'video caption')
|
|
199
|
+
await client.sendAudio(jid, { url: './clip.mp3' })
|
|
200
|
+
await client.sendLocation(jid, 'Location name', -6.2, 106.8, 'https://maps.example', '1234567890')
|
|
201
|
+
await client.sendPoll(jid, 'Pick one', ['Option 1', 'Option 2', 'Option 3'], /* multiSelect */ true)
|
|
202
|
+
await client.sendQuiz(jid, 'Correct answer?', ['1', '2', '3'], /* correctIndex */ '2')
|
|
231
203
|
```
|
|
232
204
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
205
|
+
### Special message types
|
|
206
|
+
|
|
207
|
+
Handled internally by the `Socket/luxu.js` helper, invoked automatically via
|
|
208
|
+
`sendMessage`/`relayMessage` whenever the content includes one of the fields below.
|
|
209
|
+
|
|
210
|
+
```js
|
|
211
|
+
// Product message (catalog)
|
|
212
|
+
await client.relayMessage(jid, {
|
|
213
|
+
productMessage: {
|
|
214
|
+
title: 'Product Name',
|
|
215
|
+
description: 'Product description',
|
|
216
|
+
thumbnail: { url: './product.jpg' },
|
|
217
|
+
productId: 'PRODUCT_ID',
|
|
218
|
+
retailerId: 'RETAILER_ID',
|
|
219
|
+
url: 'https://store.example/product',
|
|
220
|
+
body: 'Body text',
|
|
221
|
+
footer: 'Footer text',
|
|
222
|
+
priceAmount1000: 72502, // price x 1000
|
|
223
|
+
currencyCode: 'IDR'
|
|
238
224
|
}
|
|
239
225
|
}, {})
|
|
240
|
-
```
|
|
241
|
-
# Simple sendMessage
|
|
242
226
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
remoteJid: "status@broadcast",
|
|
252
|
-
participant: m.sender,
|
|
253
|
-
fromMe: true
|
|
254
|
-
},
|
|
255
|
-
message: {
|
|
256
|
-
conversation: "\0"
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
```
|
|
260
|
-
## send image
|
|
261
|
-
```javascript
|
|
262
|
-
await client.sendImage(m.chat, { url: "./alxd.jpg" }, "AlannWinters", {
|
|
263
|
-
contextInfo: {
|
|
264
|
-
mentionedJid: [m.chat]
|
|
265
|
-
}
|
|
266
|
-
}, {
|
|
267
|
-
key: {
|
|
268
|
-
remoteJid: "status@broadcast",
|
|
269
|
-
participant: m.sender,
|
|
270
|
-
fromMe: true
|
|
271
|
-
},
|
|
272
|
-
message: {
|
|
273
|
-
conversation: "\0"
|
|
274
|
-
}
|
|
275
|
-
})
|
|
276
|
-
```
|
|
227
|
+
// Order message
|
|
228
|
+
await client.sendMessage(jid, {
|
|
229
|
+
thumbnail: fs.readFileSync('./thumb.jpg'),
|
|
230
|
+
message: 'Order details',
|
|
231
|
+
orderTitle: 'Store Name',
|
|
232
|
+
totalAmount1000: 72502,
|
|
233
|
+
totalCurrencyCode: 'IDR'
|
|
234
|
+
}, { quoted: m })
|
|
277
235
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}, {
|
|
285
|
-
key: {
|
|
286
|
-
remoteJid: "status@broadcast",
|
|
287
|
-
participant: m.sender,
|
|
288
|
-
fromMe: true
|
|
289
|
-
},
|
|
290
|
-
message: {
|
|
291
|
-
conversation: "\0"
|
|
236
|
+
// Poll result snapshot (usually from a newsletter)
|
|
237
|
+
await client.sendMessage(jid, {
|
|
238
|
+
pollResultMessage: {
|
|
239
|
+
name: 'Poll Title',
|
|
240
|
+
options: [{ optionName: 'Option 1' }, { optionName: 'Option 2' }],
|
|
241
|
+
newsletter: { newsletterName: 'Newsletter Name', newsletterJid: '1234567890@newsletter' }
|
|
292
242
|
}
|
|
293
243
|
})
|
|
294
|
-
```
|
|
295
244
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
fromMe: true
|
|
307
|
-
},
|
|
308
|
-
message: {
|
|
309
|
-
conversation: "\0"
|
|
310
|
-
}
|
|
245
|
+
// Interactive message (button)
|
|
246
|
+
await client.sendMessage(jid, {
|
|
247
|
+
image: { url: './banner.jpg' },
|
|
248
|
+
text: 'Message body',
|
|
249
|
+
title: 'Title',
|
|
250
|
+
footer: 'Footer',
|
|
251
|
+
interactiveButtons: [{
|
|
252
|
+
name: 'cta_url',
|
|
253
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Visit', url: 'https://example.com' })
|
|
254
|
+
}]
|
|
311
255
|
})
|
|
312
|
-
```
|
|
313
256
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
contextInfo: {
|
|
318
|
-
mentionedJid: [m.chat]
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: {
|
|
322
|
-
remoteJid: "status@broadcast",
|
|
323
|
-
participant: m.sender,
|
|
324
|
-
fromMe: true
|
|
325
|
-
},
|
|
326
|
-
message: {
|
|
327
|
-
conversation: "\0"
|
|
328
|
-
}
|
|
257
|
+
// Group member label
|
|
258
|
+
await client.sendMessage(jid, {
|
|
259
|
+
groupLabel: { labelText: 'Admin' }
|
|
329
260
|
})
|
|
330
|
-
```
|
|
331
261
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
await client.sendPoll(m.chat, "AlannWinters", ["1", "2", "3"], true, {
|
|
335
|
-
contextInfo: {
|
|
336
|
-
mentionedJid: [m.chat]
|
|
337
|
-
}
|
|
338
|
-
}, {
|
|
339
|
-
key: {
|
|
340
|
-
remoteJid: "status@broadcast",
|
|
341
|
-
participant: m.sender,
|
|
342
|
-
fromMe: true
|
|
343
|
-
},
|
|
344
|
-
message: {
|
|
345
|
-
conversation: "\0"
|
|
346
|
-
}
|
|
347
|
-
})
|
|
262
|
+
// Broadcast to specific group members
|
|
263
|
+
await client.sendMessageMembers(jid, { extendedTextMessage: { text: 'Announcement' } }, {})
|
|
348
264
|
```
|
|
349
265
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
},
|
|
362
|
-
message: {
|
|
363
|
-
conversation: "\0"
|
|
364
|
-
}
|
|
266
|
+
> Fields like `sender` and `participant: true` in the second argument of
|
|
267
|
+
> `sendMessage`/`relayMessage` are used for group-participant send context — see
|
|
268
|
+
> [`docs/API.md`](docs/API.md) for details on each socket layer.
|
|
269
|
+
|
|
270
|
+
## Events
|
|
271
|
+
|
|
272
|
+
All interaction happens through events on `client.ev`:
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
client.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
276
|
+
console.log('Connection status:', connection)
|
|
365
277
|
})
|
|
366
|
-
```
|
|
367
278
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
extendedTextMessage: {
|
|
372
|
-
text: "AlannWinters"
|
|
279
|
+
client.ev.on('messages.upsert', ({ messages, type }) => {
|
|
280
|
+
for (const m of messages) {
|
|
281
|
+
console.log('Incoming message:', m.message)
|
|
373
282
|
}
|
|
374
283
|
})
|
|
284
|
+
|
|
285
|
+
client.ev.on('creds.update', saveCreds)
|
|
375
286
|
```
|
|
376
287
|
|
|
377
|
-
|
|
288
|
+
See the full list of events in `lib/Types/Events.js`.
|
|
289
|
+
|
|
290
|
+
## Examples
|
|
291
|
+
|
|
292
|
+
Ready-to-run scripts live in [`examples/`](examples):
|
|
293
|
+
|
|
294
|
+
- [`examples/qr-login.js`](examples/qr-login.js) — QR login with auto-reconnect
|
|
295
|
+
- [`examples/pairing-code.js`](examples/pairing-code.js) — pairing code login
|
|
296
|
+
- [`examples/store-usage.js`](examples/store-usage.js) — using the in-memory store
|
|
297
|
+
|
|
298
|
+
## Known Limitations
|
|
299
|
+
|
|
300
|
+
- **No `.d.ts` for `lib/`** — only `WAProto` ships TypeScript types. Full autocomplete requires the TS source, which isn't included in this build.
|
|
301
|
+
- **Console banner on import** — every time the package is `import`ed, an ASCII art banner and promotional link are printed to stdout. In production or multi-instance setups this becomes log noise.
|
|
302
|
+
- **`optionHash` for per-option image polls** is not implemented — it appears to require further reverse-engineering at the WhatsApp APK level.
|
|
303
|
+
- See [`docs/API.md`](docs/API.md#️-important-notes) for other technical notes.
|
|
378
304
|
|
|
379
305
|
## Why Choose WhatsApp Baileys?
|
|
380
306
|
|
|
@@ -424,10 +350,9 @@ Thanks to the following awesome contributors who help improve this project
|
|
|
424
350
|
</a>
|
|
425
351
|
</td>
|
|
426
352
|
<td align="center">
|
|
427
|
-
<a href="https://github.com/
|
|
428
|
-
<img src="https://github.com/
|
|
429
|
-
<br
|
|
430
|
-
<sub><b>D | Yuukey-7eppeli</b></sub>
|
|
353
|
+
<a href="https://github.com/Xazepysk">
|
|
354
|
+
<img src="https://github.com/XazepysK.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
|
|
355
|
+
<br /><sub><b>Xaz zepysK</b></sub>
|
|
431
356
|
</a>
|
|
432
357
|
</td>
|
|
433
358
|
<td align="center">
|
|
@@ -445,5 +370,4 @@ Thanks to the following awesome contributors who help improve this project
|
|
|
445
370
|
</a>
|
|
446
371
|
</td>
|
|
447
372
|
</tr>
|
|
448
|
-
</table>
|
|
449
|
-
|
|
373
|
+
</table>
|
package/lib/Defaults/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { proto } from '../../WAProto/index.js';
|
|
|
2
2
|
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
3
|
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
4
|
import logger from '../Utils/logger.js';
|
|
5
|
-
const version = [2, 3000,
|
|
5
|
+
const version = [2, 3000, 1043857760];
|
|
6
6
|
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
7
|
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
8
8
|
export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
package/lib/Socket/chats.js
CHANGED
|
@@ -397,6 +397,11 @@ export const makeChatsSocket = (config) => {
|
|
|
397
397
|
return {
|
|
398
398
|
onMutation(mutation) {
|
|
399
399
|
processSyncAction(mutation, ev, authState.creds.me, isInitialSync ? { accountSettings: authState.creds.accountSettings } : undefined, logger);
|
|
400
|
+
const nctSalt = mutation?.syncAction?.value?.nctSaltSyncAction?.salt;
|
|
401
|
+
if (nctSalt?.length) {
|
|
402
|
+
authState.keys.set({ 'nct-salt': { default: Buffer.from(nctSalt) } })
|
|
403
|
+
.catch(err => logger?.debug({ err: err?.message }, 'failed to store nct salt'));
|
|
404
|
+
}
|
|
400
405
|
}
|
|
401
406
|
};
|
|
402
407
|
};
|