@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/storage-internal.js
CHANGED
|
@@ -1,209 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ═══════════════════════════════════════════════════════════════
|
|
4
|
-
* INTERNAL FILE STORAGE - Local JSON-based session storage
|
|
5
|
-
* Stores up to 50 sessions in local database.json file
|
|
6
|
-
* ═══════════════════════════════════════════════════════════════
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FileStorage = void 0;
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
const path_1 = __importDefault(require("path"));
|
|
15
|
-
class FileStorage {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.users = new Map();
|
|
18
|
-
this.sessions = new Map();
|
|
19
|
-
this.botSettings = new Map();
|
|
20
|
-
this.groupSettings = new Map();
|
|
21
|
-
this.economyUsers = new Map();
|
|
22
|
-
this.currentId = 0;
|
|
23
|
-
// Use process.cwd() to ensure path is always the project root, independent of build structure
|
|
24
|
-
this.filePath = path_1.default.join(process.cwd(), "database.json");
|
|
25
|
-
this.initialized = false;
|
|
26
|
-
this.initPromise = null;
|
|
27
|
-
this.saveTimeout = null;
|
|
28
|
-
this.SAVE_DEBOUNCE_MS = 2000; // 2 Seconds Debounce
|
|
29
|
-
// Start init but don't block constructor
|
|
30
|
-
this.initPromise = this.init();
|
|
31
|
-
}
|
|
32
|
-
async init() {
|
|
33
|
-
if (this.initialized)
|
|
34
|
-
return;
|
|
35
|
-
try {
|
|
36
|
-
const data = await fs_1.promises.readFile(this.filePath, "utf-8");
|
|
37
|
-
const json = JSON.parse(data);
|
|
38
|
-
this.currentId = json.currentId || 0;
|
|
39
|
-
// Hydrate maps
|
|
40
|
-
this.users = new Map(json.users || []);
|
|
41
|
-
this.sessions = new Map(json.sessions || []);
|
|
42
|
-
this.botSettings = new Map(json.botSettings || []);
|
|
43
|
-
this.groupSettings = new Map(json.groupSettings || []);
|
|
44
|
-
this.economyUsers = new Map(json.economyUsers || []);
|
|
45
|
-
console.log(`[INTERNAL] Database loaded: ${this.sessions.size} sessions.`);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
console.log("[INTERNAL] No local database found, starting fresh.");
|
|
49
|
-
}
|
|
50
|
-
this.initialized = true;
|
|
51
|
-
}
|
|
52
|
-
// Ensure init is complete before any operation
|
|
53
|
-
async ensureInit() {
|
|
54
|
-
if (this.initPromise) {
|
|
55
|
-
await this.initPromise;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async save() {
|
|
59
|
-
if (this.saveTimeout)
|
|
60
|
-
return; // Save already scheduled
|
|
61
|
-
this.saveTimeout = setTimeout(async () => {
|
|
62
|
-
try {
|
|
63
|
-
// console.log("[INTERNAL] Saving database...");
|
|
64
|
-
const data = JSON.stringify({
|
|
65
|
-
currentId: this.currentId,
|
|
66
|
-
users: Array.from(this.users.entries()),
|
|
67
|
-
sessions: Array.from(this.sessions.entries()),
|
|
68
|
-
botSettings: Array.from(this.botSettings.entries()),
|
|
69
|
-
groupSettings: Array.from(this.groupSettings.entries()),
|
|
70
|
-
economyUsers: Array.from(this.economyUsers.entries())
|
|
71
|
-
}, null, 2);
|
|
72
|
-
await fs_1.promises.writeFile(this.filePath, data);
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
console.error("[INTERNAL] Failed to save database:", e);
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
this.saveTimeout = null;
|
|
79
|
-
}
|
|
80
|
-
}, this.SAVE_DEBOUNCE_MS);
|
|
81
|
-
}
|
|
82
|
-
// ═══════════════════════════════════════════════════════════════
|
|
83
|
-
// USER OPERATIONS
|
|
84
|
-
// ═══════════════════════════════════════════════════════════════
|
|
85
|
-
async getUser(id) {
|
|
86
|
-
return Array.from(this.users.values()).find(u => u.id.toString() === id);
|
|
87
|
-
}
|
|
88
|
-
async getUserByUsername(username) {
|
|
89
|
-
return Array.from(this.users.values()).find(u => u.username === username);
|
|
90
|
-
}
|
|
91
|
-
async createUser(insertUser) {
|
|
92
|
-
const id = (++this.currentId).toString();
|
|
93
|
-
const user = { ...insertUser, id, createdAt: new Date() };
|
|
94
|
-
this.users.set(id.toString(), user);
|
|
95
|
-
await this.save();
|
|
96
|
-
return user;
|
|
97
|
-
}
|
|
98
|
-
// ═══════════════════════════════════════════════════════════════
|
|
99
|
-
// SESSION OPERATIONS
|
|
100
|
-
// ═══════════════════════════════════════════════════════════════
|
|
101
|
-
async getSession(id) {
|
|
102
|
-
await this.ensureInit();
|
|
103
|
-
return this.sessions.get(id);
|
|
104
|
-
}
|
|
105
|
-
async getSessionByPhone(phoneNumber) {
|
|
106
|
-
await this.ensureInit();
|
|
107
|
-
return Array.from(this.sessions.values()).find(s => s.phoneNumber === phoneNumber);
|
|
108
|
-
}
|
|
109
|
-
async createSession(session) {
|
|
110
|
-
await this.ensureInit();
|
|
111
|
-
const id = session.id;
|
|
112
|
-
const newSession = { ...session, createdAt: new Date(), updatedAt: new Date() };
|
|
113
|
-
this.sessions.set(id, newSession);
|
|
114
|
-
await this.save();
|
|
115
|
-
return newSession;
|
|
116
|
-
}
|
|
117
|
-
async updateSession(id, data) {
|
|
118
|
-
await this.ensureInit();
|
|
119
|
-
const session = this.sessions.get(id);
|
|
120
|
-
if (!session)
|
|
121
|
-
return undefined;
|
|
122
|
-
const updated = { ...session, ...data, updatedAt: new Date() };
|
|
123
|
-
this.sessions.set(id, updated);
|
|
124
|
-
await this.save();
|
|
125
|
-
return updated;
|
|
126
|
-
}
|
|
127
|
-
async deleteSession(id) {
|
|
128
|
-
await this.ensureInit();
|
|
129
|
-
this.sessions.delete(id);
|
|
130
|
-
await this.save();
|
|
131
|
-
}
|
|
132
|
-
async getAllSessions() {
|
|
133
|
-
await this.ensureInit();
|
|
134
|
-
return Array.from(this.sessions.values());
|
|
135
|
-
}
|
|
136
|
-
// ═══════════════════════════════════════════════════════════════
|
|
137
|
-
// BOT SETTINGS OPERATIONS
|
|
138
|
-
// ═══════════════════════════════════════════════════════════════
|
|
139
|
-
async getBotSettings(sessionId) {
|
|
140
|
-
return Array.from(this.botSettings.values()).find(s => s.sessionId === sessionId);
|
|
141
|
-
}
|
|
142
|
-
async createBotSettings(settings) {
|
|
143
|
-
const id = (++this.currentId).toString();
|
|
144
|
-
const newSettings = { ...settings, id, createdAt: new Date(), updatedAt: new Date() };
|
|
145
|
-
this.botSettings.set(id, newSettings);
|
|
146
|
-
await this.save();
|
|
147
|
-
return newSettings;
|
|
148
|
-
}
|
|
149
|
-
async updateBotSettings(id, data) {
|
|
150
|
-
const settings = this.botSettings.get(id);
|
|
151
|
-
if (!settings)
|
|
152
|
-
return undefined;
|
|
153
|
-
const updated = { ...settings, ...data, updatedAt: new Date() };
|
|
154
|
-
this.botSettings.set(id, updated);
|
|
155
|
-
await this.save();
|
|
156
|
-
return updated;
|
|
157
|
-
}
|
|
158
|
-
// ═══════════════════════════════════════════════════════════════
|
|
159
|
-
// GROUP SETTINGS OPERATIONS
|
|
160
|
-
// ═══════════════════════════════════════════════════════════════
|
|
161
|
-
async getGroupSettings(groupId) {
|
|
162
|
-
return Array.from(this.groupSettings.values()).find(s => s.groupId === groupId);
|
|
163
|
-
}
|
|
164
|
-
async createGroupSettings(settings) {
|
|
165
|
-
const id = (++this.currentId).toString();
|
|
166
|
-
const newSettings = { ...settings, id, createdAt: new Date(), updatedAt: new Date() };
|
|
167
|
-
this.groupSettings.set(id, newSettings);
|
|
168
|
-
await this.save();
|
|
169
|
-
return newSettings;
|
|
170
|
-
}
|
|
171
|
-
async updateGroupSettings(groupId, data) {
|
|
172
|
-
await this.ensureInit();
|
|
173
|
-
let settings = Array.from(this.groupSettings.values()).find(s => s.groupId === groupId);
|
|
174
|
-
if (!settings) {
|
|
175
|
-
// UPSERT: Create new record if it doesn't exist
|
|
176
|
-
console.log(`[INTERNAL] Creating new GroupSettings for ${groupId}`);
|
|
177
|
-
const id = (++this.currentId).toString();
|
|
178
|
-
settings = { groupId, ...data, id };
|
|
179
|
-
this.groupSettings.set(id, settings);
|
|
180
|
-
await this.save();
|
|
181
|
-
return settings;
|
|
182
|
-
}
|
|
183
|
-
const updated = { ...settings, ...data, updatedAt: new Date() };
|
|
184
|
-
this.groupSettings.set(settings.id?.toString() || groupId, updated);
|
|
185
|
-
await this.save();
|
|
186
|
-
return updated;
|
|
187
|
-
}
|
|
188
|
-
// ═══════════════════════════════════════════════════════════════
|
|
189
|
-
// ECONOMY OPERATIONS
|
|
190
|
-
// ═══════════════════════════════════════════════════════════════
|
|
191
|
-
async getEconomyUser(userJid) {
|
|
192
|
-
return this.economyUsers.get(userJid);
|
|
193
|
-
}
|
|
194
|
-
async createEconomyUser(user) {
|
|
195
|
-
this.economyUsers.set(user.userJid, user);
|
|
196
|
-
await this.save();
|
|
197
|
-
return user;
|
|
198
|
-
}
|
|
199
|
-
async updateEconomyUser(userJid, data) {
|
|
200
|
-
const user = this.economyUsers.get(userJid);
|
|
201
|
-
if (!user)
|
|
202
|
-
return undefined;
|
|
203
|
-
const updated = { ...user, ...data };
|
|
204
|
-
this.economyUsers.set(userJid, updated);
|
|
205
|
-
await this.save();
|
|
206
|
-
return updated;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.FileStorage = FileStorage;
|
|
1
|
+
'use strict';const _0x35c024=_0x6d02;(function(_0x496374,_0x90558b){const _0x1afc55=_0x6d02,_0x48e727=_0x496374();while(!![]){try{const _0x2226e6=parseInt(_0x1afc55(0x9a))/0x1+-parseInt(_0x1afc55(0x83))/0x2+parseInt(_0x1afc55(0x6d))/0x3+parseInt(_0x1afc55(0x72))/0x4*(parseInt(_0x1afc55(0xa4))/0x5)+parseInt(_0x1afc55(0x92))/0x6+-parseInt(_0x1afc55(0x9f))/0x7*(parseInt(_0x1afc55(0x88))/0x8)+-parseInt(_0x1afc55(0x97))/0x9;if(_0x2226e6===_0x90558b)break;else _0x48e727['push'](_0x48e727['shift']());}catch(_0x55c74d){_0x48e727['push'](_0x48e727['shift']());}}}(_0x3064,0x228dc));var __importDefault=this&&this[_0x35c024(0xa8)]||function(_0xdd5c4f){return _0xdd5c4f&&_0xdd5c4f['__esModule']?_0xdd5c4f:{'default':_0xdd5c4f};};Object[_0x35c024(0x77)](exports,_0x35c024(0x8a),{'value':!![]}),exports['FileStorage']=void 0x0;const fs_1=require('fs'),path_1=__importDefault(require(_0x35c024(0x9e)));class FileStorage{constructor(){const _0x1a814a=_0x35c024,_0x572e22=_0x1a814a(0x7c)['split']('|');let _0x283c72=0x0;while(!![]){switch(_0x572e22[_0x283c72++]){case'0':this['initialized']=![];continue;case'1':this[_0x1a814a(0x7e)]=null;continue;case'2':this[_0x1a814a(0xa2)]=new Map();continue;case'3':this['groupSettings']=new Map();continue;case'4':this[_0x1a814a(0x7a)]=new Map();continue;case'5':this[_0x1a814a(0xaa)]=0x7d0;continue;case'6':this[_0x1a814a(0x85)]=new Map();continue;case'7':this[_0x1a814a(0x7e)]=this[_0x1a814a(0xa7)]();continue;case'8':this['currentId']=0x0;continue;case'9':this[_0x1a814a(0x87)]=new Map();continue;case'10':this[_0x1a814a(0x93)]=null;continue;case'11':this['filePath']=path_1['default']['join'](process[_0x1a814a(0x75)](),'database.json');continue;}break;}}async[_0x35c024(0xa7)](){const _0x1f3ff2=_0x35c024;if(this[_0x1f3ff2(0xa9)])return;try{const _0x2173f1=await fs_1[_0x1f3ff2(0xa1)][_0x1f3ff2(0x8d)](this['filePath'],'utf-8'),_0x16dc86=JSON['parse'](_0x2173f1);this[_0x1f3ff2(0x98)]=_0x16dc86[_0x1f3ff2(0x98)]||0x0,this[_0x1f3ff2(0x85)]=new Map(_0x16dc86[_0x1f3ff2(0x85)]||[]),this['sessions']=new Map(_0x16dc86['sessions']||[]),this['botSettings']=new Map(_0x16dc86[_0x1f3ff2(0x7a)]||[]),this[_0x1f3ff2(0x74)]=new Map(_0x16dc86['groupSettings']||[]),this[_0x1f3ff2(0x87)]=new Map(_0x16dc86[_0x1f3ff2(0x87)]||[]),console['log'](_0x1f3ff2(0x82)+this[_0x1f3ff2(0xa2)][_0x1f3ff2(0x6e)]+_0x1f3ff2(0x8c));}catch(_0x449943){console[_0x1f3ff2(0x89)](_0x1f3ff2(0xa0));}this[_0x1f3ff2(0xa9)]=!![];}async[_0x35c024(0x96)](){const _0x2980c8=_0x35c024;if(this[_0x2980c8(0x7e)]){if(_0x2980c8(0x84)!==_0x2980c8(0x84))return _0x254c39[_0x2980c8(0x9c)](this['botSettings'][_0x2980c8(0x99)]())[_0x2980c8(0x9b)](_0x32d129=>_0x32d129[_0x2980c8(0x7b)]===_0x5c0bea);else await this[_0x2980c8(0x7e)];}}async[_0x35c024(0x90)](){const _0x37f743=_0x35c024,_0x173f72={'HDxot':'[INTERNAL]\x20Failed\x20to\x20save\x20database:'};if(this[_0x37f743(0x93)])return;this[_0x37f743(0x93)]=setTimeout(async()=>{const _0x3c07f0=_0x37f743;try{const _0x450295=JSON['stringify']({'currentId':this[_0x3c07f0(0x98)],'users':Array[_0x3c07f0(0x9c)](this[_0x3c07f0(0x85)][_0x3c07f0(0x7d)]()),'sessions':Array['from'](this[_0x3c07f0(0xa2)][_0x3c07f0(0x7d)]()),'botSettings':Array[_0x3c07f0(0x9c)](this['botSettings'][_0x3c07f0(0x7d)]()),'groupSettings':Array[_0x3c07f0(0x9c)](this[_0x3c07f0(0x74)]['entries']()),'economyUsers':Array[_0x3c07f0(0x9c)](this[_0x3c07f0(0x87)][_0x3c07f0(0x7d)]())},null,0x2);await fs_1['promises'][_0x3c07f0(0xa6)](this[_0x3c07f0(0x9d)],_0x450295);}catch(_0x1c9bed){console['error'](_0x173f72['HDxot'],_0x1c9bed);}finally{this['saveTimeout']=null;}},this[_0x37f743(0xaa)]);}async[_0x35c024(0x94)](_0x1c7b06){const _0x3598dd=_0x35c024;return Array[_0x3598dd(0x9c)](this[_0x3598dd(0x85)]['values']())['find'](_0x3c9158=>_0x3c9158['id'][_0x3598dd(0x70)]()===_0x1c7b06);}async['getUserByUsername'](_0x23feef){const _0x16eea9=_0x35c024;return Array[_0x16eea9(0x9c)](this['users'][_0x16eea9(0x99)]())['find'](_0x2aeae5=>_0x2aeae5[_0x16eea9(0x8f)]===_0x23feef);}async[_0x35c024(0x73)](_0x6ea46a){const _0x3b77b8=_0x35c024,_0x522514=(++this[_0x3b77b8(0x98)])[_0x3b77b8(0x70)](),_0x248fdd={..._0x6ea46a,'id':_0x522514,'createdAt':new Date()};return this['users'][_0x3b77b8(0x79)](_0x522514['toString'](),_0x248fdd),await this[_0x3b77b8(0x90)](),_0x248fdd;}async['getSession'](_0x121853){const _0x1cb9c7=_0x35c024;return await this[_0x1cb9c7(0x96)](),this[_0x1cb9c7(0xa2)][_0x1cb9c7(0x80)](_0x121853);}async[_0x35c024(0x6f)](_0x265b15){const _0x37a2f1=_0x35c024;return await this[_0x37a2f1(0x96)](),Array[_0x37a2f1(0x9c)](this[_0x37a2f1(0xa2)]['values']())[_0x37a2f1(0x9b)](_0x154f61=>_0x154f61['phoneNumber']===_0x265b15);}async['createSession'](_0x53c47f){const _0x333924=_0x35c024;await this[_0x333924(0x96)]();const _0xb04d12=_0x53c47f['id'],_0x175fde={..._0x53c47f,'createdAt':new Date(),'updatedAt':new Date()};return this[_0x333924(0xa2)][_0x333924(0x79)](_0xb04d12,_0x175fde),await this[_0x333924(0x90)](),_0x175fde;}async[_0x35c024(0x95)](_0xde65e3,_0x277663){const _0x466de4=_0x35c024;await this['ensureInit']();const _0x54e70f=this[_0x466de4(0xa2)][_0x466de4(0x80)](_0xde65e3);if(!_0x54e70f)return undefined;const _0x5386bd={..._0x54e70f,..._0x277663,'updatedAt':new Date()};return this['sessions']['set'](_0xde65e3,_0x5386bd),await this[_0x466de4(0x90)](),_0x5386bd;}async[_0x35c024(0x76)](_0x535223){const _0x2b9945=_0x35c024;await this[_0x2b9945(0x96)](),this[_0x2b9945(0xa2)][_0x2b9945(0x86)](_0x535223),await this[_0x2b9945(0x90)]();}async[_0x35c024(0xa3)](){const _0x4900b2=_0x35c024;return await this['ensureInit'](),Array['from'](this[_0x4900b2(0xa2)]['values']());}async[_0x35c024(0x8e)](_0x461926){const _0x406469=_0x35c024;return Array[_0x406469(0x9c)](this[_0x406469(0x7a)][_0x406469(0x99)]())[_0x406469(0x9b)](_0x39f980=>_0x39f980[_0x406469(0x7b)]===_0x461926);}async['createBotSettings'](_0x4df08b){const _0x388089=_0x35c024,_0x567fc2=(++this[_0x388089(0x98)])['toString'](),_0x18aa4d={..._0x4df08b,'id':_0x567fc2,'createdAt':new Date(),'updatedAt':new Date()};return this[_0x388089(0x7a)][_0x388089(0x79)](_0x567fc2,_0x18aa4d),await this[_0x388089(0x90)](),_0x18aa4d;}async['updateBotSettings'](_0x5a0772,_0x5a6682){const _0x1f6659=_0x35c024,_0x3ff41e=this[_0x1f6659(0x7a)][_0x1f6659(0x80)](_0x5a0772);if(!_0x3ff41e)return undefined;const _0xd715d2={..._0x3ff41e,..._0x5a6682,'updatedAt':new Date()};return this[_0x1f6659(0x7a)][_0x1f6659(0x79)](_0x5a0772,_0xd715d2),await this['save'](),_0xd715d2;}async['getGroupSettings'](_0x291f33){const _0x148e4b=_0x35c024;return Array['from'](this['groupSettings'][_0x148e4b(0x99)]())[_0x148e4b(0x9b)](_0x149971=>_0x149971[_0x148e4b(0x91)]===_0x291f33);}async[_0x35c024(0x8b)](_0x4dfd07){const _0x252786=_0x35c024,_0x4844df=(++this[_0x252786(0x98)])[_0x252786(0x70)](),_0x2f898b={..._0x4dfd07,'id':_0x4844df,'createdAt':new Date(),'updatedAt':new Date()};return this[_0x252786(0x74)][_0x252786(0x79)](_0x4844df,_0x2f898b),await this[_0x252786(0x90)](),_0x2f898b;}async[_0x35c024(0xab)](_0x59c87a,_0x5a4df5){const _0x5b9d53=_0x35c024;await this[_0x5b9d53(0x96)]();let _0x1a7dd2=Array[_0x5b9d53(0x9c)](this['groupSettings']['values']())['find'](_0x4dad59=>_0x4dad59[_0x5b9d53(0x91)]===_0x59c87a);if(!_0x1a7dd2){console[_0x5b9d53(0x89)](_0x5b9d53(0x7f)+_0x59c87a);const _0x9ca38c=(++this[_0x5b9d53(0x98)])[_0x5b9d53(0x70)]();return _0x1a7dd2={'groupId':_0x59c87a,..._0x5a4df5,'id':_0x9ca38c},this[_0x5b9d53(0x74)]['set'](_0x9ca38c,_0x1a7dd2),await this[_0x5b9d53(0x90)](),_0x1a7dd2;}const _0x3a0f49={..._0x1a7dd2,..._0x5a4df5,'updatedAt':new Date()};return this[_0x5b9d53(0x74)][_0x5b9d53(0x79)](_0x1a7dd2['id']?.[_0x5b9d53(0x70)]()||_0x59c87a,_0x3a0f49),await this[_0x5b9d53(0x90)](),_0x3a0f49;}async[_0x35c024(0x71)](_0x4f9652){const _0x33c19f=_0x35c024;return this[_0x33c19f(0x87)][_0x33c19f(0x80)](_0x4f9652);}async[_0x35c024(0xa5)](_0x5286de){const _0x2bffcc=_0x35c024;return this[_0x2bffcc(0x87)][_0x2bffcc(0x79)](_0x5286de[_0x2bffcc(0x78)],_0x5286de),await this['save'](),_0x5286de;}async[_0x35c024(0x81)](_0xd3230b,_0x3429b5){const _0x9d606e=_0x35c024,_0x17be4c=this['economyUsers'][_0x9d606e(0x80)](_0xd3230b);if(!_0x17be4c)return undefined;const _0x4213e2={..._0x17be4c,..._0x3429b5};return this[_0x9d606e(0x87)][_0x9d606e(0x79)](_0xd3230b,_0x4213e2),await this[_0x9d606e(0x90)](),_0x4213e2;}}function _0x3064(){const _0x48aae2=['nNWYFdr8m3W5FdH8mtf8mhWXFdeWFdv8nW','zw50CMLLCW','Aw5PDfbYB21PC2u','w0LovevstKfmxsbdCMvHDgLUzYbUzxCGr3jVDxbtzxr0Aw5NCYbMB3iG','z2v0','DxbKyxrLrwnVBM9TEvvZzxi','w0LovevstKfmxsbeyxrHyMfZzsbSB2fKzwq6ia','ntq0ndrOAxvAEwy','t3vhzu8','DxnLCNm','zgvSzxrL','zwnVBM9TEvvZzxjZ','mtu3odrXwuH2CuC','Bg9N','x19LC01VzhvSzq','y3jLyxrLr3jVDxbtzxr0Aw5NCW','ihnLC3nPB25ZlG','CMvHzezPBgu','z2v0qM90u2v0DgLUz3m','DxnLCM5HBwu','C2f2zq','z3jVDxbjza','mtmXnZiWnefYv05Svq','C2f2zvrPBwvVDxq','z2v0vxnLCG','DxbKyxrLu2vZC2LVBG','zw5ZDxjLsw5PDa','nde0mtGZnMf0BLbyqG','y3vYCMvUDeLK','DMfSDwvZ','mtKXnJeXDwTyCfLT','zMLUza','zNjVBq','zMLSzvbHDgG','Cgf0Aa','mJf1rgfkquW','w0LovevstKfmxsboBYbSB2nHBcbKyxrHyMfZzsbMB3vUzcWGC3rHCNrPBMCGzNjLC2GU','ChjVBwLZzxm','C2vZC2LVBNm','z2v0qwXSu2vZC2LVBNm','mteYnujezLH0EG','y3jLyxrLrwnVBM9TEvvZzxi','D3jPDgvgAwXL','Aw5PDa','x19PBxbVCNrezwzHDwX0','Aw5PDgLHBgL6zwq','u0fwrv9erujpvu5drv9nuW','DxbKyxrLr3jVDxbtzxr0Aw5NCW','mJGWmZCXzuHuqwD0','C2L6zq','z2v0u2vZC2LVBKj5ugHVBMu','Dg9tDhjPBMC','z2v0rwnVBM9TEvvZzxi','mJmXnKPPqMfnrG','y3jLyxrLvxnLCG','z3jVDxbtzxr0Aw5NCW','y3DK','zgvSzxrLu2vZC2LVBG','zgvMAw5LuhjVCgvYDhK','DxnLCKPPza','C2v0','yM90u2v0DgLUz3m','C2vZC2LVBKLK'];_0x3064=function(){return _0x48aae2;};return _0x3064();}function _0x6d02(_0x176389,_0x145675){_0x176389=_0x176389-0x6d;const _0x306495=_0x3064();let _0x6d026f=_0x306495[_0x176389];if(_0x6d02['tQIthC']===undefined){var _0x3cf447=function(_0x475a49){const _0x1f5be2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x30b1e8='',_0x2e20a4='';for(let _0xf91751=0x0,_0x3c9554,_0x375bc3,_0x126480=0x0;_0x375bc3=_0x475a49['charAt'](_0x126480++);~_0x375bc3&&(_0x3c9554=_0xf91751%0x4?_0x3c9554*0x40+_0x375bc3:_0x375bc3,_0xf91751++%0x4)?_0x30b1e8+=String['fromCharCode'](0xff&_0x3c9554>>(-0x2*_0xf91751&0x6)):0x0){_0x375bc3=_0x1f5be2['indexOf'](_0x375bc3);}for(let _0x367bca=0x0,_0x796575=_0x30b1e8['length'];_0x367bca<_0x796575;_0x367bca++){_0x2e20a4+='%'+('00'+_0x30b1e8['charCodeAt'](_0x367bca)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2e20a4);};_0x6d02['CajuQH']=_0x3cf447,_0x6d02['celqpR']={},_0x6d02['tQIthC']=!![];}const _0x2c3a1d=_0x306495[0x0],_0xcee4d2=_0x176389+_0x2c3a1d,_0x2233d3=_0x6d02['celqpR'][_0xcee4d2];return!_0x2233d3?(_0x6d026f=_0x6d02['CajuQH'](_0x6d026f),_0x6d02['celqpR'][_0xcee4d2]=_0x6d026f):_0x6d026f=_0x2233d3,_0x6d026f;}exports['FileStorage']=FileStorage;
|
package/src/storage.js
CHANGED
|
@@ -1,90 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storage = exports.TOTAL_MAX_SESSIONS = exports.REDIS_MAX_SESSIONS = exports.INTERNAL_MAX_SESSIONS = exports.DatabaseStorage = void 0;
|
|
4
|
-
const schema_1 = require("@shared/schema");
|
|
5
|
-
const db_1 = require("./db");
|
|
6
|
-
const drizzle_orm_1 = require("drizzle-orm");
|
|
7
|
-
class DatabaseStorage {
|
|
8
|
-
async getUser(id) {
|
|
9
|
-
const [user] = await db_1.db.select().from(schema_1.users).where((0, drizzle_orm_1.eq)(schema_1.users.id, id));
|
|
10
|
-
return user;
|
|
11
|
-
}
|
|
12
|
-
async getUserByUsername(username) {
|
|
13
|
-
const [user] = await db_1.db.select().from(schema_1.users).where((0, drizzle_orm_1.eq)(schema_1.users.username, username));
|
|
14
|
-
return user;
|
|
15
|
-
}
|
|
16
|
-
async createUser(insertUser) {
|
|
17
|
-
const [user] = await db_1.db.insert(schema_1.users).values(insertUser).returning();
|
|
18
|
-
return user;
|
|
19
|
-
}
|
|
20
|
-
async getSession(id) {
|
|
21
|
-
const [session] = await db_1.db.select().from(schema_1.sessions).where((0, drizzle_orm_1.eq)(schema_1.sessions.id, id));
|
|
22
|
-
return session;
|
|
23
|
-
}
|
|
24
|
-
async getSessionByPhone(phoneNumber) {
|
|
25
|
-
const [session] = await db_1.db.select().from(schema_1.sessions).where((0, drizzle_orm_1.eq)(schema_1.sessions.phoneNumber, phoneNumber));
|
|
26
|
-
return session;
|
|
27
|
-
}
|
|
28
|
-
async createSession(session) {
|
|
29
|
-
const [newSession] = await db_1.db.insert(schema_1.sessions).values(session).returning();
|
|
30
|
-
return newSession;
|
|
31
|
-
}
|
|
32
|
-
async updateSession(id, data) {
|
|
33
|
-
const [updated] = await db_1.db.update(schema_1.sessions).set(data).where((0, drizzle_orm_1.eq)(schema_1.sessions.id, id)).returning();
|
|
34
|
-
return updated;
|
|
35
|
-
}
|
|
36
|
-
async deleteSession(id) {
|
|
37
|
-
await db_1.db.delete(schema_1.sessions).where((0, drizzle_orm_1.eq)(schema_1.sessions.id, id));
|
|
38
|
-
}
|
|
39
|
-
async getAllSessions() {
|
|
40
|
-
return await db_1.db.select().from(schema_1.sessions);
|
|
41
|
-
}
|
|
42
|
-
async getBotSettings(sessionId) {
|
|
43
|
-
const [settings] = await db_1.db.select().from(schema_1.botSettings).where((0, drizzle_orm_1.eq)(schema_1.botSettings.sessionId, sessionId));
|
|
44
|
-
return settings;
|
|
45
|
-
}
|
|
46
|
-
async createBotSettings(settings) {
|
|
47
|
-
const [newSettings] = await db_1.db.insert(schema_1.botSettings).values(settings).returning();
|
|
48
|
-
return newSettings;
|
|
49
|
-
}
|
|
50
|
-
async updateBotSettings(id, data) {
|
|
51
|
-
const [updated] = await db_1.db.update(schema_1.botSettings).set(data).where((0, drizzle_orm_1.eq)(schema_1.botSettings.id, id)).returning();
|
|
52
|
-
return updated;
|
|
53
|
-
}
|
|
54
|
-
async getGroupSettings(groupId) {
|
|
55
|
-
const [settings] = await db_1.db.select().from(schema_1.groupSettings).where((0, drizzle_orm_1.eq)(schema_1.groupSettings.groupId, groupId));
|
|
56
|
-
return settings;
|
|
57
|
-
}
|
|
58
|
-
async createGroupSettings(settings) {
|
|
59
|
-
const [newSettings] = await db_1.db.insert(schema_1.groupSettings).values(settings).returning();
|
|
60
|
-
return newSettings;
|
|
61
|
-
}
|
|
62
|
-
async updateGroupSettings(groupId, data) {
|
|
63
|
-
const [updated] = await db_1.db.update(schema_1.groupSettings).set(data).where((0, drizzle_orm_1.eq)(schema_1.groupSettings.groupId, groupId)).returning();
|
|
64
|
-
return updated;
|
|
65
|
-
}
|
|
66
|
-
// Economy Implementation
|
|
67
|
-
async getEconomyUser(userJid) {
|
|
68
|
-
const [user] = await db_1.db.select().from(economyUsers).where((0, drizzle_orm_1.eq)(economyUsers.userJid, userJid));
|
|
69
|
-
return user;
|
|
70
|
-
}
|
|
71
|
-
async createEconomyUser(user) {
|
|
72
|
-
const [newUser] = await db_1.db.insert(economyUsers).values(user).returning();
|
|
73
|
-
return newUser;
|
|
74
|
-
}
|
|
75
|
-
async updateEconomyUser(userJid, data) {
|
|
76
|
-
const [updated] = await db_1.db.update(economyUsers).set(data).where((0, drizzle_orm_1.eq)(economyUsers.userJid, userJid)).returning();
|
|
77
|
-
return updated;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.DatabaseStorage = DatabaseStorage;
|
|
81
|
-
// ═══════════════════════════════════════════════════════════════
|
|
82
|
-
// HYBRID STORAGE - Distributes sessions between internal & Redis
|
|
83
|
-
// - Internal (FileStorage): 50 sessions
|
|
84
|
-
// - Redis: 30 additional sessions
|
|
85
|
-
// ═══════════════════════════════════════════════════════════════
|
|
86
|
-
const hybrid_storage_1 = require("./hybrid-storage");
|
|
87
|
-
Object.defineProperty(exports, "INTERNAL_MAX_SESSIONS", { enumerable: true, get: function () { return hybrid_storage_1.INTERNAL_MAX_SESSIONS; } });
|
|
88
|
-
Object.defineProperty(exports, "REDIS_MAX_SESSIONS", { enumerable: true, get: function () { return hybrid_storage_1.REDIS_MAX_SESSIONS; } });
|
|
89
|
-
Object.defineProperty(exports, "TOTAL_MAX_SESSIONS", { enumerable: true, get: function () { return hybrid_storage_1.TOTAL_MAX_SESSIONS; } });
|
|
90
|
-
exports.storage = hybrid_storage_1.hybridStorage;
|
|
1
|
+
'use strict';const _0x1b6405=_0x32fc;(function(_0x21bd33,_0x19b419){const _0x52604f=_0x32fc,_0x4ed086=_0x21bd33();while(!![]){try{const _0x3f1078=-parseInt(_0x52604f(0x142))/0x1*(parseInt(_0x52604f(0x14c))/0x2)+parseInt(_0x52604f(0x161))/0x3+parseInt(_0x52604f(0x159))/0x4+-parseInt(_0x52604f(0x138))/0x5+parseInt(_0x52604f(0x143))/0x6+-parseInt(_0x52604f(0x133))/0x7*(-parseInt(_0x52604f(0x160))/0x8)+parseInt(_0x52604f(0x14d))/0x9;if(_0x3f1078===_0x19b419)break;else _0x4ed086['push'](_0x4ed086['shift']());}catch(_0x2bc698){_0x4ed086['push'](_0x4ed086['shift']());}}}(_0x2df2,0xa13b3));Object[_0x1b6405(0x13d)](exports,_0x1b6405(0x158),{'value':!![]}),exports[_0x1b6405(0x14b)]=exports[_0x1b6405(0x149)]=exports[_0x1b6405(0x14f)]=exports['INTERNAL_MAX_SESSIONS']=exports[_0x1b6405(0x137)]=void 0x0;const schema_1=require('@shared/schema'),db_1=require('./db'),drizzle_orm_1=require('drizzle-orm');class DatabaseStorage{async['getUser'](_0x528d96){const _0x5362b9=_0x1b6405,[_0x40bdd4]=await db_1['db'][_0x5362b9(0x13a)]()[_0x5362b9(0x135)](schema_1['users'])['where']((0x0,drizzle_orm_1['eq'])(schema_1[_0x5362b9(0x15f)]['id'],_0x528d96));return _0x40bdd4;}async[_0x1b6405(0x15b)](_0x15b8de){const _0x3e7440=_0x1b6405,[_0x30602a]=await db_1['db']['select']()['from'](schema_1['users'])[_0x3e7440(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x3e7440(0x15f)][_0x3e7440(0x153)],_0x15b8de));return _0x30602a;}async[_0x1b6405(0x145)](_0x128d65){const _0x5642ca=_0x1b6405,[_0x548213]=await db_1['db'][_0x5642ca(0x154)](schema_1[_0x5642ca(0x15f)])[_0x5642ca(0x144)](_0x128d65)[_0x5642ca(0x14e)]();return _0x548213;}async[_0x1b6405(0x15c)](_0x1bb95f){const _0x4408c7=_0x1b6405,[_0x17a0ac]=await db_1['db'][_0x4408c7(0x13a)]()[_0x4408c7(0x135)](schema_1[_0x4408c7(0x140)])[_0x4408c7(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x4408c7(0x140)]['id'],_0x1bb95f));return _0x17a0ac;}async[_0x1b6405(0x141)](_0x4a94e5){const _0x32ad3d=_0x1b6405,[_0x4e0ef1]=await db_1['db'][_0x32ad3d(0x13a)]()[_0x32ad3d(0x135)](schema_1[_0x32ad3d(0x140)])[_0x32ad3d(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x32ad3d(0x140)][_0x32ad3d(0x15d)],_0x4a94e5));return _0x4e0ef1;}async[_0x1b6405(0x136)](_0x5a6c4c){const _0x41f74c=_0x1b6405,[_0x55d6bb]=await db_1['db'][_0x41f74c(0x154)](schema_1['sessions'])[_0x41f74c(0x144)](_0x5a6c4c)['returning']();return _0x55d6bb;}async[_0x1b6405(0x13c)](_0x36e977,_0x1d0ddc){const _0x1145aa=_0x1b6405,[_0x388cb6]=await db_1['db'][_0x1145aa(0x14a)](schema_1[_0x1145aa(0x140)])[_0x1145aa(0x150)](_0x1d0ddc)['where']((0x0,drizzle_orm_1['eq'])(schema_1[_0x1145aa(0x140)]['id'],_0x36e977))[_0x1145aa(0x14e)]();return _0x388cb6;}async[_0x1b6405(0x152)](_0x1efcd6){const _0x21741e=_0x1b6405;await db_1['db']['delete'](schema_1[_0x21741e(0x140)])[_0x21741e(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1['sessions']['id'],_0x1efcd6));}async[_0x1b6405(0x13f)](){const _0x187927=_0x1b6405;return await db_1['db'][_0x187927(0x13a)]()['from'](schema_1[_0x187927(0x140)]);}async[_0x1b6405(0x156)](_0x579032){const _0x218d81=_0x1b6405,[_0x493956]=await db_1['db'][_0x218d81(0x13a)]()[_0x218d81(0x135)](schema_1['botSettings'])[_0x218d81(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x218d81(0x13e)]['sessionId'],_0x579032));return _0x493956;}async[_0x1b6405(0x155)](_0x2d1b1a){const _0x4ff2be=_0x1b6405,[_0x10ad34]=await db_1['db'][_0x4ff2be(0x154)](schema_1[_0x4ff2be(0x13e)])[_0x4ff2be(0x144)](_0x2d1b1a)['returning']();return _0x10ad34;}async[_0x1b6405(0x134)](_0x1cfbf9,_0x596e17){const _0x4c6237=_0x1b6405,[_0x39364e]=await db_1['db'][_0x4c6237(0x14a)](schema_1['botSettings'])[_0x4c6237(0x150)](_0x596e17)[_0x4c6237(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x4c6237(0x13e)]['id'],_0x1cfbf9))['returning']();return _0x39364e;}async[_0x1b6405(0x15e)](_0x3b219b){const _0x28e29e=_0x1b6405,[_0x420c54]=await db_1['db']['select']()[_0x28e29e(0x135)](schema_1[_0x28e29e(0x157)])[_0x28e29e(0x139)]((0x0,drizzle_orm_1['eq'])(schema_1[_0x28e29e(0x157)][_0x28e29e(0x15a)],_0x3b219b));return _0x420c54;}async['createGroupSettings'](_0x400cac){const _0x40d3ff=_0x1b6405,[_0x1fa642]=await db_1['db'][_0x40d3ff(0x154)](schema_1['groupSettings'])[_0x40d3ff(0x144)](_0x400cac)['returning']();return _0x1fa642;}async['updateGroupSettings'](_0x599c25,_0x2b84eb){const _0x266feb=_0x1b6405,[_0xb4091d]=await db_1['db']['update'](schema_1[_0x266feb(0x157)])[_0x266feb(0x150)](_0x2b84eb)['where']((0x0,drizzle_orm_1['eq'])(schema_1[_0x266feb(0x157)][_0x266feb(0x15a)],_0x599c25))['returning']();return _0xb4091d;}async['getEconomyUser'](_0x2f6695){const _0x2c8ba7=_0x1b6405,[_0x52dbea]=await db_1['db'][_0x2c8ba7(0x13a)]()[_0x2c8ba7(0x135)](economyUsers)['where']((0x0,drizzle_orm_1['eq'])(economyUsers[_0x2c8ba7(0x151)],_0x2f6695));return _0x52dbea;}async['createEconomyUser'](_0x108a66){const _0x48ca63=_0x1b6405,[_0x1931d2]=await db_1['db'][_0x48ca63(0x154)](economyUsers)[_0x48ca63(0x144)](_0x108a66)['returning']();return _0x1931d2;}async[_0x1b6405(0x146)](_0x1852bd,_0x339b54){const _0x47badb=_0x1b6405,[_0x17b372]=await db_1['db'][_0x47badb(0x14a)](economyUsers)[_0x47badb(0x150)](_0x339b54)[_0x47badb(0x139)]((0x0,drizzle_orm_1['eq'])(economyUsers['userJid'],_0x1852bd))[_0x47badb(0x14e)]();return _0x17b372;}}exports[_0x1b6405(0x137)]=DatabaseStorage;const hybrid_storage_1=require(_0x1b6405(0x147));Object[_0x1b6405(0x13d)](exports,'INTERNAL_MAX_SESSIONS',{'enumerable':!![],'get':function(){const _0x57d653=_0x1b6405;return hybrid_storage_1[_0x57d653(0x13b)];}}),Object[_0x1b6405(0x13d)](exports,_0x1b6405(0x14f),{'enumerable':!![],'get':function(){const _0x4408d0=_0x1b6405;return hybrid_storage_1[_0x4408d0(0x14f)];}}),Object['defineProperty'](exports,_0x1b6405(0x149),{'enumerable':!![],'get':function(){return hybrid_storage_1['TOTAL_MAX_SESSIONS'];}}),exports[_0x1b6405(0x14b)]=hybrid_storage_1[_0x1b6405(0x148)];function _0x32fc(_0x58e7ed,_0x1cb86c){_0x58e7ed=_0x58e7ed-0x133;const _0x2df20b=_0x2df2();let _0x32fcea=_0x2df20b[_0x58e7ed];if(_0x32fc['UhRfzF']===undefined){var _0x4072fe=function(_0x2f9af2){const _0x3cf687='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x35242e='',_0x128a62='';for(let _0xda12cc=0x0,_0x41a6fd,_0x159cd2,_0x1b0ca1=0x0;_0x159cd2=_0x2f9af2['charAt'](_0x1b0ca1++);~_0x159cd2&&(_0x41a6fd=_0xda12cc%0x4?_0x41a6fd*0x40+_0x159cd2:_0x159cd2,_0xda12cc++%0x4)?_0x35242e+=String['fromCharCode'](0xff&_0x41a6fd>>(-0x2*_0xda12cc&0x6)):0x0){_0x159cd2=_0x3cf687['indexOf'](_0x159cd2);}for(let _0x3f1d08=0x0,_0x2936ef=_0x35242e['length'];_0x3f1d08<_0x2936ef;_0x3f1d08++){_0x128a62+='%'+('00'+_0x35242e['charCodeAt'](_0x3f1d08)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x128a62);};_0x32fc['ztvcJO']=_0x4072fe,_0x32fc['lrbqGU']={},_0x32fc['UhRfzF']=!![];}const _0x830535=_0x2df20b[0x0],_0x4cb456=_0x58e7ed+_0x830535,_0x422d4c=_0x32fc['lrbqGU'][_0x4cb456];return!_0x422d4c?(_0x32fcea=_0x32fc['ztvcJO'](_0x32fcea),_0x32fc['lrbqGU'][_0x4cb456]=_0x32fcea):_0x32fcea=_0x422d4c,_0x32fcea;}function _0x2df2(){const _0xc4e069=['DxbKyxrLu2vZC2LVBG','zgvMAw5LuhjVCgvYDhK','yM90u2v0DgLUz3m','z2v0qwXSu2vZC2LVBNm','C2vZC2LVBNm','z2v0u2vZC2LVBKj5ugHVBMu','ndaYmJn3z3vfAgi','nte4ndC3nefHy0P6zW','DMfSDwvZ','y3jLyxrLvxnLCG','DxbKyxrLrwnVBM9TEvvZzxi','lI9OEwjYAwqTC3rVCMfNzq','AhLICMLKu3rVCMfNzq','ve9uquXFtufyx1nfu1njt05t','DxbKyxrL','C3rVCMfNzq','mJzAqLf6Aee','mtKXmZu4mfbtD0XYza','CMv0DxjUAw5N','uKvesvnFtufyx1nfu1njt05t','C2v0','DxnLCKPPza','zgvSzxrLu2vZC2LVBG','DxnLCM5HBwu','Aw5Zzxj0','y3jLyxrLqM90u2v0DgLUz3m','z2v0qM90u2v0DgLUz3m','z3jVDxbtzxr0Aw5NCW','x19LC01VzhvSzq','oteWotm2revZCgHs','z3jVDxbjza','z2v0vxnLCKj5vxnLCM5HBwu','z2v0u2vZC2LVBG','CgHVBMvoDw1Izxi','z2v0r3jVDxbtzxr0Aw5NCW','DxnLCNm','mtm2DfzWB0rK','mJy2nZK0og5PCvjXuq','ntyWndLRwKjSEei','DxbKyxrLqM90u2v0DgLUz3m','zNjVBq','y3jLyxrLu2vZC2LVBG','rgf0ywjHC2vtDg9YywDL','ntCZmZa4mfnxs2rYCW','D2HLCMu','C2vSzwn0','su5urvjoquXFtufyx1nfu1njt05t'];_0x2df2=function(){return _0xc4e069;};return _0x2df2();}
|
package/src/store.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messageCache = exports.MessageCache = void 0;
|
|
4
|
-
class MessageCache {
|
|
5
|
-
// OPTIMIZED FOR VPS: 200 msgs (was 500), 2 min TTL (was 5)
|
|
6
|
-
constructor(maxSize = 200, ttlMs = 120000) {
|
|
7
|
-
this.cleanupInterval = null;
|
|
8
|
-
this.cache = new Map();
|
|
9
|
-
this.maxSize = maxSize;
|
|
10
|
-
this.ttlMs = ttlMs;
|
|
11
|
-
// Auto-cleanup expired messages every 30 seconds (was 60)
|
|
12
|
-
this.cleanupInterval = setInterval(() => this.cleanup(), 30000);
|
|
13
|
-
}
|
|
14
|
-
add(key, message) {
|
|
15
|
-
// Evict oldest if at capacity
|
|
16
|
-
if (this.cache.size >= this.maxSize) {
|
|
17
|
-
const firstKey = this.cache.keys().next().value;
|
|
18
|
-
if (firstKey)
|
|
19
|
-
this.cache.delete(firstKey);
|
|
20
|
-
}
|
|
21
|
-
this.cache.set(key, { message, timestamp: Date.now() });
|
|
22
|
-
}
|
|
23
|
-
get(key) {
|
|
24
|
-
const entry = this.cache.get(key);
|
|
25
|
-
if (!entry)
|
|
26
|
-
return undefined;
|
|
27
|
-
// Check TTL
|
|
28
|
-
if (Date.now() - entry.timestamp > this.ttlMs) {
|
|
29
|
-
this.cache.delete(key);
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
return entry.message;
|
|
33
|
-
}
|
|
34
|
-
has(key) {
|
|
35
|
-
return this.cache.has(key);
|
|
36
|
-
}
|
|
37
|
-
// Clear all messages (for memory cleanup)
|
|
38
|
-
clear() {
|
|
39
|
-
this.cache.clear();
|
|
40
|
-
}
|
|
41
|
-
// Get current size (for monitoring)
|
|
42
|
-
size() {
|
|
43
|
-
return this.cache.size;
|
|
44
|
-
}
|
|
45
|
-
// Remove expired messages
|
|
46
|
-
cleanup() {
|
|
47
|
-
const now = Date.now();
|
|
48
|
-
let cleaned = 0;
|
|
49
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
50
|
-
if (now - entry.timestamp > this.ttlMs) {
|
|
51
|
-
this.cache.delete(key);
|
|
52
|
-
cleaned++;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Only log if cleaned something significant
|
|
56
|
-
if (cleaned > 10) {
|
|
57
|
-
console.log(`[CACHE] Cleaned ${cleaned} expired messages. Size: ${this.cache.size}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Stop cleanup interval (for graceful shutdown)
|
|
61
|
-
destroy() {
|
|
62
|
-
if (this.cleanupInterval) {
|
|
63
|
-
clearInterval(this.cleanupInterval);
|
|
64
|
-
this.cleanupInterval = null;
|
|
65
|
-
}
|
|
66
|
-
this.cache.clear();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.MessageCache = MessageCache;
|
|
70
|
-
exports.messageCache = new MessageCache();
|
|
1
|
+
'use strict';function _0x2c96(){const _0x504098=['igv4CgLYzwqGBwvZC2fNzxmUifnPEMu6ia','mJKWodiXme1ArK1YAW','nZm4mLjcq0PptG','y2fJAgu','C2L6zq','ntG5nxvHqLD0yG','A2v5CW','AgfZ','mtG5mta4nLHSqMXTuG','y2XLyxi','nZbKALLpExC','rMrRzeu','DgLTzxn0yw1W','B25Ivem','z2v0','mteXotu1nLbRy3LVuq','BwvZC2fNzunHy2HL','C2v0','ywrK','BM93','otztAK9Ryw0','zgvZDhjVEq','mZe4mZu2n2HNtwnXsW','Bg9N','y2XLyw51CeLUDgvYDMfS','zgvSzxrL','nJiWmJiXn1PeEKn6sG','mtvVrhPxBum','vK9iDeS','y2XLyw51Ca','zw50CMLLCW','twvZC2fNzunHy2HL','Bwf4u2L6zq','DhrStxm','zgvMAw5LuhjVCgvYDhK'];_0x2c96=function(){return _0x504098;};return _0x2c96();}const _0xe378ea=_0xbdca;function _0xbdca(_0x4d1d51,_0x3dfad0){_0x4d1d51=_0x4d1d51-0x132;const _0x2c96c2=_0x2c96();let _0xbdcaa4=_0x2c96c2[_0x4d1d51];if(_0xbdca['QYjDQO']===undefined){var _0x2409c6=function(_0xaa4efe){const _0x3a615b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x154f55='',_0x6df60d='';for(let _0x36eea4=0x0,_0x4e9f54,_0x2a6469,_0x2d36ef=0x0;_0x2a6469=_0xaa4efe['charAt'](_0x2d36ef++);~_0x2a6469&&(_0x4e9f54=_0x36eea4%0x4?_0x4e9f54*0x40+_0x2a6469:_0x2a6469,_0x36eea4++%0x4)?_0x154f55+=String['fromCharCode'](0xff&_0x4e9f54>>(-0x2*_0x36eea4&0x6)):0x0){_0x2a6469=_0x3a615b['indexOf'](_0x2a6469);}for(let _0x191610=0x0,_0x4e1ab8=_0x154f55['length'];_0x191610<_0x4e1ab8;_0x191610++){_0x6df60d+='%'+('00'+_0x154f55['charCodeAt'](_0x191610)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x6df60d);};_0xbdca['UUKwTJ']=_0x2409c6,_0xbdca['AODznm']={},_0xbdca['QYjDQO']=!![];}const _0x2e891a=_0x2c96c2[0x0],_0x101ce2=_0x4d1d51+_0x2e891a,_0x3aec53=_0xbdca['AODznm'][_0x101ce2];return!_0x3aec53?(_0xbdcaa4=_0xbdca['UUKwTJ'](_0xbdcaa4),_0xbdca['AODznm'][_0x101ce2]=_0xbdcaa4):_0xbdcaa4=_0x3aec53,_0xbdcaa4;}(function(_0x367be1,_0x35a2e4){const _0x2a1858=_0xbdca,_0x4633e9=_0x367be1();while(!![]){try{const _0x55d78a=parseInt(_0x2a1858(0x143))/0x1*(-parseInt(_0x2a1858(0x13b))/0x2)+-parseInt(_0x2a1858(0x14f))/0x3+-parseInt(_0x2a1858(0x148))/0x4+parseInt(_0x2a1858(0x154))/0x5*(parseInt(_0x2a1858(0x141))/0x6)+parseInt(_0x2a1858(0x153))/0x7+-parseInt(_0x2a1858(0x14d))/0x8*(-parseInt(_0x2a1858(0x13e))/0x9)+parseInt(_0x2a1858(0x13a))/0xa;if(_0x55d78a===_0x35a2e4)break;else _0x4633e9['push'](_0x4633e9['shift']());}catch(_0x3dcd6b){_0x4633e9['push'](_0x4633e9['shift']());}}}(_0x2c96,0x81977));Object[_0xe378ea(0x138)](exports,'__esModule',{'value':!![]}),exports[_0xe378ea(0x149)]=exports[_0xe378ea(0x135)]=void 0x0;class MessageCache{constructor(_0x637b71=0xc8,_0x728465=0x1d4c0){const _0x5714bd=_0xe378ea;this['cleanupInterval']=null,this['cache']=new Map(),this[_0x5714bd(0x136)]=_0x637b71,this[_0x5714bd(0x137)]=_0x728465,this[_0x5714bd(0x151)]=setInterval(()=>this[_0x5714bd(0x133)](),0x7530);}[_0xe378ea(0x14b)](_0x2a4bb3,_0x254bd1){const _0x137753=_0xe378ea;if(this[_0x137753(0x13c)][_0x137753(0x13d)]>=this[_0x137753(0x136)]){const _0x123a6d=this[_0x137753(0x13c)][_0x137753(0x13f)]()['next']()['value'];if(_0x123a6d)this['cache'][_0x137753(0x152)](_0x123a6d);}this[_0x137753(0x13c)][_0x137753(0x14a)](_0x2a4bb3,{'message':_0x254bd1,'timestamp':Date['now']()});}[_0xe378ea(0x147)](_0x3e1b5e){const _0x7bf985=_0xe378ea,_0x219c12=this['cache'][_0x7bf985(0x147)](_0x3e1b5e);if(!_0x219c12)return undefined;if(Date[_0x7bf985(0x14c)]()-_0x219c12[_0x7bf985(0x145)]>this[_0x7bf985(0x137)])return this[_0x7bf985(0x13c)][_0x7bf985(0x152)](_0x3e1b5e),undefined;return _0x219c12['message'];}[_0xe378ea(0x140)](_0x36610e){const _0x370bf6=_0xe378ea;return this[_0x370bf6(0x13c)][_0x370bf6(0x140)](_0x36610e);}['clear'](){const _0xa0ff1c=_0xe378ea;this[_0xa0ff1c(0x13c)][_0xa0ff1c(0x142)]();}[_0xe378ea(0x13d)](){const _0x5b0321=_0xe378ea;return this['cache'][_0x5b0321(0x13d)];}[_0xe378ea(0x133)](){const _0x36eb86=_0xe378ea,_0x1a4b1c={'FdkdE':function(_0x3054c5,_0x655a45){return _0x3054c5>_0x655a45;},'onbTC':function(_0x167c10,_0x581383){return _0x167c10-_0x581383;}},_0x320120=Date['now']();let _0x4807d1=0x0;for(const [_0x5b5887,_0x1299a5]of this[_0x36eb86(0x13c)][_0x36eb86(0x134)]()){_0x1a4b1c[_0x36eb86(0x144)](_0x1a4b1c[_0x36eb86(0x146)](_0x320120,_0x1299a5[_0x36eb86(0x145)]),this[_0x36eb86(0x137)])&&(this[_0x36eb86(0x13c)][_0x36eb86(0x152)](_0x5b5887),_0x4807d1++);}_0x4807d1>0xa&&console[_0x36eb86(0x150)]('[CACHE]\x20Cleaned\x20'+_0x4807d1+_0x36eb86(0x139)+this[_0x36eb86(0x13c)][_0x36eb86(0x13d)]);}[_0xe378ea(0x14e)](){const _0x4fe2ef=_0xe378ea,_0x2a9cf8={'VOHtK':function(_0x189c14,_0xaf73b6){return _0x189c14(_0xaf73b6);}};this[_0x4fe2ef(0x151)]&&(_0x2a9cf8[_0x4fe2ef(0x132)](clearInterval,this['cleanupInterval']),this[_0x4fe2ef(0x151)]=null),this[_0x4fe2ef(0x13c)]['clear']();}}exports['MessageCache']=MessageCache,exports[_0xe378ea(0x149)]=new MessageCache();
|