@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.
- package/README.MD +364 -364
- package/lib/Socket/messages-recv.js +34 -10
- package/lib/Socket/messages-send.js +38 -17
- package/lib/Socket/socket.js +1 -2
- package/lib/Types/Socket.d.ts +1 -1
- package/lib/Utils/cache-manager.js +7 -3
- package/lib/Utils/link-preview.js +22 -6
- package/lib/Utils/logger.js +53 -1
- package/lib/Utils/messages-media.js +2 -15
- package/lib/Utils/messages.js +40 -170
- package/lib/Utils/performance-config.js +16 -18
- package/lib/Utils/thumbnail.js +35 -0
- package/lib/Utils/use-multi-file-auth-state.js +5 -1
- package/package.json +6 -6
|
@@ -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,
|
|
12
|
+
ttl: 5 * 60 * 1000,
|
|
14
13
|
maxSize: 10000,
|
|
15
|
-
cleanupInterval: 2 * 60 * 1000
|
|
14
|
+
cleanupInterval: 2 * 60 * 1000
|
|
16
15
|
},
|
|
17
16
|
jidCache: {
|
|
18
|
-
ttl: 5 * 60 * 1000,
|
|
17
|
+
ttl: 5 * 60 * 1000,
|
|
19
18
|
maxSize: 10000,
|
|
20
|
-
cleanupInterval: 2 * 60 * 1000
|
|
19
|
+
cleanupInterval: 2 * 60 * 1000
|
|
21
20
|
},
|
|
22
21
|
lidToJidCache: {
|
|
23
|
-
ttl: 5 * 60 * 1000,
|
|
22
|
+
ttl: 5 * 60 * 1000,
|
|
24
23
|
maxSize: 5000,
|
|
25
|
-
cleanupInterval: 3 * 60 * 1000
|
|
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:
|
|
35
|
-
maxRetries: 3,
|
|
36
|
-
retryDelay:
|
|
37
|
-
retryBackoffMultiplier:
|
|
38
|
-
maxRetryDelay:
|
|
32
|
+
batchSize: 30,
|
|
33
|
+
maxRetries: 3,
|
|
34
|
+
retryDelay: 8000,
|
|
35
|
+
retryBackoffMultiplier: 2.0,
|
|
36
|
+
maxRetryDelay: 120000,
|
|
39
37
|
maxMsgRetryCount: 3,
|
|
40
|
-
memoryThreshold: 0.85,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
"description": "
|
|
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",
|