dibosockets 1.0.2 → 1.0.3
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/WAProto/WAProto.proto +4775 -5619
- package/lib/Defaults/baileys-version.json +3 -3
- package/lib/Defaults/index.js +106 -122
- package/lib/Socket/RHandler.js +530 -448
- package/lib/Socket/business.js +260 -266
- package/lib/Socket/chats.js +908 -1137
- package/lib/Socket/index.js +10 -43
- package/lib/Socket/messages-recv.js +1054 -1065
- package/lib/Socket/messages-send.js +903 -881
- package/lib/Socket/newsletter.js +303 -286
- package/lib/Socket/socket.js +654 -666
- package/lib/Store/make-in-memory-store.js +439 -439
- package/lib/Types/Newsletter.js +38 -18
- package/lib/Utils/baileys-event-stream.js +63 -63
- package/lib/Utils/event-buffer.js +518 -518
- package/lib/Utils/generics.js +428 -432
- package/lib/Utils/index.js +36 -36
- package/lib/Utils/messages-media.js +887 -926
- package/lib/Utils/messages.js +1030 -1105
- package/lib/Utils/process-message.js +385 -404
- package/lib/Utils/use-multi-file-auth-state.js +125 -122
- package/lib/Utils/validate-connection.js +173 -229
- package/lib/WABinary/jid-utils.js +83 -85
- package/lib/index.js +86 -74
- package/package.json +2 -2
- package/lib/Api/Internet/growagarden.js +0 -28
- package/lib/Api/creator.json +0 -13
- package/lib/Api/downloader/tiktokdownload.js +0 -132
- package/lib/Api/index.js +0 -38
- package/lib/Api/nsfw/loli.js +0 -79
- package/lib/Api/stalker/githubstalk.js +0 -46
- package/lib/Api/stalker/stalkroblox.js +0 -94
- package/lib/Api/stalker/tiktokstalk.js +0 -68
- package/lib/Api/tools/ssweb.js +0 -38
- package/lib/Defaults/phonenumber_mcc.json +0 -223
- package/lib/Socket/communities.js +0 -441
- package/lib/Utils/async-iterable.js +0 -41
- package/lib/Utils/browser-utils.js +0 -35
- package/lib/Utils/message-retry-manager.js +0 -128
- package/lib/Utils/resolveJid.js +0 -52
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toAsyncIterable = void 0;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Helper by @rexxhayanasi to convert various media inputs into an Async Iterable
|
|
7
|
-
* Compatible with Baileys buffer/stream handling
|
|
8
|
-
*/
|
|
9
|
-
function toAsyncIterable(input) {
|
|
10
|
-
if (!input) {
|
|
11
|
-
throw new Error("Invalid media stream (undefined/null)");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (input[Symbol.asyncIterator]) {
|
|
15
|
-
return input;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (Buffer.isBuffer(input)) {
|
|
20
|
-
return (async function* () {
|
|
21
|
-
yield input;
|
|
22
|
-
})();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (typeof input === "string") {
|
|
26
|
-
const fs = require("fs");
|
|
27
|
-
return fs.createReadStream(input);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof input.on === "function") {
|
|
31
|
-
return (async function* () {
|
|
32
|
-
for await (const chunk of input) {
|
|
33
|
-
yield chunk;
|
|
34
|
-
}
|
|
35
|
-
})();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
throw new Error("Unsupported media stream type");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.toAsyncIterable = toAsyncIterable;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlatformId = exports.Browsers = void 0;
|
|
4
|
-
|
|
5
|
-
const os = require("os");
|
|
6
|
-
const { proto } = require("../../WAProto/index.js");
|
|
7
|
-
|
|
8
|
-
const PLATFORM_MAP = {
|
|
9
|
-
'aix': 'AIX',
|
|
10
|
-
'darwin': 'Mac OS',
|
|
11
|
-
'win32': 'Windows',
|
|
12
|
-
'android': 'Android',
|
|
13
|
-
'freebsd': 'FreeBSD',
|
|
14
|
-
'openbsd': 'OpenBSD',
|
|
15
|
-
'sunos': 'Solaris',
|
|
16
|
-
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
17
|
-
'haiku': undefined,
|
|
18
|
-
'cygwin': undefined,
|
|
19
|
-
'netbsd': undefined
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
|
|
23
|
-
// Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
|
|
24
|
-
exports.Browsers = (browser) => {
|
|
25
|
-
const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
|
|
26
|
-
const osRelease = os.release(); // Ambil versi OS real-time
|
|
27
|
-
return [osName, browser, osRelease];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getPlatformId = (browser) => {
|
|
31
|
-
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
32
|
-
return platformType ? platformType.toString() : '1'; // Default Chrome
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.getPlatformId = getPlatformId;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageRetryManager = void 0;
|
|
4
|
-
|
|
5
|
-
const lru_cache_1 = require("lru-cache");
|
|
6
|
-
|
|
7
|
-
const RECENT_MESSAGES_SIZE = 512;
|
|
8
|
-
|
|
9
|
-
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000;
|
|
10
|
-
|
|
11
|
-
const PHONE_REQUEST_DELAY = 3000;
|
|
12
|
-
|
|
13
|
-
class MessageRetryManager {
|
|
14
|
-
constructor(logger, maxMsgRetryCount) {
|
|
15
|
-
this.logger = logger;
|
|
16
|
-
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
17
|
-
this._recentMessagesMap = new lru_cache_1.LRUCache({
|
|
18
|
-
max: RECENT_MESSAGES_SIZE
|
|
19
|
-
});
|
|
20
|
-
this._sessionRecreateHistory = new lru_cache_1.LRUCache({
|
|
21
|
-
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
22
|
-
ttlAutopurge: true
|
|
23
|
-
});
|
|
24
|
-
this._retryCounters = new lru_cache_1.LRUCache({
|
|
25
|
-
ttl: 15 * 60 * 1000,
|
|
26
|
-
ttlAutopurge: true,
|
|
27
|
-
updateAgeOnGet: true
|
|
28
|
-
});
|
|
29
|
-
this._pendingPhoneRequests = {};
|
|
30
|
-
this.statistics = {
|
|
31
|
-
totalRetries: 0,
|
|
32
|
-
successfulRetries: 0,
|
|
33
|
-
failedRetries: 0,
|
|
34
|
-
mediaRetries: 0,
|
|
35
|
-
sessionRecreations: 0,
|
|
36
|
-
phoneRequests: 0
|
|
37
|
-
};
|
|
38
|
-
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
39
|
-
}
|
|
40
|
-
addRecentMessage(to, id, message) {
|
|
41
|
-
const key = { to, id };
|
|
42
|
-
const keyStr = this._keyToString(key);
|
|
43
|
-
this._recentMessagesMap.set(keyStr, {
|
|
44
|
-
message,
|
|
45
|
-
timestamp: Date.now()
|
|
46
|
-
});
|
|
47
|
-
this.logger.debug(`Added message to retry cache: ${to}/${id}`);
|
|
48
|
-
}
|
|
49
|
-
getRecentMessage(to, id) {
|
|
50
|
-
const key = { to, id };
|
|
51
|
-
const keyStr = this._keyToString(key);
|
|
52
|
-
return this._recentMessagesMap.get(keyStr);
|
|
53
|
-
}
|
|
54
|
-
shouldRecreateSession(jid, retryCount, hasSession) {
|
|
55
|
-
if (!hasSession) {
|
|
56
|
-
this._sessionRecreateHistory.set(jid, Date.now());
|
|
57
|
-
this.statistics.sessionRecreations++;
|
|
58
|
-
return {
|
|
59
|
-
reason: "we don't have a Signal session with them",
|
|
60
|
-
recreate: true
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (retryCount < 2) {
|
|
64
|
-
return { reason: '', recreate: false };
|
|
65
|
-
}
|
|
66
|
-
const now = Date.now();
|
|
67
|
-
const prevTime = this._sessionRecreateHistory.get(jid);
|
|
68
|
-
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
69
|
-
this._sessionRecreateHistory.set(jid, now);
|
|
70
|
-
this.statistics.sessionRecreations++;
|
|
71
|
-
return {
|
|
72
|
-
reason: 'retry count > 1 and over an hour since last recreation',
|
|
73
|
-
recreate: true
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return { reason: '', recreate: false };
|
|
77
|
-
}
|
|
78
|
-
incrementRetryCount(messageId) {
|
|
79
|
-
this._retryCounters.set(messageId, (this._retryCounters.get(messageId) || 0) + 1);
|
|
80
|
-
this.statistics.totalRetries++;
|
|
81
|
-
return this._retryCounters.get(messageId);
|
|
82
|
-
}
|
|
83
|
-
getRetryCount(messageId) {
|
|
84
|
-
return this._retryCounters.get(messageId) || 0;
|
|
85
|
-
}
|
|
86
|
-
hasExceededMaxRetries(messageId) {
|
|
87
|
-
return this.getRetryCount(messageId) >= this.maxMsgRetryCount;
|
|
88
|
-
}
|
|
89
|
-
markRetrySuccess(messageId) {
|
|
90
|
-
this.statistics.successfulRetries++;
|
|
91
|
-
this._retryCounters.delete(messageId);
|
|
92
|
-
this._cancelPendingPhoneRequest(messageId);
|
|
93
|
-
}
|
|
94
|
-
markRetryFailed(messageId) {
|
|
95
|
-
this.statistics.failedRetries++;
|
|
96
|
-
this._retryCounters.delete(messageId);
|
|
97
|
-
}
|
|
98
|
-
schedulePhoneRequest(messageId, callback, delay = PHONE_REQUEST_DELAY) {
|
|
99
|
-
this._cancelPendingPhoneRequest(messageId);
|
|
100
|
-
this._pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
101
|
-
delete this._pendingPhoneRequests[messageId];
|
|
102
|
-
this.statistics.phoneRequests++;
|
|
103
|
-
callback();
|
|
104
|
-
}, delay);
|
|
105
|
-
this.logger.debug(`Scheduled phone request for message ${messageId} with ${delay}ms delay`);
|
|
106
|
-
}
|
|
107
|
-
cancelPendingPhoneRequest(messageId) {
|
|
108
|
-
const timeout = this._pendingPhoneRequests[messageId];
|
|
109
|
-
if (timeout) {
|
|
110
|
-
clearTimeout(timeout);
|
|
111
|
-
delete this._pendingPhoneRequests[messageId];
|
|
112
|
-
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
_keyToString(key) {
|
|
116
|
-
return `${key.to}:${key.id}`;
|
|
117
|
-
}
|
|
118
|
-
_cancelPendingPhoneRequest(messageId) {
|
|
119
|
-
const timeout = this._pendingPhoneRequests[messageId];
|
|
120
|
-
if (timeout) {
|
|
121
|
-
clearTimeout(timeout);
|
|
122
|
-
delete this._pendingPhoneRequests[messageId];
|
|
123
|
-
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
exports.MessageRetryManager = MessageRetryManager;
|
package/lib/Utils/resolveJid.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.resolveJid = resolveJid;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
Resolve LID / raw id menjadi JID WhatsApp asli
|
|
8
|
-
@param {import('@rexxhayanasi/elaina-baileys').WASocket} conn
|
|
9
|
-
@param {any} m
|
|
10
|
-
@param {string|null} target
|
|
11
|
-
@returns {Promise<string|null>}
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
async function resolveJid(conn, m, target) {
|
|
15
|
-
let input =
|
|
16
|
-
target ||
|
|
17
|
-
(m.mentionedJid && m.mentionedJid[0]) ||
|
|
18
|
-
(m.quoted && m.quoted.sender) ||
|
|
19
|
-
m.sender;
|
|
20
|
-
|
|
21
|
-
if (!input) return null;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (/@s.whatsapp.net$/.test(input))
|
|
25
|
-
return input;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!m.isGroup || !m.chat)
|
|
29
|
-
return null;
|
|
30
|
-
|
|
31
|
-
let meta;
|
|
32
|
-
try {
|
|
33
|
-
meta = await conn.groupMetadata(m.chat);
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!meta || !Array.isArray(meta.participants))
|
|
39
|
-
return null;
|
|
40
|
-
|
|
41
|
-
const participant = meta.participants.find(p =>
|
|
42
|
-
p.jid === input ||
|
|
43
|
-
p.id === input ||
|
|
44
|
-
p.lid === input ||
|
|
45
|
-
(typeof input === "string" && input.replace(/@lid$/, "") === p.lid?.replace(/@lid$/, ""))
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
if (participant && participant.jid)
|
|
49
|
-
return participant.jid;
|
|
50
|
-
|
|
51
|
-
return null;
|
|
52
|
-
}
|