@realvare/based 2.6.1 → 2.6.22

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.
@@ -7,41 +7,39 @@ exports.PerformanceConfig = exports.setPerformanceConfig = exports.getPerformanc
7
7
  */
8
8
  class PerformanceConfig {
9
9
  constructor() {
10
- // Cache settings
11
10
  this.cache = {
12
11
  lidCache: {
13
- ttl: 5 * 60 * 1000, // 5 minuti
12
+ ttl: 5 * 60 * 1000,
14
13
  maxSize: 10000,
15
- cleanupInterval: 2 * 60 * 1000 // 2 minuti
14
+ cleanupInterval: 2 * 60 * 1000
16
15
  },
17
16
  jidCache: {
18
- ttl: 5 * 60 * 1000, // 5 minuti
17
+ ttl: 5 * 60 * 1000,
19
18
  maxSize: 10000,
20
- cleanupInterval: 2 * 60 * 1000 // 2 minuti
19
+ cleanupInterval: 2 * 60 * 1000
21
20
  },
22
21
  lidToJidCache: {
23
- ttl: 5 * 60 * 1000, // 5 minuti
22
+ ttl: 5 * 60 * 1000,
24
23
  maxSize: 5000,
25
- cleanupInterval: 3 * 60 * 1000 // 3 minuti
24
+ cleanupInterval: 3 * 60 * 1000
26
25
  }
27
26
  };
28
27
 
29
- // Performance settings - Conservative defaults for anti-ban protection
30
28
  this.performance = {
31
29
  enableCache: true,
32
30
  enableLogging: false,
33
31
  enableMetrics: true,
34
- batchSize: 20, // Reduced from 50 for anti-ban
35
- maxRetries: 3, // Reduced from 5 for anti-ban
36
- retryDelay: 5000,
37
- retryBackoffMultiplier: 1.5,
38
- maxRetryDelay: 60000,
32
+ batchSize: 30,
33
+ maxRetries: 3,
34
+ retryDelay: 8000,
35
+ retryBackoffMultiplier: 2.0,
36
+ maxRetryDelay: 120000,
39
37
  maxMsgRetryCount: 3,
40
- memoryThreshold: 0.85, // 85% memory usage threshold
41
- // Anti-ban specific settings
42
- markOnlineOnConnect: false, // Don't appear always online
43
- syncFullHistory: false, // Limit initial sync
44
- keepAliveIntervalMs: 30000 // Maintain connection without excess
38
+ memoryThreshold: 0.85,
39
+ markOnlineOnConnect: false,
40
+ syncFullHistory: true,
41
+ keepAliveIntervalMs: 30000,
42
+ enableNativeLidCache: true
45
43
  };
46
44
 
47
45
  // Debug settings
@@ -0,0 +1,35 @@
1
+ const sharp = require('sharp');
2
+ const fs = require('fs/promises');
3
+ const fetch = require('node-fetch');
4
+
5
+ /**
6
+ * Generates an optimized JPEG thumbnail buffer for externalAdReply.
7
+ * @param {string | Buffer} imagePathOrBuffer - Path to image file, Buffer, or URL.
8
+ * @param {number} [size=150] - Target square size (default 150 for balance between quality and load time).
9
+ * @param {number} [quality=85] - JPEG quality (1-100, default 85).
10
+ * @returns {Promise<Buffer>} - Optimized thumbnail buffer.
11
+ */
12
+ async function generateThumbnail(imagePathOrBuffer, size = 150, quality = 85) {
13
+ let input;
14
+
15
+ if (typeof imagePathOrBuffer === 'string') {
16
+ if (imagePathOrBuffer.startsWith('http')) {
17
+ // Fetch from URL
18
+ const response = await fetch(imagePathOrBuffer);
19
+ input = Buffer.from(await response.arrayBuffer());
20
+ } else {
21
+ // Local file
22
+ input = await fs.readFile(imagePathOrBuffer);
23
+ }
24
+ } else {
25
+ input = imagePathOrBuffer;
26
+ }
27
+
28
+ return sharp(input)
29
+ .resize(size, size, { fit: 'cover', kernel: sharp.kernel.lanczos3 }) // Lanczos for sharp resizing
30
+ .sharpen() // Optional: Adds slight sharpness to counter blurring
31
+ .jpeg({ quality, mozjpeg: true }) // Use high-quality JPEG compression
32
+ .toBuffer();
33
+ }
34
+
35
+ module.exports = { generateThumbnail };
@@ -88,7 +88,11 @@ const useMultiFileAuthState = async (folder) => {
88
88
  await (0, promises_1.mkdir)(folder, { recursive: true });
89
89
  }
90
90
  const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
91
- const creds = await readData('creds.json') || (0, auth_utils_1.initAuthCreds)();
91
+ let creds = await readData('creds.json');
92
+ if (!creds) {
93
+ creds = (0, auth_utils_1.initAuthCreds)();
94
+ }
95
+
92
96
  return {
93
97
  state: {
94
98
  creds,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@realvare/based",
3
- "version": "2.6.01",
4
- "description": "whatsapp api by sam",
3
+ "version": "2.6.22",
4
+ "description": "WhatsApp Web API by Sam",
5
5
  "keywords": [
6
6
  "baileys",
7
7
  "whatsapp",
@@ -9,7 +9,9 @@
9
9
  "whatsapp-web",
10
10
  "whatsapp-bot",
11
11
  "automation",
12
- "multi-device"
12
+ "multi-device",
13
+ "lid",
14
+ "anti-ban"
13
15
  ],
14
16
  "homepage": "https://github.com/realvare/based.git",
15
17
  "repository": {
@@ -56,6 +58,7 @@
56
58
  "music-metadata": "^7.12.3",
57
59
  "pino": "^9.6",
58
60
  "protobufjs": "^7.2.5",
61
+ "sharp": "^0.33.5",
59
62
  "uuid": "^10.0.0",
60
63
  "ws": "^8.18.0"
61
64
  },
@@ -96,9 +99,6 @@
96
99
  },
97
100
  "link-preview-js": {
98
101
  "optional": true
99
- },
100
- "sharp": {
101
- "optional": true
102
102
  }
103
103
  },
104
104
  "packageManager": "yarn@1.22.19",