@yemo-dev/yebail 1.0.0
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/EXAMPLES.md +641 -0
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.js +116311 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +142 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults/yebail-version.json +7 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.js +196 -0
- package/lib/Signal/lid-mapping.js +148 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +72 -0
- package/lib/Socket/business.js +368 -0
- package/lib/Socket/chats.js +992 -0
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +323 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.js +1133 -0
- package/lib/Socket/messages-send.js +992 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.js +631 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +421 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.js +188 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.js +763 -0
- package/lib/Utils/crypto.js +187 -0
- package/lib/Utils/decode-wa-message.js +293 -0
- package/lib/Utils/event-buffer.js +514 -0
- package/lib/Utils/generics.js +453 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.js +37 -0
- package/lib/Utils/link-preview.js +121 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +47 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +910 -0
- package/lib/Utils/messages.js +1129 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.js +448 -0
- package/lib/Utils/signal.js +150 -0
- package/lib/Utils/use-custom-auth-state.js +110 -0
- package/lib/Utils/use-multi-file-auth-state.js +43 -0
- package/lib/Utils/use-sqlite-auth-state.js +39 -0
- package/lib/Utils/validate-connection.js +237 -0
- package/lib/Utils/yebail-event-stream.js +55 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +275 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +136 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +46 -0
- package/package.json +114 -0
package/EXAMPLES.md
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
# yebails code examples (`sendMessage`)
|
|
2
|
+
|
|
3
|
+
GitHub-only distribution. After `npm install` or `npm install github:yemo-dev/baileys`:
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const makeWASocket = require('yebails').default
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
From a local clone (without global install):
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
const makeWASocket = require('./lib').default
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Replace `jid` with the target recipient (`628xxx@s.whatsapp.net` or `group@g.us`). All examples assume `const sock = makeWASocket({ ... })` and `await sock.sendMessage(jid, content, options)`.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Authentication & database persistence
|
|
20
|
+
|
|
21
|
+
yebails supports **local** and **cloud** databases the same way: you choose how `creds` and key bundles are stored. Built-in options:
|
|
22
|
+
|
|
23
|
+
### 1) Filesystem (default)
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const { default: makeWASocket, useMultiFileAuthState } = require('yebails')
|
|
27
|
+
|
|
28
|
+
const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
|
|
29
|
+
const sock = makeWASocket({ auth: state })
|
|
30
|
+
sock.ev.on('creds.update', saveCreds)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2) SQLite (single local `.db` file)
|
|
34
|
+
|
|
35
|
+
Install the optional native driver: `npm install better-sqlite3`
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const { default: makeWASocket, useSqliteAuthState } = require('yebails')
|
|
39
|
+
|
|
40
|
+
const { state, saveCreds } = await useSqliteAuthState('./wa-session.db')
|
|
41
|
+
const sock = makeWASocket({ auth: state })
|
|
42
|
+
sock.ev.on('creds.update', saveCreds)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3) Custom / cloud (Redis, Mongo, HTTP API, etc.)
|
|
46
|
+
|
|
47
|
+
Implement three async functions: **`get(key)`** → JSON string or `null`, **`set(key, jsonString)`**, **`remove(key)`**. Keys are normalized filenames (e.g. `creds.json`, `pre-key-1.json`).
|
|
48
|
+
|
|
49
|
+
**Redis (example with `ioredis`):**
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const Redis = require('ioredis')
|
|
53
|
+
const { default: makeWASocket, useCustomAuthState } = require('yebails')
|
|
54
|
+
|
|
55
|
+
const redis = new Redis(process.env.REDIS_URL)
|
|
56
|
+
const prefix = 'yebails:session:'
|
|
57
|
+
|
|
58
|
+
const { state, saveCreds } = await useCustomAuthState({
|
|
59
|
+
get: async (key) => (await redis.get(prefix + key)) ?? null,
|
|
60
|
+
set: async (key, value) => { await redis.set(prefix + key, value) },
|
|
61
|
+
remove: async (key) => { await redis.del(prefix + key) }
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const sock = makeWASocket({ auth: state })
|
|
65
|
+
sock.ev.on('creds.update', saveCreds)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Cloud HTTP (sketch):** your backend stores `{ key, value }` rows; `get`/`set`/`remove` call `fetch` to your API. Use TLS, auth headers, and encryption for production.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Plain text
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
await sock.sendMessage(jid, { text: 'Hello' })
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Text + quoted reply
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
await sock.sendMessage(jid, { text: 'Reply' }, { quoted: fullMessage })
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Text + mention
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
await sock.sendMessage(jid, {
|
|
88
|
+
text: '@6281234567890 hello',
|
|
89
|
+
mentions: ['6281234567890@s.whatsapp.net']
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Link preview (requires `link-preview-js` in your project + unfurl)
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
await sock.sendMessage(jid, { text: 'See https://example.com' })
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Legacy buttons (`buttons`)
|
|
102
|
+
|
|
103
|
+
Mostly works in private chats on many client versions.
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
await sock.sendMessage(jid, {
|
|
107
|
+
text: 'Choose:',
|
|
108
|
+
footer: 'footer',
|
|
109
|
+
buttons: [
|
|
110
|
+
{ buttonId: 'id1', buttonText: { displayText: 'One' } },
|
|
111
|
+
{ buttonId: 'id2', buttonText: { displayText: 'Two' } }
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## List (`sections` / list)
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
await sock.sendMessage(jid, {
|
|
120
|
+
text: 'List description',
|
|
121
|
+
footer: 'footer',
|
|
122
|
+
title: 'Title',
|
|
123
|
+
buttonText: 'Open list',
|
|
124
|
+
sections: [
|
|
125
|
+
{
|
|
126
|
+
title: 'Section A',
|
|
127
|
+
rows: [
|
|
128
|
+
{ title: 'Option 1', rowId: 'opt1', description: 'desc' },
|
|
129
|
+
{ title: 'Option 2', rowId: 'opt2' }
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Template buttons (hydrated)
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
await sock.sendMessage(jid, {
|
|
140
|
+
text: 'Content',
|
|
141
|
+
footer: 'Footer',
|
|
142
|
+
templateButtons: [
|
|
143
|
+
{ index: 1, urlButton: { displayText: 'Website', url: 'https://example.com' } },
|
|
144
|
+
{ index: 2, callButton: { displayText: 'Call', phoneNumber: '628xxx' } },
|
|
145
|
+
{ index: 3, quickReplyButton: { displayText: 'OK', id: 'ok' } }
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Interactive native: quick reply & URL
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
await sock.sendMessage(jid, {
|
|
156
|
+
text: 'Interactive body',
|
|
157
|
+
title: 'Title',
|
|
158
|
+
subtitle: 'Subtitle',
|
|
159
|
+
footer: 'Footer',
|
|
160
|
+
interactiveButtons: [
|
|
161
|
+
{
|
|
162
|
+
name: 'quick_reply',
|
|
163
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Klik', id: 'btn_1' })
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'cta_url',
|
|
167
|
+
buttonParamsJson: JSON.stringify({
|
|
168
|
+
display_text: 'Open link',
|
|
169
|
+
url: 'https://example.com',
|
|
170
|
+
merchant_url: 'https://example.com'
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Interactive: copy code, call, catalog
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
await sock.sendMessage(jid, {
|
|
181
|
+
text: 'Choose an action',
|
|
182
|
+
footer: 'Footer',
|
|
183
|
+
interactiveButtons: [
|
|
184
|
+
{
|
|
185
|
+
name: 'cta_copy',
|
|
186
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Salin', copy_code: 'KODE123' })
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'cta_call',
|
|
190
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Hubungi', phone_number: '6281234567890' })
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'cta_catalog',
|
|
194
|
+
buttonParamsJson: JSON.stringify({ business_phone_number: '6281234567890' })
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
})
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Interactive: PIX payment (`payment_info`)
|
|
201
|
+
|
|
202
|
+
`text` is still recommended (an empty string is allowed) to keep the payload valid.
|
|
203
|
+
|
|
204
|
+
```js
|
|
205
|
+
await sock.sendMessage(jid, {
|
|
206
|
+
text: '',
|
|
207
|
+
interactiveButtons: [
|
|
208
|
+
{
|
|
209
|
+
name: 'payment_info',
|
|
210
|
+
buttonParamsJson: JSON.stringify({
|
|
211
|
+
payment_settings: [
|
|
212
|
+
{
|
|
213
|
+
type: 'pix_static_code',
|
|
214
|
+
pix_static_code: {
|
|
215
|
+
merchant_name: 'Store',
|
|
216
|
+
key: 'email@domain.com',
|
|
217
|
+
key_type: 'EMAIL'
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
})
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`key_type` umum: `EMAIL`, `PHONE`, `CPF`, `EVP`.
|
|
228
|
+
|
|
229
|
+
## Interactive: review & pay (`review_and_pay`)
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
await sock.sendMessage(jid, {
|
|
233
|
+
text: '',
|
|
234
|
+
interactiveButtons: [
|
|
235
|
+
{
|
|
236
|
+
name: 'review_and_pay',
|
|
237
|
+
buttonParamsJson: JSON.stringify({
|
|
238
|
+
currency: 'IDR',
|
|
239
|
+
payment_configuration: '',
|
|
240
|
+
payment_type: '',
|
|
241
|
+
total_amount: { value: '100000', offset: '100' },
|
|
242
|
+
reference_id: 'REF-001',
|
|
243
|
+
type: 'physical-goods',
|
|
244
|
+
payment_method: 'confirm',
|
|
245
|
+
payment_status: 'captured',
|
|
246
|
+
payment_timestamp: Math.floor(Date.now() / 1000),
|
|
247
|
+
order: {
|
|
248
|
+
status: 'completed',
|
|
249
|
+
description: '',
|
|
250
|
+
subtotal: { value: '100000', offset: '100' },
|
|
251
|
+
order_type: 'PAYMENT_REQUEST',
|
|
252
|
+
items: [
|
|
253
|
+
{
|
|
254
|
+
retailer_id: 'sku1',
|
|
255
|
+
name: 'Product',
|
|
256
|
+
amount: { value: '100000', offset: '100' },
|
|
257
|
+
quantity: '1'
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
additional_note: 'Thank you',
|
|
262
|
+
native_payment_methods: [],
|
|
263
|
+
share_payment_status: false
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
})
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Interactive + image / video / document
|
|
271
|
+
|
|
272
|
+
Add media fields in the same object (document thumbnails are often required).
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
await sock.sendMessage(jid, {
|
|
276
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
277
|
+
caption: 'Caption',
|
|
278
|
+
title: 'Title',
|
|
279
|
+
subtitle: 'Subtitle',
|
|
280
|
+
footer: 'Footer',
|
|
281
|
+
hasMediaAttachment: false,
|
|
282
|
+
interactiveButtons: [
|
|
283
|
+
{
|
|
284
|
+
name: 'quick_reply',
|
|
285
|
+
buttonParamsJson: JSON.stringify({ display_text: 'OK', id: 'ok' })
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
})
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Interactive: single select (single-choice menu)
|
|
292
|
+
|
|
293
|
+
```js
|
|
294
|
+
await sock.sendMessage(jid, {
|
|
295
|
+
text: 'Pick one',
|
|
296
|
+
footer: 'Footer',
|
|
297
|
+
interactiveButtons: [
|
|
298
|
+
{
|
|
299
|
+
name: 'single_select',
|
|
300
|
+
buttonParamsJson: JSON.stringify({
|
|
301
|
+
title: 'Menu',
|
|
302
|
+
sections: [
|
|
303
|
+
{
|
|
304
|
+
title: 'Option group',
|
|
305
|
+
highlight_label: 'Options',
|
|
306
|
+
rows: [
|
|
307
|
+
{ header: 'A', title: 'One', description: 'Description', id: 'id1' },
|
|
308
|
+
{ header: 'B', title: 'Two', description: '', id: 'id2' }
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
})
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Interactive: native flow (galaxy / flow - adjust token and flow id for your business)
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
await sock.sendMessage(jid, {
|
|
322
|
+
text: 'Open flow',
|
|
323
|
+
footer: 'Footer',
|
|
324
|
+
interactiveButtons: [
|
|
325
|
+
{
|
|
326
|
+
name: 'galaxy_message',
|
|
327
|
+
buttonParamsJson: JSON.stringify({
|
|
328
|
+
mode: 'published',
|
|
329
|
+
flow_message_version: '3',
|
|
330
|
+
flow_token: '1:xxx:hash',
|
|
331
|
+
flow_id: '1307913409923914',
|
|
332
|
+
flow_cta: 'Start',
|
|
333
|
+
flow_action: 'navigate',
|
|
334
|
+
flow_action_payload: {
|
|
335
|
+
screen: 'SCREEN_ONE',
|
|
336
|
+
params: { user_id: '123' }
|
|
337
|
+
},
|
|
338
|
+
flow_metadata: {
|
|
339
|
+
flow_json_version: '201',
|
|
340
|
+
data_api_protocol: 'v2',
|
|
341
|
+
flow_name: 'Lead',
|
|
342
|
+
data_api_version: 'v2',
|
|
343
|
+
categories: ['Lead Generation']
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
})
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Interactive: address, location, webview (button names must match protocol)
|
|
352
|
+
|
|
353
|
+
```js
|
|
354
|
+
await sock.sendMessage(jid, {
|
|
355
|
+
text: 'Action',
|
|
356
|
+
interactiveButtons: [
|
|
357
|
+
{
|
|
358
|
+
name: 'address_message',
|
|
359
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Address' })
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: 'send_location',
|
|
363
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Send location' })
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: 'open_webview',
|
|
367
|
+
buttonParamsJson: JSON.stringify({
|
|
368
|
+
title: 'Open',
|
|
369
|
+
link: { in_app_webview: true, url: 'https://example.com' }
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
})
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Shop storefront (`shop` + `id`)
|
|
377
|
+
|
|
378
|
+
```js
|
|
379
|
+
await sock.sendMessage(jid, {
|
|
380
|
+
text: 'View catalog',
|
|
381
|
+
title: 'Title',
|
|
382
|
+
subtitle: 'Subtitle',
|
|
383
|
+
footer: 'Footer',
|
|
384
|
+
shop: { surface: 1, id: 'https://example.com' },
|
|
385
|
+
viewOnce: true
|
|
386
|
+
})
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Image / video / audio / sticker / document
|
|
392
|
+
|
|
393
|
+
```js
|
|
394
|
+
await sock.sendMessage(jid, { image: { url: 'https://...' }, caption: '...' })
|
|
395
|
+
await sock.sendMessage(jid, { video: { url: 'https://...' }, caption: '...' })
|
|
396
|
+
await sock.sendMessage(jid, { audio: { url: 'https://...' }, mimetype: 'audio/mp4', ptt: true })
|
|
397
|
+
await sock.sendMessage(jid, { sticker: Buffer.from(...) })
|
|
398
|
+
await sock.sendMessage(jid, { document: { url: 'https://...' }, mimetype: 'application/pdf', fileName: 'a.pdf' })
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## GIF (video + flag)
|
|
402
|
+
|
|
403
|
+
```js
|
|
404
|
+
await sock.sendMessage(jid, { video: bufferOrUrl, gifPlayback: true, caption: 'gif' })
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## PTV (round video)
|
|
408
|
+
|
|
409
|
+
```js
|
|
410
|
+
await sock.sendMessage(jid, { video: { url: '...' }, ptv: true })
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## View once
|
|
414
|
+
|
|
415
|
+
```js
|
|
416
|
+
await sock.sendMessage(jid, { image: { url: '...' }, viewOnce: true })
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## Album
|
|
420
|
+
|
|
421
|
+
```js
|
|
422
|
+
await sock.sendMessage(jid, {
|
|
423
|
+
album: [
|
|
424
|
+
{ image: { url: '...' }, caption: '1' },
|
|
425
|
+
{ video: { url: '...' }, caption: '2' }
|
|
426
|
+
]
|
|
427
|
+
})
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Location
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
await sock.sendMessage(jid, {
|
|
436
|
+
location: { degreesLatitude: -6.2, degreesLongitude: 106.8, name: 'Jakarta' }
|
|
437
|
+
})
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Contact (vCard)
|
|
441
|
+
|
|
442
|
+
```js
|
|
443
|
+
const vcard = 'BEGIN:VCARD\nVERSION:3.0\nFN:Name\nTEL;type=CELL;waid=6281234567890:+62 812-3456-7890\nEND:VCARD'
|
|
444
|
+
await sock.sendMessage(jid, {
|
|
445
|
+
contacts: { displayName: 'Contact', contacts: [{ vcard }] }
|
|
446
|
+
})
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Reaction
|
|
450
|
+
|
|
451
|
+
```js
|
|
452
|
+
await sock.sendMessage(jid, { react: { text: ':thumbs_up:', key: messageKey } })
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Delete for everyone
|
|
456
|
+
|
|
457
|
+
```js
|
|
458
|
+
await sock.sendMessage(jid, { delete: msg.key })
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Edit message
|
|
462
|
+
|
|
463
|
+
```js
|
|
464
|
+
await sock.sendMessage(jid, { text: 'New text', edit: messageKey })
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
## Forward
|
|
468
|
+
|
|
469
|
+
```js
|
|
470
|
+
await sock.sendMessage(jid, { forward: fullMessage, force: true })
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## Disappearing messages in chat
|
|
474
|
+
|
|
475
|
+
```js
|
|
476
|
+
await sock.sendMessage(jid, { disappearingMessagesInChat: true })
|
|
477
|
+
await sock.sendMessage(jid, { text: 'one-time', ephemeralExpiration: 86400 })
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## Poll
|
|
481
|
+
|
|
482
|
+
```js
|
|
483
|
+
await sock.sendMessage(jid, {
|
|
484
|
+
poll: {
|
|
485
|
+
name: 'Options',
|
|
486
|
+
values: ['A', 'B'],
|
|
487
|
+
selectableCount: 1,
|
|
488
|
+
toAnnouncementGroup: false
|
|
489
|
+
}
|
|
490
|
+
})
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
## Event (schedule)
|
|
494
|
+
|
|
495
|
+
```js
|
|
496
|
+
await sock.sendMessage(jid, {
|
|
497
|
+
event: {
|
|
498
|
+
isCanceled: false,
|
|
499
|
+
name: 'Meeting',
|
|
500
|
+
description: 'Description',
|
|
501
|
+
location: { degreesLatitude: 0, degreesLongitude: 0, name: 'Online' },
|
|
502
|
+
call: 'audio',
|
|
503
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
504
|
+
endTime: Math.floor(Date.now() / 1000) + 3600,
|
|
505
|
+
extraGuestsAllowed: true
|
|
506
|
+
}
|
|
507
|
+
})
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
## Order / product (business catalog)
|
|
511
|
+
|
|
512
|
+
```js
|
|
513
|
+
await sock.sendMessage(jid, {
|
|
514
|
+
order: {
|
|
515
|
+
id: 'id-pesanan',
|
|
516
|
+
thumbnail: bufferOrUrl,
|
|
517
|
+
itemCount: '1',
|
|
518
|
+
status: 'INQUIRY',
|
|
519
|
+
surface: 'CATALOG',
|
|
520
|
+
text: 'Buyer note',
|
|
521
|
+
title: 'Order title',
|
|
522
|
+
seller: '628xxx@s.whatsapp.net',
|
|
523
|
+
token: 'token',
|
|
524
|
+
amount: '100000',
|
|
525
|
+
currency: 'IDR'
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
await sock.sendMessage(jid, {
|
|
530
|
+
product: {
|
|
531
|
+
productImage: { url: '...' },
|
|
532
|
+
productId: 'id',
|
|
533
|
+
title: 'Product',
|
|
534
|
+
description: 'Description',
|
|
535
|
+
currencyCode: 'IDR',
|
|
536
|
+
priceAmount1000: '50000',
|
|
537
|
+
retailerId: 'store',
|
|
538
|
+
url: 'https://...',
|
|
539
|
+
productImageCount: 1
|
|
540
|
+
},
|
|
541
|
+
businessOwnerJid: '628xxx@s.whatsapp.net'
|
|
542
|
+
})
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
## Group invite
|
|
546
|
+
|
|
547
|
+
```js
|
|
548
|
+
await sock.sendMessage(jid, {
|
|
549
|
+
groupInvite: {
|
|
550
|
+
jid: '123@g.us',
|
|
551
|
+
subject: 'Group name',
|
|
552
|
+
text: 'Join us',
|
|
553
|
+
inviteCode: 'kode',
|
|
554
|
+
inviteExpiration: 86400,
|
|
555
|
+
jpegThumbnail: optionalBuffer
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Payment invite / request payment
|
|
561
|
+
|
|
562
|
+
```js
|
|
563
|
+
await sock.sendMessage(jid, { paymentInvite: { type: 1, expiry: 0 } })
|
|
564
|
+
|
|
565
|
+
await sock.sendMessage(jid, {
|
|
566
|
+
requestPayment: {
|
|
567
|
+
note: 'Pay',
|
|
568
|
+
currency: 'IDR',
|
|
569
|
+
amount: '50000',
|
|
570
|
+
from: '628xxx@s.whatsapp.net',
|
|
571
|
+
expiry: 0
|
|
572
|
+
}
|
|
573
|
+
})
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
## Pin / keep in chat
|
|
577
|
+
|
|
578
|
+
```js
|
|
579
|
+
await sock.sendMessage(jid, { pin: { type: 1, time: 86400, key: messageKey } })
|
|
580
|
+
await sock.sendMessage(jid, { keep: { key: messageKey, type: 1 } })
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
## Scheduled call (message stub)
|
|
584
|
+
|
|
585
|
+
```js
|
|
586
|
+
await sock.sendMessage(jid, { call: { title: 'Call', type: 1, time: Date.now() } })
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
## Newsletter admin invite
|
|
590
|
+
|
|
591
|
+
```js
|
|
592
|
+
await sock.sendMessage(jid, {
|
|
593
|
+
inviteAdmin: {
|
|
594
|
+
jid: 'xxx@newsletter',
|
|
595
|
+
subject: 'Channel',
|
|
596
|
+
text: 'Become admin',
|
|
597
|
+
inviteExpiration: 86400,
|
|
598
|
+
thumbnail: optionalBuffer
|
|
599
|
+
}
|
|
600
|
+
})
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
## Phone number (protocol)
|
|
604
|
+
|
|
605
|
+
```js
|
|
606
|
+
await sock.sendMessage(jid, { sharePhoneNumber: {} })
|
|
607
|
+
await sock.sendMessage(jid, { requestPhoneNumber: {} })
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
## Button/list reply (as user)
|
|
611
|
+
|
|
612
|
+
```js
|
|
613
|
+
await sock.sendMessage(jid, {
|
|
614
|
+
buttonReply: { displayText: 'Yes', id: 'yes' },
|
|
615
|
+
type: 'plain'
|
|
616
|
+
})
|
|
617
|
+
|
|
618
|
+
await sock.sendMessage(jid, {
|
|
619
|
+
buttonReply: { name: 'Row', description: 'Description', rowId: 'r1' },
|
|
620
|
+
type: 'list'
|
|
621
|
+
})
|
|
622
|
+
|
|
623
|
+
await sock.sendMessage(jid, {
|
|
624
|
+
buttonReply: { displayText: 'Template', id: 'x', index: '0' },
|
|
625
|
+
type: 'template'
|
|
626
|
+
})
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
## AI marker (send option)
|
|
630
|
+
|
|
631
|
+
```js
|
|
632
|
+
await sock.sendMessage(jid, { text: 'Hello' }, { ai: true })
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
---
|
|
636
|
+
|
|
637
|
+
## Notes
|
|
638
|
+
|
|
639
|
+
- Native button names (`name` in `interactiveButtons`) must match what the server expects; the examples above follow common Baileys patterns.
|
|
640
|
+
- Some message types are only stable in private chats or only available for business accounts.
|
|
641
|
+
- For `relayMessage` with an AI flag, use uppercase `AI: true` according to your socket implementation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 yemo-dev / yebails contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|