@itsliaaa/starcore 0.0.0-alpha.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/LICENSE +661 -0
- package/README.md +765 -0
- package/engine-requirements.js +12 -0
- package/lib/Auth.js +19 -0
- package/lib/Client.js +19 -0
- package/lib/Constants.js +19 -0
- package/lib/Database.js +19 -0
- package/lib/Media.js +19 -0
- package/lib/Message.js +19 -0
- package/lib/Request.js +19 -0
- package/lib/Scraper.js +19 -0
- package/lib/Serialize.js +19 -0
- package/lib/Socket.js +19 -0
- package/lib/Store.js +19 -0
- package/lib/Utilities.js +19 -0
- package/lib/index.js +19 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
# ✨ @itsliaaa/starcore
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@itsliaaa/starcore)
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A lightweight yet powerful Baileys wrapper designed to simplify development while extending support for additional message types and WhatsApp features.
|
|
7
|
+
<br><br>
|
|
8
|
+
<a href="https://www.npmjs.com/package/@itsliaaa/starcore">
|
|
9
|
+
<img src="https://img.shields.io/npm/v/@itsliaaa/starcore?style=for-the-badge&logo=npm"/>
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@itsliaaa/starcore">
|
|
12
|
+
<img src="https://img.shields.io/npm/dm/@itsliaaa/starcore?style=for-the-badge&logo=npm"/>
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/itsliaaa/starcore">
|
|
15
|
+
<img src="https://img.shields.io/github/stars/itsliaaa/starcore?style=for-the-badge&logo=github"/>
|
|
16
|
+
</a>
|
|
17
|
+
<a href="LICENSE">
|
|
18
|
+
<img src="https://img.shields.io/badge/license-AGPL--3.0-blue?style=for-the-badge"/>
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://nodejs.org">
|
|
21
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
|
|
22
|
+
</a>
|
|
23
|
+
<a href="#">
|
|
24
|
+
<img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/>
|
|
25
|
+
</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
☕ For donation: [Saweria](https://saweria.co/itsliaaa)
|
|
29
|
+
|
|
30
|
+
> ⚠️ **Minimum Baileys Version**: `7.0.0-rc10` or higher.
|
|
31
|
+
|
|
32
|
+
### 📌 Highlights
|
|
33
|
+
|
|
34
|
+
- Improved `createParticipantNodes()` by introducing yielding, preventing potential freezes during participant node generation.
|
|
35
|
+
- Enhanced `relayMessage()` with newsletter support and compatibility for sending several important binary payloads.
|
|
36
|
+
- Adapted `prepareWAMessageMedia()` to fully support media delivery to newsletters.
|
|
37
|
+
- Added support for sending `stickerPackMessage` through `sendStickerPack()`.
|
|
38
|
+
- Extended support for multiple interactive messages and button-based message types.
|
|
39
|
+
- Introduced `newsletterSubscribed()` to easily retrieve data from all newsletters the account is currently subscribed to.
|
|
40
|
+
|
|
41
|
+
Built with a focus on simplicity, and better compatibility with modern WhatsApp features.
|
|
42
|
+
|
|
43
|
+
### 🌱 Future Plans
|
|
44
|
+
|
|
45
|
+
For now, the alpha release ships with a built-in JSON adapter for Database, Store, and Auth State.
|
|
46
|
+
|
|
47
|
+
More adapters will join the party in future releases. ✨
|
|
48
|
+
|
|
49
|
+
Until then, JSON remains the recommended choice for development, testing, and lightweight deployments.
|
|
50
|
+
|
|
51
|
+
### 📄 Basic Usage
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import { Client } from '@itsliaaa/starcore'
|
|
55
|
+
|
|
56
|
+
const client = new Client({
|
|
57
|
+
auth: {
|
|
58
|
+
name: 'session',
|
|
59
|
+
pairingCode: true, // Turn "false" to use QR Code
|
|
60
|
+
phoneNumber: '6281111111111'
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
client.on('message', (ctx) => {
|
|
65
|
+
if (ctx.body === 'hello') {
|
|
66
|
+
ctx.m.reply('👋 Hello there!')
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> [!IMPORTANT]
|
|
72
|
+
> The underlying Baileys socket instance is available through `client.sock`.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
const client = new Client({ ... })
|
|
76
|
+
const sock = client.sock
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ⚙️ Advanced Usage
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { Client } from '@itsliaaa/starcore'
|
|
83
|
+
|
|
84
|
+
const client = new Client({
|
|
85
|
+
auth: {
|
|
86
|
+
name: 'session',
|
|
87
|
+
pairingCode: true,
|
|
88
|
+
phoneNumber: '6281111111111',
|
|
89
|
+
customCode: 'starcore'
|
|
90
|
+
},
|
|
91
|
+
isBotMessageId: (id) =>
|
|
92
|
+
typeof id === 'string' && id.includes('3EB0'),
|
|
93
|
+
messageIdPrefix: 'starcore',
|
|
94
|
+
readMessage: true,
|
|
95
|
+
updatePresence: true,
|
|
96
|
+
updateProtoOnStartup: true,
|
|
97
|
+
autoFollowNewsletter: '1111122222@newsletter', // String | String[] | false
|
|
98
|
+
newsletterAnnotation: {
|
|
99
|
+
newsletterJid: '',
|
|
100
|
+
newsletterName: ''
|
|
101
|
+
}, // IForwardedNewsletterMessageInfo | false
|
|
102
|
+
saveStoreInterval: 30 * 60 * 1000, // Default: 30 minutes
|
|
103
|
+
temporaryFileInterval: 45 * 60 * 1000, // Default: 45 minutes
|
|
104
|
+
gcInterval: 1.5 * 60 * 60 * 1000 // Default: 1.5 hours
|
|
105
|
+
}, {
|
|
106
|
+
// Baileys socket configuration
|
|
107
|
+
shouldIgnoreJid: (jid) =>
|
|
108
|
+
typeof jid === 'string' && jid.endsWith('bot')
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 📡 Events Reference
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
client.once('ready', console.log)
|
|
116
|
+
client.on('message', console.log)
|
|
117
|
+
client.on('message.edit', console.log)
|
|
118
|
+
client.on('message.delete', console.log)
|
|
119
|
+
client.on('poll', console.log)
|
|
120
|
+
client.on('status', console.log)
|
|
121
|
+
client.on('group.add', console.log)
|
|
122
|
+
client.on('group.promote', console.log)
|
|
123
|
+
client.on('group.demote', console.log)
|
|
124
|
+
client.on('group.remove', console.log)
|
|
125
|
+
client.on('label.update', console.log)
|
|
126
|
+
client.on('caller', console.log)
|
|
127
|
+
client.on('presence', console.log)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 👥 Find User ID
|
|
131
|
+
|
|
132
|
+
Quickly resolve a user's `JID` and retrieve both `PN` and `LID` in a synchronous function.
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// Accepts either @s.whatsapp.net or @lid
|
|
136
|
+
const jidLid = '621111111111@s.whatsapp.net'
|
|
137
|
+
|
|
138
|
+
const result = sock.findUserId(jidLid)
|
|
139
|
+
|
|
140
|
+
// --- Success
|
|
141
|
+
// {
|
|
142
|
+
// phoneNumber: '621111111111@s.whatsapp.net',
|
|
143
|
+
// lid: '121111111111@lid'
|
|
144
|
+
// }
|
|
145
|
+
|
|
146
|
+
// --- Not found
|
|
147
|
+
// {
|
|
148
|
+
// phoneNumber: '621111111111@s.whatsapp.net',
|
|
149
|
+
// lid: undefined // or null
|
|
150
|
+
// }
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 📨 Sending Messages
|
|
154
|
+
|
|
155
|
+
#### 🔠 Text
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
sock.sendText(jid, '👋🏻 Hello', message, {
|
|
159
|
+
mentionAll: false, // Optional
|
|
160
|
+
mentions: ['621111111111@lid', '621111111111@s.whatsapp.net'], // Optional
|
|
161
|
+
})
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### 📰 Link Preview
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
168
|
+
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
169
|
+
title: '🌱 @itsliaaa/starcore',
|
|
170
|
+
description: 'Underrated Baileys Wrapper',
|
|
171
|
+
previewType: 0, // Or use 1 for video playback in the link preview
|
|
172
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg') // Buffer or url
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
// --- Send a text message with a large link preview and favicon
|
|
176
|
+
sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
177
|
+
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
178
|
+
title: '🌱 @itsliaaa/starcore',
|
|
179
|
+
description: 'Underrated Baileys Wrapper',
|
|
180
|
+
previewType: 0,
|
|
181
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
182
|
+
favicon: fs.readFileSync('./path/to/tiny-image.png'), // Optional, Buffer or url
|
|
183
|
+
largeThumbnail: true, // Must true if want to send large preview
|
|
184
|
+
width: 720,
|
|
185
|
+
height: 480
|
|
186
|
+
})
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### 😄 Reaction
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
sock.sendReact(jid, '✨', message.key)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 📂 Media
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
sock.sendMedia(jid, bufferOrUrl, message, {
|
|
199
|
+
mime: 'image/jpeg', // Optional, will automatically detect the mime
|
|
200
|
+
document: false, // Optional, force send as document
|
|
201
|
+
ptv: false, // Optional, force send as PTV
|
|
202
|
+
gif: false, // Optional
|
|
203
|
+
ptt: false // Optional
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### ⚪ PTV
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
sock.sendPtv(jid, bufferOrUrl, message)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### 📃 Sticker
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
sock.sendSticker(jid, bufferOrUrl, message, {
|
|
217
|
+
packName: '@itsliaaa/starcore',
|
|
218
|
+
packPublisher: 'by Lia Wynn 🌱',
|
|
219
|
+
isAiSticker: true, // Optional
|
|
220
|
+
isAvatar: false, // Optional
|
|
221
|
+
premium: 1 // Optional
|
|
222
|
+
})
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### 📦 Sticker Pack
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
sock.sendStickerPack = async (jid, [bufferOrUrl, bufferOrUrl], m, {
|
|
229
|
+
cover: bufferOrUrl,
|
|
230
|
+
name: '📦 Sticker Pack',
|
|
231
|
+
publisher: 'GitHub: itsliaaa',
|
|
232
|
+
description: '✨ itsliaaa/starcore'
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### 👤 Contact
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
sock.sendContact(jid, [{
|
|
240
|
+
name: 'Lia Wynn',
|
|
241
|
+
org: '🛎️ Waitress',
|
|
242
|
+
email: 'my-email@gmail.com',
|
|
243
|
+
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
244
|
+
location: 'Jakarta',
|
|
245
|
+
other: '❤️ Simplified WhatsApp API',
|
|
246
|
+
number: '621111111111'
|
|
247
|
+
}, {
|
|
248
|
+
name: '❤️ My Big Brother',
|
|
249
|
+
org: '👥 Siblings',
|
|
250
|
+
email: 'his-email@gmail.com',
|
|
251
|
+
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
252
|
+
location: 'Jakarta',
|
|
253
|
+
other: '❤️ Simplified WhatsApp API',
|
|
254
|
+
number: '621111111111'
|
|
255
|
+
}], message)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### 🖼️ Album
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
sock.sendAlbum(jid, [{
|
|
262
|
+
media: bufferOrUrl,
|
|
263
|
+
caption: 'Image'
|
|
264
|
+
}, {
|
|
265
|
+
media: bufferOrUrl,
|
|
266
|
+
caption: 'Video'
|
|
267
|
+
}], message)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### 🗄️ Interactive
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
sock.sendInteractive(jid, [{
|
|
274
|
+
text: '👋🏻 Greeting',
|
|
275
|
+
id: '#Greeting',
|
|
276
|
+
icon: 'review' // Optional
|
|
277
|
+
}, {
|
|
278
|
+
text: '📞 Call',
|
|
279
|
+
call: '621111111111'
|
|
280
|
+
}, {
|
|
281
|
+
text: '📋 Copy',
|
|
282
|
+
copy: '@itsliaaa/starcore'
|
|
283
|
+
}, {
|
|
284
|
+
text: '🌐 Source',
|
|
285
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
286
|
+
useWebview: true // Optional
|
|
287
|
+
}, {
|
|
288
|
+
text: '📋 Select',
|
|
289
|
+
sections: [{
|
|
290
|
+
title: '✨ Section 1',
|
|
291
|
+
rows: [{
|
|
292
|
+
header: '',
|
|
293
|
+
title: '🏷️ Coupon',
|
|
294
|
+
description: '',
|
|
295
|
+
id: '#CouponCode'
|
|
296
|
+
}]
|
|
297
|
+
}, {
|
|
298
|
+
title: '✨ Section 2',
|
|
299
|
+
highlight_label: '🔥 Popular',
|
|
300
|
+
rows: [{
|
|
301
|
+
header: '',
|
|
302
|
+
title: '💭 Secret Ingredient',
|
|
303
|
+
description: '',
|
|
304
|
+
id: '#SecretIngredient'
|
|
305
|
+
}]
|
|
306
|
+
}],
|
|
307
|
+
icon: 'default' // Optional
|
|
308
|
+
}], message, {
|
|
309
|
+
media: bufferOrUrl,
|
|
310
|
+
caption: '🗄️ Interactive Message',
|
|
311
|
+
footer: '@itsliaaa/starcore',
|
|
312
|
+
optionText: '👉🏻 Select Options', // Optional, wrap all native flow into a single list
|
|
313
|
+
optionTitle: '📄 Select Options', // Optional
|
|
314
|
+
offerText: '🏷️ Newest Coupon!', // Optional, add an offer into message
|
|
315
|
+
offerCode: '@itsliaaa/starcore', // Optional
|
|
316
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore', // Optional
|
|
317
|
+
offerExpiration: Date.now() + 3_600_000, // Optional
|
|
318
|
+
asTemplate: false // Optional, wrap the interactive message as template
|
|
319
|
+
})
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### 🎠 Carousel
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
sock.sendCarousel(jid, [{
|
|
326
|
+
media: bufferOrUrl,
|
|
327
|
+
caption: '🖼️ Image 1',
|
|
328
|
+
footer: '🏷️️ Pinterest',
|
|
329
|
+
nativeFlow: [{
|
|
330
|
+
text: '🌐 Source',
|
|
331
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
332
|
+
useWebview: true
|
|
333
|
+
}]
|
|
334
|
+
}, {
|
|
335
|
+
media: bufferOrUrl,
|
|
336
|
+
caption: '🖼️ Image 2',
|
|
337
|
+
footer: '🏷️ Pinterest',
|
|
338
|
+
offerText: '🏷️ New Coupon!',
|
|
339
|
+
offerCode: '@itsliaaa/starcore',
|
|
340
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
341
|
+
offerExpiration: Date.now() + 3_600_000,
|
|
342
|
+
nativeFlow: [{
|
|
343
|
+
text: '🌐 Source',
|
|
344
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/starcore'
|
|
345
|
+
}]
|
|
346
|
+
}, {
|
|
347
|
+
media: bufferOrUrl,
|
|
348
|
+
caption: '🖼️ Image 3',
|
|
349
|
+
footer: '🏷️ Pinterest',
|
|
350
|
+
optionText: '👉🏻 Select Options',
|
|
351
|
+
optionTitle: '👉🏻 Select Options',
|
|
352
|
+
offerText: '🏷️ New Coupon!',
|
|
353
|
+
offerCode: '@itsliaaa/starcore',
|
|
354
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore',
|
|
355
|
+
offerExpiration: Date.now() + 3_600_000,
|
|
356
|
+
nativeFlow: [{
|
|
357
|
+
text: '🛒 Product',
|
|
358
|
+
id: '#Product',
|
|
359
|
+
icon: 'default'
|
|
360
|
+
}, {
|
|
361
|
+
text: '🌐 Source',
|
|
362
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/starcore'
|
|
363
|
+
}]
|
|
364
|
+
}], message, {
|
|
365
|
+
text: '🎠 Carousel Message',
|
|
366
|
+
footer: '@itsliaaa/starcore'
|
|
367
|
+
})
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### 🔘 Legacy Button
|
|
371
|
+
|
|
372
|
+
```javascript
|
|
373
|
+
// --- Regular buttons message
|
|
374
|
+
sock.sendLegacyButton(jid, [{
|
|
375
|
+
text: '👋🏻 SignUp',
|
|
376
|
+
id: '#SignUp'
|
|
377
|
+
}], message, {
|
|
378
|
+
text: '👆🏻 Buttons!',
|
|
379
|
+
footer: '@itsliaaa/starcore',
|
|
380
|
+
viewOnce: false // Optional, change to "true" if want proper render on WhatsApp Web
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
// --- Buttons with Media & List
|
|
384
|
+
sock.sendLegacyButton(jid, [{
|
|
385
|
+
text: '👋🏻 Rating',
|
|
386
|
+
id: '#Rating'
|
|
387
|
+
}, {
|
|
388
|
+
text: '📋 Select',
|
|
389
|
+
sections: [{
|
|
390
|
+
title: '✨ Section 1',
|
|
391
|
+
rows: [{
|
|
392
|
+
header: '',
|
|
393
|
+
title: '💭 Secret Ingredient',
|
|
394
|
+
description: '',
|
|
395
|
+
id: '#SecretIngredient'
|
|
396
|
+
}]
|
|
397
|
+
}, {
|
|
398
|
+
title: '✨ Section 2',
|
|
399
|
+
highlight_label: '🔥 Popular',
|
|
400
|
+
rows: [{
|
|
401
|
+
header: '',
|
|
402
|
+
title: '🏷️ Coupon',
|
|
403
|
+
description: '',
|
|
404
|
+
id: '#CouponCode'
|
|
405
|
+
}]
|
|
406
|
+
}]
|
|
407
|
+
}], message, {
|
|
408
|
+
media: bufferOrUrl,
|
|
409
|
+
caption: '👆🏻 Buttons and List!',
|
|
410
|
+
footer: '@itsliaaa/starcore'
|
|
411
|
+
})
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
#### 📋 Legacy List
|
|
415
|
+
|
|
416
|
+
> [!NOTE]
|
|
417
|
+
> This message is only works in private chat (`@s.whatsapp.net`)
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
sock.sendLegacyList(jid, [{
|
|
421
|
+
title: '🚀 Menu 1',
|
|
422
|
+
rows: [{
|
|
423
|
+
title: '✨ AI',
|
|
424
|
+
description: '',
|
|
425
|
+
rowId: '#AI'
|
|
426
|
+
}]
|
|
427
|
+
}, {
|
|
428
|
+
title: '🌱 Menu 2',
|
|
429
|
+
rows: [{
|
|
430
|
+
title: '🔍 Search',
|
|
431
|
+
description: '',
|
|
432
|
+
rowId: '#Search'
|
|
433
|
+
}]
|
|
434
|
+
}], message, {
|
|
435
|
+
text: '📋 List!',
|
|
436
|
+
footer: '@itsliaaa/starcore',
|
|
437
|
+
buttonText: '📋 Select',
|
|
438
|
+
title: '👋🏻 Hello'
|
|
439
|
+
})
|
|
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
|
+
|
|
466
|
+
#### 📈 Poll Result
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
// --- Regular poll result message
|
|
470
|
+
sock.sendPollResult(jid, '📈 Poll Result', [{
|
|
471
|
+
name: '🔥 Fire',
|
|
472
|
+
voteCount: 133
|
|
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
|
|
482
|
+
}, {
|
|
483
|
+
name: '❤️ Love it',
|
|
484
|
+
voteCount: 18
|
|
485
|
+
}], message)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
#### ✨ Rich
|
|
489
|
+
|
|
490
|
+
```javascript
|
|
491
|
+
sock.sendRich(jid, [{
|
|
492
|
+
text: '# ✨ @itsliaaa/starcore\n\n---\n',
|
|
493
|
+
}, {
|
|
494
|
+
language: 'javascript',
|
|
495
|
+
code: `console.log("Hello World")`
|
|
496
|
+
}, {
|
|
497
|
+
title: 'The Table',
|
|
498
|
+
table: [{
|
|
499
|
+
isHeading: true,
|
|
500
|
+
items: ['', 'Node.js', 'Bun', 'Deno']
|
|
501
|
+
}, {
|
|
502
|
+
isHeading: false,
|
|
503
|
+
items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
|
|
504
|
+
}, {
|
|
505
|
+
isHeading: false,
|
|
506
|
+
items: ['Performance', '4/5', '5/5', '4/5']
|
|
507
|
+
}]
|
|
508
|
+
}, {
|
|
509
|
+
video: 'https://path-to-video.com/',
|
|
510
|
+
thumbnailUrl: 'https://path-to-tiny-image.com/',
|
|
511
|
+
mime: 'video/mp4',
|
|
512
|
+
fileLength: 13_603,
|
|
513
|
+
duration: 60
|
|
514
|
+
}, {
|
|
515
|
+
image: 'https://path-to-image.com/',
|
|
516
|
+
mime: 'image/jpeg'
|
|
517
|
+
}, {
|
|
518
|
+
reels: [{
|
|
519
|
+
reelUrl: 'https://path-to-web.com/',
|
|
520
|
+
thumbnailUrl: 'https://path-to-image.com/',
|
|
521
|
+
creator: 'Lia Wynn',
|
|
522
|
+
avatarUrl: 'https://path-to-tiny-image.com/',
|
|
523
|
+
title: 'Simple Baileys Wrapper',
|
|
524
|
+
likesCount: 1,
|
|
525
|
+
sharesCount: 1,
|
|
526
|
+
viewCount: 1,
|
|
527
|
+
source: 'https://path-to-web.com/',
|
|
528
|
+
isVerified: true
|
|
529
|
+
}]
|
|
530
|
+
}, {
|
|
531
|
+
posts: [{
|
|
532
|
+
caption: 'Lightweight Baileys Wrapper',
|
|
533
|
+
title: '',
|
|
534
|
+
subtitle: '',
|
|
535
|
+
creator: 'Lia Wynn',
|
|
536
|
+
avatarUrl: 'https://path-to-tiny-image.com/',
|
|
537
|
+
thumbnailUrl: 'https://path-to-image.com/',
|
|
538
|
+
likesCount: 1,
|
|
539
|
+
commentsCount: 1,
|
|
540
|
+
sharesCount: 1,
|
|
541
|
+
postUrl: 'https://path-to-web.com/',
|
|
542
|
+
deepLink: '',
|
|
543
|
+
footerLabel: '',
|
|
544
|
+
footerIcon: '',
|
|
545
|
+
sourceApp: 'FACEBOOK',
|
|
546
|
+
orientation: 'LANDSCAPE',
|
|
547
|
+
type: 'IMAGE',
|
|
548
|
+
isVerified: true,
|
|
549
|
+
isCarousel: false
|
|
550
|
+
}]
|
|
551
|
+
}, {
|
|
552
|
+
title: 'Starseed Premium Script',
|
|
553
|
+
brand: 'Starseed',
|
|
554
|
+
price: 'Rp 150.000',
|
|
555
|
+
salePrice: 'Rp 75.000',
|
|
556
|
+
productUrl: 'https://path-to-web.com/',
|
|
557
|
+
imageUrl: 'https://path-to-image.com/',
|
|
558
|
+
additionalImages: [{
|
|
559
|
+
url: 'https://path-to-tiny-image.com/'
|
|
560
|
+
}] // Optional
|
|
561
|
+
}, {
|
|
562
|
+
products: [{
|
|
563
|
+
title: 'Starseed Premium Script',
|
|
564
|
+
brand: 'Starseed',
|
|
565
|
+
price: 'Rp 150.000',
|
|
566
|
+
salePrice: 'Rp 75.000',
|
|
567
|
+
productUrl: 'https://path-to-web.com/',
|
|
568
|
+
imageUrl: 'https://path-to-image.com/'
|
|
569
|
+
}, {
|
|
570
|
+
title: 'Self-Bot Script',
|
|
571
|
+
brand: 'Starseed',
|
|
572
|
+
price: 'Rp 50.000',
|
|
573
|
+
productUrl: 'https://path-to-web.com/',
|
|
574
|
+
imageUrl: 'https://path-to-image.com/',
|
|
575
|
+
additionalImages: [{
|
|
576
|
+
url: 'https://path-to-tiny-image.com/'
|
|
577
|
+
}]
|
|
578
|
+
}]
|
|
579
|
+
}, {
|
|
580
|
+
latex: 'https://quicklatex.com/cache3/82/ql_0676ade0cd04eda37aeb3d0bcd427682_l3.png',
|
|
581
|
+
expression: 'x^2 + 2x + 1',
|
|
582
|
+
mime: 'image/png',
|
|
583
|
+
width: 603,
|
|
584
|
+
height: 111,
|
|
585
|
+
fontHeight: 83.5,
|
|
586
|
+
padding: 15
|
|
587
|
+
}, {
|
|
588
|
+
text: '- Citation:',
|
|
589
|
+
entities: [{
|
|
590
|
+
title: 'Example of Citation',
|
|
591
|
+
citationUrl: 'https://wa.me/0',
|
|
592
|
+
displayName: '@itsliaaa/starcore'
|
|
593
|
+
}]
|
|
594
|
+
}, {
|
|
595
|
+
text: '- Inline Link:',
|
|
596
|
+
entities: [{
|
|
597
|
+
inlineUrl: 'https://wa.me/0',
|
|
598
|
+
displayName: '@itsliaaa/starcore',
|
|
599
|
+
isTrusted: true
|
|
600
|
+
}]
|
|
601
|
+
}, {
|
|
602
|
+
text: '- LaTeX:',
|
|
603
|
+
entities: [{
|
|
604
|
+
expression: 'x^2 + 2x + 1',
|
|
605
|
+
latex: 'https://quicklatex.com/cache3/82/ql_0676ade0cd04eda37aeb3d0bcd427682_l3.png',
|
|
606
|
+
width: 603,
|
|
607
|
+
height: 111,
|
|
608
|
+
fontHeight: 83.5,
|
|
609
|
+
padding: 15
|
|
610
|
+
}]
|
|
611
|
+
}, {
|
|
612
|
+
suggestion: '@itsliaaa/starcore'
|
|
613
|
+
}, {
|
|
614
|
+
suggestions: ['@itsliaaa/starcore', 'Baileys Wrapper', 'Baileys']
|
|
615
|
+
}, {
|
|
616
|
+
suggestions: ['@itsliaaa/starcore', 'Rich Response', 'Scroll Layout'],
|
|
617
|
+
canScroll: true
|
|
618
|
+
}, {
|
|
619
|
+
tip: '@itsliaaa/starcore'
|
|
620
|
+
}, {
|
|
621
|
+
searchResults: [{
|
|
622
|
+
displayName: 'Simple Baileys Wrapper',
|
|
623
|
+
sourceUrl: 'https://path-to-web.com/',
|
|
624
|
+
faviconUrl: 'https://path-to-tiny-image.com/',
|
|
625
|
+
mime: 'image/jpeg' // Optional, the mime type of favicon
|
|
626
|
+
}]
|
|
627
|
+
}], message, {
|
|
628
|
+
notify: false, // Optional
|
|
629
|
+
disclaimerText: 'Example Usage of sendRich()'
|
|
630
|
+
})
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
#### 🗒️ Copy & Forward
|
|
634
|
+
|
|
635
|
+
```javascript
|
|
636
|
+
sock.sendCopyMessage(jid, message, {
|
|
637
|
+
forwardingScore: 1, // Optional
|
|
638
|
+
quoted: message // Optional
|
|
639
|
+
})
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
#### 🎞️ Status Mention
|
|
643
|
+
|
|
644
|
+
> [!NOTE]
|
|
645
|
+
> Can be treated as `sendMessage()`.
|
|
646
|
+
|
|
647
|
+
```javascript
|
|
648
|
+
sock.sendStatus([jid], {
|
|
649
|
+
text: '👋🏻 Hello!'
|
|
650
|
+
}, {
|
|
651
|
+
mention: false, // Optional
|
|
652
|
+
closeFriends: {
|
|
653
|
+
name: '@itsliaaa/starcore',
|
|
654
|
+
emoji: '✨'
|
|
655
|
+
} // Optional
|
|
656
|
+
})
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
#### 👥 Group Status
|
|
660
|
+
|
|
661
|
+
> [!NOTE]
|
|
662
|
+
> Can be treated as `sendMessage()`.
|
|
663
|
+
|
|
664
|
+
```javascript
|
|
665
|
+
sock.sendGroupStatus(jid, {
|
|
666
|
+
text: '👋🏻 Hello!'
|
|
667
|
+
}, {
|
|
668
|
+
closeFriends: {
|
|
669
|
+
name: '@itsliaaa/starcore',
|
|
670
|
+
emoji: '✨'
|
|
671
|
+
} // Optional
|
|
672
|
+
})
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### 🗳️ Database
|
|
676
|
+
|
|
677
|
+
> [!IMPORTANT]
|
|
678
|
+
> Currently, only the JSON adapter is available. Additional adapters are planned for future releases.
|
|
679
|
+
|
|
680
|
+
```javascript
|
|
681
|
+
import { Database } from '@itsliaaa/starcore'
|
|
682
|
+
|
|
683
|
+
const db = Database.saveToLocal('database.json')
|
|
684
|
+
const data = await db.read('database.json') // Read database from file, will return empty object if not exists
|
|
685
|
+
await db.write({
|
|
686
|
+
users: {},
|
|
687
|
+
groups: {},
|
|
688
|
+
contacts: {},
|
|
689
|
+
settings: {}
|
|
690
|
+
}) // Save data to file
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### 🌐 Request
|
|
694
|
+
|
|
695
|
+
> [!NOTE]
|
|
696
|
+
> This feature relies on Node.js's built-in `fetch()` API along with several other native Node.js capabilities. Therefore, it's highly recommended to use Node.js version 20 or newer (>= 20) to ensure everything works properly.
|
|
697
|
+
|
|
698
|
+
```javascript
|
|
699
|
+
import { Request } from '@itsliaaa/starcore'
|
|
700
|
+
|
|
701
|
+
// --- Quick request
|
|
702
|
+
const result = await Request.request('https://path-to-web-api.com/', {
|
|
703
|
+
timeout: 3000 // Default: 1.5 minutes
|
|
704
|
+
})
|
|
705
|
+
|
|
706
|
+
// --- Get url from redirect url
|
|
707
|
+
const maxRedirects = 3 // Default: 3
|
|
708
|
+
const realUrl = await Request.resolveUrl('https://path-to-redirect.com/', maxRedirects)
|
|
709
|
+
|
|
710
|
+
// --- Create a fast path
|
|
711
|
+
const someApi = Request.createApiRequest('https://path-to-web-api.com/')
|
|
712
|
+
|
|
713
|
+
const getResult = await someApi('path/to/get', {
|
|
714
|
+
q: 'Hello'
|
|
715
|
+
}, {
|
|
716
|
+
// Optional
|
|
717
|
+
timeout: 3000,
|
|
718
|
+
method: 'GET',
|
|
719
|
+
headers: {}
|
|
720
|
+
})
|
|
721
|
+
|
|
722
|
+
const postResult = await someApi('path/to/post', null, {
|
|
723
|
+
method: 'POST',
|
|
724
|
+
headers: {
|
|
725
|
+
'Content-Type': 'application/json'
|
|
726
|
+
},
|
|
727
|
+
body: JSON.stringify({
|
|
728
|
+
q: 'Hello'
|
|
729
|
+
})
|
|
730
|
+
})
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### 📚 Exported Modules
|
|
734
|
+
|
|
735
|
+
```javascript
|
|
736
|
+
import {
|
|
737
|
+
Database,
|
|
738
|
+
Client,
|
|
739
|
+
Request,
|
|
740
|
+
Scraper,
|
|
741
|
+
Utilities
|
|
742
|
+
} from '@itsliaaa/starcore'
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
### 🚀 Try the Bot
|
|
746
|
+
|
|
747
|
+
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/starcore](https://www.npmjs.com/package/@itsliaaa/starcore).
|
|
748
|
+
Perfect for managing groups, moderating chats, and adding fun with quiz games and handy tools.
|
|
749
|
+
|
|
750
|
+
👉🏻 [@itsliaaa/starseed](https://github.com/itsliaaa/starseed#readme)
|
|
751
|
+
|
|
752
|
+
### 📣 Credits
|
|
753
|
+
|
|
754
|
+
This project uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto) for the `updateProtoOnStartup` feature.
|
|
755
|
+
|
|
756
|
+
Special thanks to the original Baileys maintainers and contributors:
|
|
757
|
+
- [purpshell](https://github.com/purpshell)
|
|
758
|
+
- [jlucaso1](https://github.com/jlucaso1)
|
|
759
|
+
- [adiwajshing](https://github.com/adiwajshing)
|
|
760
|
+
|
|
761
|
+
<!-- Please do not replace my name with yours. It's disrespectful. -->
|
|
762
|
+
|
|
763
|
+
**This project is created and maintained by [Lia Wynn](https://github.com/itsliaaa)**
|
|
764
|
+
|
|
765
|
+
Please do not remove or alter the original credits, copyright notices, or attributions.
|