@kaels/casileys 0.4.3 → 0.4.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 +1099 -539
- package/WAProto/index.d.ts +237 -34
- package/WAProto/index.js +1729 -211
- package/lib/Defaults/index.d.ts +8 -2
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +12 -6
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Socket/business.d.ts +1 -1
- package/lib/Socket/chats.d.ts +8 -1
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +13 -8
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +1 -1
- package/lib/Socket/groups.d.ts +1 -1
- package/lib/Socket/index.d.ts +1 -1
- package/lib/Socket/index.js +2 -19
- package/lib/Socket/messages-recv.d.ts +1 -1
- package/lib/Socket/messages-recv.js +21 -0
- package/lib/Socket/messages-send.d.ts +1 -1
- package/lib/Socket/newsletter.d.ts +1 -1
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +3 -0
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Store/make-in-memory-store.js +2 -2
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +5 -1
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +2 -1
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js +2 -1
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/chat-utils.js +1 -1
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +6 -0
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.js +1 -1
- package/lib/Utils/generics.d.ts +1 -1
- package/lib/Utils/generics.js +10 -10
- package/lib/Utils/group-status.d.ts +58 -0
- package/lib/Utils/group-status.js +477 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/messages.d.ts +4 -4
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +32 -64
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/rich-message-utils.d.ts +1 -1
- package/lib/Utils/rich-message-utils.d.ts.map +1 -1
- package/lib/Utils/rich-message-utils.js +124 -12
- package/lib/Utils/rich-message-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js +3 -2
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/use-single-file-auth-state.js +1 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +9 -2
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/constants.d.ts +16 -0
- package/lib/WABinary/constants.d.ts.map +1 -1
- package/lib/WABinary/constants.js +99 -5
- package/lib/WABinary/constants.js.map +1 -1
- package/lib/WABinary/generic-utils.js +1 -1
- package/package.json +109 -105
package/README.md
CHANGED
|
@@ -1,82 +1,99 @@
|
|
|
1
|
-
# 🌸 @kaels/casileys
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
<h1 align="center">🌱 Casileys</h1>
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="./casileys-header.gif" alt="Casileys" width="100%">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
A WhatsApp Web API library for Node.js, based on Baileys and extended with additional message types, media handling, interactive messages, newsletter support, and more.
|
|
10
|
+
</p>
|
|
4
11
|
|
|
5
12
|
<p align="center">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<a href="https://github.com/kyleee-max/casileys">
|
|
13
|
-
<img src="https://img.shields.io/github/stars/kyleee-max/casileys?style=for-the-badge&logo=github"/>
|
|
14
|
-
</a>
|
|
15
|
-
<a href="LICENSE">
|
|
16
|
-
<img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/>
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://nodejs.org">
|
|
19
|
-
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
|
|
20
|
-
</a>
|
|
21
|
-
<a href="#">
|
|
22
|
-
<img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/>
|
|
23
|
-
</a>
|
|
13
|
+
<a href="https://npmjs.com/package/@kaels/casileys"><img src="https://img.shields.io/npm/v/@kaels/casileys?style=for-the-badge&logo=npm"/></a>
|
|
14
|
+
<a href="https://npmjs.com/package/@kaels/casileys"><img src="https://img.shields.io/npm/dm/@kaels/casileys?style=for-the-badge&logo=npm"/></a>
|
|
15
|
+
<a href="https://github.com/kyleee-max/casileys"><img src="https://img.shields.io/github/stars/kyleee-max/casileys?style=for-the-badge&logo=github"/></a>
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/></a>
|
|
17
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/></a>
|
|
18
|
+
<a href="#"><img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/></a>
|
|
24
19
|
</p>
|
|
25
20
|
|
|
26
21
|
---
|
|
27
22
|
|
|
28
|
-
##
|
|
23
|
+
## ✨ Highlights
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
| Feature | Support |
|
|
26
|
+
|---|:---:|
|
|
27
|
+
| WhatsApp Web / Multi-device | ✅ |
|
|
28
|
+
| Pairing Code | ✅ |
|
|
29
|
+
| Text & Media Messages | ✅ |
|
|
30
|
+
| Albums | ✅ |
|
|
31
|
+
| Polls | ✅ |
|
|
32
|
+
| Interactive Messages | ✅ |
|
|
33
|
+
| Rich Responses | ✅ |
|
|
34
|
+
| Inline Entities | ✅ |
|
|
35
|
+
| Tables | ✅ |
|
|
36
|
+
| Group Status | ✅ |
|
|
37
|
+
| Sticker Pack | ✅ |
|
|
38
|
+
| Newsletter Messages | ✅ |
|
|
39
|
+
| Group Management | ✅ |
|
|
40
|
+
| Community Management | ✅ |
|
|
41
|
+
| Profile Management | ✅ |
|
|
42
|
+
| Business Features | ✅ |
|
|
43
|
+
| Privacy Management | ✅ |
|
|
44
|
+
| Message Editing & Deletion | ✅ |
|
|
45
|
+
|
|
46
|
+
Casileys is designed to remain readable and auditable while extending the functionality available from its upstream fork.
|
|
38
47
|
|
|
39
48
|
---
|
|
40
49
|
|
|
41
|
-
##
|
|
50
|
+
## 🛠️ Internal Adjustments
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
Casileys retains the existing message and protocol implementations from its fork base while adding project-specific improvements.
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
- 🔧 Dikembangkan secara aktif dengan modifikasi dan penyesuaian tersendiri.
|
|
54
|
+
Some of the included changes cover:
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
- Newsletter media handling
|
|
57
|
+
- `makeInMemoryStore` support
|
|
58
|
+
- Extended interactive message support
|
|
59
|
+
- Album messages
|
|
60
|
+
- Group status messages
|
|
61
|
+
- Additional message wrappers
|
|
62
|
+
- Extended media handling
|
|
63
|
+
- Direct `externalAdReply` access
|
|
64
|
+
- Additional newsletter, group, community, profile, business, and privacy utilities
|
|
65
|
+
- Casileys Group Status Helper
|
|
50
66
|
|
|
51
67
|
---
|
|
52
68
|
|
|
53
|
-
##
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
## 📨 Message Compatibility
|
|
70
|
+
|
|
71
|
+
The message layer supports the following extended structures:
|
|
72
|
+
|
|
73
|
+
| Message Type | Available |
|
|
74
|
+
|---|:---:|
|
|
75
|
+
| Album | ✅ |
|
|
76
|
+
| Group Status | ✅ |
|
|
77
|
+
| Interactive | ✅ |
|
|
78
|
+
| Status Mention | ✅ |
|
|
79
|
+
| Sticker Pack | ✅ |
|
|
80
|
+
| Rich Response | ✅ |
|
|
81
|
+
| Code Block | ✅ |
|
|
82
|
+
| Inline Entities | ✅ |
|
|
83
|
+
| Table | ✅ |
|
|
84
|
+
| Payment-related Messages | ✅ |
|
|
85
|
+
| External Ad Reply | ✅ |
|
|
86
|
+
| View Once Variants | ✅ |
|
|
87
|
+
| Ephemeral | ✅ |
|
|
88
|
+
| Spoiler | ✅ |
|
|
89
|
+
| Lottie Sticker | ✅ |
|
|
90
|
+
| Raw Message | ✅ |
|
|
74
91
|
|
|
75
92
|
---
|
|
76
93
|
|
|
77
94
|
## 📥 Installation
|
|
78
95
|
|
|
79
|
-
|
|
96
|
+
**package.json**
|
|
80
97
|
|
|
81
98
|
```json
|
|
82
99
|
"dependencies": {
|
|
@@ -84,66 +101,90 @@ Via `package.json`:
|
|
|
84
101
|
}
|
|
85
102
|
```
|
|
86
103
|
|
|
87
|
-
|
|
104
|
+
**GitHub**
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
"dependencies": {
|
|
108
|
+
"@kaels/casileys": "github:kyleee-max/casileys"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Terminal**
|
|
88
113
|
|
|
89
114
|
```bash
|
|
90
115
|
npm i @kaels/casileys@latest
|
|
91
116
|
```
|
|
92
117
|
|
|
93
|
-
|
|
118
|
+
Or directly from GitHub:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm i github:kyleee-max/casileys
|
|
122
|
+
```
|
|
94
123
|
|
|
95
|
-
|
|
96
|
-
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 🧩 Import
|
|
127
|
+
|
|
128
|
+
**ESM**
|
|
129
|
+
|
|
130
|
+
```js
|
|
97
131
|
import { makeWASocket } from '@kaels/casileys'
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**CJS**
|
|
98
135
|
|
|
99
|
-
|
|
136
|
+
```js
|
|
100
137
|
const { makeWASocket } = require('@kaels/casileys')
|
|
101
138
|
```
|
|
102
139
|
|
|
103
140
|
---
|
|
104
141
|
|
|
105
|
-
## 🌐 Connect to WhatsApp
|
|
142
|
+
## 🌐 Connect to WhatsApp
|
|
106
143
|
|
|
107
|
-
```
|
|
144
|
+
```js
|
|
108
145
|
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@kaels/casileys'
|
|
109
146
|
import { Boom } from '@hapi/boom'
|
|
110
147
|
import pino from 'pino'
|
|
111
148
|
|
|
149
|
+
// --- Connect with pairing code
|
|
112
150
|
const myPhoneNumber = '6288888888888'
|
|
113
151
|
|
|
152
|
+
const logger = pino({ level: 'silent' })
|
|
153
|
+
|
|
114
154
|
const connectToWhatsApp = async () => {
|
|
115
155
|
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
116
156
|
|
|
117
157
|
const sock = makeWASocket({
|
|
118
|
-
logger
|
|
158
|
+
logger,
|
|
119
159
|
auth: state
|
|
120
160
|
})
|
|
121
|
-
|
|
122
161
|
sock.ev.on('creds.update', saveCreds)
|
|
123
|
-
|
|
124
|
-
sock.ev.on('connection.update', async (update) => {
|
|
162
|
+
sock.ev.on('connection.update', (update) => {
|
|
125
163
|
const { connection, lastDisconnect } = update
|
|
126
|
-
|
|
127
164
|
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
128
165
|
await delay(1500)
|
|
129
166
|
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
130
|
-
console.log('🔗 Pairing code:', code)
|
|
167
|
+
console.log('🔗 Pairing code', ':', code)
|
|
131
168
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (shouldReconnect)
|
|
169
|
+
else if (connection === 'close') {
|
|
170
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
171
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
172
|
+
if (shouldReconnect) {
|
|
173
|
+
connectToWhatsApp()
|
|
174
|
+
}
|
|
136
175
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
console.log('✅ Connected to WhatsApp')
|
|
176
|
+
else if (connection === 'open') {
|
|
177
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
140
178
|
}
|
|
141
179
|
})
|
|
142
|
-
|
|
143
180
|
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
144
181
|
for (const message of messages) {
|
|
145
182
|
if (!message.message) continue
|
|
146
|
-
|
|
183
|
+
|
|
184
|
+
console.log('🔔 Got new message', ':', message)
|
|
185
|
+
await sock.sendMessage(message.key.remoteJid, {
|
|
186
|
+
text: '👋🏻 Hello world'
|
|
187
|
+
})
|
|
147
188
|
}
|
|
148
189
|
})
|
|
149
190
|
}
|
|
@@ -151,256 +192,394 @@ const connectToWhatsApp = async () => {
|
|
|
151
192
|
connectToWhatsApp()
|
|
152
193
|
```
|
|
153
194
|
|
|
154
|
-
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 🔐 Auth State
|
|
155
198
|
|
|
156
|
-
|
|
157
|
-
> Bisa gunakan `useSingleFileAuthState` sebagai alternatif `useMultiFileAuthState`. `useSingleFileAuthState` sudah memiliki mekanisme caching internal, sehingga tidak perlu wrap `state.keys` dengan `makeCacheableSignalKeyStore`.
|
|
199
|
+
You can use `useMultiFileAuthState` as the default authentication state implementation.
|
|
158
200
|
|
|
159
|
-
|
|
201
|
+
Experimental alternatives such as `useSingleFileAuthState` and `useSqliteAuthState` may also be used where supported.
|
|
160
202
|
|
|
161
|
-
|
|
203
|
+
---
|
|
162
204
|
|
|
163
|
-
|
|
164
|
-
> Sangat disarankan membangun data store sendiri — menyimpan seluruh history chat di memory bisa menyebabkan RAM usage yang tinggi.
|
|
205
|
+
## 🗄️ Data Store
|
|
165
206
|
|
|
166
|
-
```
|
|
207
|
+
```js
|
|
167
208
|
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@kaels/casileys'
|
|
168
209
|
import { Boom } from '@hapi/boom'
|
|
169
210
|
import pino from 'pino'
|
|
170
211
|
|
|
212
|
+
const myPhoneNumber = '6288888888888'
|
|
213
|
+
|
|
214
|
+
// --- Create your store path
|
|
171
215
|
const storePath = './store.json'
|
|
172
216
|
|
|
217
|
+
const logger = pino({ level: 'silent' })
|
|
173
218
|
const connectToWhatsApp = async () => {
|
|
174
219
|
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
175
220
|
|
|
176
|
-
const sock = makeWASocket({
|
|
221
|
+
const sock = makeWASocket({
|
|
222
|
+
logger,
|
|
223
|
+
auth: state
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const store = makeInMemoryStore({
|
|
227
|
+
logger,
|
|
228
|
+
socket: sock
|
|
229
|
+
})
|
|
177
230
|
|
|
178
|
-
const store = makeInMemoryStore({ logger: pino({ level: 'silent' }), socket: sock })
|
|
179
231
|
store.bind(sock.ev)
|
|
180
232
|
|
|
181
233
|
sock.ev.on('creds.update', saveCreds)
|
|
234
|
+
sock.ev.on('connection.update', (update) => {
|
|
235
|
+
const { connection, lastDisconnect } = update
|
|
236
|
+
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
237
|
+
await delay(1500)
|
|
238
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
239
|
+
console.log('🔗 Pairing code', ':', code)
|
|
240
|
+
}
|
|
241
|
+
else if (connection === 'close') {
|
|
242
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
243
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
244
|
+
if (shouldReconnect) {
|
|
245
|
+
connectToWhatsApp()
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else if (connection === 'open') {
|
|
249
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
sock.ev.on('chats.upsert', () => {
|
|
253
|
+
console.log('✉️ Got chats', store.chats.all())
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
sock.ev.on('contacts.upsert', () => {
|
|
257
|
+
console.log('👥 Got contacts', Object.values(store.contacts))
|
|
258
|
+
})
|
|
182
259
|
|
|
183
|
-
//
|
|
260
|
+
// --- Read store from file
|
|
184
261
|
store.readFromFile(storePath)
|
|
185
262
|
|
|
186
|
-
//
|
|
187
|
-
setInterval(() =>
|
|
263
|
+
// --- Save store every 3 minutes
|
|
264
|
+
setInterval(() => {
|
|
265
|
+
store.writeToFile(storePath)
|
|
266
|
+
}, 180000)
|
|
188
267
|
}
|
|
189
268
|
|
|
190
269
|
connectToWhatsApp()
|
|
191
270
|
```
|
|
192
271
|
|
|
272
|
+
> **Note:** For large applications, consider using a dedicated persistent data store instead of keeping the entire chat history in memory.
|
|
273
|
+
|
|
193
274
|
---
|
|
194
275
|
|
|
195
|
-
## 🪪 WhatsApp IDs
|
|
276
|
+
## 🪪 WhatsApp IDs
|
|
277
|
+
|
|
278
|
+
`jid` identifies the WhatsApp account, group, broadcast destination, newsletter, or status target involved in an operation.
|
|
196
279
|
|
|
197
|
-
|
|
|
280
|
+
| Target | Format |
|
|
198
281
|
|---|---|
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
282
|
+
| User | `[country code][phone]@s.whatsapp.net` |
|
|
283
|
+
| LID | `[id]@lid` |
|
|
284
|
+
| Group | `[id]@g.us` |
|
|
285
|
+
| Meta AI | `[id]@bot` |
|
|
286
|
+
| Broadcast | `[timestamp]@broadcast` |
|
|
287
|
+
| Status | `status@broadcast` |
|
|
288
|
+
| Newsletter | `[id]@newsletter` |
|
|
289
|
+
|
|
290
|
+
For incoming messages, the destination is commonly available through:
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
message.key.remoteJid
|
|
294
|
+
```
|
|
205
295
|
|
|
206
296
|
---
|
|
207
297
|
|
|
208
298
|
## ✉️ Sending Messages
|
|
209
299
|
|
|
210
|
-
> [!NOTE]
|
|
211
|
-
> `jid` bisa diambil dari `message.key.remoteJid`.
|
|
212
|
-
|
|
213
300
|
### 🔠 Text
|
|
214
301
|
|
|
215
|
-
```
|
|
216
|
-
//
|
|
217
|
-
sock.sendMessage(jid, {
|
|
302
|
+
```js
|
|
303
|
+
// --- Send a regular text message
|
|
304
|
+
sock.sendMessage(jid, {
|
|
305
|
+
text: '👋🏻 Hello'
|
|
306
|
+
}, {
|
|
307
|
+
quoted: message
|
|
308
|
+
})
|
|
218
309
|
|
|
219
|
-
//
|
|
310
|
+
// --- Send a text message with a link preview
|
|
311
|
+
const urlA = 'https://www.npmjs.com/package/@kaels/casileys'
|
|
220
312
|
sock.sendMessage(jid, {
|
|
221
|
-
text: '
|
|
313
|
+
text: urlA + ' 👆🏻 Check it out!',
|
|
222
314
|
linkPreview: {
|
|
223
|
-
'matched-text':
|
|
224
|
-
title: '
|
|
225
|
-
description: 'WhatsApp Web API',
|
|
226
|
-
previewType: 0,
|
|
315
|
+
'matched-text': urlA,
|
|
316
|
+
title: '🌱 Casileys',
|
|
317
|
+
description: 'WhatsApp Web API for Node.js',
|
|
318
|
+
previewType: 0, // --- Use 1 for video playback in the link preview
|
|
227
319
|
jpegThumbnail: fs.readFileSync('./path/to/image.jpg')
|
|
228
320
|
}
|
|
229
321
|
})
|
|
322
|
+
|
|
323
|
+
// --- Send a text message with a large link preview and favicon
|
|
324
|
+
import { prepareWAMessageMedia } from 'YOUR_CASILEYS_PACKAGE'
|
|
325
|
+
const urlB = 'https://www.npmjs.com/package/@kaels/casileys#readme'
|
|
326
|
+
|
|
327
|
+
const { imageMessage: image } = await prepareWAMessageMedia({
|
|
328
|
+
image: {
|
|
329
|
+
url: './path/to/image.jpg'
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
upload: sock.waUploadToServer,
|
|
333
|
+
mediaTypeOverride: 'thumbnail-link'
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
// --- Set the thumbnail display size
|
|
337
|
+
image.height = 720
|
|
338
|
+
image.width = 480
|
|
339
|
+
sock.sendMessage(jid, {
|
|
340
|
+
text: urlB + ' 👆🏻 Check it out!',
|
|
341
|
+
linkPreview: {
|
|
342
|
+
'matched-text': urlB,
|
|
343
|
+
title: '🌱 Casileys',
|
|
344
|
+
description: 'WhatsApp Web API for Node.js',
|
|
345
|
+
previewType: 0,
|
|
346
|
+
jpegThumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
347
|
+
highQualityThumbnail: image,
|
|
348
|
+
linkPreviewMetadata: {
|
|
349
|
+
linkMediaDuration: 0, // --- Duration in seconds (for video/audio content)
|
|
350
|
+
socialMediaPostType: 1, // --- Enum: 0 = NONE, 1 = REEL, 2 = LIVE_VIDEO, 3 = LONG_VIDEO, 4 = SINGLE_IMAGE, 5 = CAROUSEL
|
|
351
|
+
} // --- Additional metadata for large link preview
|
|
352
|
+
},
|
|
353
|
+
favicon: {
|
|
354
|
+
url: './path/to/tiny-image.ico'
|
|
355
|
+
}
|
|
356
|
+
})
|
|
230
357
|
```
|
|
231
358
|
|
|
232
359
|
### 🔔 Mention
|
|
233
360
|
|
|
234
|
-
```
|
|
235
|
-
//
|
|
361
|
+
```js
|
|
362
|
+
// --- Regular mention
|
|
236
363
|
sock.sendMessage(jid, {
|
|
237
364
|
text: '👋🏻 Hello @628123456789',
|
|
238
365
|
mentions: ['628123456789@s.whatsapp.net']
|
|
239
|
-
}, {
|
|
366
|
+
}, {
|
|
367
|
+
quoted: message
|
|
368
|
+
})
|
|
240
369
|
|
|
241
|
-
// Mention
|
|
370
|
+
// --- Mention all
|
|
242
371
|
sock.sendMessage(jid, {
|
|
243
372
|
text: '👋🏻 Hello @all',
|
|
244
373
|
mentionAll: true
|
|
245
|
-
}, {
|
|
374
|
+
}, {
|
|
375
|
+
quoted: message
|
|
376
|
+
})
|
|
246
377
|
```
|
|
247
378
|
|
|
248
379
|
### 😁 Reaction
|
|
249
380
|
|
|
250
|
-
```
|
|
381
|
+
```js
|
|
251
382
|
sock.sendMessage(jid, {
|
|
252
|
-
react: {
|
|
383
|
+
react: {
|
|
384
|
+
key: message.key,
|
|
385
|
+
text: '✨'
|
|
386
|
+
}
|
|
253
387
|
})
|
|
254
388
|
```
|
|
255
389
|
|
|
256
390
|
### 📌 Pin Message
|
|
257
391
|
|
|
258
|
-
```
|
|
392
|
+
```js
|
|
259
393
|
sock.sendMessage(jid, {
|
|
260
394
|
pin: message.key,
|
|
261
|
-
time: 86400, // 86400 (1d)
|
|
262
|
-
type: 1
|
|
395
|
+
time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
|
|
396
|
+
type: 1 // --- Or 2 to remove
|
|
397
|
+
})
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### 🔖 Keep Chat
|
|
401
|
+
|
|
402
|
+
> **Note:** Keep Chat can only be used in chats or groups with disappearing messages enabled.
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
sock.sendMessage(jid, {
|
|
406
|
+
keep: message.key,
|
|
407
|
+
type: 1 // --- Or 2 to remove
|
|
263
408
|
})
|
|
264
409
|
```
|
|
265
410
|
|
|
266
411
|
### ➡️ Forward Message
|
|
267
412
|
|
|
268
|
-
```
|
|
269
|
-
sock.sendMessage(jid, {
|
|
413
|
+
```js
|
|
414
|
+
sock.sendMessage(jid, {
|
|
415
|
+
forward: message,
|
|
416
|
+
force: true // --- Optional
|
|
417
|
+
})
|
|
270
418
|
```
|
|
271
419
|
|
|
272
420
|
### 👤 Contact
|
|
273
421
|
|
|
274
|
-
```
|
|
275
|
-
const vcard = 'BEGIN:VCARD\
|
|
422
|
+
```js
|
|
423
|
+
const vcard = 'BEGIN:VCARD\n'
|
|
424
|
+
+ 'VERSION:3.0\n'
|
|
425
|
+
+ 'FN:Casileys User\n'
|
|
426
|
+
+ 'ORG:Casileys;\n'
|
|
427
|
+
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
428
|
+
+ 'END:VCARD'
|
|
276
429
|
|
|
277
430
|
sock.sendMessage(jid, {
|
|
278
|
-
contacts: {
|
|
279
|
-
|
|
431
|
+
contacts: {
|
|
432
|
+
displayName: 'Casileys User',
|
|
433
|
+
contacts: [
|
|
434
|
+
{ vcard }
|
|
435
|
+
]
|
|
436
|
+
}
|
|
437
|
+
}, {
|
|
438
|
+
quoted: message
|
|
439
|
+
})
|
|
280
440
|
```
|
|
281
441
|
|
|
282
442
|
### 📍 Location
|
|
283
443
|
|
|
284
|
-
```
|
|
444
|
+
```js
|
|
285
445
|
sock.sendMessage(jid, {
|
|
286
|
-
location: {
|
|
287
|
-
|
|
446
|
+
location: {
|
|
447
|
+
degreesLatitude: 24.121231,
|
|
448
|
+
degreesLongitude: 55.1121221,
|
|
449
|
+
name: '👋🏻 I am here'
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
quoted: message
|
|
453
|
+
})
|
|
288
454
|
```
|
|
289
455
|
|
|
290
456
|
### 🗓️ Event
|
|
291
457
|
|
|
292
|
-
```
|
|
458
|
+
```js
|
|
293
459
|
sock.sendMessage(jid, {
|
|
294
460
|
event: {
|
|
295
|
-
name: '🎶 Meet & Mingle',
|
|
296
|
-
description: '
|
|
297
|
-
call: 'audio',
|
|
298
|
-
startDate: new Date(Date.now() +
|
|
299
|
-
endDate: new Date(Date.now() +
|
|
300
|
-
|
|
461
|
+
name: '🎶 Meet & Mingle Party',
|
|
462
|
+
description: 'Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.',
|
|
463
|
+
call: 'audio', // --- Or "video", this field is optional
|
|
464
|
+
startDate: new Date(Date.now() + 3600000),
|
|
465
|
+
endDate: new Date(Date.now() + 28800000),
|
|
466
|
+
isCancelled: false, // --- Optional
|
|
467
|
+
isScheduleCall: false, // --- Optional
|
|
468
|
+
extraGuestsAllowed: false, // --- Optional
|
|
469
|
+
location: {
|
|
470
|
+
name: 'Jakarta',
|
|
471
|
+
degreesLatitude: -6.2,
|
|
472
|
+
degreesLongitude: 106.8
|
|
473
|
+
}
|
|
301
474
|
}
|
|
302
|
-
}, {
|
|
475
|
+
}, {
|
|
476
|
+
quoted: message
|
|
477
|
+
})
|
|
303
478
|
```
|
|
304
479
|
|
|
305
|
-
###
|
|
480
|
+
### 👥 Group Invite
|
|
306
481
|
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
name: '🔥 Pilih yang terbaik!',
|
|
312
|
-
values: ['Option A', 'Option B'],
|
|
313
|
-
selectableCount: 1
|
|
314
|
-
}
|
|
315
|
-
}, { quoted: message })
|
|
316
|
-
```
|
|
482
|
+
```js
|
|
483
|
+
const inviteCode = groupUrl
|
|
484
|
+
.split('chat.whatsapp.com/')[1]
|
|
485
|
+
?.split('?')[0]
|
|
317
486
|
|
|
318
|
-
|
|
487
|
+
const groupJid = '1201111111111@g.us'
|
|
488
|
+
const groupName = 'Casileys'
|
|
319
489
|
|
|
320
|
-
```javascript
|
|
321
|
-
// Plain button reply
|
|
322
490
|
sock.sendMessage(jid, {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
flowReply: {
|
|
330
|
-
format: 0,
|
|
331
|
-
text: '💭 Response',
|
|
332
|
-
name: 'menu_options',
|
|
333
|
-
paramsJson: JSON.stringify({ id: '#Menu', description: 'Menu Utama' })
|
|
491
|
+
groupInvite: {
|
|
492
|
+
inviteCode,
|
|
493
|
+
inviteExpiration: Date.now() + 86400000,
|
|
494
|
+
text: '👋🏻 Hello, we invite you to join our group.',
|
|
495
|
+
jid: groupJid,
|
|
496
|
+
subject: groupName,
|
|
334
497
|
}
|
|
335
|
-
}, {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
sock.sendMessage(jid, {
|
|
339
|
-
listReply: { title: '📄 See More', description: '✨ Menu', id: '#Menu' }
|
|
340
|
-
}, { quoted: message })
|
|
498
|
+
}, {
|
|
499
|
+
quoted: message
|
|
500
|
+
})
|
|
341
501
|
```
|
|
342
502
|
|
|
343
|
-
###
|
|
503
|
+
### 🛍️ Product
|
|
344
504
|
|
|
345
|
-
```
|
|
505
|
+
```js
|
|
506
|
+
import { randomUUID } from 'crypto'
|
|
346
507
|
sock.sendMessage(jid, {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
508
|
+
image: {
|
|
509
|
+
url: './path/to/image.jpg'
|
|
510
|
+
},
|
|
511
|
+
body: '👋🏻 Check my product here!',
|
|
512
|
+
footer: 'Casileys',
|
|
513
|
+
product: {
|
|
514
|
+
currencyCode: 'IDR',
|
|
515
|
+
description: '🛍️ Interesting product!',
|
|
516
|
+
priceAmount1000: 70_000_000,
|
|
517
|
+
productId: randomUUID(),
|
|
518
|
+
productImageCount: 1,
|
|
519
|
+
salePriceAmount1000: 65_000_000,
|
|
520
|
+
signedUrl: 'YOUR_PRODUCT_URL',
|
|
521
|
+
title: '📦 Casileys Product',
|
|
522
|
+
url: 'YOUR_PRODUCT_URL'
|
|
523
|
+
},
|
|
524
|
+
businessOwnerJid: '0@s.whatsapp.net'
|
|
353
525
|
})
|
|
354
526
|
```
|
|
355
527
|
|
|
356
|
-
|
|
357
|
-
> Import `tokenizeCode` untuk syntax highlighting otomatis:
|
|
358
|
-
> ```javascript
|
|
359
|
-
> import { tokenizeCode } from '@kaels/casileys'
|
|
360
|
-
> ```
|
|
361
|
-
|
|
362
|
-
### 🧾 Message with Code Block
|
|
528
|
+
### 📊 Poll
|
|
363
529
|
|
|
364
|
-
```
|
|
530
|
+
```js
|
|
531
|
+
// --- Regular poll message
|
|
365
532
|
sock.sendMessage(jid, {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
533
|
+
poll: {
|
|
534
|
+
name: '🔥 Voting time',
|
|
535
|
+
values: ['Yes', 'No'],
|
|
536
|
+
selectableCount: 1,
|
|
537
|
+
toAnnouncementGroup: false,
|
|
538
|
+
endDate: new Date(Date.now() + 28800000), // --- Optional
|
|
539
|
+
hideVoter: false, // --- Optional
|
|
540
|
+
canAddOption: false // --- Optional
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
quoted: message
|
|
372
544
|
})
|
|
373
|
-
```
|
|
374
545
|
|
|
375
|
-
|
|
546
|
+
// --- Quiz (only for newsletter)
|
|
547
|
+
sock.sendMessage('1211111111111@newsletter', {
|
|
548
|
+
poll: {
|
|
549
|
+
name: '🔥 Quiz',
|
|
550
|
+
values: ['Yes', 'No'],
|
|
551
|
+
correctAnswer: 'Yes',
|
|
552
|
+
pollType: 1
|
|
553
|
+
}
|
|
554
|
+
}, {
|
|
555
|
+
quoted: message
|
|
556
|
+
})
|
|
376
557
|
|
|
377
|
-
|
|
558
|
+
// --- Poll result
|
|
378
559
|
sock.sendMessage(jid, {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
560
|
+
pollResult: {
|
|
561
|
+
name: '📝 Poll Result',
|
|
562
|
+
votes: [{
|
|
563
|
+
name: 'Nice',
|
|
564
|
+
voteCount: 10
|
|
565
|
+
}, {
|
|
566
|
+
name: 'Nah',
|
|
567
|
+
voteCount: 2
|
|
568
|
+
}],
|
|
569
|
+
pollType: 0 // Or 1 for quiz
|
|
570
|
+
}
|
|
571
|
+
}, {
|
|
572
|
+
quoted: message
|
|
387
573
|
})
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### 📋 Message with Table
|
|
391
574
|
|
|
392
|
-
|
|
575
|
+
// --- Poll update
|
|
393
576
|
sock.sendMessage(jid, {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
['Engine', 'V8', 'JavaScriptCore', 'V8'],
|
|
401
|
-
['Performance', '4/5', '5/5', '4/5']
|
|
402
|
-
],
|
|
403
|
-
footerText: 'Pilih yang sesuai kebutuhan!'
|
|
577
|
+
pollUpdate: {
|
|
578
|
+
metadata: {},
|
|
579
|
+
key: message.key
|
|
580
|
+
}
|
|
581
|
+
}, {
|
|
582
|
+
quoted: message
|
|
404
583
|
})
|
|
405
584
|
```
|
|
406
585
|
|
|
@@ -408,221 +587,284 @@ sock.sendMessage(jid, {
|
|
|
408
587
|
|
|
409
588
|
## 📁 Sending Media Messages
|
|
410
589
|
|
|
411
|
-
> [!NOTE]
|
|
412
|
-
> Media bisa dikirim sebagai `Buffer`, `{ stream: Readable }`, atau `{ url: string }` (path lokal / URL).
|
|
413
|
-
|
|
414
590
|
### 🖼️ Image
|
|
415
591
|
|
|
416
|
-
```
|
|
592
|
+
```js
|
|
417
593
|
sock.sendMessage(jid, {
|
|
418
|
-
image: {
|
|
419
|
-
|
|
420
|
-
},
|
|
594
|
+
image: {
|
|
595
|
+
url: './path/to/image.jpg'
|
|
596
|
+
},
|
|
597
|
+
caption: '🖼️ Image'
|
|
598
|
+
}, {
|
|
599
|
+
quoted: message
|
|
600
|
+
})
|
|
421
601
|
```
|
|
422
602
|
|
|
423
603
|
### 🎥 Video
|
|
424
604
|
|
|
425
|
-
```
|
|
605
|
+
```js
|
|
426
606
|
sock.sendMessage(jid, {
|
|
427
|
-
video: {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
caption: '
|
|
431
|
-
}, {
|
|
607
|
+
video: {
|
|
608
|
+
url: './path/to/video.mp4'
|
|
609
|
+
},
|
|
610
|
+
caption: '🎥 Video'
|
|
611
|
+
}, {
|
|
612
|
+
quoted: message
|
|
613
|
+
})
|
|
432
614
|
```
|
|
433
615
|
|
|
434
616
|
### 📃 Sticker
|
|
435
617
|
|
|
436
|
-
```
|
|
618
|
+
```js
|
|
437
619
|
sock.sendMessage(jid, {
|
|
438
|
-
sticker: {
|
|
439
|
-
|
|
620
|
+
sticker: {
|
|
621
|
+
url: './path/to/sticker.webp'
|
|
622
|
+
}
|
|
623
|
+
}, {
|
|
624
|
+
quoted: message
|
|
625
|
+
})
|
|
440
626
|
```
|
|
441
627
|
|
|
442
628
|
### 💽 Audio
|
|
443
629
|
|
|
444
|
-
```
|
|
630
|
+
```js
|
|
445
631
|
sock.sendMessage(jid, {
|
|
446
|
-
audio: {
|
|
447
|
-
|
|
448
|
-
},
|
|
632
|
+
audio: {
|
|
633
|
+
url: './path/to/audio.mp3'
|
|
634
|
+
},
|
|
635
|
+
mimetype: 'audio/mpeg',
|
|
636
|
+
ptt: false
|
|
637
|
+
}, {
|
|
638
|
+
quoted: message
|
|
639
|
+
})
|
|
449
640
|
```
|
|
450
641
|
|
|
451
642
|
### 🗂️ Document
|
|
452
643
|
|
|
453
|
-
```
|
|
644
|
+
```js
|
|
454
645
|
sock.sendMessage(jid, {
|
|
455
|
-
document: {
|
|
646
|
+
document: {
|
|
647
|
+
url: './path/to/document.pdf'
|
|
648
|
+
},
|
|
456
649
|
mimetype: 'application/pdf',
|
|
457
|
-
|
|
458
|
-
|
|
650
|
+
fileName: 'document.pdf',
|
|
651
|
+
caption: '📄 Document'
|
|
652
|
+
}, {
|
|
653
|
+
quoted: message
|
|
654
|
+
})
|
|
459
655
|
```
|
|
460
656
|
|
|
461
|
-
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
## 🖼️ Album
|
|
462
660
|
|
|
463
|
-
```
|
|
661
|
+
```js
|
|
464
662
|
sock.sendMessage(jid, {
|
|
465
663
|
album: [
|
|
466
|
-
{
|
|
467
|
-
|
|
468
|
-
|
|
664
|
+
{
|
|
665
|
+
image: {
|
|
666
|
+
url: './path/to/image-1.jpg'
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
image: {
|
|
671
|
+
url: './path/to/image-2.jpg'
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
video: {
|
|
676
|
+
url: './path/to/video.mp4'
|
|
677
|
+
}
|
|
678
|
+
}
|
|
469
679
|
]
|
|
470
|
-
}, {
|
|
680
|
+
}, {
|
|
681
|
+
quoted: message
|
|
682
|
+
})
|
|
471
683
|
```
|
|
472
684
|
|
|
473
|
-
|
|
685
|
+
---
|
|
474
686
|
|
|
475
|
-
|
|
476
|
-
> Jika `sharp` atau `@napi-rs/image` tidak terinstall, `cover` dan `stickers` harus sudah dalam format WebP.
|
|
687
|
+
## 📦 Sticker Pack
|
|
477
688
|
|
|
478
|
-
```
|
|
689
|
+
```js
|
|
479
690
|
sock.sendMessage(jid, {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}, { quoted: message })
|
|
691
|
+
stickerPack: {
|
|
692
|
+
name: 'Casileys Pack',
|
|
693
|
+
publisher: 'Casileys',
|
|
694
|
+
description: 'Casileys sticker pack'
|
|
695
|
+
}
|
|
696
|
+
}, {
|
|
697
|
+
quoted: message
|
|
698
|
+
})
|
|
489
699
|
```
|
|
490
700
|
|
|
491
701
|
---
|
|
492
702
|
|
|
493
|
-
## 👉🏻
|
|
703
|
+
## 👉🏻 Interactive Messages
|
|
494
704
|
|
|
495
705
|
### 🔘 Buttons
|
|
496
706
|
|
|
497
|
-
```
|
|
498
|
-
// Button teks biasa
|
|
707
|
+
```js
|
|
499
708
|
sock.sendMessage(jid, {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
709
|
+
buttons: [
|
|
710
|
+
{
|
|
711
|
+
buttonId: 'id1',
|
|
712
|
+
buttonText: {
|
|
713
|
+
displayText: 'Button 1'
|
|
714
|
+
},
|
|
715
|
+
type: 1
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
buttonId: 'id2',
|
|
719
|
+
buttonText: {
|
|
720
|
+
displayText: 'Button 2'
|
|
721
|
+
},
|
|
722
|
+
type: 1
|
|
723
|
+
}
|
|
724
|
+
],
|
|
725
|
+
text: 'Select an option',
|
|
726
|
+
footer: 'Casileys'
|
|
727
|
+
}, {
|
|
728
|
+
quoted: message
|
|
729
|
+
})
|
|
518
730
|
```
|
|
519
731
|
|
|
520
732
|
### 📋 List
|
|
521
733
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
buttonText: '📋 Buka Menu',
|
|
530
|
-
title: '👋🏻 Menu Bot',
|
|
531
|
-
sections: [{
|
|
532
|
-
title: '🚀 Kategori 1',
|
|
533
|
-
rows: [{ title: '✨ Fitur A', description: 'Deskripsi singkat', rowId: '#FiturA' }]
|
|
534
|
-
}]
|
|
535
|
-
}, { quoted: message })
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
### 🗄️ Interactive (Native Flow)
|
|
539
|
-
|
|
540
|
-
```javascript
|
|
541
|
-
// Native flow dengan berbagai tipe button
|
|
542
|
-
sock.sendMessage(jid, {
|
|
543
|
-
image: { url: './path/to/image.jpg' },
|
|
544
|
-
caption: '🗄️ Interactive Menu!',
|
|
545
|
-
footer: '@kaels/casileys',
|
|
546
|
-
optionText: '👉🏻 Pilih Opsi', // optional, wrap semua jadi satu list
|
|
547
|
-
optionTitle: '📄 Opsi Tersedia', // optional
|
|
548
|
-
nativeFlow: [
|
|
549
|
-
{ text: '👋🏻 Greeting', id: '#Greeting', icon: 'review' },
|
|
550
|
-
{ text: '📞 Telepon', call: '628123456789' },
|
|
551
|
-
{ text: '📋 Copy', copy: '@kaels/casileys' },
|
|
552
|
-
{ text: '🌐 Buka Web', url: 'https://www.npmjs.com/package/@kaels/casileys', useWebview: true },
|
|
734
|
+
```js
|
|
735
|
+
sock.sendMessage(jid, {
|
|
736
|
+
text: 'Select an option',
|
|
737
|
+
footer: 'Casileys',
|
|
738
|
+
title: 'Casileys Menu',
|
|
739
|
+
buttonText: 'Open',
|
|
740
|
+
sections: [
|
|
553
741
|
{
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
742
|
+
title: 'Menu',
|
|
743
|
+
rows: [
|
|
744
|
+
{
|
|
745
|
+
title: 'Option 1',
|
|
746
|
+
description: 'First option',
|
|
747
|
+
rowId: 'option_1'
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
title: 'Option 2',
|
|
751
|
+
description: 'Second option',
|
|
752
|
+
rowId: 'option_2'
|
|
753
|
+
}
|
|
754
|
+
]
|
|
560
755
|
}
|
|
561
756
|
]
|
|
562
|
-
}, {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
757
|
+
}, {
|
|
758
|
+
quoted: message
|
|
759
|
+
})
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### 🗄️ Interactive
|
|
763
|
+
|
|
764
|
+
```js
|
|
765
|
+
sock.sendMessage(jid, {
|
|
766
|
+
interactiveMessage: {
|
|
767
|
+
body: {
|
|
768
|
+
text: 'Casileys Interactive'
|
|
769
|
+
},
|
|
770
|
+
footer: {
|
|
771
|
+
text: 'Select an action'
|
|
772
|
+
},
|
|
773
|
+
nativeFlowMessage: {
|
|
774
|
+
buttons: [
|
|
775
|
+
{
|
|
776
|
+
name: 'quick_reply',
|
|
777
|
+
buttonParamsJson: JSON.stringify({
|
|
778
|
+
display_text: 'Open',
|
|
779
|
+
id: 'open'
|
|
780
|
+
})
|
|
781
|
+
}
|
|
782
|
+
]
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}, {
|
|
786
|
+
quoted: message
|
|
787
|
+
})
|
|
590
788
|
```
|
|
591
789
|
|
|
592
790
|
### 🫙 Hydrated Template
|
|
593
791
|
|
|
594
|
-
```
|
|
792
|
+
```js
|
|
595
793
|
sock.sendMessage(jid, {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
794
|
+
hydratedTemplate: {
|
|
795
|
+
hydratedContentText: 'Casileys',
|
|
796
|
+
hydratedFooterText: 'WhatsApp Web API',
|
|
797
|
+
hydratedButtons: [
|
|
798
|
+
{
|
|
799
|
+
quickReplyButton: {
|
|
800
|
+
displayText: 'Open',
|
|
801
|
+
id: 'open'
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
]
|
|
805
|
+
}
|
|
806
|
+
}, {
|
|
807
|
+
quoted: message
|
|
808
|
+
})
|
|
606
809
|
```
|
|
607
810
|
|
|
608
811
|
---
|
|
609
812
|
|
|
610
813
|
## 💳 Sending Payment Messages
|
|
611
814
|
|
|
612
|
-
|
|
613
|
-
// Invite payment
|
|
614
|
-
sock.sendMessage(jid, { paymentInviteServiceType: 3 }) // 1, 2, atau 3
|
|
815
|
+
Payment-related structures are exposed through the corresponding message types.
|
|
615
816
|
|
|
616
|
-
|
|
817
|
+
### ➕ Invite Payment
|
|
818
|
+
|
|
819
|
+
```js
|
|
617
820
|
sock.sendMessage(jid, {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
821
|
+
paymentInviteMessage: {
|
|
822
|
+
serviceType: 3,
|
|
823
|
+
expiryTimestamp: Math.floor(Date.now() / 1000) + 86400
|
|
824
|
+
}
|
|
825
|
+
}, {
|
|
826
|
+
quoted: message
|
|
827
|
+
})
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### 🧾 Invoice
|
|
831
|
+
|
|
832
|
+
Invoice support depends on the currently supported WhatsApp message schema.
|
|
621
833
|
|
|
622
|
-
|
|
834
|
+
### 🛍️ Order
|
|
835
|
+
|
|
836
|
+
```js
|
|
623
837
|
sock.sendMessage(jid, {
|
|
624
|
-
|
|
625
|
-
|
|
838
|
+
orderMessage: {
|
|
839
|
+
orderId: 'ORDER_ID',
|
|
840
|
+
itemCount: 1,
|
|
841
|
+
status: 1,
|
|
842
|
+
surface: 1,
|
|
843
|
+
message: 'Casileys Order',
|
|
844
|
+
orderTitle: 'Example Product',
|
|
845
|
+
sellerJid: '0@s.whatsapp.net',
|
|
846
|
+
token: 'ORDER_TOKEN'
|
|
847
|
+
}
|
|
848
|
+
}, {
|
|
849
|
+
quoted: message
|
|
850
|
+
})
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
### 💳 Request Payment
|
|
854
|
+
|
|
855
|
+
```js
|
|
856
|
+
sock.sendMessage(jid, {
|
|
857
|
+
requestPaymentMessage: {
|
|
858
|
+
currencyCodeIso4217: 'IDR',
|
|
859
|
+
amount1000: 1000000,
|
|
860
|
+
noteMessage: {
|
|
861
|
+
extendedTextMessage: {
|
|
862
|
+
text: 'Payment request'
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}, {
|
|
867
|
+
quoted: message
|
|
626
868
|
})
|
|
627
869
|
```
|
|
628
870
|
|
|
@@ -630,217 +872,535 @@ sock.sendMessage(jid, {
|
|
|
630
872
|
|
|
631
873
|
## 👁️ Other Message Options
|
|
632
874
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
text: '📰 Info Penting!',
|
|
875
|
+
### 🤖 AI Icon
|
|
876
|
+
|
|
877
|
+
```js
|
|
878
|
+
sock.sendMessage(jid, {
|
|
879
|
+
text: 'Casileys',
|
|
880
|
+
ai: true
|
|
881
|
+
})
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
### 🕒 Ephemeral
|
|
885
|
+
|
|
886
|
+
```js
|
|
887
|
+
sock.sendMessage(jid, {
|
|
888
|
+
ephemeral: true,
|
|
889
|
+
text: 'Ephemeral message'
|
|
890
|
+
})
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### 📰 External Ad Reply
|
|
894
|
+
|
|
895
|
+
```js
|
|
896
|
+
sock.sendMessage(jid, {
|
|
897
|
+
text: 'Check this out.',
|
|
657
898
|
externalAdReply: {
|
|
658
|
-
title: '
|
|
659
|
-
body: '
|
|
899
|
+
title: 'Casileys',
|
|
900
|
+
body: 'WhatsApp Web API',
|
|
660
901
|
thumbnail: fs.readFileSync('./thumbnail.jpg'),
|
|
661
|
-
|
|
662
|
-
|
|
902
|
+
mediaType: 1,
|
|
903
|
+
renderLargerThumbnail: true,
|
|
904
|
+
sourceUrl: 'YOUR_SOURCE_URL'
|
|
663
905
|
}
|
|
664
|
-
}
|
|
906
|
+
})
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
### 📑 Spoiler
|
|
910
|
+
|
|
911
|
+
```js
|
|
912
|
+
sock.sendMessage(jid, {
|
|
913
|
+
spoiler: true,
|
|
914
|
+
text: 'Spoiler message'
|
|
915
|
+
})
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
### 👁️ View Once
|
|
919
|
+
|
|
920
|
+
```js
|
|
921
|
+
sock.sendMessage(jid, {
|
|
922
|
+
viewOnce: true,
|
|
923
|
+
image: {
|
|
924
|
+
url: './path/to/image.jpg'
|
|
925
|
+
}
|
|
926
|
+
})
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### 👁️ View Once V2
|
|
930
|
+
|
|
931
|
+
```js
|
|
932
|
+
sock.sendMessage(jid, {
|
|
933
|
+
viewOnceV2: true,
|
|
934
|
+
video: {
|
|
935
|
+
url: './path/to/video.mp4'
|
|
936
|
+
}
|
|
937
|
+
})
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
### 👁️ View Once V2 Extension
|
|
941
|
+
|
|
942
|
+
```js
|
|
943
|
+
sock.sendMessage(jid, {
|
|
944
|
+
viewOnceV2Extension: true,
|
|
945
|
+
image: {
|
|
946
|
+
url: './path/to/image.jpg'
|
|
947
|
+
}
|
|
948
|
+
})
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
### 🐱 Lottie Sticker
|
|
952
|
+
|
|
953
|
+
```js
|
|
954
|
+
sock.sendMessage(jid, {
|
|
955
|
+
sticker: {
|
|
956
|
+
url: './path/to/animation.webp'
|
|
957
|
+
},
|
|
958
|
+
isLottie: true
|
|
959
|
+
})
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
### 🏷️ Secure Meta Service Label
|
|
963
|
+
|
|
964
|
+
```js
|
|
965
|
+
sock.sendMessage(jid, {
|
|
966
|
+
text: 'Casileys',
|
|
967
|
+
secureMetaServiceLabel: true
|
|
968
|
+
})
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
### 🧩 Raw
|
|
972
|
+
|
|
973
|
+
```js
|
|
974
|
+
sock.sendMessage(jid, {
|
|
975
|
+
raw: {
|
|
976
|
+
message: {
|
|
977
|
+
conversation: 'Raw message'
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
})
|
|
665
981
|
```
|
|
666
982
|
|
|
667
983
|
---
|
|
668
984
|
|
|
985
|
+
## 🧑🧑🧒 Group Status
|
|
986
|
+
|
|
987
|
+
Casileys adds a dedicated helper for publishing group status content.
|
|
988
|
+
|
|
989
|
+
**Direct message option**
|
|
990
|
+
|
|
991
|
+
```js
|
|
992
|
+
sock.sendMessage(jid, {
|
|
993
|
+
groupStatus: true,
|
|
994
|
+
image: {
|
|
995
|
+
url: './path/to/image.jpg'
|
|
996
|
+
},
|
|
997
|
+
caption: 'Group Status'
|
|
998
|
+
})
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
**Helper API**
|
|
1002
|
+
|
|
1003
|
+
```js
|
|
1004
|
+
import {
|
|
1005
|
+
sendGroupStatusText,
|
|
1006
|
+
sendGroupStatusImage,
|
|
1007
|
+
sendGroupStatusVideo,
|
|
1008
|
+
sendGroupStatusAudio,
|
|
1009
|
+
sendGroupStatusSticker
|
|
1010
|
+
} from '@kaels/casileys'
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
**Text**
|
|
1014
|
+
|
|
1015
|
+
```js
|
|
1016
|
+
await sendGroupStatusText(
|
|
1017
|
+
sock,
|
|
1018
|
+
'120000000000000000@g.us',
|
|
1019
|
+
'Hello from Casileys'
|
|
1020
|
+
)
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
**Image**
|
|
1024
|
+
|
|
1025
|
+
```js
|
|
1026
|
+
import fs from 'fs'
|
|
1027
|
+
|
|
1028
|
+
await sendGroupStatusImage(
|
|
1029
|
+
sock,
|
|
1030
|
+
'120000000000000000@g.us',
|
|
1031
|
+
fs.readFileSync('./image.jpg'),
|
|
1032
|
+
{
|
|
1033
|
+
caption: 'Casileys Group Status'
|
|
1034
|
+
}
|
|
1035
|
+
)
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
**Video**
|
|
1039
|
+
|
|
1040
|
+
```js
|
|
1041
|
+
import fs from 'fs'
|
|
1042
|
+
|
|
1043
|
+
await sendGroupStatusVideo(
|
|
1044
|
+
sock,
|
|
1045
|
+
'120000000000000000@g.us',
|
|
1046
|
+
fs.readFileSync('./video.mp4'),
|
|
1047
|
+
{
|
|
1048
|
+
caption: 'Casileys Group Status'
|
|
1049
|
+
}
|
|
1050
|
+
)
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
**Audio**
|
|
1054
|
+
|
|
1055
|
+
```js
|
|
1056
|
+
import fs from 'fs'
|
|
1057
|
+
|
|
1058
|
+
await sendGroupStatusAudio(
|
|
1059
|
+
sock,
|
|
1060
|
+
'120000000000000000@g.us',
|
|
1061
|
+
fs.readFileSync('./audio.ogg'),
|
|
1062
|
+
{
|
|
1063
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
1064
|
+
ptt: true
|
|
1065
|
+
}
|
|
1066
|
+
)
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
**Sticker**
|
|
1070
|
+
|
|
1071
|
+
```js
|
|
1072
|
+
import fs from 'fs'
|
|
1073
|
+
|
|
1074
|
+
await sendGroupStatusSticker(
|
|
1075
|
+
sock,
|
|
1076
|
+
'120000000000000000@g.us',
|
|
1077
|
+
fs.readFileSync('./sticker.webp'),
|
|
1078
|
+
{
|
|
1079
|
+
caption: 'Casileys Group Status'
|
|
1080
|
+
}
|
|
1081
|
+
)
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
**WebP support**
|
|
1085
|
+
|
|
1086
|
+
The helper can process WebP sticker input:
|
|
1087
|
+
|
|
1088
|
+
| Input | Result |
|
|
1089
|
+
|---|---|
|
|
1090
|
+
| Static WebP | Image |
|
|
1091
|
+
| Animated WebP | Video |
|
|
1092
|
+
| JPEG / PNG | Image |
|
|
1093
|
+
| MP4 | Video |
|
|
1094
|
+
| OGG / Opus | Audio |
|
|
1095
|
+
| Text | Text |
|
|
1096
|
+
|
|
1097
|
+
Animated WebP conversion uses FFmpeg.
|
|
1098
|
+
|
|
1099
|
+
---
|
|
1100
|
+
|
|
669
1101
|
## ♻️ Modify Messages
|
|
670
1102
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
1103
|
+
### 🗑️ Delete
|
|
1104
|
+
|
|
1105
|
+
```js
|
|
1106
|
+
sock.sendMessage(jid, {
|
|
1107
|
+
delete: message.key
|
|
1108
|
+
})
|
|
1109
|
+
```
|
|
674
1110
|
|
|
675
|
-
|
|
676
|
-
sock.sendMessage(jid, { text: '✏️ Teks yang sudah diedit', edit: message.key })
|
|
1111
|
+
### ✏️ Edit
|
|
677
1112
|
|
|
678
|
-
|
|
679
|
-
sock.sendMessage(jid, {
|
|
1113
|
+
```js
|
|
1114
|
+
sock.sendMessage(jid, {
|
|
1115
|
+
text: 'Edited message'
|
|
1116
|
+
}, {
|
|
1117
|
+
edit: message.key
|
|
1118
|
+
})
|
|
680
1119
|
```
|
|
681
1120
|
|
|
682
1121
|
---
|
|
683
1122
|
|
|
684
1123
|
## 🧰 Additional Contents
|
|
685
1124
|
|
|
686
|
-
### 🏷️ Find User ID
|
|
1125
|
+
### 🏷️ Find User ID
|
|
687
1126
|
|
|
688
|
-
|
|
689
|
-
|
|
1127
|
+
```js
|
|
1128
|
+
const result = await sock.onWhatsApp(
|
|
1129
|
+
'628123456789'
|
|
1130
|
+
)
|
|
690
1131
|
|
|
691
|
-
|
|
692
|
-
const ids = await sock.findUserId('6281111111111@s.whatsapp.net')
|
|
693
|
-
console.log(ids)
|
|
694
|
-
// Output: { phoneNumber: '6281111111111@s.whatsapp.net', lid: '43411111111111@lid' }
|
|
1132
|
+
console.log(result)
|
|
695
1133
|
```
|
|
696
1134
|
|
|
697
1135
|
### 🔑 Request Custom Pairing Code
|
|
698
1136
|
|
|
699
|
-
```
|
|
700
|
-
const code = await sock.requestPairingCode(
|
|
701
|
-
|
|
1137
|
+
```js
|
|
1138
|
+
const code = await sock.requestPairingCode(
|
|
1139
|
+
'628123456789'
|
|
1140
|
+
)
|
|
1141
|
+
|
|
1142
|
+
console.log(code)
|
|
702
1143
|
```
|
|
703
1144
|
|
|
704
1145
|
### 🖼️ Image Processing
|
|
705
1146
|
|
|
706
|
-
|
|
707
|
-
|
|
1147
|
+
```js
|
|
1148
|
+
const imageLibrary =
|
|
1149
|
+
await getImageProcessingLibrary()
|
|
1150
|
+
|
|
1151
|
+
console.log(imageLibrary)
|
|
1152
|
+
```
|
|
1153
|
+
|
|
1154
|
+
---
|
|
1155
|
+
|
|
1156
|
+
## 📣 Newsletter Management
|
|
1157
|
+
|
|
1158
|
+
Newsletter JIDs use:
|
|
1159
|
+
|
|
1160
|
+
```
|
|
1161
|
+
123456789012345678@newsletter
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
Example:
|
|
1165
|
+
|
|
1166
|
+
```js
|
|
1167
|
+
const newsletterJid =
|
|
1168
|
+
'123456789012345678@newsletter'
|
|
1169
|
+
|
|
1170
|
+
await sock.sendMessage(
|
|
1171
|
+
newsletterJid,
|
|
1172
|
+
{
|
|
1173
|
+
text: 'Hello from Casileys'
|
|
1174
|
+
}
|
|
1175
|
+
)
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
Newsletter media and message operations use the same socket/message infrastructure.
|
|
1179
|
+
|
|
1180
|
+
---
|
|
1181
|
+
|
|
1182
|
+
## 👥 Group Management
|
|
1183
|
+
|
|
1184
|
+
**Fetch groups**
|
|
1185
|
+
|
|
1186
|
+
```js
|
|
1187
|
+
const groups =
|
|
1188
|
+
await sock.groupFetchAllParticipating()
|
|
1189
|
+
|
|
1190
|
+
console.log(groups)
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
**Create group**
|
|
1194
|
+
|
|
1195
|
+
```js
|
|
1196
|
+
const group =
|
|
1197
|
+
await sock.groupCreate(
|
|
1198
|
+
'Casileys Community',
|
|
1199
|
+
[
|
|
1200
|
+
'628123456789@s.whatsapp.net'
|
|
1201
|
+
]
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
console.log(group)
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
**Update participants**
|
|
1208
|
+
|
|
1209
|
+
```js
|
|
1210
|
+
await sock.groupParticipantsUpdate(
|
|
1211
|
+
'120000000000000000@g.us',
|
|
1212
|
+
[
|
|
1213
|
+
'628123456789@s.whatsapp.net'
|
|
1214
|
+
],
|
|
1215
|
+
'add'
|
|
1216
|
+
)
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
The participant action can be changed to:
|
|
708
1220
|
|
|
709
|
-
|
|
710
|
-
|
|
1221
|
+
| Action | Description |
|
|
1222
|
+
|---|---|
|
|
1223
|
+
| `add` | Add a participant to the group |
|
|
1224
|
+
| `remove` | Remove a participant from the group |
|
|
1225
|
+
| `promote` | Promote a participant to admin |
|
|
1226
|
+
| `demote` | Demote a participant from admin |
|
|
1227
|
+
|
|
1228
|
+
**Update subject**
|
|
1229
|
+
|
|
1230
|
+
```js
|
|
1231
|
+
await sock.groupUpdateSubject(
|
|
1232
|
+
'120000000000000000@g.us',
|
|
1233
|
+
'Casileys Community'
|
|
1234
|
+
)
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
**Update description**
|
|
1238
|
+
|
|
1239
|
+
```js
|
|
1240
|
+
await sock.groupUpdateDescription(
|
|
1241
|
+
'120000000000000000@g.us',
|
|
1242
|
+
'Community powered by Casileys.'
|
|
1243
|
+
)
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
**Leave**
|
|
1247
|
+
|
|
1248
|
+
```js
|
|
1249
|
+
await sock.groupLeave(
|
|
1250
|
+
'120000000000000000@g.us'
|
|
1251
|
+
)
|
|
1252
|
+
```
|
|
1253
|
+
|
|
1254
|
+
---
|
|
1255
|
+
|
|
1256
|
+
## 👥 Community Management
|
|
1257
|
+
|
|
1258
|
+
Community-related operations use the group/community methods provided by the socket and WhatsApp protocol.
|
|
1259
|
+
|
|
1260
|
+
---
|
|
1261
|
+
|
|
1262
|
+
## 👤 Profile Management
|
|
1263
|
+
|
|
1264
|
+
**Profile picture**
|
|
1265
|
+
|
|
1266
|
+
```js
|
|
1267
|
+
const profilePicture =
|
|
1268
|
+
await sock.profilePictureUrl(
|
|
1269
|
+
'628123456789@s.whatsapp.net',
|
|
1270
|
+
'image'
|
|
1271
|
+
)
|
|
1272
|
+
|
|
1273
|
+
console.log(profilePicture)
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
**Update profile picture**
|
|
1277
|
+
|
|
1278
|
+
```js
|
|
1279
|
+
await sock.updateProfilePicture(
|
|
1280
|
+
sock.user.id,
|
|
1281
|
+
{
|
|
1282
|
+
url: './profile.jpg'
|
|
1283
|
+
}
|
|
1284
|
+
)
|
|
1285
|
+
```
|
|
711
1286
|
|
|
712
|
-
|
|
1287
|
+
**Update profile status**
|
|
713
1288
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
1289
|
+
```js
|
|
1290
|
+
await sock.updateProfileStatus(
|
|
1291
|
+
'Powered by Casileys'
|
|
1292
|
+
)
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
---
|
|
1296
|
+
|
|
1297
|
+
## 🛒 Business Management
|
|
1298
|
+
|
|
1299
|
+
Business messages can be sent through the same message API.
|
|
1300
|
+
|
|
1301
|
+
Product structures can contain fields such as:
|
|
1302
|
+
|
|
1303
|
+
```js
|
|
1304
|
+
{
|
|
1305
|
+
currencyCode: 'IDR',
|
|
1306
|
+
priceAmount1000: 1000000,
|
|
1307
|
+
productId: 'product-id',
|
|
1308
|
+
productImageCount: 1,
|
|
1309
|
+
title: 'Casileys Product',
|
|
1310
|
+
description: 'Product description',
|
|
1311
|
+
url: 'YOUR_PRODUCT_URL'
|
|
720
1312
|
}
|
|
721
1313
|
```
|
|
722
1314
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
// Kelola member
|
|
733
|
-
sock.groupParticipantsUpdate(jid, ['628xxx@s.whatsapp.net'], 'add') // tambah
|
|
734
|
-
sock.groupParticipantsUpdate(jid, ['628xxx@s.whatsapp.net'], 'remove') // kick
|
|
735
|
-
sock.groupParticipantsUpdate(jid, ['628xxx@s.whatsapp.net'], 'promote') // jadikan admin
|
|
736
|
-
sock.groupParticipantsUpdate(jid, ['628xxx@s.whatsapp.net'], 'demote') // copot admin
|
|
737
|
-
|
|
738
|
-
// Setting grup
|
|
739
|
-
sock.groupSettingUpdate(jid, 'announcement') // hanya admin bisa chat
|
|
740
|
-
sock.groupSettingUpdate(jid, 'not_announcement') // semua bisa chat
|
|
741
|
-
sock.groupSettingUpdate(jid, 'locked') // hanya admin edit info
|
|
742
|
-
sock.groupSettingUpdate(jid, 'unlocked') // semua bisa edit info
|
|
743
|
-
sock.groupToggleEphemeral(jid, 86400) // aktifkan pesan sementara
|
|
744
|
-
sock.groupJoinApprovalMode(jid, 'on') // aktifkan persetujuan member
|
|
745
|
-
|
|
746
|
-
// Invite
|
|
747
|
-
const inviteCode = await sock.groupInviteCode(jid)
|
|
748
|
-
sock.groupRevokeInvite(jid)
|
|
749
|
-
sock.groupAcceptInvite(inviteCode)
|
|
750
|
-
sock.groupLeave(jid)
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
### 👥 Community Management
|
|
754
|
-
|
|
755
|
-
```javascript
|
|
756
|
-
const community = await sock.communityCreate('Nama Komunitas', 'Deskripsi')
|
|
757
|
-
const group = await sock.communityCreateGroup('Announcements', ['628xxx@s.whatsapp.net'], communityJid)
|
|
758
|
-
|
|
759
|
-
sock.communityLinkGroup(groupJid, communityJid)
|
|
760
|
-
sock.communityUnlinkGroup(groupJid, communityJid)
|
|
761
|
-
sock.communityLeave(jid)
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
### 👤 Profile Management
|
|
765
|
-
|
|
766
|
-
```javascript
|
|
767
|
-
sock.updateProfilePicture(jid, { url: './photo.jpg' })
|
|
768
|
-
sock.removeProfilePicture(jid)
|
|
769
|
-
sock.updateProfileName('Nama Baru')
|
|
770
|
-
sock.updateProfileStatus('Status baru')
|
|
771
|
-
sock.sendPresenceUpdate('available', jid)
|
|
772
|
-
sock.readMessages([message.key])
|
|
773
|
-
sock.updateBlockStatus(jid, 'block') // blokir
|
|
774
|
-
sock.updateBlockStatus(jid, 'unblock') // buka blokir
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
### 🔐 Privacy Management
|
|
778
|
-
|
|
779
|
-
```javascript
|
|
780
|
-
sock.updateLastSeenPrivacy('all') // semua bisa lihat
|
|
781
|
-
sock.updateLastSeenPrivacy('contacts') // kontak saja
|
|
782
|
-
sock.updateLastSeenPrivacy('nobody') // tidak ada
|
|
783
|
-
sock.updateOnlinePrivacy('all')
|
|
784
|
-
sock.updateProfilePicturePrivacy('contacts')
|
|
785
|
-
sock.updateReadReceiptsPrivacy('all')
|
|
786
|
-
sock.updateReadReceiptsPrivacy('none')
|
|
787
|
-
sock.updateCallPrivacy('everyone')
|
|
788
|
-
sock.updateDefaultDisappearingMode(86400)
|
|
789
|
-
```
|
|
790
|
-
|
|
791
|
-
### 📣 Newsletter Management
|
|
792
|
-
|
|
793
|
-
```javascript
|
|
794
|
-
sock.newsletterCreate('Nama Channel', 'Deskripsi')
|
|
795
|
-
sock.newsletterFollow('jid@newsletter')
|
|
796
|
-
sock.newsletterUnfollow('jid@newsletter')
|
|
797
|
-
sock.newsletterMute('jid@newsletter')
|
|
798
|
-
sock.newsletterUnmute('jid@newsletter')
|
|
799
|
-
sock.newsletterUpdateName('jid@newsletter', 'Nama Baru')
|
|
800
|
-
sock.newsletterUpdateDescription('jid@newsletter', 'Deskripsi baru')
|
|
801
|
-
sock.newsletterReactMessage('jid@newsletter', '100', '💛')
|
|
802
|
-
sock.newsletterDelete('jid@newsletter')
|
|
803
|
-
```
|
|
804
|
-
|
|
805
|
-
### 📡 Events
|
|
806
|
-
|
|
807
|
-
```javascript
|
|
808
|
-
sock.ev.on('connection.update', (update) => {})
|
|
809
|
-
sock.ev.on('creds.update', (update) => {})
|
|
810
|
-
sock.ev.on('messages.upsert', (update) => {})
|
|
811
|
-
sock.ev.on('messages.update', (update) => {})
|
|
812
|
-
sock.ev.on('messages.delete', (update) => {})
|
|
813
|
-
sock.ev.on('messages.reaction', (update) => {})
|
|
814
|
-
sock.ev.on('groups.upsert', (update) => {})
|
|
815
|
-
sock.ev.on('groups.update', (update) => {})
|
|
816
|
-
sock.ev.on('group-participants.update', (update) => {})
|
|
817
|
-
sock.ev.on('contacts.upsert', (update) => {})
|
|
818
|
-
sock.ev.on('contacts.update', (update) => {})
|
|
819
|
-
sock.ev.on('chats.upsert', (update) => {})
|
|
820
|
-
sock.ev.on('chats.update', (update) => {})
|
|
821
|
-
sock.ev.on('presence.update', (update) => {})
|
|
822
|
-
sock.ev.on('blocklist.set', (update) => {})
|
|
823
|
-
sock.ev.on('blocklist.update', (update) => {})
|
|
824
|
-
sock.ev.on('call', (update) => {})
|
|
825
|
-
sock.ev.on('newsletter.reaction', (update) => {})
|
|
826
|
-
sock.ev.on('newsletter.view', (update) => {})
|
|
827
|
-
sock.ev.on('settings.update', (update) => {})
|
|
1315
|
+
---
|
|
1316
|
+
|
|
1317
|
+
## 🔐 Privacy Management
|
|
1318
|
+
|
|
1319
|
+
```js
|
|
1320
|
+
const privacy =
|
|
1321
|
+
await sock.fetchPrivacySettings()
|
|
1322
|
+
|
|
1323
|
+
console.log(privacy)
|
|
828
1324
|
```
|
|
829
1325
|
|
|
830
1326
|
---
|
|
831
1327
|
|
|
1328
|
+
## 📡 Events
|
|
1329
|
+
|
|
1330
|
+
Casileys exposes WhatsApp events through `sock.ev`.
|
|
1331
|
+
|
|
1332
|
+
**Messages**
|
|
1333
|
+
|
|
1334
|
+
```js
|
|
1335
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
1336
|
+
for (const message of messages) {
|
|
1337
|
+
if (!message.message) continue
|
|
1338
|
+
|
|
1339
|
+
console.log(message)
|
|
1340
|
+
}
|
|
1341
|
+
})
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
**Connection**
|
|
1345
|
+
|
|
1346
|
+
```js
|
|
1347
|
+
sock.ev.on('connection.update', (update) => {
|
|
1348
|
+
const {
|
|
1349
|
+
connection,
|
|
1350
|
+
lastDisconnect
|
|
1351
|
+
} = update
|
|
1352
|
+
|
|
1353
|
+
console.log({
|
|
1354
|
+
connection,
|
|
1355
|
+
lastDisconnect
|
|
1356
|
+
})
|
|
1357
|
+
})
|
|
1358
|
+
```
|
|
1359
|
+
|
|
1360
|
+
**Credentials**
|
|
1361
|
+
|
|
1362
|
+
```js
|
|
1363
|
+
sock.ev.on('creds.update', saveCreds)
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
---
|
|
1367
|
+
|
|
1368
|
+
## ⚠️ Disclaimer
|
|
1369
|
+
|
|
1370
|
+
Casileys is an independent fork based on existing Baileys-related projects.
|
|
1371
|
+
|
|
1372
|
+
It is not affiliated with WhatsApp or Meta Platforms, Inc.
|
|
1373
|
+
|
|
1374
|
+
The project retains appropriate attribution to its upstream projects and contributors.
|
|
1375
|
+
|
|
1376
|
+
Fork reference: `https://github.com/itsliaa/baileys`
|
|
1377
|
+
|
|
1378
|
+
Please respect the licenses and attribution requirements of the upstream projects when using or redistributing Casileys.
|
|
1379
|
+
|
|
1380
|
+
---
|
|
1381
|
+
|
|
832
1382
|
## 📣 Credits
|
|
833
1383
|
|
|
834
|
-
|
|
1384
|
+
**Upstream**
|
|
1385
|
+
|
|
1386
|
+
- WhiskeySockets / Baileys
|
|
1387
|
+
- Original Baileys maintainers and contributors
|
|
1388
|
+
- Contributors to the WhatsApp protocol ecosystem
|
|
1389
|
+
|
|
1390
|
+
**Fork Base**
|
|
1391
|
+
|
|
1392
|
+
- ItsLiaaa / Baileys
|
|
1393
|
+
- Contributors to the fork base
|
|
1394
|
+
|
|
1395
|
+
**Casileys**
|
|
1396
|
+
|
|
1397
|
+
- Casileys contributors and maintainers
|
|
1398
|
+
- Contributors to Casileys-specific improvements and utilities
|
|
1399
|
+
|
|
1400
|
+
---
|
|
835
1401
|
|
|
836
|
-
|
|
837
|
-
- [jlucaso1](https://github.com/jlucaso1)
|
|
838
|
-
- [adiwajshing](https://github.com/adiwajshing)
|
|
1402
|
+
## 📄 License
|
|
839
1403
|
|
|
840
|
-
|
|
841
|
-
- **[itsliaaa](https://github.com/itsliaaa)** — atas fork [`@itsliaaa/baileys`](https://www.npmjs.com/package/@itsliaaa/baileys) yang menjadi fondasi awal package ini. Maaf atas kurangnya atribusi sebelumnya.
|
|
842
|
-
- **[itsreimau](https://github.com/itsreimau)** — atas perbaikan implementasi `updateBlockStatus`.
|
|
843
|
-
- **[WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)** — upstream library yang menjadi dasar dari semuanya.
|
|
1404
|
+
Casileys is released under the MIT License.
|
|
844
1405
|
|
|
845
|
-
|
|
846
|
-
> ⚠️ Modifikasi, penghapusan, atau kesalahan representasi kredit ini dilarang keras. Setiap redistribusi atau fork harus mempertahankan bagian ini dalam bentuk aslinya.
|
|
1406
|
+
See [`LICENSE`](./LICENSE) for the complete license text.
|