@itsliaaa/starcore 0.0.0-alpha.0 → 0.0.0-alpha.10
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 +201 -661
- package/README.md +950 -105
- package/lib/Auth.js +1 -1
- package/lib/Client.js +1 -1
- package/lib/Constants.js +1 -1
- package/lib/Database.js +1 -1
- package/lib/Extend.js +19 -0
- package/lib/Media.js +1 -1
- package/lib/Message.js +1 -1
- package/lib/Request.js +1 -1
- package/lib/Scraper.js +1 -1
- package/lib/Serialize.js +1 -1
- package/lib/Socket.js +1 -1
- package/lib/Store.js +1 -1
- package/lib/Utilities.js +1 -1
- package/lib/Watcher.js +19 -0
- package/lib/index.js +1 -1
- package/package.json +21 -9
- package/engine-requirements.js +0 -12
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<img src="https://img.shields.io/github/stars/itsliaaa/starcore?style=for-the-badge&logo=github"/>
|
|
16
16
|
</a>
|
|
17
17
|
<a href="LICENSE">
|
|
18
|
-
<img src="https://img.shields.io/badge/license-
|
|
18
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=for-the-badge"/>
|
|
19
19
|
</a>
|
|
20
20
|
<a href="https://nodejs.org">
|
|
21
21
|
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
|
|
@@ -32,23 +32,116 @@
|
|
|
32
32
|
### 📌 Highlights
|
|
33
33
|
|
|
34
34
|
- Improved `createParticipantNodes()` by introducing yielding, preventing potential freezes during participant node generation.
|
|
35
|
-
- Enhanced `relayMessage()` with newsletter support and compatibility for sending
|
|
36
|
-
- Adapted `prepareWAMessageMedia()` to
|
|
35
|
+
- Enhanced `relayMessage()` with newsletter support and compatibility for sending additional binary payloads.
|
|
36
|
+
- Adapted `prepareWAMessageMedia()` to support media delivery to newsletters.
|
|
37
37
|
- Added support for sending `stickerPackMessage` through `sendStickerPack()`.
|
|
38
|
-
- Extended support for multiple interactive
|
|
39
|
-
- Introduced `newsletterSubscribed()` to
|
|
38
|
+
- Extended support for multiple interactive and button-based message types.
|
|
39
|
+
- Introduced `newsletterSubscribed()` to retrieve information about all newsletters the account is currently subscribed to.
|
|
40
|
+
- `secretEncryptedMessage` is transparently decrypted into `editedMessage`.
|
|
41
|
+
- `vote` in `pollUpdateMessage` is transparently decrypted to reveal the user's selected poll option(s).
|
|
40
42
|
|
|
41
43
|
Built with a focus on simplicity, and better compatibility with modern WhatsApp features.
|
|
42
44
|
|
|
43
|
-
###
|
|
45
|
+
### 📋 Table of Contents
|
|
46
|
+
|
|
47
|
+
- [📌 Highlights](#-highlights)
|
|
48
|
+
- [📥 Installations](#-installations)
|
|
49
|
+
- [📄 Via `package.json`](#-via-packagejson)
|
|
50
|
+
- [⌨️ Via terminal](#%EF%B8%8F-via-terminal)
|
|
51
|
+
- [🧩 Import (ESM & CJS)](#-import-esm--cjs)
|
|
52
|
+
- [📄 Quick Start](#-quick-start)
|
|
53
|
+
- [⚙️ Advanced Usage](#%EF%B8%8F-advanced-usage)
|
|
54
|
+
- [🧳 Environments](#-environments)
|
|
55
|
+
- [🗄️ Managing Store](#%EF%B8%8F-store-data)
|
|
56
|
+
- [🗑️ Temporary Folder](#%EF%B8%8F-temporary-folder)
|
|
57
|
+
- [📡 Events Reference](#-events-reference)
|
|
58
|
+
- [📄 Message Event Metadata](#-message-event-metadata)
|
|
59
|
+
- [👥 Find User ID](#-find-user-id)
|
|
60
|
+
- [📨 Sending Messages](#-sending-messages)
|
|
61
|
+
- [🔠 Text](#-text)
|
|
62
|
+
- [📰 Link Preview](#-link-preview)
|
|
63
|
+
- [😄 Reaction](#-reaction)
|
|
64
|
+
- [📂 Media](#-media)
|
|
65
|
+
- [⚪ PTV](#-ptv)
|
|
66
|
+
- [📃 Sticker](#-sticker)
|
|
67
|
+
- [📦 Sticker Pack](#-sticker-pack)
|
|
68
|
+
- [👤 Contact](#-contact)
|
|
69
|
+
- [🖼️ Album](#%EF%B8%8F-album)
|
|
70
|
+
- [📊 Poll](#-poll)
|
|
71
|
+
- [📈 Poll Result](#-poll-result)
|
|
72
|
+
- [🗄️ Interactive](#%EF%B8%8F-interactive)
|
|
73
|
+
- [🎠 Carousel](#-carousel)
|
|
74
|
+
- [🔘 Legacy Button](#-legacy-button)
|
|
75
|
+
- [📋 Legacy List](#-legacy-list)
|
|
76
|
+
- [✨ Rich](#-rich)
|
|
77
|
+
- [🗒️ Copy & Forward](#%EF%B8%8F-copy--forward)
|
|
78
|
+
- [🎞️ Status Mention](#%EF%B8%8F-status-mention)
|
|
79
|
+
- [👥 Group Status](#-group-status)
|
|
80
|
+
- [♻️ Modify Messages](#%EF%B8%8F-modify-messages)
|
|
81
|
+
- [🗑️ Delete Messages](#%EF%B8%8F-delete-messages)
|
|
82
|
+
- [✏️ Edit Messages](#%EF%B8%8F-edit-messages)
|
|
83
|
+
- [⚙️ Baileys Features](#%EF%B8%8F-baileys-features)
|
|
84
|
+
- [🔑 Request Custom Pairing Code](#-request-custom-pairing-code)
|
|
85
|
+
- [📣 Newsletter Management](#-newsletter-management)
|
|
86
|
+
- [👥 Group Management](#-group-management)
|
|
87
|
+
- [👥 Community Management](#-community-management)
|
|
88
|
+
- [👤 Profile Management](#-profile-management)
|
|
89
|
+
- [🛒 Business Management](#-business-management)
|
|
90
|
+
- [🔐 Privacy Management](#-privacy-management)
|
|
91
|
+
- [📡 Baileys Events Reference](#-baileys-events-reference)
|
|
92
|
+
- [🗳️ Database](#%EF%B8%8F-database)
|
|
93
|
+
- [📎 JSON](#-json)
|
|
94
|
+
- [📎 SQLite](#-sqlite)
|
|
95
|
+
- [🧩 Extend](#-extend)
|
|
96
|
+
- [🌐 Request](#-request)
|
|
97
|
+
- [📚 Exported Modules](#-exported-modules)
|
|
98
|
+
- [🚀 Try the Bot](#-try-the-bot)
|
|
99
|
+
- [📣 Credits](#-credits)
|
|
100
|
+
|
|
101
|
+
### 📥 Installations
|
|
44
102
|
|
|
45
|
-
|
|
103
|
+
> [!IMPORTANT]
|
|
104
|
+
> [`@itsliaaa/starcore`](https://www.npmjs.com/package/@itsliaaa/starcore) does **NOT** install Baileys automatically.
|
|
105
|
+
>
|
|
106
|
+
> You must install a compatible version of Baileys manually before using this package.
|
|
107
|
+
|
|
108
|
+
#### 📄 Via `package.json`
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
# NPM
|
|
112
|
+
"dependencies": {
|
|
113
|
+
"@itsliaaa/starcore": "latest",
|
|
114
|
+
"baileys": "^7.0.0-rc13"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# GitHub
|
|
118
|
+
"dependencies": {
|
|
119
|
+
"@itsliaaa/starcore": "github:itsliaaa/starcore",
|
|
120
|
+
"baileys": "^7.0.0-rc13"
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### ⌨️ Via terminal
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# NPM
|
|
128
|
+
npm i @itsliaaa/starcore@latest baileys@7.0.0-rc13
|
|
129
|
+
|
|
130
|
+
# GitHub
|
|
131
|
+
npm i @itsliaaa/starcore@github:itsliaaa/starcore baileys@7.0.0-rc13
|
|
132
|
+
```
|
|
46
133
|
|
|
47
|
-
|
|
134
|
+
#### 🧩 Import (ESM & CJS)
|
|
48
135
|
|
|
49
|
-
|
|
136
|
+
```javascript
|
|
137
|
+
// --- ESM
|
|
138
|
+
import { Client } from '@itsliaaa/starcore'
|
|
139
|
+
|
|
140
|
+
// --- CJS (tested and working on Node.js 24 ✅)
|
|
141
|
+
const { Client } = require('@itsliaaa/starcore')
|
|
142
|
+
```
|
|
50
143
|
|
|
51
|
-
### 📄
|
|
144
|
+
### 📄 Quick Start
|
|
52
145
|
|
|
53
146
|
```javascript
|
|
54
147
|
import { Client } from '@itsliaaa/starcore'
|
|
@@ -86,22 +179,21 @@ const client = new Client({
|
|
|
86
179
|
name: 'session',
|
|
87
180
|
pairingCode: true,
|
|
88
181
|
phoneNumber: '6281111111111',
|
|
89
|
-
customCode: 'starcore'
|
|
182
|
+
customCode: 'starcore',
|
|
183
|
+
type: 'json' // 'json' | 'sqlite'
|
|
90
184
|
},
|
|
91
185
|
isBotMessageId: (id) =>
|
|
92
186
|
typeof id === 'string' && id.includes('3EB0'),
|
|
93
|
-
messageIdPrefix: '
|
|
94
|
-
|
|
95
|
-
updatePresence: true,
|
|
96
|
-
updateProtoOnStartup: true,
|
|
97
|
-
autoFollowNewsletter: '
|
|
187
|
+
messageIdPrefix: 'STARCORE',
|
|
188
|
+
watchPath: './plugins', // Default: null
|
|
189
|
+
updatePresence: true, // Default: true
|
|
190
|
+
updateProtoOnStartup: true, // Default: false
|
|
191
|
+
autoFollowNewsletter: '1211111111111@newsletter', // String | String[] | false
|
|
98
192
|
newsletterAnnotation: {
|
|
99
|
-
newsletterJid: '',
|
|
100
|
-
newsletterName: ''
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
temporaryFileInterval: 45 * 60 * 1000, // Default: 45 minutes
|
|
104
|
-
gcInterval: 1.5 * 60 * 60 * 1000 // Default: 1.5 hours
|
|
193
|
+
newsletterJid: '1211111111111@newsletter',
|
|
194
|
+
newsletterName: '@itsliaaa/starcore',
|
|
195
|
+
contentType: 1
|
|
196
|
+
} // IForwardedNewsletterMessageInfo | false
|
|
105
197
|
}, {
|
|
106
198
|
// Baileys socket configuration
|
|
107
199
|
shouldIgnoreJid: (jid) =>
|
|
@@ -109,10 +201,67 @@ const client = new Client({
|
|
|
109
201
|
})
|
|
110
202
|
```
|
|
111
203
|
|
|
204
|
+
#### 🧳 Environments
|
|
205
|
+
|
|
206
|
+
The following environment variables are used by default. Override them with [`dotenv`](https://www.npmjs.com/package/dotenv) when needed.
|
|
207
|
+
|
|
208
|
+
```ini
|
|
209
|
+
# .env
|
|
210
|
+
FFMPEG_PATH="ffmpeg"
|
|
211
|
+
TEMPORARY_PATH="temp"
|
|
212
|
+
TZ="Asia/Jakarta"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### 🗄️ Managing Store
|
|
216
|
+
|
|
217
|
+
Manually load and save store data.
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
client.on('ready', ({ store }) => {
|
|
221
|
+
store.readFromFile()
|
|
222
|
+
|
|
223
|
+
setInterval(async () => {
|
|
224
|
+
try {
|
|
225
|
+
await store.writeToFile()
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error('❌ An unexpected error occurred when saving store', ':', error)
|
|
229
|
+
}
|
|
230
|
+
}, 600_000)
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### 🗑️ Temporary Folder
|
|
235
|
+
|
|
236
|
+
Since `0.0.0-alpha.3`, temporary files are no longer cleaned up automatically. Implement your own cleanup routine if required.
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
import { readdir, unlink } from 'fs/promises'
|
|
240
|
+
import { join } from 'path'
|
|
241
|
+
|
|
242
|
+
setInterval(async () => {
|
|
243
|
+
try {
|
|
244
|
+
const temporaryFiles = await readdir(process.env.TEMPORARY_PATH)
|
|
245
|
+
|
|
246
|
+
if (temporaryFiles.length) {
|
|
247
|
+
for (const fileName of temporaryFiles) {
|
|
248
|
+
const filePath = join(process.env.TEMPORARY_PATH, fileName)
|
|
249
|
+
await unlink(filePath)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
console.log('🗑️ Cleaned up temp folder')
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.error('❌ Failed to clean temp folder', ':', error)
|
|
257
|
+
}
|
|
258
|
+
}, 300_000)
|
|
259
|
+
```
|
|
260
|
+
|
|
112
261
|
### 📡 Events Reference
|
|
113
262
|
|
|
114
263
|
```javascript
|
|
115
|
-
client.
|
|
264
|
+
client.on('ready', console.log)
|
|
116
265
|
client.on('message', console.log)
|
|
117
266
|
client.on('message.edit', console.log)
|
|
118
267
|
client.on('message.delete', console.log)
|
|
@@ -122,30 +271,110 @@ client.on('group.add', console.log)
|
|
|
122
271
|
client.on('group.promote', console.log)
|
|
123
272
|
client.on('group.demote', console.log)
|
|
124
273
|
client.on('group.remove', console.log)
|
|
274
|
+
client.on('group.request', console.log)
|
|
125
275
|
client.on('label.update', console.log)
|
|
126
276
|
client.on('caller', console.log)
|
|
127
277
|
client.on('presence', console.log)
|
|
128
278
|
```
|
|
129
279
|
|
|
280
|
+
#### 📄 Message Event Metadata
|
|
281
|
+
|
|
282
|
+
The following example shows the payload received from the `message` event.
|
|
283
|
+
|
|
284
|
+
This event is the primary source of incoming messages and includes commonly used information such as chat ID, sender, message type, quoted message, mentions, and helper methods.
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
{
|
|
288
|
+
m: {
|
|
289
|
+
key: {
|
|
290
|
+
remoteJid: '120111111111111111@g.us',
|
|
291
|
+
remoteJidAlt: undefined,
|
|
292
|
+
remoteJidUsername: undefined,
|
|
293
|
+
fromMe: false,
|
|
294
|
+
id: 'AC1908CA012689BB9F468E6B4478EBAB',
|
|
295
|
+
participant: '1211111111111@lid',
|
|
296
|
+
participantAlt: '6281111111111@s.whatsapp.net',
|
|
297
|
+
participantUsername: undefined,
|
|
298
|
+
addressingMode: 'lid'
|
|
299
|
+
},
|
|
300
|
+
category: undefined,
|
|
301
|
+
messageTimestamp: 1782264500,
|
|
302
|
+
pushName: 'liaaa',
|
|
303
|
+
broadcast: false,
|
|
304
|
+
message: Message {
|
|
305
|
+
extendedTextMessage: [ExtendedTextMessage],
|
|
306
|
+
messageContextInfo: [MessageContextInfo]
|
|
307
|
+
},
|
|
308
|
+
id: 'AC1908CA012689BB9F468E6B4478EBAB',
|
|
309
|
+
chat: '120111111111111111@g.us',
|
|
310
|
+
sender: '6281111111111@s.whatsapp.net',
|
|
311
|
+
senderLid: '1211111111111@lid',
|
|
312
|
+
device: 'android',
|
|
313
|
+
fromMe: false,
|
|
314
|
+
isBot: false,
|
|
315
|
+
isGroup: true,
|
|
316
|
+
type: 'extendedTextMessage',
|
|
317
|
+
msg: ExtendedTextMessage {
|
|
318
|
+
endCardTiles: [],
|
|
319
|
+
text: '@itsliaaa/starcore',
|
|
320
|
+
previewType: 0,
|
|
321
|
+
contextInfo: [ContextInfo],
|
|
322
|
+
inviteLinkGroupTypeV2: 0
|
|
323
|
+
},
|
|
324
|
+
quoted: {
|
|
325
|
+
text: '@itsliaaa/starcore',
|
|
326
|
+
contextInfo: [ContextInfo],
|
|
327
|
+
id: 'AC15B9E93FABF8C9EA230B9093D57OCR',
|
|
328
|
+
chat: '120111111111111111@g.us',
|
|
329
|
+
sender: '6281111111111@s.whatsapp.net',
|
|
330
|
+
senderLid: '1211111111111@lid',
|
|
331
|
+
device: 'android',
|
|
332
|
+
fromMe: false,
|
|
333
|
+
isBot: false,
|
|
334
|
+
isGroup: true,
|
|
335
|
+
type: 'conversation',
|
|
336
|
+
body: '@itsliaaa/starcore',
|
|
337
|
+
pushName: 'liaaa',
|
|
338
|
+
fakeObj: [Object],
|
|
339
|
+
mentionedJid: [],
|
|
340
|
+
expiration: 86400,
|
|
341
|
+
reply: [Function (anonymous)],
|
|
342
|
+
react: [Function (anonymous)]
|
|
343
|
+
},
|
|
344
|
+
body: '@itsliaaa/starcore',
|
|
345
|
+
mentionedJid: [],
|
|
346
|
+
expiration: 86400,
|
|
347
|
+
reply: [Function (anonymous)],
|
|
348
|
+
react: [Function (anonymous)]
|
|
349
|
+
},
|
|
350
|
+
body: '@itsliaaa/starcore',
|
|
351
|
+
prefixes: [ '.', '#', '/', '!' ],
|
|
352
|
+
prefix: '',
|
|
353
|
+
command: '@itsliaaa/starcore',
|
|
354
|
+
args: [],
|
|
355
|
+
text: ''
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
130
359
|
### 👥 Find User ID
|
|
131
360
|
|
|
132
361
|
Quickly resolve a user's `JID` and retrieve both `PN` and `LID` in a synchronous function.
|
|
133
362
|
|
|
134
363
|
```javascript
|
|
135
364
|
// Accepts either @s.whatsapp.net or @lid
|
|
136
|
-
const jidLid = '
|
|
365
|
+
const jidLid = '6281111111111@s.whatsapp.net'
|
|
137
366
|
|
|
138
367
|
const result = sock.findUserId(jidLid)
|
|
139
368
|
|
|
140
369
|
// --- Success
|
|
141
370
|
// {
|
|
142
|
-
// phoneNumber: '
|
|
143
|
-
// lid: '
|
|
371
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
372
|
+
// lid: '1211111111111@lid'
|
|
144
373
|
// }
|
|
145
374
|
|
|
146
375
|
// --- Not found
|
|
147
376
|
// {
|
|
148
|
-
// phoneNumber: '
|
|
377
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
149
378
|
// lid: undefined // or null
|
|
150
379
|
// }
|
|
151
380
|
```
|
|
@@ -155,16 +384,16 @@ const result = sock.findUserId(jidLid)
|
|
|
155
384
|
#### 🔠 Text
|
|
156
385
|
|
|
157
386
|
```javascript
|
|
158
|
-
sock.sendText(jid, '👋🏻 Hello',
|
|
387
|
+
sock.sendText(jid, '👋🏻 Hello', m, {
|
|
159
388
|
mentionAll: false, // Optional
|
|
160
|
-
mentions: ['
|
|
389
|
+
mentions: ['1211111111111@lid', '6281111111111@s.whatsapp.net'], // Optional
|
|
161
390
|
})
|
|
162
391
|
```
|
|
163
392
|
|
|
164
393
|
#### 📰 Link Preview
|
|
165
394
|
|
|
166
395
|
```javascript
|
|
167
|
-
sock.sendAdText(jid, '👆🏻 Check it out!',
|
|
396
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', m, {
|
|
168
397
|
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
169
398
|
title: '🌱 @itsliaaa/starcore',
|
|
170
399
|
description: 'Underrated Baileys Wrapper',
|
|
@@ -173,9 +402,9 @@ sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
|
173
402
|
})
|
|
174
403
|
|
|
175
404
|
// --- Send a text message with a large link preview and favicon
|
|
176
|
-
sock.sendAdText(jid, '👆🏻 Check it out!',
|
|
405
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', m, {
|
|
177
406
|
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
178
|
-
title: '
|
|
407
|
+
title: '✨ @itsliaaa/starcore',
|
|
179
408
|
description: 'Underrated Baileys Wrapper',
|
|
180
409
|
previewType: 0,
|
|
181
410
|
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
@@ -189,13 +418,13 @@ sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
|
189
418
|
#### 😄 Reaction
|
|
190
419
|
|
|
191
420
|
```javascript
|
|
192
|
-
sock.sendReact(jid, '✨',
|
|
421
|
+
sock.sendReact(jid, '✨', m.key)
|
|
193
422
|
```
|
|
194
423
|
|
|
195
424
|
#### 📂 Media
|
|
196
425
|
|
|
197
426
|
```javascript
|
|
198
|
-
sock.sendMedia(jid, bufferOrUrl,
|
|
427
|
+
sock.sendMedia(jid, bufferOrUrl, m, {
|
|
199
428
|
mime: 'image/jpeg', // Optional, will automatically detect the mime
|
|
200
429
|
document: false, // Optional, force send as document
|
|
201
430
|
ptv: false, // Optional, force send as PTV
|
|
@@ -207,13 +436,13 @@ sock.sendMedia(jid, bufferOrUrl, message, {
|
|
|
207
436
|
#### ⚪ PTV
|
|
208
437
|
|
|
209
438
|
```javascript
|
|
210
|
-
sock.sendPtv(jid, bufferOrUrl,
|
|
439
|
+
sock.sendPtv(jid, bufferOrUrl, m)
|
|
211
440
|
```
|
|
212
441
|
|
|
213
442
|
#### 📃 Sticker
|
|
214
443
|
|
|
215
444
|
```javascript
|
|
216
|
-
sock.sendSticker(jid, bufferOrUrl,
|
|
445
|
+
sock.sendSticker(jid, bufferOrUrl, m, {
|
|
217
446
|
packName: '@itsliaaa/starcore',
|
|
218
447
|
packPublisher: 'by Lia Wynn 🌱',
|
|
219
448
|
isAiSticker: true, // Optional
|
|
@@ -243,7 +472,7 @@ sock.sendContact(jid, [{
|
|
|
243
472
|
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
244
473
|
location: 'Jakarta',
|
|
245
474
|
other: '❤️ Simplified WhatsApp API',
|
|
246
|
-
number: '
|
|
475
|
+
number: '6281111111111'
|
|
247
476
|
}, {
|
|
248
477
|
name: '❤️ My Big Brother',
|
|
249
478
|
org: '👥 Siblings',
|
|
@@ -251,8 +480,8 @@ sock.sendContact(jid, [{
|
|
|
251
480
|
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
252
481
|
location: 'Jakarta',
|
|
253
482
|
other: '❤️ Simplified WhatsApp API',
|
|
254
|
-
number: '
|
|
255
|
-
}],
|
|
483
|
+
number: '6281111111111'
|
|
484
|
+
}], m)
|
|
256
485
|
```
|
|
257
486
|
|
|
258
487
|
#### 🖼️ Album
|
|
@@ -264,7 +493,53 @@ sock.sendAlbum(jid, [{
|
|
|
264
493
|
}, {
|
|
265
494
|
media: bufferOrUrl,
|
|
266
495
|
caption: 'Video'
|
|
267
|
-
}],
|
|
496
|
+
}], m)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
#### 📊 Poll
|
|
500
|
+
|
|
501
|
+
```javascript
|
|
502
|
+
// --- Regular poll message
|
|
503
|
+
sock.sendPoll(jid, [
|
|
504
|
+
'✨ Yes', '💀 No'
|
|
505
|
+
], m, {
|
|
506
|
+
name: '🔥 Is it good?',
|
|
507
|
+
selectableCount: 1,
|
|
508
|
+
toAnnouncementGroup: false,
|
|
509
|
+
endDate: Date.now() + 28_800_000, // Optional
|
|
510
|
+
hideVoter: false, // Optional
|
|
511
|
+
canAddOption: false // Optional
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
// --- Quiz (only for newsletter)
|
|
515
|
+
sock.sendQuiz('1211111111111@newsletter', [
|
|
516
|
+
'✨ Yes', '💀 No'
|
|
517
|
+
], m, {
|
|
518
|
+
name: '🔥 Quiz!',
|
|
519
|
+
correctAnswer: '✨ Yes'
|
|
520
|
+
})
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
#### 📈 Poll Result
|
|
524
|
+
|
|
525
|
+
```javascript
|
|
526
|
+
// --- Regular poll result message
|
|
527
|
+
sock.sendPollResult(jid, '📈 Poll Result', [{
|
|
528
|
+
name: '🔥 Fire',
|
|
529
|
+
voteCount: 133
|
|
530
|
+
}, {
|
|
531
|
+
name: '❤️ Love it',
|
|
532
|
+
voteCount: 18
|
|
533
|
+
}], m)
|
|
534
|
+
|
|
535
|
+
// --- Quiz result message
|
|
536
|
+
sock.sendQuizResult(jid, '🏆 Quiz Result', [{
|
|
537
|
+
name: '🔥 Fire',
|
|
538
|
+
voteCount: 133
|
|
539
|
+
}, {
|
|
540
|
+
name: '❤️ Love it',
|
|
541
|
+
voteCount: 18
|
|
542
|
+
}], m)
|
|
268
543
|
```
|
|
269
544
|
|
|
270
545
|
#### 🗄️ Interactive
|
|
@@ -276,14 +551,15 @@ sock.sendInteractive(jid, [{
|
|
|
276
551
|
icon: 'review' // Optional
|
|
277
552
|
}, {
|
|
278
553
|
text: '📞 Call',
|
|
279
|
-
call: '
|
|
554
|
+
call: '6281111111111'
|
|
280
555
|
}, {
|
|
281
556
|
text: '📋 Copy',
|
|
282
557
|
copy: '@itsliaaa/starcore'
|
|
283
558
|
}, {
|
|
284
559
|
text: '🌐 Source',
|
|
285
560
|
url: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
286
|
-
|
|
561
|
+
useWebView: true, // Optional
|
|
562
|
+
webViewPresentation: null // Optional
|
|
287
563
|
}, {
|
|
288
564
|
text: '📋 Select',
|
|
289
565
|
sections: [{
|
|
@@ -305,10 +581,12 @@ sock.sendInteractive(jid, [{
|
|
|
305
581
|
}]
|
|
306
582
|
}],
|
|
307
583
|
icon: 'default' // Optional
|
|
308
|
-
}],
|
|
584
|
+
}], m, {
|
|
309
585
|
media: bufferOrUrl,
|
|
310
586
|
caption: '🗄️ Interactive Message',
|
|
311
587
|
footer: '@itsliaaa/starcore',
|
|
588
|
+
audioFooter: '/path/to/audio.mp3', // Optional
|
|
589
|
+
ptt: false, // Optional, applied when "audioFooter" is set
|
|
312
590
|
optionText: '👉🏻 Select Options', // Optional, wrap all native flow into a single list
|
|
313
591
|
optionTitle: '📄 Select Options', // Optional
|
|
314
592
|
offerText: '🏷️ Newest Coupon!', // Optional, add an offer into message
|
|
@@ -361,7 +639,7 @@ sock.sendCarousel(jid, [{
|
|
|
361
639
|
text: '🌐 Source',
|
|
362
640
|
url: 'https://www.npmjs.com/package/@itsliaaa/starcore'
|
|
363
641
|
}]
|
|
364
|
-
}],
|
|
642
|
+
}], m, {
|
|
365
643
|
text: '🎠 Carousel Message',
|
|
366
644
|
footer: '@itsliaaa/starcore'
|
|
367
645
|
})
|
|
@@ -374,7 +652,7 @@ sock.sendCarousel(jid, [{
|
|
|
374
652
|
sock.sendLegacyButton(jid, [{
|
|
375
653
|
text: '👋🏻 SignUp',
|
|
376
654
|
id: '#SignUp'
|
|
377
|
-
}],
|
|
655
|
+
}], m, {
|
|
378
656
|
text: '👆🏻 Buttons!',
|
|
379
657
|
footer: '@itsliaaa/starcore',
|
|
380
658
|
viewOnce: false // Optional, change to "true" if want proper render on WhatsApp Web
|
|
@@ -404,7 +682,7 @@ sock.sendLegacyButton(jid, [{
|
|
|
404
682
|
id: '#CouponCode'
|
|
405
683
|
}]
|
|
406
684
|
}]
|
|
407
|
-
}],
|
|
685
|
+
}], m, {
|
|
408
686
|
media: bufferOrUrl,
|
|
409
687
|
caption: '👆🏻 Buttons and List!',
|
|
410
688
|
footer: '@itsliaaa/starcore'
|
|
@@ -417,6 +695,7 @@ sock.sendLegacyButton(jid, [{
|
|
|
417
695
|
> This message is only works in private chat (`@s.whatsapp.net`)
|
|
418
696
|
|
|
419
697
|
```javascript
|
|
698
|
+
// --- Regular legacy list message
|
|
420
699
|
sock.sendLegacyList(jid, [{
|
|
421
700
|
title: '🚀 Menu 1',
|
|
422
701
|
rows: [{
|
|
@@ -431,58 +710,36 @@ sock.sendLegacyList(jid, [{
|
|
|
431
710
|
description: '',
|
|
432
711
|
rowId: '#Search'
|
|
433
712
|
}]
|
|
434
|
-
}],
|
|
713
|
+
}], m, {
|
|
435
714
|
text: '📋 List!',
|
|
436
715
|
footer: '@itsliaaa/starcore',
|
|
437
716
|
buttonText: '📋 Select',
|
|
438
717
|
title: '👋🏻 Hello'
|
|
439
718
|
})
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
#### 📊 Poll
|
|
443
|
-
|
|
444
|
-
```javascript
|
|
445
|
-
// --- Regular poll message
|
|
446
|
-
sock.sendPoll(jid, [
|
|
447
|
-
'✨ Yes', '💀 No'
|
|
448
|
-
], message, {
|
|
449
|
-
name: '🔥 Is it good?',
|
|
450
|
-
selectableCount: 1,
|
|
451
|
-
toAnnouncementGroup: false,
|
|
452
|
-
endDate: new Date(Date.now() + 28_800_000), // Optional
|
|
453
|
-
hideVoter: false, // Optional
|
|
454
|
-
canAddOption: false // Optional
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
// --- Quiz (only for newsletter)
|
|
458
|
-
sock.sendQuiz('1211111111111@newsletter', [
|
|
459
|
-
'✨ Yes', '💀 No'
|
|
460
|
-
], message, {
|
|
461
|
-
name: '🔥 Quiz!',
|
|
462
|
-
correctAnswer: '✨ Yes'
|
|
463
|
-
})
|
|
464
|
-
```
|
|
465
719
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
name: '❤️ Love it',
|
|
475
|
-
voteCount: 18
|
|
476
|
-
}], message)
|
|
477
|
-
|
|
478
|
-
// --- Quiz result message
|
|
479
|
-
sock.sendQuizResult(jid, '🏆 Quiz Result', [{
|
|
480
|
-
name: '🔥 Fire',
|
|
481
|
-
voteCount: 133
|
|
720
|
+
// --- Product list message
|
|
721
|
+
client.sendLegacyList(m.chat, [{
|
|
722
|
+
title: '📄 Section #1',
|
|
723
|
+
products: [{
|
|
724
|
+
productId: '177878345044'
|
|
725
|
+
}, {
|
|
726
|
+
productId: '607964531532'
|
|
727
|
+
}]
|
|
482
728
|
}, {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
729
|
+
title: '📋 Section #2',
|
|
730
|
+
products: [{
|
|
731
|
+
productId: '506965808593'
|
|
732
|
+
}, {
|
|
733
|
+
productId: '676909529293'
|
|
734
|
+
}]
|
|
735
|
+
}], m, {
|
|
736
|
+
text: '🛍️ Product List!',
|
|
737
|
+
footer: '@itsliaaa/starcore',
|
|
738
|
+
buttonText: '📋 See Products',
|
|
739
|
+
image: bufferOrUrl,
|
|
740
|
+
headerProductId: '656988410262',
|
|
741
|
+
businessOwnerJid: '0@s.whatsapp.net'
|
|
742
|
+
})
|
|
486
743
|
```
|
|
487
744
|
|
|
488
745
|
#### ✨ Rich
|
|
@@ -624,7 +881,7 @@ sock.sendRich(jid, [{
|
|
|
624
881
|
faviconUrl: 'https://path-to-tiny-image.com/',
|
|
625
882
|
mime: 'image/jpeg' // Optional, the mime type of favicon
|
|
626
883
|
}]
|
|
627
|
-
}],
|
|
884
|
+
}], m, {
|
|
628
885
|
notify: false, // Optional
|
|
629
886
|
disclaimerText: 'Example Usage of sendRich()'
|
|
630
887
|
})
|
|
@@ -633,9 +890,9 @@ sock.sendRich(jid, [{
|
|
|
633
890
|
#### 🗒️ Copy & Forward
|
|
634
891
|
|
|
635
892
|
```javascript
|
|
636
|
-
sock.sendCopyMessage(jid,
|
|
893
|
+
sock.sendCopyMessage(jid, m, {
|
|
637
894
|
forwardingScore: 1, // Optional
|
|
638
|
-
quoted:
|
|
895
|
+
quoted: m // Optional
|
|
639
896
|
})
|
|
640
897
|
```
|
|
641
898
|
|
|
@@ -646,7 +903,10 @@ sock.sendCopyMessage(jid, message, {
|
|
|
646
903
|
|
|
647
904
|
```javascript
|
|
648
905
|
sock.sendStatus([jid], {
|
|
649
|
-
text: '👋🏻 Hello!'
|
|
906
|
+
text: '👋🏻 Hello!',
|
|
907
|
+
font: 0,
|
|
908
|
+
textColor: '#FFFFFF', // Optional
|
|
909
|
+
backgroundColor: '#FF0000' // Optional
|
|
650
910
|
}, {
|
|
651
911
|
mention: false, // Optional
|
|
652
912
|
closeFriends: {
|
|
@@ -663,7 +923,10 @@ sock.sendStatus([jid], {
|
|
|
663
923
|
|
|
664
924
|
```javascript
|
|
665
925
|
sock.sendGroupStatus(jid, {
|
|
666
|
-
text: '👋🏻 Hello!'
|
|
926
|
+
text: '👋🏻 Hello!',
|
|
927
|
+
font: 0,
|
|
928
|
+
textColor: '#FFFFFF', // Optional
|
|
929
|
+
backgroundColor: '#000000' // Optional
|
|
667
930
|
}, {
|
|
668
931
|
closeFriends: {
|
|
669
932
|
name: '@itsliaaa/starcore',
|
|
@@ -672,24 +935,604 @@ sock.sendGroupStatus(jid, {
|
|
|
672
935
|
})
|
|
673
936
|
```
|
|
674
937
|
|
|
938
|
+
### ♻️ Modify Messages
|
|
939
|
+
|
|
940
|
+
#### 🗑️ Delete Messages
|
|
941
|
+
|
|
942
|
+
```javascript
|
|
943
|
+
sock.sendMessage(jid, {
|
|
944
|
+
delete: m.key
|
|
945
|
+
})
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
#### ✏️ Edit Messages
|
|
949
|
+
|
|
950
|
+
```javascript
|
|
951
|
+
// --- Edit plain text
|
|
952
|
+
sock.sendMessage(jid, {
|
|
953
|
+
text: '✨ I mean, nice!',
|
|
954
|
+
edit: m.key
|
|
955
|
+
})
|
|
956
|
+
|
|
957
|
+
// --- Edit media messages caption
|
|
958
|
+
sock.sendMessage(jid, {
|
|
959
|
+
caption: '✨ I mean, here is the image!',
|
|
960
|
+
edit: m.key
|
|
961
|
+
})
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
### ⚙️ Baileys Features
|
|
965
|
+
|
|
966
|
+
#### 🔑 Request Custom Pairing Code
|
|
967
|
+
|
|
968
|
+
> [!NOTE]
|
|
969
|
+
> The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
970
|
+
|
|
971
|
+
```javascript
|
|
972
|
+
const phoneNumber = '6281111111111'
|
|
973
|
+
const customPairingCode = 'STARCORE'
|
|
974
|
+
|
|
975
|
+
await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
976
|
+
|
|
977
|
+
console.log('🔗 Pairing code', ':', customPairingCode)
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
#### 📣 Newsletter Management
|
|
981
|
+
|
|
982
|
+
```javascript
|
|
983
|
+
// --- Create a new one
|
|
984
|
+
sock.newsletterCreate('@itsliaaa/starcore', '📣 Fresh updates weekly')
|
|
985
|
+
|
|
986
|
+
// --- Get info
|
|
987
|
+
const metadata = sock.newsletterMetadata('1211111111111@newsletter')
|
|
988
|
+
console.dir(metadata, { depth: null })
|
|
989
|
+
|
|
990
|
+
// --- Get subscribers count
|
|
991
|
+
const subscribers = await sock.newsletterSubscribers('1211111111111@newsletter')
|
|
992
|
+
console.dir(subscribers, { depth: null })
|
|
993
|
+
|
|
994
|
+
// --- Follow and Unfollow
|
|
995
|
+
sock.newsletterFollow('1211111111111@newsletter')
|
|
996
|
+
sock.newsletterUnfollow('1211111111111@newsletter')
|
|
997
|
+
|
|
998
|
+
// --- Mute and Unmute
|
|
999
|
+
sock.newsletterMute('1211111111111@newsletter')
|
|
1000
|
+
sock.newsletterUnmute('1211111111111@newsletter')
|
|
1001
|
+
|
|
1002
|
+
// --- Demote admin
|
|
1003
|
+
sock.newsletterDemote('1211111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1004
|
+
|
|
1005
|
+
// --- Change owner
|
|
1006
|
+
sock.newsletterChangeOwner('1211111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1007
|
+
|
|
1008
|
+
// --- Update newsletter
|
|
1009
|
+
sock.newsletterUpdate('1211111111111@newsletter', { name: '@itsliaaa/starcore' })
|
|
1010
|
+
|
|
1011
|
+
// --- Change name
|
|
1012
|
+
sock.newsletterUpdateName('1211111111111@newsletter', '✨ @itsliaaa/starcore')
|
|
1013
|
+
|
|
1014
|
+
// --- Change description
|
|
1015
|
+
sock.newsletterUpdateDescription('1211111111111@newsletter', '📣 Fresh updates weekly')
|
|
1016
|
+
|
|
1017
|
+
// --- Change photo
|
|
1018
|
+
sock.newsletterUpdatePicture('1211111111111@newsletter', {
|
|
1019
|
+
url: 'path/to/image.jpg'
|
|
1020
|
+
})
|
|
1021
|
+
|
|
1022
|
+
// --- Remove photo
|
|
1023
|
+
sock.newsletterRemovePicture('1211111111111@newsletter')
|
|
1024
|
+
|
|
1025
|
+
// --- React to a message
|
|
1026
|
+
sock.newsletterReactMessage('1211111111111@newsletter', '100', '💛')
|
|
1027
|
+
|
|
1028
|
+
// --- Get admin count
|
|
1029
|
+
const count = await sock.newsletterAdminCount('1211111111111@newsletter')
|
|
1030
|
+
|
|
1031
|
+
// --- Get all subscribed newsletters
|
|
1032
|
+
const newsletters = await sock.newsletterSubscribed()
|
|
1033
|
+
console.dir(newsletters, { depth: null })
|
|
1034
|
+
|
|
1035
|
+
// --- Fetch newsletter messages
|
|
1036
|
+
const messages = sock.newsletterFetchMessages('jid', '1211111111111@newsletter', 50, 0, 0)
|
|
1037
|
+
console.dir(messages, { depth: null })
|
|
1038
|
+
|
|
1039
|
+
// --- Delete newsletter
|
|
1040
|
+
sock.newsletterDelete('1211111111111@newsletter')
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
#### 👥 Group Management
|
|
1044
|
+
|
|
1045
|
+
```javascript
|
|
1046
|
+
// --- Create a new one and add participants using their JIDs
|
|
1047
|
+
const group = sock.groupCreate('@itsliaaa/starcore', ['6281111111111@s.whatsapp.net'])
|
|
1048
|
+
console.dir(group, { depth: null })
|
|
1049
|
+
|
|
1050
|
+
// --- Get info
|
|
1051
|
+
const metadata = await sock.groupMetadata(jid)
|
|
1052
|
+
console.dir(metadata, { depth: null })
|
|
1053
|
+
|
|
1054
|
+
// --- Get group invite code
|
|
1055
|
+
const inviteCode = await sock.groupInviteCode(jid)
|
|
1056
|
+
console.dir(inviteCode, { depth: null })
|
|
1057
|
+
|
|
1058
|
+
// --- Revoke invite link
|
|
1059
|
+
sock.groupRevokeInvite(jid)
|
|
1060
|
+
|
|
1061
|
+
// --- Accept group invite
|
|
1062
|
+
sock.groupAcceptInvite(inviteCode)
|
|
1063
|
+
|
|
1064
|
+
// --- Leave group
|
|
1065
|
+
sock.groupLeave(jid)
|
|
1066
|
+
|
|
1067
|
+
// --- Add participants
|
|
1068
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'add')
|
|
1069
|
+
|
|
1070
|
+
// --- Remove participants
|
|
1071
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'remove')
|
|
1072
|
+
|
|
1073
|
+
// --- Promote to admin
|
|
1074
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'promote')
|
|
1075
|
+
|
|
1076
|
+
// --- Demote from admin
|
|
1077
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'demote')
|
|
1078
|
+
|
|
1079
|
+
// --- Accept join requests
|
|
1080
|
+
sock.groupRequestParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'approve')
|
|
1081
|
+
|
|
1082
|
+
// --- Change name
|
|
1083
|
+
sock.groupUpdateSubject(jid, '✨ @itsliaaa/starcore')
|
|
1084
|
+
|
|
1085
|
+
// --- Change description
|
|
1086
|
+
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1087
|
+
|
|
1088
|
+
// --- Change photo
|
|
1089
|
+
sock.updateProfilePicture(jid, {
|
|
1090
|
+
url: 'path/to/image.jpg'
|
|
1091
|
+
})
|
|
1092
|
+
|
|
1093
|
+
// --- Remove photo
|
|
1094
|
+
sock.removeProfilePicture(jid)
|
|
1095
|
+
|
|
1096
|
+
// --- Set group as admin only for chatting
|
|
1097
|
+
sock.groupSettingUpdate(jid, 'announcement')
|
|
1098
|
+
|
|
1099
|
+
// --- Set group as open to all for chatting
|
|
1100
|
+
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
1101
|
+
|
|
1102
|
+
// --- Set admin only can edit group info
|
|
1103
|
+
sock.groupSettingUpdate(jid, 'locked')
|
|
1104
|
+
|
|
1105
|
+
// --- Set all participants can edit group info
|
|
1106
|
+
sock.groupSettingUpdate(jid, 'unlocked')
|
|
1107
|
+
|
|
1108
|
+
// --- Set admin only can add participants
|
|
1109
|
+
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1110
|
+
|
|
1111
|
+
// --- Set all participants can add participants
|
|
1112
|
+
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1113
|
+
|
|
1114
|
+
// --- Enable or disable temporary messages with seconds format
|
|
1115
|
+
sock.groupToggleEphemeral(jid, 86400)
|
|
1116
|
+
|
|
1117
|
+
// --- Disable temporary messages
|
|
1118
|
+
sock.groupToggleEphemeral(jid, 0)
|
|
1119
|
+
|
|
1120
|
+
// --- Enable or disable membership approval mode
|
|
1121
|
+
sock.groupJoinApprovalMode(jid, 'on')
|
|
1122
|
+
sock.groupJoinApprovalMode(jid, 'off')
|
|
1123
|
+
|
|
1124
|
+
// --- Get all groups metadata
|
|
1125
|
+
const groups = await sock.groupFetchAllParticipating()
|
|
1126
|
+
console.dir(groups, { depth: null })
|
|
1127
|
+
|
|
1128
|
+
// --- Get pending join requests
|
|
1129
|
+
const requests = await sock.groupRequestParticipantsList(jid)
|
|
1130
|
+
console.dir(requests, { depth: null })
|
|
1131
|
+
|
|
1132
|
+
// --- Get group info from link
|
|
1133
|
+
const group = await sock.groupGetInviteInfo('ABC123456789')
|
|
1134
|
+
console.log('👥 Got group info from invite code', ':', group)
|
|
1135
|
+
|
|
1136
|
+
// --- Update bot member label
|
|
1137
|
+
sock.updateMemberLabel(jid, '@itsliaaa/starcore')
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
#### 👥 Community Management
|
|
1141
|
+
|
|
1142
|
+
```javascript
|
|
1143
|
+
// --- Create a new one and add description
|
|
1144
|
+
const community = await sock.communityCreate('@itsliaaa/starcore', '📣 Fresh updates weekly')
|
|
1145
|
+
console.dir(community, { depth: null })
|
|
1146
|
+
|
|
1147
|
+
// --- Create a subgroup for community and add participants using their JIDs
|
|
1148
|
+
const group = await sock.communityCreateGroup('📢 Announcements', ['6281111111111@s.whatsapp.net'], communityJid)
|
|
1149
|
+
|
|
1150
|
+
// --- Link an existing group
|
|
1151
|
+
sock.communityLinkGroup(groupJid, communityJid)
|
|
1152
|
+
|
|
1153
|
+
// --- Unlink an existing group
|
|
1154
|
+
sock.communityUnlinkGroup(groupJid, communityJid)
|
|
1155
|
+
|
|
1156
|
+
// --- Get info
|
|
1157
|
+
const metadata = await sock.communityMetadata(jid)
|
|
1158
|
+
console.dir(metadata, { depth: null })
|
|
1159
|
+
|
|
1160
|
+
// --- Get community invite code
|
|
1161
|
+
const inviteCode = await sock.communityInviteCode(jid)
|
|
1162
|
+
console.dir(inviteCode, { depth: null })
|
|
1163
|
+
|
|
1164
|
+
// --- Revoke invite link
|
|
1165
|
+
sock.communityRevokeInvite(jid)
|
|
1166
|
+
|
|
1167
|
+
// --- Accept community invite
|
|
1168
|
+
sock.communityAcceptInvite(inviteCode)
|
|
1169
|
+
|
|
1170
|
+
// --- Leave community
|
|
1171
|
+
sock.communityLeave(jid)
|
|
1172
|
+
|
|
1173
|
+
// --- Accept join requests
|
|
1174
|
+
sock.communityRequestParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'approve')
|
|
1175
|
+
|
|
1176
|
+
// --- Change name
|
|
1177
|
+
sock.communityUpdateSubject(jid, '✨ @itsliaaa/starcore')
|
|
1178
|
+
|
|
1179
|
+
// --- Change description
|
|
1180
|
+
sock.communityUpdateDescription(jid, 'Updated description')
|
|
1181
|
+
|
|
1182
|
+
// --- Set community as admin only for chatting
|
|
1183
|
+
sock.communitySettingUpdate(jid, 'announcement')
|
|
1184
|
+
|
|
1185
|
+
// --- Set community as open to all for chatting
|
|
1186
|
+
sock.communitySettingUpdate(jid, 'not_announcement')
|
|
1187
|
+
|
|
1188
|
+
// --- Set admin only can edit community info
|
|
1189
|
+
sock.communitySettingUpdate(jid, 'locked')
|
|
1190
|
+
|
|
1191
|
+
// --- Set all participants can edit community info
|
|
1192
|
+
sock.communitySettingUpdate(jid, 'unlocked')
|
|
1193
|
+
|
|
1194
|
+
// --- Set admin only can add participants
|
|
1195
|
+
sock.communityMemberAddMode(jid, 'admin_add')
|
|
1196
|
+
|
|
1197
|
+
// --- Set all participants can add participants
|
|
1198
|
+
sock.communityMemberAddMode(jid, 'all_member_add')
|
|
1199
|
+
|
|
1200
|
+
// --- Enable or disable temporary messages with seconds format
|
|
1201
|
+
sock.communityToggleEphemeral(jid, 86400)
|
|
1202
|
+
|
|
1203
|
+
// --- Disable temporary messages
|
|
1204
|
+
sock.communityToggleEphemeral(jid, 0)
|
|
1205
|
+
|
|
1206
|
+
// --- Enable or disable membership approval mode
|
|
1207
|
+
sock.communityJoinApprovalMode(jid, 'on')
|
|
1208
|
+
sock.communityJoinApprovalMode(jid, 'off')
|
|
1209
|
+
|
|
1210
|
+
// --- Get all communities metadata
|
|
1211
|
+
const communities = await sock.communityFetchAllParticipating()
|
|
1212
|
+
console.dir(communities, { depth: null })
|
|
1213
|
+
|
|
1214
|
+
// --- Get all community linked groups
|
|
1215
|
+
const linked = await sock.communityFetchLinkedGroups(jid)
|
|
1216
|
+
console.dir(linked, { depth: null })
|
|
1217
|
+
|
|
1218
|
+
// --- Get pending join requests
|
|
1219
|
+
const requests = await sock.communityRequestParticipantsList(jid)
|
|
1220
|
+
console.dir(requests, { depth: null })
|
|
1221
|
+
|
|
1222
|
+
// --- Get community info from link
|
|
1223
|
+
const community = await sock.communityGetInviteInfo('ABC123456789')
|
|
1224
|
+
console.log('👥 Got community info from invite code', ':', community)
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
#### 👤 Profile Management
|
|
1228
|
+
|
|
1229
|
+
```javascript
|
|
1230
|
+
// --- Get user profile picture
|
|
1231
|
+
const url = await sock.profilePictureUrl(jid, 'image')
|
|
1232
|
+
console.log('🖼️ Got user profile url', url)
|
|
1233
|
+
|
|
1234
|
+
// --- Update profile picture
|
|
1235
|
+
sock.updateProfilePicture(jid, buffer)
|
|
1236
|
+
sock.updateProfilePicture(jid, { url })
|
|
1237
|
+
|
|
1238
|
+
// --- Remove profile picture
|
|
1239
|
+
sock.removeProfilePicture(jid)
|
|
1240
|
+
|
|
1241
|
+
// --- Update profile name
|
|
1242
|
+
sock.updateProfileName('My Name')
|
|
1243
|
+
|
|
1244
|
+
// --- Update profile status
|
|
1245
|
+
sock.updateProfileStatus('Available')
|
|
1246
|
+
|
|
1247
|
+
// --- Presence
|
|
1248
|
+
sock.sendPresenceUpdate('available', jid)
|
|
1249
|
+
sock.presenceSubscribe(jid)
|
|
1250
|
+
|
|
1251
|
+
// --- Read receipts
|
|
1252
|
+
sock.readMessages([m.key])
|
|
1253
|
+
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1254
|
+
|
|
1255
|
+
// --- Block user
|
|
1256
|
+
sock.updateBlockStatus(jid, 'block')
|
|
1257
|
+
|
|
1258
|
+
// --- Unblock user
|
|
1259
|
+
sock.updateBlockStatus(jid, 'unblock')
|
|
1260
|
+
|
|
1261
|
+
// --- Fetch blocklist
|
|
1262
|
+
const blocked = await sock.fetchBlocklist()
|
|
1263
|
+
console.dir(blocked, { depth: null })
|
|
1264
|
+
|
|
1265
|
+
// --- Modify chats
|
|
1266
|
+
sock.chatModify({
|
|
1267
|
+
archive: true,
|
|
1268
|
+
lastMessageOrig: m,
|
|
1269
|
+
lastMessage: m
|
|
1270
|
+
}, jid)
|
|
1271
|
+
|
|
1272
|
+
// --- Star messages
|
|
1273
|
+
sock.star(jid, [{ id: messageId, fromMe: true }], true)
|
|
1274
|
+
|
|
1275
|
+
// --- Contact
|
|
1276
|
+
sock.addOrEditContact(jid, { displayName: 'Starseed' })
|
|
1277
|
+
sock.removeContact(jid)
|
|
1278
|
+
|
|
1279
|
+
// --- Label
|
|
1280
|
+
sock.addChatLabel(jid, labelId)
|
|
1281
|
+
sock.removeChatLabel(jid, labelId)
|
|
1282
|
+
sock.addMessageLabel(jid, messageId, labelId)
|
|
1283
|
+
|
|
1284
|
+
// --- Favorites
|
|
1285
|
+
sock.keepFavorites([
|
|
1286
|
+
'6281111111111@s.whatsapp.net',
|
|
1287
|
+
'1211111111111@g.us'
|
|
1288
|
+
])
|
|
1289
|
+
sock.keepFavorites([
|
|
1290
|
+
'6281111111111@s.whatsapp.net' // Only this one remains
|
|
1291
|
+
])
|
|
1292
|
+
|
|
1293
|
+
// --- App state sync
|
|
1294
|
+
sock.resyncAppState(['regular', 'critical_block'], true)
|
|
1295
|
+
|
|
1296
|
+
// --- Get business profile
|
|
1297
|
+
const profile = await sock.getBusinessProfile(jid)
|
|
1298
|
+
console.dir(profile, { depth: null })
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
#### 🛒 Business Management
|
|
1302
|
+
|
|
1303
|
+
```javascript
|
|
1304
|
+
// --- Create a new product
|
|
1305
|
+
const product = await sock.productCreate({
|
|
1306
|
+
name: '🧩 Starseed (Premium)',
|
|
1307
|
+
description: 'Get a full version of Starseed!',
|
|
1308
|
+
price: 100000,
|
|
1309
|
+
currency: 'IDR',
|
|
1310
|
+
originCountryCode: 'ID',
|
|
1311
|
+
images: [
|
|
1312
|
+
bufferImage,
|
|
1313
|
+
{
|
|
1314
|
+
url: './path/to/image.jpg'
|
|
1315
|
+
}
|
|
1316
|
+
]
|
|
1317
|
+
})
|
|
1318
|
+
console.dir(product, { depth: null })
|
|
1319
|
+
|
|
1320
|
+
// --- Update product
|
|
1321
|
+
await sock.productUpdate(productId, {
|
|
1322
|
+
name: '🧩 Starseed (Premium)',
|
|
1323
|
+
description: 'Get a full version of Starseed with more features!',
|
|
1324
|
+
price: 75000,
|
|
1325
|
+
currency: 'IDR',
|
|
1326
|
+
images: [
|
|
1327
|
+
{
|
|
1328
|
+
url: './path/to/image.jpg'
|
|
1329
|
+
}
|
|
1330
|
+
]
|
|
1331
|
+
})
|
|
1332
|
+
|
|
1333
|
+
// --- Delete product
|
|
1334
|
+
sock.productDelete([productId])
|
|
1335
|
+
|
|
1336
|
+
// --- Get catalog info
|
|
1337
|
+
const { products, nextPageCursor } = await sock.getCatalog({
|
|
1338
|
+
jid: '6281111111111@s.whatsapp.net',
|
|
1339
|
+
limit: 10
|
|
1340
|
+
})
|
|
1341
|
+
|
|
1342
|
+
// --- Get collections
|
|
1343
|
+
const collections = await sock.getCollections('6281111111111@s.whatsapp.net', 10)
|
|
1344
|
+
console.dir(collections, { depth: null })
|
|
1345
|
+
|
|
1346
|
+
// --- Get order info
|
|
1347
|
+
const order = await sock.getOrderDetails(orderId, tokenBase64)
|
|
1348
|
+
console.dir(order, { depth: null })
|
|
1349
|
+
|
|
1350
|
+
// --- Update business profile
|
|
1351
|
+
await sock.updateBusinessProfile({
|
|
1352
|
+
address: 'Jakarta, Indonesia',
|
|
1353
|
+
description: '🛒 Official Starseed Store',
|
|
1354
|
+
websites: ['https://www.npmjs.com/package/@itsliaaa/starcore'],
|
|
1355
|
+
email: 'more-more@gmail.com',
|
|
1356
|
+
hours: {
|
|
1357
|
+
timezone: 'Asia/Jakarta',
|
|
1358
|
+
days: [{ day: 'mon', mode: 'open_24h' }]
|
|
1359
|
+
}
|
|
1360
|
+
})
|
|
1361
|
+
|
|
1362
|
+
// --- Update cover
|
|
1363
|
+
sock.updateCoverPhoto({
|
|
1364
|
+
url: './path/to/image.jpg'
|
|
1365
|
+
})
|
|
1366
|
+
|
|
1367
|
+
// --- Remove cover
|
|
1368
|
+
sock.removeCoverPhoto(coverId)
|
|
1369
|
+
|
|
1370
|
+
// --- Update quick replies
|
|
1371
|
+
sock.addOrEditQuickReply({
|
|
1372
|
+
shortcut: 'hello',
|
|
1373
|
+
message: 'Hello from business account',
|
|
1374
|
+
})
|
|
1375
|
+
|
|
1376
|
+
// --- Remove quick reply
|
|
1377
|
+
sock.removeQuickReply(timestamp)
|
|
1378
|
+
```
|
|
1379
|
+
|
|
1380
|
+
#### 🔐 Privacy Management
|
|
1381
|
+
|
|
1382
|
+
```javascript
|
|
1383
|
+
// --- Update last seen privacy
|
|
1384
|
+
sock.updateLastSeenPrivacy('all')
|
|
1385
|
+
sock.updateLastSeenPrivacy('contacts')
|
|
1386
|
+
sock.updateLastSeenPrivacy('contact_blacklist')
|
|
1387
|
+
sock.updateLastSeenPrivacy('nobody')
|
|
1388
|
+
|
|
1389
|
+
// --- Update online privacy
|
|
1390
|
+
sock.updateOnlinePrivacy('all')
|
|
1391
|
+
sock.updateOnlinePrivacy('match_last_seen')
|
|
1392
|
+
|
|
1393
|
+
// --- Update profile picture privacy
|
|
1394
|
+
sock.updateProfilePicturePrivacy('contacts')
|
|
1395
|
+
|
|
1396
|
+
// --- Update status privacy
|
|
1397
|
+
sock.updateStatusPrivacy('contacts')
|
|
1398
|
+
|
|
1399
|
+
// --- Update read receipts privacy
|
|
1400
|
+
sock.updateReadReceiptsPrivacy('all')
|
|
1401
|
+
sock.updateReadReceiptsPrivacy('none')
|
|
1402
|
+
|
|
1403
|
+
// --- Update groups add privacy
|
|
1404
|
+
sock.updateGroupsAddPrivacy('all')
|
|
1405
|
+
sock.updateGroupsAddPrivacy('contacts')
|
|
1406
|
+
|
|
1407
|
+
// --- Update messages privacy
|
|
1408
|
+
sock.updateMessagesPrivacy('all')
|
|
1409
|
+
sock.updateMessagesPrivacy('contacts')
|
|
1410
|
+
sock.updateMessagesPrivacy('nobody')
|
|
1411
|
+
|
|
1412
|
+
// --- Update call privacy
|
|
1413
|
+
sock.updateCallPrivacy('everyone')
|
|
1414
|
+
|
|
1415
|
+
// --- Update default disappearing mode
|
|
1416
|
+
sock.updateDefaultDisappearingMode(86400)
|
|
1417
|
+
|
|
1418
|
+
// --- Update link previews privacy
|
|
1419
|
+
sock.updateDisableLinkPreviewsPrivacy(true)
|
|
1420
|
+
```
|
|
1421
|
+
|
|
1422
|
+
#### 📡 Baileys Events Reference
|
|
1423
|
+
|
|
1424
|
+
```javascript
|
|
1425
|
+
sock.ev.on('connection.update', console.log)
|
|
1426
|
+
sock.ev.on('creds.update', console.log)
|
|
1427
|
+
sock.ev.on('messaging-history.set', console.log)
|
|
1428
|
+
sock.ev.on('messaging-history.status', console.log)
|
|
1429
|
+
sock.ev.on('chats.upsert', console.log)
|
|
1430
|
+
sock.ev.on('chats.update', console.log)
|
|
1431
|
+
sock.ev.on('chats.delete', console.log)
|
|
1432
|
+
sock.ev.on('chats.lock', console.log)
|
|
1433
|
+
sock.ev.on('lid-mapping.update', console.log)
|
|
1434
|
+
sock.ev.on('presence.update', console.log)
|
|
1435
|
+
sock.ev.on('contacts.upsert', console.log)
|
|
1436
|
+
sock.ev.on('contacts.update', console.log)
|
|
1437
|
+
sock.ev.on('messages.delete', console.log)
|
|
1438
|
+
sock.ev.on('messages.update', console.log)
|
|
1439
|
+
sock.ev.on('messages.media-update', console.log)
|
|
1440
|
+
sock.ev.on('messages.upsert', console.log)
|
|
1441
|
+
sock.ev.on('messages.reaction', console.log)
|
|
1442
|
+
sock.ev.on('message-receipt.update', console.log)
|
|
1443
|
+
sock.ev.on('groups.upsert', console.log)
|
|
1444
|
+
sock.ev.on('groups.update', console.log)
|
|
1445
|
+
sock.ev.on('group-participants.update', console.log)
|
|
1446
|
+
sock.ev.on('group.join-request', console.log)
|
|
1447
|
+
sock.ev.on('group.member-tag.update', console.log)
|
|
1448
|
+
sock.ev.on('blocklist.set', console.log)
|
|
1449
|
+
sock.ev.on('blocklist.update', console.log)
|
|
1450
|
+
sock.ev.on('call', console.log)
|
|
1451
|
+
sock.ev.on('labels.edit', console.log)
|
|
1452
|
+
sock.ev.on('labels.association', console.log)
|
|
1453
|
+
sock.ev.on('newsletter.reaction', console.log)
|
|
1454
|
+
sock.ev.on('newsletter.view', console.log)
|
|
1455
|
+
sock.ev.on('newsletter-participants.update', console.log)
|
|
1456
|
+
sock.ev.on('newsletter-settings.update', console.log)
|
|
1457
|
+
sock.ev.on('settings.update', console.log)
|
|
1458
|
+
```
|
|
1459
|
+
|
|
675
1460
|
### 🗳️ Database
|
|
676
1461
|
|
|
677
|
-
|
|
678
|
-
|
|
1462
|
+
Including two built-in database backends to fit different use cases:
|
|
1463
|
+
|
|
1464
|
+
- **JSON**: A lightweight solution for small projects and straightforward data storage.
|
|
1465
|
+
- **SQLite**: Powered by `better-sqlite3`, delivering high performance, low overhead, and a hassle-free experience.
|
|
1466
|
+
|
|
1467
|
+
#### 📎 JSON
|
|
679
1468
|
|
|
680
1469
|
```javascript
|
|
681
1470
|
import { Database } from '@itsliaaa/starcore'
|
|
682
1471
|
|
|
683
|
-
const db = Database.
|
|
684
|
-
|
|
1472
|
+
const db = await Database.json('database.json')
|
|
1473
|
+
|
|
1474
|
+
const data = await db.read()
|
|
1475
|
+
|
|
685
1476
|
await db.write({
|
|
686
1477
|
users: {},
|
|
687
1478
|
groups: {},
|
|
688
|
-
contacts: {},
|
|
689
1479
|
settings: {}
|
|
690
|
-
})
|
|
1480
|
+
})
|
|
691
1481
|
```
|
|
692
1482
|
|
|
1483
|
+
#### 📎 SQLite
|
|
1484
|
+
|
|
1485
|
+
> [!IMPORTANT]
|
|
1486
|
+
> [`better-sqlite3@>=12.2.0`](https://www.npmjs.com/package/better-sqlite3) is a peer dependency. You must install it manually and add it to your project's `package.json`.
|
|
1487
|
+
|
|
1488
|
+
```javascript
|
|
1489
|
+
import { Database } from '@itsliaaa/starcore'
|
|
1490
|
+
|
|
1491
|
+
const db = await Database.sqlite('database.db')
|
|
1492
|
+
|
|
1493
|
+
const data = db.read()
|
|
1494
|
+
|
|
1495
|
+
db.write({
|
|
1496
|
+
users: {},
|
|
1497
|
+
groups: {},
|
|
1498
|
+
settings: {}
|
|
1499
|
+
})
|
|
1500
|
+
|
|
1501
|
+
db.close()
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
### 🧩 Extend
|
|
1505
|
+
|
|
1506
|
+
If you prefer not to use the `Client` wrapper but still want the additional features provided by this package, you can use `Extend`.
|
|
1507
|
+
|
|
1508
|
+
> [!TIP]
|
|
1509
|
+
> `sock` is used as the Baileys socket instance throughout this example. If your project uses a different variable name (e.g. `conn` or `client`), replace `sock` with your own variable name.
|
|
1510
|
+
|
|
1511
|
+
> [!CAUTION]
|
|
1512
|
+
> Your Baileys instance must be extensible and writable, as `Extend` attaches additional methods to the instance.
|
|
1513
|
+
|
|
1514
|
+
```javascript
|
|
1515
|
+
import { Extend } from '@itsliaaa/starcore'
|
|
1516
|
+
import { makeWASocket } from 'baileys'
|
|
1517
|
+
|
|
1518
|
+
const sock = makeWASocket({ ... })
|
|
1519
|
+
|
|
1520
|
+
await Extend(sock, {
|
|
1521
|
+
messageIdPrefix: 'STARCORE',
|
|
1522
|
+
updatePresence: true, // Default: true
|
|
1523
|
+
autoFollowNewsletter: '1211111111111@newsletter', // String | String[] | false
|
|
1524
|
+
newsletterAnnotation: {
|
|
1525
|
+
newsletterJid: '1211111111111@newsletter',
|
|
1526
|
+
newsletterName: '@itsliaaa/starcore',
|
|
1527
|
+
contentType: 1
|
|
1528
|
+
} // IForwardedNewsletterMessageInfo | false
|
|
1529
|
+
})
|
|
1530
|
+
|
|
1531
|
+
// sock.sendText(jid, 'Hello there', message)
|
|
1532
|
+
```
|
|
1533
|
+
|
|
1534
|
+
Besides extending your socket with additional helper methods, `Extend` also provides built-in decryption for `secretEncryptedMessage` to obtain `editedMessage` and automatically decrypts the `vote` payload contained in `pollUpdateMessage`.
|
|
1535
|
+
|
|
693
1536
|
### 🌐 Request
|
|
694
1537
|
|
|
695
1538
|
> [!NOTE]
|
|
@@ -734,17 +1577,19 @@ const postResult = await someApi('path/to/post', null, {
|
|
|
734
1577
|
|
|
735
1578
|
```javascript
|
|
736
1579
|
import {
|
|
737
|
-
Database,
|
|
738
1580
|
Client,
|
|
1581
|
+
Database,
|
|
1582
|
+
Extend,
|
|
739
1583
|
Request,
|
|
740
1584
|
Scraper,
|
|
741
|
-
Utilities
|
|
1585
|
+
Utilities,
|
|
1586
|
+
Watcher
|
|
742
1587
|
} from '@itsliaaa/starcore'
|
|
743
1588
|
```
|
|
744
1589
|
|
|
745
1590
|
### 🚀 Try the Bot
|
|
746
1591
|
|
|
747
|
-
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/
|
|
1592
|
+
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys).
|
|
748
1593
|
Perfect for managing groups, moderating chats, and adding fun with quiz games and handy tools.
|
|
749
1594
|
|
|
750
1595
|
👉🏻 [@itsliaaa/starseed](https://github.com/itsliaaa/starseed#readme)
|