@itsliaaa/starcore 0.0.0-alpha.1 → 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 +348 -102
- 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,11 +32,13 @@
|
|
|
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
|
|
|
@@ -47,9 +49,13 @@ Built with a focus on simplicity, and better compatibility with modern WhatsApp
|
|
|
47
49
|
- [📄 Via `package.json`](#-via-packagejson)
|
|
48
50
|
- [⌨️ Via terminal](#%EF%B8%8F-via-terminal)
|
|
49
51
|
- [🧩 Import (ESM & CJS)](#-import-esm--cjs)
|
|
50
|
-
- [📄 Quick
|
|
52
|
+
- [📄 Quick Start](#-quick-start)
|
|
51
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)
|
|
52
57
|
- [📡 Events Reference](#-events-reference)
|
|
58
|
+
- [📄 Message Event Metadata](#-message-event-metadata)
|
|
53
59
|
- [👥 Find User ID](#-find-user-id)
|
|
54
60
|
- [📨 Sending Messages](#-sending-messages)
|
|
55
61
|
- [🔠 Text](#-text)
|
|
@@ -61,12 +67,12 @@ Built with a focus on simplicity, and better compatibility with modern WhatsApp
|
|
|
61
67
|
- [📦 Sticker Pack](#-sticker-pack)
|
|
62
68
|
- [👤 Contact](#-contact)
|
|
63
69
|
- [🖼️ Album](#%EF%B8%8F-album)
|
|
70
|
+
- [📊 Poll](#-poll)
|
|
71
|
+
- [📈 Poll Result](#-poll-result)
|
|
64
72
|
- [🗄️ Interactive](#%EF%B8%8F-interactive)
|
|
65
73
|
- [🎠 Carousel](#-carousel)
|
|
66
74
|
- [🔘 Legacy Button](#-legacy-button)
|
|
67
75
|
- [📋 Legacy List](#-legacy-list)
|
|
68
|
-
- [📊 Poll](#-poll)
|
|
69
|
-
- [📈 Poll Result](#-poll-result)
|
|
70
76
|
- [✨ Rich](#-rich)
|
|
71
77
|
- [🗒️ Copy & Forward](#%EF%B8%8F-copy--forward)
|
|
72
78
|
- [🎞️ Status Mention](#%EF%B8%8F-status-mention)
|
|
@@ -84,6 +90,9 @@ Built with a focus on simplicity, and better compatibility with modern WhatsApp
|
|
|
84
90
|
- [🔐 Privacy Management](#-privacy-management)
|
|
85
91
|
- [📡 Baileys Events Reference](#-baileys-events-reference)
|
|
86
92
|
- [🗳️ Database](#%EF%B8%8F-database)
|
|
93
|
+
- [📎 JSON](#-json)
|
|
94
|
+
- [📎 SQLite](#-sqlite)
|
|
95
|
+
- [🧩 Extend](#-extend)
|
|
87
96
|
- [🌐 Request](#-request)
|
|
88
97
|
- [📚 Exported Modules](#-exported-modules)
|
|
89
98
|
- [🚀 Try the Bot](#-try-the-bot)
|
|
@@ -91,17 +100,24 @@ Built with a focus on simplicity, and better compatibility with modern WhatsApp
|
|
|
91
100
|
|
|
92
101
|
### 📥 Installations
|
|
93
102
|
|
|
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
|
+
|
|
94
108
|
#### 📄 Via `package.json`
|
|
95
109
|
|
|
96
110
|
```json
|
|
97
111
|
# NPM
|
|
98
112
|
"dependencies": {
|
|
99
|
-
"@itsliaaa/starcore": "latest"
|
|
113
|
+
"@itsliaaa/starcore": "latest",
|
|
114
|
+
"baileys": "^7.0.0-rc13"
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
# GitHub
|
|
103
118
|
"dependencies": {
|
|
104
|
-
"@itsliaaa/starcore": "github:itsliaaa/starcore"
|
|
119
|
+
"@itsliaaa/starcore": "github:itsliaaa/starcore",
|
|
120
|
+
"baileys": "^7.0.0-rc13"
|
|
105
121
|
}
|
|
106
122
|
```
|
|
107
123
|
|
|
@@ -109,10 +125,10 @@ Built with a focus on simplicity, and better compatibility with modern WhatsApp
|
|
|
109
125
|
|
|
110
126
|
```bash
|
|
111
127
|
# NPM
|
|
112
|
-
npm i @itsliaaa/starcore@latest
|
|
128
|
+
npm i @itsliaaa/starcore@latest baileys@7.0.0-rc13
|
|
113
129
|
|
|
114
130
|
# GitHub
|
|
115
|
-
npm i github:itsliaaa/starcore
|
|
131
|
+
npm i @itsliaaa/starcore@github:itsliaaa/starcore baileys@7.0.0-rc13
|
|
116
132
|
```
|
|
117
133
|
|
|
118
134
|
#### 🧩 Import (ESM & CJS)
|
|
@@ -125,7 +141,7 @@ import { Client } from '@itsliaaa/starcore'
|
|
|
125
141
|
const { Client } = require('@itsliaaa/starcore')
|
|
126
142
|
```
|
|
127
143
|
|
|
128
|
-
### 📄 Quick
|
|
144
|
+
### 📄 Quick Start
|
|
129
145
|
|
|
130
146
|
```javascript
|
|
131
147
|
import { Client } from '@itsliaaa/starcore'
|
|
@@ -163,21 +179,21 @@ const client = new Client({
|
|
|
163
179
|
name: 'session',
|
|
164
180
|
pairingCode: true,
|
|
165
181
|
phoneNumber: '6281111111111',
|
|
166
|
-
customCode: 'starcore'
|
|
182
|
+
customCode: 'starcore',
|
|
183
|
+
type: 'json' // 'json' | 'sqlite'
|
|
167
184
|
},
|
|
168
185
|
isBotMessageId: (id) =>
|
|
169
186
|
typeof id === 'string' && id.includes('3EB0'),
|
|
170
187
|
messageIdPrefix: 'STARCORE',
|
|
188
|
+
watchPath: './plugins', // Default: null
|
|
171
189
|
updatePresence: true, // Default: true
|
|
172
|
-
updateProtoOnStartup: true, // Default:
|
|
190
|
+
updateProtoOnStartup: true, // Default: false
|
|
173
191
|
autoFollowNewsletter: '1211111111111@newsletter', // String | String[] | false
|
|
174
192
|
newsletterAnnotation: {
|
|
175
|
-
newsletterJid: '',
|
|
176
|
-
newsletterName: ''
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
temporaryFileInterval: 45 * 60 * 1000, // Default: 45 minutes
|
|
180
|
-
gcInterval: 1.5 * 60 * 60 * 1000 // Default: 1.5 hours
|
|
193
|
+
newsletterJid: '1211111111111@newsletter',
|
|
194
|
+
newsletterName: '@itsliaaa/starcore',
|
|
195
|
+
contentType: 1
|
|
196
|
+
} // IForwardedNewsletterMessageInfo | false
|
|
181
197
|
}, {
|
|
182
198
|
// Baileys socket configuration
|
|
183
199
|
shouldIgnoreJid: (jid) =>
|
|
@@ -185,6 +201,63 @@ const client = new Client({
|
|
|
185
201
|
})
|
|
186
202
|
```
|
|
187
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
|
+
|
|
188
261
|
### 📡 Events Reference
|
|
189
262
|
|
|
190
263
|
```javascript
|
|
@@ -198,11 +271,91 @@ client.on('group.add', console.log)
|
|
|
198
271
|
client.on('group.promote', console.log)
|
|
199
272
|
client.on('group.demote', console.log)
|
|
200
273
|
client.on('group.remove', console.log)
|
|
274
|
+
client.on('group.request', console.log)
|
|
201
275
|
client.on('label.update', console.log)
|
|
202
276
|
client.on('caller', console.log)
|
|
203
277
|
client.on('presence', console.log)
|
|
204
278
|
```
|
|
205
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
|
+
|
|
206
359
|
### 👥 Find User ID
|
|
207
360
|
|
|
208
361
|
Quickly resolve a user's `JID` and retrieve both `PN` and `LID` in a synchronous function.
|
|
@@ -231,7 +384,7 @@ const result = sock.findUserId(jidLid)
|
|
|
231
384
|
#### 🔠 Text
|
|
232
385
|
|
|
233
386
|
```javascript
|
|
234
|
-
sock.sendText(jid, '👋🏻 Hello',
|
|
387
|
+
sock.sendText(jid, '👋🏻 Hello', m, {
|
|
235
388
|
mentionAll: false, // Optional
|
|
236
389
|
mentions: ['1211111111111@lid', '6281111111111@s.whatsapp.net'], // Optional
|
|
237
390
|
})
|
|
@@ -240,7 +393,7 @@ sock.sendText(jid, '👋🏻 Hello', message, {
|
|
|
240
393
|
#### 📰 Link Preview
|
|
241
394
|
|
|
242
395
|
```javascript
|
|
243
|
-
sock.sendAdText(jid, '👆🏻 Check it out!',
|
|
396
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', m, {
|
|
244
397
|
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
245
398
|
title: '🌱 @itsliaaa/starcore',
|
|
246
399
|
description: 'Underrated Baileys Wrapper',
|
|
@@ -249,9 +402,9 @@ sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
|
249
402
|
})
|
|
250
403
|
|
|
251
404
|
// --- Send a text message with a large link preview and favicon
|
|
252
|
-
sock.sendAdText(jid, '👆🏻 Check it out!',
|
|
405
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', m, {
|
|
253
406
|
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
254
|
-
title: '
|
|
407
|
+
title: '✨ @itsliaaa/starcore',
|
|
255
408
|
description: 'Underrated Baileys Wrapper',
|
|
256
409
|
previewType: 0,
|
|
257
410
|
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
@@ -265,13 +418,13 @@ sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
|
265
418
|
#### 😄 Reaction
|
|
266
419
|
|
|
267
420
|
```javascript
|
|
268
|
-
sock.sendReact(jid, '✨',
|
|
421
|
+
sock.sendReact(jid, '✨', m.key)
|
|
269
422
|
```
|
|
270
423
|
|
|
271
424
|
#### 📂 Media
|
|
272
425
|
|
|
273
426
|
```javascript
|
|
274
|
-
sock.sendMedia(jid, bufferOrUrl,
|
|
427
|
+
sock.sendMedia(jid, bufferOrUrl, m, {
|
|
275
428
|
mime: 'image/jpeg', // Optional, will automatically detect the mime
|
|
276
429
|
document: false, // Optional, force send as document
|
|
277
430
|
ptv: false, // Optional, force send as PTV
|
|
@@ -283,13 +436,13 @@ sock.sendMedia(jid, bufferOrUrl, message, {
|
|
|
283
436
|
#### ⚪ PTV
|
|
284
437
|
|
|
285
438
|
```javascript
|
|
286
|
-
sock.sendPtv(jid, bufferOrUrl,
|
|
439
|
+
sock.sendPtv(jid, bufferOrUrl, m)
|
|
287
440
|
```
|
|
288
441
|
|
|
289
442
|
#### 📃 Sticker
|
|
290
443
|
|
|
291
444
|
```javascript
|
|
292
|
-
sock.sendSticker(jid, bufferOrUrl,
|
|
445
|
+
sock.sendSticker(jid, bufferOrUrl, m, {
|
|
293
446
|
packName: '@itsliaaa/starcore',
|
|
294
447
|
packPublisher: 'by Lia Wynn 🌱',
|
|
295
448
|
isAiSticker: true, // Optional
|
|
@@ -328,7 +481,7 @@ sock.sendContact(jid, [{
|
|
|
328
481
|
location: 'Jakarta',
|
|
329
482
|
other: '❤️ Simplified WhatsApp API',
|
|
330
483
|
number: '6281111111111'
|
|
331
|
-
}],
|
|
484
|
+
}], m)
|
|
332
485
|
```
|
|
333
486
|
|
|
334
487
|
#### 🖼️ Album
|
|
@@ -340,7 +493,53 @@ sock.sendAlbum(jid, [{
|
|
|
340
493
|
}, {
|
|
341
494
|
media: bufferOrUrl,
|
|
342
495
|
caption: 'Video'
|
|
343
|
-
}],
|
|
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)
|
|
344
543
|
```
|
|
345
544
|
|
|
346
545
|
#### 🗄️ Interactive
|
|
@@ -359,7 +558,8 @@ sock.sendInteractive(jid, [{
|
|
|
359
558
|
}, {
|
|
360
559
|
text: '🌐 Source',
|
|
361
560
|
url: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
362
|
-
|
|
561
|
+
useWebView: true, // Optional
|
|
562
|
+
webViewPresentation: null // Optional
|
|
363
563
|
}, {
|
|
364
564
|
text: '📋 Select',
|
|
365
565
|
sections: [{
|
|
@@ -381,10 +581,12 @@ sock.sendInteractive(jid, [{
|
|
|
381
581
|
}]
|
|
382
582
|
}],
|
|
383
583
|
icon: 'default' // Optional
|
|
384
|
-
}],
|
|
584
|
+
}], m, {
|
|
385
585
|
media: bufferOrUrl,
|
|
386
586
|
caption: '🗄️ Interactive Message',
|
|
387
587
|
footer: '@itsliaaa/starcore',
|
|
588
|
+
audioFooter: '/path/to/audio.mp3', // Optional
|
|
589
|
+
ptt: false, // Optional, applied when "audioFooter" is set
|
|
388
590
|
optionText: '👉🏻 Select Options', // Optional, wrap all native flow into a single list
|
|
389
591
|
optionTitle: '📄 Select Options', // Optional
|
|
390
592
|
offerText: '🏷️ Newest Coupon!', // Optional, add an offer into message
|
|
@@ -437,7 +639,7 @@ sock.sendCarousel(jid, [{
|
|
|
437
639
|
text: '🌐 Source',
|
|
438
640
|
url: 'https://www.npmjs.com/package/@itsliaaa/starcore'
|
|
439
641
|
}]
|
|
440
|
-
}],
|
|
642
|
+
}], m, {
|
|
441
643
|
text: '🎠 Carousel Message',
|
|
442
644
|
footer: '@itsliaaa/starcore'
|
|
443
645
|
})
|
|
@@ -450,7 +652,7 @@ sock.sendCarousel(jid, [{
|
|
|
450
652
|
sock.sendLegacyButton(jid, [{
|
|
451
653
|
text: '👋🏻 SignUp',
|
|
452
654
|
id: '#SignUp'
|
|
453
|
-
}],
|
|
655
|
+
}], m, {
|
|
454
656
|
text: '👆🏻 Buttons!',
|
|
455
657
|
footer: '@itsliaaa/starcore',
|
|
456
658
|
viewOnce: false // Optional, change to "true" if want proper render on WhatsApp Web
|
|
@@ -480,7 +682,7 @@ sock.sendLegacyButton(jid, [{
|
|
|
480
682
|
id: '#CouponCode'
|
|
481
683
|
}]
|
|
482
684
|
}]
|
|
483
|
-
}],
|
|
685
|
+
}], m, {
|
|
484
686
|
media: bufferOrUrl,
|
|
485
687
|
caption: '👆🏻 Buttons and List!',
|
|
486
688
|
footer: '@itsliaaa/starcore'
|
|
@@ -493,6 +695,7 @@ sock.sendLegacyButton(jid, [{
|
|
|
493
695
|
> This message is only works in private chat (`@s.whatsapp.net`)
|
|
494
696
|
|
|
495
697
|
```javascript
|
|
698
|
+
// --- Regular legacy list message
|
|
496
699
|
sock.sendLegacyList(jid, [{
|
|
497
700
|
title: '🚀 Menu 1',
|
|
498
701
|
rows: [{
|
|
@@ -507,58 +710,36 @@ sock.sendLegacyList(jid, [{
|
|
|
507
710
|
description: '',
|
|
508
711
|
rowId: '#Search'
|
|
509
712
|
}]
|
|
510
|
-
}],
|
|
713
|
+
}], m, {
|
|
511
714
|
text: '📋 List!',
|
|
512
715
|
footer: '@itsliaaa/starcore',
|
|
513
716
|
buttonText: '📋 Select',
|
|
514
717
|
title: '👋🏻 Hello'
|
|
515
718
|
})
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
#### 📊 Poll
|
|
519
|
-
|
|
520
|
-
```javascript
|
|
521
|
-
// --- Regular poll message
|
|
522
|
-
sock.sendPoll(jid, [
|
|
523
|
-
'✨ Yes', '💀 No'
|
|
524
|
-
], message, {
|
|
525
|
-
name: '🔥 Is it good?',
|
|
526
|
-
selectableCount: 1,
|
|
527
|
-
toAnnouncementGroup: false,
|
|
528
|
-
endDate: new Date(Date.now() + 28_800_000), // Optional
|
|
529
|
-
hideVoter: false, // Optional
|
|
530
|
-
canAddOption: false // Optional
|
|
531
|
-
})
|
|
532
719
|
|
|
533
|
-
// ---
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
#### 📈 Poll Result
|
|
543
|
-
|
|
544
|
-
```javascript
|
|
545
|
-
// --- Regular poll result message
|
|
546
|
-
sock.sendPollResult(jid, '📈 Poll Result', [{
|
|
547
|
-
name: '🔥 Fire',
|
|
548
|
-
voteCount: 133
|
|
549
|
-
}, {
|
|
550
|
-
name: '❤️ Love it',
|
|
551
|
-
voteCount: 18
|
|
552
|
-
}], message)
|
|
553
|
-
|
|
554
|
-
// --- Quiz result message
|
|
555
|
-
sock.sendQuizResult(jid, '🏆 Quiz Result', [{
|
|
556
|
-
name: '🔥 Fire',
|
|
557
|
-
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
|
+
}]
|
|
558
728
|
}, {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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
|
+
})
|
|
562
743
|
```
|
|
563
744
|
|
|
564
745
|
#### ✨ Rich
|
|
@@ -700,7 +881,7 @@ sock.sendRich(jid, [{
|
|
|
700
881
|
faviconUrl: 'https://path-to-tiny-image.com/',
|
|
701
882
|
mime: 'image/jpeg' // Optional, the mime type of favicon
|
|
702
883
|
}]
|
|
703
|
-
}],
|
|
884
|
+
}], m, {
|
|
704
885
|
notify: false, // Optional
|
|
705
886
|
disclaimerText: 'Example Usage of sendRich()'
|
|
706
887
|
})
|
|
@@ -709,9 +890,9 @@ sock.sendRich(jid, [{
|
|
|
709
890
|
#### 🗒️ Copy & Forward
|
|
710
891
|
|
|
711
892
|
```javascript
|
|
712
|
-
sock.sendCopyMessage(jid,
|
|
893
|
+
sock.sendCopyMessage(jid, m, {
|
|
713
894
|
forwardingScore: 1, // Optional
|
|
714
|
-
quoted:
|
|
895
|
+
quoted: m // Optional
|
|
715
896
|
})
|
|
716
897
|
```
|
|
717
898
|
|
|
@@ -722,7 +903,10 @@ sock.sendCopyMessage(jid, message, {
|
|
|
722
903
|
|
|
723
904
|
```javascript
|
|
724
905
|
sock.sendStatus([jid], {
|
|
725
|
-
text: '👋🏻 Hello!'
|
|
906
|
+
text: '👋🏻 Hello!',
|
|
907
|
+
font: 0,
|
|
908
|
+
textColor: '#FFFFFF', // Optional
|
|
909
|
+
backgroundColor: '#FF0000' // Optional
|
|
726
910
|
}, {
|
|
727
911
|
mention: false, // Optional
|
|
728
912
|
closeFriends: {
|
|
@@ -739,7 +923,10 @@ sock.sendStatus([jid], {
|
|
|
739
923
|
|
|
740
924
|
```javascript
|
|
741
925
|
sock.sendGroupStatus(jid, {
|
|
742
|
-
text: '👋🏻 Hello!'
|
|
926
|
+
text: '👋🏻 Hello!',
|
|
927
|
+
font: 0,
|
|
928
|
+
textColor: '#FFFFFF', // Optional
|
|
929
|
+
backgroundColor: '#000000' // Optional
|
|
743
930
|
}, {
|
|
744
931
|
closeFriends: {
|
|
745
932
|
name: '@itsliaaa/starcore',
|
|
@@ -754,7 +941,7 @@ sock.sendGroupStatus(jid, {
|
|
|
754
941
|
|
|
755
942
|
```javascript
|
|
756
943
|
sock.sendMessage(jid, {
|
|
757
|
-
delete:
|
|
944
|
+
delete: m.key
|
|
758
945
|
})
|
|
759
946
|
```
|
|
760
947
|
|
|
@@ -764,13 +951,13 @@ sock.sendMessage(jid, {
|
|
|
764
951
|
// --- Edit plain text
|
|
765
952
|
sock.sendMessage(jid, {
|
|
766
953
|
text: '✨ I mean, nice!',
|
|
767
|
-
edit:
|
|
954
|
+
edit: m.key
|
|
768
955
|
})
|
|
769
956
|
|
|
770
957
|
// --- Edit media messages caption
|
|
771
958
|
sock.sendMessage(jid, {
|
|
772
959
|
caption: '✨ I mean, here is the image!',
|
|
773
|
-
edit:
|
|
960
|
+
edit: m.key
|
|
774
961
|
})
|
|
775
962
|
```
|
|
776
963
|
|
|
@@ -868,7 +1055,6 @@ console.dir(metadata, { depth: null })
|
|
|
868
1055
|
const inviteCode = await sock.groupInviteCode(jid)
|
|
869
1056
|
console.dir(inviteCode, { depth: null })
|
|
870
1057
|
|
|
871
|
-
|
|
872
1058
|
// --- Revoke invite link
|
|
873
1059
|
sock.groupRevokeInvite(jid)
|
|
874
1060
|
|
|
@@ -1063,7 +1249,7 @@ sock.sendPresenceUpdate('available', jid)
|
|
|
1063
1249
|
sock.presenceSubscribe(jid)
|
|
1064
1250
|
|
|
1065
1251
|
// --- Read receipts
|
|
1066
|
-
sock.readMessages([
|
|
1252
|
+
sock.readMessages([m.key])
|
|
1067
1253
|
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1068
1254
|
|
|
1069
1255
|
// --- Block user
|
|
@@ -1079,8 +1265,8 @@ console.dir(blocked, { depth: null })
|
|
|
1079
1265
|
// --- Modify chats
|
|
1080
1266
|
sock.chatModify({
|
|
1081
1267
|
archive: true,
|
|
1082
|
-
lastMessageOrig:
|
|
1083
|
-
lastMessage:
|
|
1268
|
+
lastMessageOrig: m,
|
|
1269
|
+
lastMessage: m
|
|
1084
1270
|
}, jid)
|
|
1085
1271
|
|
|
1086
1272
|
// --- Star messages
|
|
@@ -1101,7 +1287,7 @@ sock.keepFavorites([
|
|
|
1101
1287
|
'1211111111111@g.us'
|
|
1102
1288
|
])
|
|
1103
1289
|
sock.keepFavorites([
|
|
1104
|
-
'6281111111111@s.whatsapp.net' //
|
|
1290
|
+
'6281111111111@s.whatsapp.net' // Only this one remains
|
|
1105
1291
|
])
|
|
1106
1292
|
|
|
1107
1293
|
// --- App state sync
|
|
@@ -1273,22 +1459,80 @@ sock.ev.on('settings.update', console.log)
|
|
|
1273
1459
|
|
|
1274
1460
|
### 🗳️ Database
|
|
1275
1461
|
|
|
1276
|
-
|
|
1277
|
-
|
|
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
|
|
1278
1468
|
|
|
1279
1469
|
```javascript
|
|
1280
1470
|
import { Database } from '@itsliaaa/starcore'
|
|
1281
1471
|
|
|
1282
|
-
const db = Database.
|
|
1283
|
-
|
|
1472
|
+
const db = await Database.json('database.json')
|
|
1473
|
+
|
|
1474
|
+
const data = await db.read()
|
|
1475
|
+
|
|
1284
1476
|
await db.write({
|
|
1285
1477
|
users: {},
|
|
1286
1478
|
groups: {},
|
|
1287
|
-
contacts: {},
|
|
1288
1479
|
settings: {}
|
|
1289
|
-
})
|
|
1480
|
+
})
|
|
1290
1481
|
```
|
|
1291
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
|
+
|
|
1292
1536
|
### 🌐 Request
|
|
1293
1537
|
|
|
1294
1538
|
> [!NOTE]
|
|
@@ -1333,11 +1577,13 @@ const postResult = await someApi('path/to/post', null, {
|
|
|
1333
1577
|
|
|
1334
1578
|
```javascript
|
|
1335
1579
|
import {
|
|
1336
|
-
Database,
|
|
1337
1580
|
Client,
|
|
1581
|
+
Database,
|
|
1582
|
+
Extend,
|
|
1338
1583
|
Request,
|
|
1339
1584
|
Scraper,
|
|
1340
|
-
Utilities
|
|
1585
|
+
Utilities,
|
|
1586
|
+
Watcher
|
|
1341
1587
|
} from '@itsliaaa/starcore'
|
|
1342
1588
|
```
|
|
1343
1589
|
|