@realvare/based 2.5.7 → 2.5.8
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 +1288 -1544
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Socket/messages-recv.js +0 -29
- package/lib/Socket/messages-send.js +1406 -1410
- package/lib/Socket/socket.js +1 -1
- package/lib/Types/Message.d.ts +413 -413
- package/lib/Utils/cache-manager.js +1 -16
- package/lib/Utils/messages.js +1338 -1373
- package/lib/Utils/performance-config.d.ts +0 -4
- package/lib/Utils/performance-config.js +4 -8
- package/package.json +6 -3
- package/lib/Utils/rate-limiter.js +0 -95
|
@@ -18,10 +18,6 @@ export interface PerformanceSettings {
|
|
|
18
18
|
maxRetryDelay: number;
|
|
19
19
|
maxMsgRetryCount: number;
|
|
20
20
|
memoryThreshold: number;
|
|
21
|
-
// Anti-ban specific settings
|
|
22
|
-
markOnlineOnConnect?: boolean;
|
|
23
|
-
syncFullHistory?: boolean;
|
|
24
|
-
keepAliveIntervalMs?: number;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
export interface DebugSettings {
|
|
@@ -26,22 +26,18 @@ class PerformanceConfig {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
// Performance settings
|
|
29
|
+
// Performance settings
|
|
30
30
|
this.performance = {
|
|
31
31
|
enableCache: true,
|
|
32
32
|
enableLogging: false,
|
|
33
33
|
enableMetrics: true,
|
|
34
|
-
batchSize:
|
|
35
|
-
maxRetries:
|
|
34
|
+
batchSize: 50,
|
|
35
|
+
maxRetries: 5,
|
|
36
36
|
retryDelay: 5000,
|
|
37
37
|
retryBackoffMultiplier: 1.5,
|
|
38
38
|
maxRetryDelay: 60000,
|
|
39
39
|
maxMsgRetryCount: 3,
|
|
40
|
-
memoryThreshold: 0.85
|
|
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
|
|
40
|
+
memoryThreshold: 0.85 // 85% memory usage threshold
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
// Debug settings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realvare/based",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "whatsapp api by sam",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
|
38
38
|
"preinstall": "node ./engine-requirements.js",
|
|
39
39
|
"release": "release-it",
|
|
40
|
-
"test": "
|
|
40
|
+
"test": "jest"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
@@ -97,6 +97,9 @@
|
|
|
97
97
|
"link-preview-js": {
|
|
98
98
|
"optional": true
|
|
99
99
|
},
|
|
100
|
+
"qrcode-terminal": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
100
103
|
"sharp": {
|
|
101
104
|
"optional": true
|
|
102
105
|
}
|
|
@@ -105,4 +108,4 @@
|
|
|
105
108
|
"engines": {
|
|
106
109
|
"node": ">=20.0.0"
|
|
107
110
|
}
|
|
108
|
-
}
|
|
111
|
+
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* RateLimiter class for controlling message sending frequency
|
|
5
|
-
* to prevent ban detection by simulating human-like behavior
|
|
6
|
-
*/
|
|
7
|
-
class RateLimiter {
|
|
8
|
-
constructor(limitPerSecond = 1) {
|
|
9
|
-
this.limitPerSecond = limitPerSecond;
|
|
10
|
-
this.interval = 1000 / limitPerSecond; // milliseconds between messages
|
|
11
|
-
this.queue = [];
|
|
12
|
-
this.processing = false;
|
|
13
|
-
this.lastSendTime = 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Add a task to the rate limiting queue
|
|
18
|
-
* @param {Function} task - Async function to execute
|
|
19
|
-
* @returns {Promise} - Promise that resolves when task is complete
|
|
20
|
-
*/
|
|
21
|
-
async add(task) {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
this.queue.push({ task, resolve, reject });
|
|
24
|
-
if (!this.processing) {
|
|
25
|
-
this.process();
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Process the queue with rate limiting
|
|
32
|
-
*/
|
|
33
|
-
async process() {
|
|
34
|
-
if (this.processing || this.queue.length === 0) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.processing = true;
|
|
39
|
-
|
|
40
|
-
while (this.queue.length > 0) {
|
|
41
|
-
const { task, resolve, reject } = this.queue.shift();
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
const timeSinceLastSend = now - this.lastSendTime;
|
|
44
|
-
|
|
45
|
-
// Wait if we need to respect the rate limit
|
|
46
|
-
if (timeSinceLastSend < this.interval) {
|
|
47
|
-
const waitTime = this.interval - timeSinceLastSend;
|
|
48
|
-
await new Promise(r => setTimeout(r, waitTime));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const result = await task();
|
|
53
|
-
this.lastSendTime = Date.now();
|
|
54
|
-
resolve(result);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
reject(error);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Add small random delay to simulate human behavior (0-500ms)
|
|
60
|
-
const randomDelay = Math.random() * 500;
|
|
61
|
-
await new Promise(r => setTimeout(r, randomDelay));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.processing = false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Update the rate limit
|
|
69
|
-
* @param {number} newLimit - New messages per second limit
|
|
70
|
-
*/
|
|
71
|
-
setLimit(newLimit) {
|
|
72
|
-
this.limitPerSecond = newLimit;
|
|
73
|
-
this.interval = 1000 / newLimit;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get current queue length
|
|
78
|
-
* @returns {number} - Number of pending tasks
|
|
79
|
-
*/
|
|
80
|
-
getQueueLength() {
|
|
81
|
-
return this.queue.length;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Clear all pending tasks
|
|
86
|
-
*/
|
|
87
|
-
clear() {
|
|
88
|
-
this.queue.forEach(({ reject }) => {
|
|
89
|
-
reject(new Error('Rate limiter cleared'));
|
|
90
|
-
});
|
|
91
|
-
this.queue = [];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = RateLimiter;
|