astrabail 1.1.0 → 1.1.2
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/engine-requirements.js +48 -5
- package/lib/Socket/chats.js +31 -2
- package/lib/Socket/groups.js +3 -1
- package/package.json +2 -2
- package/readme.md +18 -15
package/engine-requirements.js
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const currentVersion = process.versions.node;
|
|
4
|
+
const majorVersion = parseInt(currentVersion.split('.')[0], 10);
|
|
5
|
+
const requiredVersion = 20;
|
|
6
|
+
|
|
7
|
+
if (majorVersion < requiredVersion) {
|
|
8
|
+
// Menggunakan ANSI Escape Codes murni agar tetap berfungsi meski dependencies belum diinstall
|
|
9
|
+
const colors = {
|
|
10
|
+
red: '\x1b[31m',
|
|
11
|
+
yellow: '\x1b[33m',
|
|
12
|
+
cyan: '\x1b[36m',
|
|
13
|
+
blue: '\x1b[34m',
|
|
14
|
+
reset: '\x1b[0m',
|
|
15
|
+
bold: '\x1b[1m'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const width = 60;
|
|
19
|
+
|
|
20
|
+
const printLine = (text, color = '') => {
|
|
21
|
+
// Hilangkan ANSI codes untuk menghitung panjang karakter asli
|
|
22
|
+
const plainText = text.replace(/\x1b\[[0-9;]*m/g, '');
|
|
23
|
+
const padLen = Math.max(0, width - 4 - plainText.length);
|
|
24
|
+
const padding = ' '.repeat(padLen);
|
|
25
|
+
console.error(`${colors.red}${colors.bold}│${colors.reset} ${color}${text}${colors.reset}${padding} ${colors.red}${colors.bold}│${colors.reset}`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
console.error('');
|
|
29
|
+
console.error(`${colors.red}${colors.bold}┌${'─'.repeat(width - 2)}┐${colors.reset}`);
|
|
30
|
+
console.error(`${colors.red}${colors.bold}│${' '.repeat(Math.floor((width - 32) / 2))}🔥 ASTRA ENGINE CRASHED 🔥${' '.repeat(Math.ceil((width - 32) / 2) - 2)}│${colors.reset}`);
|
|
31
|
+
console.error(`${colors.red}${colors.bold}├${'─'.repeat(width - 2)}┤${colors.reset}`);
|
|
32
|
+
|
|
33
|
+
printLine('');
|
|
34
|
+
printLine(`${colors.bold}AstraBail requires a modern Node.js environment.`, colors.yellow);
|
|
35
|
+
printLine('This library uses advanced multi-device capabilities', colors.yellow);
|
|
36
|
+
printLine('that are only supported on the latest V8 Engine.', colors.yellow);
|
|
37
|
+
printLine('');
|
|
38
|
+
printLine(`Required Node.js : ${colors.cyan}${colors.bold}>= v${requiredVersion}.0.0`);
|
|
39
|
+
printLine(`Current Node.js : ${colors.red}${colors.bold}v${currentVersion}`);
|
|
40
|
+
printLine('');
|
|
41
|
+
printLine(`Action Required:`, colors.cyan);
|
|
42
|
+
printLine(`Please upgrade your Node.js version to proceed.`);
|
|
43
|
+
printLine(`${colors.blue}https://nodejs.org/en/download/`);
|
|
44
|
+
printLine('');
|
|
45
|
+
|
|
46
|
+
console.error(`${colors.red}${colors.bold}└${'─'.repeat(width - 2)}┘${colors.reset}`);
|
|
47
|
+
console.error('');
|
|
48
|
+
|
|
6
49
|
process.exit(1);
|
|
7
50
|
}
|
package/lib/Socket/chats.js
CHANGED
|
@@ -845,6 +845,20 @@ const makeChatsSocket = (config) => {
|
|
|
845
845
|
await Promise.all([fetchProps(), fetchBlocklist(), fetchPrivacySettings()]);
|
|
846
846
|
};
|
|
847
847
|
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
848
|
+
// --- AUTO-NORMALIZE JID (ASTRA FEATURE - OPTIMIZED) ---
|
|
849
|
+
try {
|
|
850
|
+
if (msg.key) {
|
|
851
|
+
// Hanya decode jika JID benar-benar mengandung karakter titik dua (Device ID)
|
|
852
|
+
// Ini membuat performa tetap secepat kilat (0ms latency penalty)
|
|
853
|
+
if (msg.key.remoteJid && msg.key.remoteJid.includes(':')) {
|
|
854
|
+
msg.key.remoteJid = (0, index_js_5.jidNormalizedUser)(msg.key.remoteJid);
|
|
855
|
+
}
|
|
856
|
+
if (msg.key.participant && msg.key.participant.includes(':')) {
|
|
857
|
+
msg.key.participant = (0, index_js_5.jidNormalizedUser)(msg.key.participant);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
} catch { }
|
|
861
|
+
// --------------------------------------------------------
|
|
848
862
|
// ── Auto-inject isAdmin, isBotAdmin, metadata ─────────────────────────
|
|
849
863
|
try {
|
|
850
864
|
const remoteJid = msg.key?.remoteJid || '';
|
|
@@ -860,10 +874,24 @@ const makeChatsSocket = (config) => {
|
|
|
860
874
|
return String(jid).split('@')[0];
|
|
861
875
|
}
|
|
862
876
|
};
|
|
863
|
-
//
|
|
877
|
+
// ✅ HANYA baca dari cache — TIDAK await network call
|
|
878
|
+
// Ini memastikan upsertMessage tidak pernah blocking karena network I/O
|
|
864
879
|
let meta = null;
|
|
865
880
|
try {
|
|
866
|
-
|
|
881
|
+
// getCachedGroupMetadata sudah tersedia via sock (dari groups.js)
|
|
882
|
+
// Jika ada, pakai. Jika tidak ada di cache, langsung skip (non-blocking)
|
|
883
|
+
if (typeof sock.groupMetadata === 'function') {
|
|
884
|
+
const cached = sock._getCachedMetadata
|
|
885
|
+
? await sock._getCachedMetadata(remoteJid)
|
|
886
|
+
: null;
|
|
887
|
+
meta = cached || null;
|
|
888
|
+
// Jika cache miss, refresh di background tanpa blocking pesan
|
|
889
|
+
if (!meta) {
|
|
890
|
+
setImmediate(() => {
|
|
891
|
+
sock.groupMetadata(remoteJid).catch(() => { });
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
}
|
|
867
895
|
}
|
|
868
896
|
catch { }
|
|
869
897
|
if (meta && Array.isArray(meta.participants)) {
|
|
@@ -911,6 +939,7 @@ const makeChatsSocket = (config) => {
|
|
|
911
939
|
}
|
|
912
940
|
catch { }
|
|
913
941
|
// ─────────────────────────────────────────────────────────────────────
|
|
942
|
+
|
|
914
943
|
ev.emit('messages.upsert', { messages: [msg], type });
|
|
915
944
|
if (!!msg.pushName) {
|
|
916
945
|
let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -88,7 +88,8 @@ const makeGroupsSocket = (config) => {
|
|
|
88
88
|
}
|
|
89
89
|
// Auto-refresh dari network untuk semua aksi participant
|
|
90
90
|
// Ini memastikan data selalu akurat dari server WA
|
|
91
|
-
|
|
91
|
+
// Gunakan setImmediate agar tidak memblok event loop (mencegah bot freeze saat ada user join)
|
|
92
|
+
setImmediate(() => _refreshGroupMetadata(id));
|
|
92
93
|
});
|
|
93
94
|
// ── End group metadata cache ───────────────────────────────────────────────
|
|
94
95
|
const groupQuery = async (jid, type, content) => query({
|
|
@@ -159,6 +160,7 @@ const makeGroupsSocket = (config) => {
|
|
|
159
160
|
return {
|
|
160
161
|
...sock,
|
|
161
162
|
groupMetadata,
|
|
163
|
+
_getCachedMetadata: getCachedGroupMetadata,
|
|
162
164
|
groupCreate: async (subject, participants) => {
|
|
163
165
|
const key = (0, index_js_3.generateMessageIDV2)();
|
|
164
166
|
const result = await groupQuery('@g.us', 'set', [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astrabail",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"update": "25 April 2026",
|
|
5
5
|
"description": "Professional Whatsapp Web API Library",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"cache-manager": "^5.7.6",
|
|
56
56
|
"cheerio": "^1.0.0-rc.10",
|
|
57
57
|
"libphonenumber-js": "^1.10.20",
|
|
58
|
-
"libsignal": "github:
|
|
58
|
+
"libsignal": "github:Danimaru-ze/astra-libsignal",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
60
|
"music-metadata": "^7.12.3",
|
|
61
61
|
"pino": "^9.6",
|
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<strong>Professional WhatsApp Web API Library — Built for the Next Generation of Bots</strong><br/>
|
|
9
|
-
<sub>Fork-optimized from
|
|
9
|
+
<sub>Fork-optimized from Baileys · Powered by Astra-Libsignal · Maintained by <a href="https://github.com/Danimaru-ze">Danimaru-ze</a></sub>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
<a href="https://whatsapp.com/channel/0029Vazo6KM8kyyJ4eWh3A25">
|
|
26
26
|
<img src="https://img.shields.io/badge/WhatsApp-Channel-25D366?style=flat-square&logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
|
|
27
27
|
</a>
|
|
28
|
+
<a href="https://github.com/Danimaru-ze/astra-libsignal">
|
|
29
|
+
<img src="https://img.shields.io/badge/Crypto_Engine-Astra_Libsignal-8A2BE2?style=flat-square" alt="Astra Libsignal" />
|
|
30
|
+
</a>
|
|
28
31
|
</p>
|
|
29
32
|
|
|
30
33
|
</div>
|
|
@@ -33,7 +36,7 @@
|
|
|
33
36
|
|
|
34
37
|
## ✨ Tentang AstraBail
|
|
35
38
|
|
|
36
|
-
**AstraBail** adalah library WhatsApp Web API profesional yang dioptimalkan dari basis *
|
|
39
|
+
**AstraBail** adalah library WhatsApp Web API profesional yang dioptimalkan dari basis *Baileys*. Dikelola oleh **Danimaru-ze**, library ini dirancang untuk performa tinggi, stabilitas maksimal, dan kemudahan integrasi ke berbagai proyek bot WhatsApp modern. Kini ditenagai penuh oleh **astra-libsignal** untuk proses enkripsi tingkat tinggi.
|
|
37
40
|
|
|
38
41
|
### 🚀 Fitur Unggulan
|
|
39
42
|
|
|
@@ -253,7 +256,7 @@ WhatsApp provides a multi-device API that allows AstraBail to be authenticated a
|
|
|
253
256
|
### 🔹 Memulai Socket dengan Kode QR
|
|
254
257
|
|
|
255
258
|
> [!TIP]
|
|
256
|
-
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://
|
|
259
|
+
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
|
|
257
260
|
|
|
258
261
|
```javascript
|
|
259
262
|
const { default: makeWASocket } = require("astrabail")
|
|
@@ -391,7 +394,7 @@ sock.ev.on('creds.update', saveCreds)
|
|
|
391
394
|
They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
|
|
392
395
|
|
|
393
396
|
> [!IMPORTANT]
|
|
394
|
-
> **The events are [these](https://
|
|
397
|
+
> **The events are [these](https://baileys.whiskeysockets.io/types/AstraBailEventMap.html)**, it's important you see all events
|
|
395
398
|
|
|
396
399
|
You can listen to these events like this:
|
|
397
400
|
```javascript
|
|
@@ -594,8 +597,8 @@ dengan broadcast: true seperti dijelaskan pada bagian sebelumnya.`
|
|
|
594
597
|
## 💬 Mengirim Pesan
|
|
595
598
|
|
|
596
599
|
- Send all types of messages with a single function
|
|
597
|
-
- **[Here](https://
|
|
598
|
-
- **[Here](https://
|
|
600
|
+
- **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
|
|
601
|
+
- **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
|
|
599
602
|
|
|
600
603
|
```javascript
|
|
601
604
|
const jid: string
|
|
@@ -1039,7 +1042,7 @@ await client.sendMessage(
|
|
|
1039
1042
|
|
|
1040
1043
|
<a id="handling-events"></a>
|
|
1041
1044
|
#### 📤 Meneruskan Pesan
|
|
1042
|
-
- You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://
|
|
1045
|
+
- You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object
|
|
1043
1046
|
```javascript
|
|
1044
1047
|
const msg = getMessageFromStore() // implement this on your end
|
|
1045
1048
|
await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
|
|
@@ -1082,7 +1085,7 @@ await sock.sendMessage(
|
|
|
1082
1085
|
|
|
1083
1086
|
<a id="handling-events"></a>
|
|
1084
1087
|
#### ❤️ Pesan Reaksi
|
|
1085
|
-
- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://
|
|
1088
|
+
- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
|
|
1086
1089
|
```javascript
|
|
1087
1090
|
await sock.sendMessage(
|
|
1088
1091
|
jid,
|
|
@@ -1097,7 +1100,7 @@ await sock.sendMessage(
|
|
|
1097
1100
|
|
|
1098
1101
|
<a id="handling-events"></a>
|
|
1099
1102
|
#### 📌 Pesan Pin
|
|
1100
|
-
- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://
|
|
1103
|
+
- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
|
|
1101
1104
|
|
|
1102
1105
|
- Time can be:
|
|
1103
1106
|
|
|
@@ -1157,7 +1160,7 @@ await sock.sendMessage(
|
|
|
1157
1160
|
Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
1158
1161
|
|
|
1159
1162
|
> [!NOTE]
|
|
1160
|
-
> In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://
|
|
1163
|
+
> In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
|
|
1161
1164
|
|
|
1162
1165
|
- When specifying a media url, AstraBail never loads the entire buffer into memory; it even encrypts the media as a readable stream.
|
|
1163
1166
|
|
|
@@ -1337,7 +1340,7 @@ await sock.rejectCall(callId, callFrom)
|
|
|
1337
1340
|
|
|
1338
1341
|
<a id="handling-events"></a>
|
|
1339
1342
|
### 📖 Membaca Pesan
|
|
1340
|
-
- A set of message [keys](https://
|
|
1343
|
+
- A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
|
|
1341
1344
|
- You cannot mark an entire 'chat' read as it were with AstraBail Web.
|
|
1342
1345
|
This means you have to keep track of unread messages.
|
|
1343
1346
|
|
|
@@ -1353,7 +1356,7 @@ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.k
|
|
|
1353
1356
|
<a id="handling-events"></a>
|
|
1354
1357
|
### 🟢 Memperbarui Presence
|
|
1355
1358
|
|
|
1356
|
-
- ``` presence ``` can be one of [these](https://
|
|
1359
|
+
- ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
|
|
1357
1360
|
- The presence expires after about 10 seconds.
|
|
1358
1361
|
- This lets the person/group with `jid` know whether you're online, offline, typing etc.
|
|
1359
1362
|
|
|
@@ -1580,7 +1583,7 @@ await sock.updateProfileName('My name')
|
|
|
1580
1583
|
- To change your display picture or a group's
|
|
1581
1584
|
|
|
1582
1585
|
> [!NOTE]
|
|
1583
|
-
> Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://
|
|
1586
|
+
> Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
|
|
1584
1587
|
|
|
1585
1588
|
```javascript
|
|
1586
1589
|
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
|
@@ -1824,8 +1827,8 @@ await sock.sendMessage(
|
|
|
1824
1827
|
}
|
|
1825
1828
|
)
|
|
1826
1829
|
```
|
|
1827
|
-
- Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://
|
|
1828
|
-
- You can add `backgroundColor` and other options in the message options, see [here](https://
|
|
1830
|
+
- Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
|
|
1831
|
+
- You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
|
|
1829
1832
|
- `broadcast: true` enables broadcast mode
|
|
1830
1833
|
- `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
|
|
1831
1834
|
|