astrabail 1.1.1 → 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.
@@ -874,10 +874,24 @@ const makeChatsSocket = (config) => {
874
874
  return String(jid).split('@')[0];
875
875
  }
876
876
  };
877
- // Fetch metadata (pakai cache jika tersedia)
877
+ // ✅ HANYA baca dari cache — TIDAK await network call
878
+ // Ini memastikan upsertMessage tidak pernah blocking karena network I/O
878
879
  let meta = null;
879
880
  try {
880
- meta = await sock.groupMetadata(remoteJid);
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
+ }
881
895
  }
882
896
  catch { }
883
897
  if (meta && Array.isArray(meta.participants)) {
@@ -925,6 +939,7 @@ const makeChatsSocket = (config) => {
925
939
  }
926
940
  catch { }
927
941
  // ─────────────────────────────────────────────────────────────────────
942
+
928
943
  ev.emit('messages.upsert', { messages: [msg], type });
929
944
  if (!!msg.pushName) {
930
945
  let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
@@ -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
- _refreshGroupMetadata(id);
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.1",
3
+ "version": "1.1.2",
4
4
  "update": "25 April 2026",
5
5
  "description": "Professional Whatsapp Web API Library",
6
6
  "keywords": [
package/readme.md CHANGED
@@ -256,7 +256,7 @@ WhatsApp provides a multi-device API that allows AstraBail to be authenticated a
256
256
  ### 🔹 Memulai Socket dengan Kode QR
257
257
 
258
258
  > [!TIP]
259
- > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://AstraBail.whiskeysockets.io/types/BrowsersMap.html)**
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)**
260
260
 
261
261
  ```javascript
262
262
  const { default: makeWASocket } = require("astrabail")
@@ -394,7 +394,7 @@ sock.ev.on('creds.update', saveCreds)
394
394
  They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
395
395
 
396
396
  > [!IMPORTANT]
397
- > **The events are [these](https://AstraBail.whiskeysockets.io/types/AstraBailEventMap.html)**, it's important you see all events
397
+ > **The events are [these](https://baileys.whiskeysockets.io/types/AstraBailEventMap.html)**, it's important you see all events
398
398
 
399
399
  You can listen to these events like this:
400
400
  ```javascript
@@ -597,8 +597,8 @@ dengan broadcast: true seperti dijelaskan pada bagian sebelumnya.`
597
597
  ## 💬 Mengirim Pesan
598
598
 
599
599
  - Send all types of messages with a single function
600
- - **[Here](https://AstraBail.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
601
- - **[Here](https://AstraBail.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
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**
602
602
 
603
603
  ```javascript
604
604
  const jid: string
@@ -1042,7 +1042,7 @@ await client.sendMessage(
1042
1042
 
1043
1043
  <a id="handling-events"></a>
1044
1044
  #### 📤 Meneruskan Pesan
1045
- - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://AstraBail.whiskeysockets.io/types/WAMessage.html) object
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
1046
1046
  ```javascript
1047
1047
  const msg = getMessageFromStore() // implement this on your end
1048
1048
  await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
@@ -1085,7 +1085,7 @@ await sock.sendMessage(
1085
1085
 
1086
1086
  <a id="handling-events"></a>
1087
1087
  #### ❤️ Pesan Reaksi
1088
- - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://AstraBail.whiskeysockets.io/types/WAMessageKey.html) object
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
1089
1089
  ```javascript
1090
1090
  await sock.sendMessage(
1091
1091
  jid,
@@ -1100,7 +1100,7 @@ await sock.sendMessage(
1100
1100
 
1101
1101
  <a id="handling-events"></a>
1102
1102
  #### 📌 Pesan Pin
1103
- - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://AstraBail.whiskeysockets.io/types/WAMessageKey.html) object
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
1104
1104
 
1105
1105
  - Time can be:
1106
1106
 
@@ -1160,7 +1160,7 @@ await sock.sendMessage(
1160
1160
  Sending media (video, stickers, images) is easier & more efficient than ever.
1161
1161
 
1162
1162
  > [!NOTE]
1163
- > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://AstraBail.whiskeysockets.io/types/WAMediaUpload.html)
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)
1164
1164
 
1165
1165
  - When specifying a media url, AstraBail never loads the entire buffer into memory; it even encrypts the media as a readable stream.
1166
1166
 
@@ -1340,7 +1340,7 @@ await sock.rejectCall(callId, callFrom)
1340
1340
 
1341
1341
  <a id="handling-events"></a>
1342
1342
  ### 📖 Membaca Pesan
1343
- - A set of message [keys](https://AstraBail.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
1343
+ - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
1344
1344
  - You cannot mark an entire 'chat' read as it were with AstraBail Web.
1345
1345
  This means you have to keep track of unread messages.
1346
1346
 
@@ -1356,7 +1356,7 @@ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.k
1356
1356
  <a id="handling-events"></a>
1357
1357
  ### 🟢 Memperbarui Presence
1358
1358
 
1359
- - ``` presence ``` can be one of [these](https://AstraBail.whiskeysockets.io/types/WAPresence.html)
1359
+ - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
1360
1360
  - The presence expires after about 10 seconds.
1361
1361
  - This lets the person/group with `jid` know whether you're online, offline, typing etc.
1362
1362
 
@@ -1583,7 +1583,7 @@ await sock.updateProfileName('My name')
1583
1583
  - To change your display picture or a group's
1584
1584
 
1585
1585
  > [!NOTE]
1586
- > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://AstraBail.whiskeysockets.io/types/WAMediaUpload.html)
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)
1587
1587
 
1588
1588
  ```javascript
1589
1589
  await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
@@ -1827,8 +1827,8 @@ await sock.sendMessage(
1827
1827
  }
1828
1828
  )
1829
1829
  ```
1830
- - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://AstraBail.whiskeysockets.io/types/AnyRegularMessageContent.html)
1831
- - You can add `backgroundColor` and other options in the message options, see [here](https://AstraBail.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
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)
1832
1832
  - `broadcast: true` enables broadcast mode
1833
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.
1834
1834