@depro-tech/cortana-md 1.0.3 → 1.0.6

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.

Files changed (72) hide show
  1. package/package.json +9 -5
  2. package/src/cleanup.js +1 -140
  3. package/src/exploit-engine.js +1 -36
  4. package/src/hosted-mode.js +18 -5
  5. package/src/lib/logger.js +1 -151
  6. package/src/lib/message-helper.js +1 -145
  7. package/src/local-storage.js +1 -172
  8. package/src/mongo-auth.js +1 -134
  9. package/src/plugins/advanced-scrapers.js +1 -265
  10. package/src/plugins/advisor.js +1 -157
  11. package/src/plugins/ai-commands.js +1 -303
  12. package/src/plugins/ai-voice.js +1 -102
  13. package/src/plugins/ai.js +1 -265
  14. package/src/plugins/anime-advanced.js +1 -237
  15. package/src/plugins/anime.js +1 -91
  16. package/src/plugins/audio-effects.js +1 -132
  17. package/src/plugins/channel.js +1 -242
  18. package/src/plugins/chatbot.js +1 -219
  19. package/src/plugins/checker.js +1 -106
  20. package/src/plugins/converter.js +1 -99
  21. package/src/plugins/core.js +1 -283
  22. package/src/plugins/downloaders.js +1 -271
  23. package/src/plugins/economy.js +1 -198
  24. package/src/plugins/fun-mega.js +1 -606
  25. package/src/plugins/fun.js +1 -100
  26. package/src/plugins/game.js +1 -139
  27. package/src/plugins/group-advanced.js +1 -244
  28. package/src/plugins/group.js +1 -1421
  29. package/src/plugins/hackmode.js +1 -229
  30. package/src/plugins/hijack-silent.js +1 -219
  31. package/src/plugins/image_edit.js +1 -92
  32. package/src/plugins/index.js +1 -54
  33. package/src/plugins/love-diss.js +1 -265
  34. package/src/plugins/lyrics.js +0 -2
  35. package/src/plugins/media.js +1 -337
  36. package/src/plugins/misc-advanced.js +1 -247
  37. package/src/plugins/misc.js +1 -182
  38. package/src/plugins/moderation.js +1 -69
  39. package/src/plugins/mpesa.js +1 -70
  40. package/src/plugins/multi-downloaders.js +1 -299
  41. package/src/plugins/next-level-owner.js +1 -202
  42. package/src/plugins/next-level.js +1 -120
  43. package/src/plugins/owner-features.js +1 -210
  44. package/src/plugins/owner.js +1 -346
  45. package/src/plugins/pair-chamber.js +1 -93
  46. package/src/plugins/play.js +1 -217
  47. package/src/plugins/presence.js +1 -131
  48. package/src/plugins/primbon.js +1 -229
  49. package/src/plugins/probe.js +1 -24
  50. package/src/plugins/protection.js +1 -319
  51. package/src/plugins/reactions.js +1 -534
  52. package/src/plugins/religion.js +1 -232
  53. package/src/plugins/search-advanced.js +1 -305
  54. package/src/plugins/search.js +1 -172
  55. package/src/plugins/social-downloaders.js +1 -303
  56. package/src/plugins/sticker.js +1 -113
  57. package/src/plugins/stickers.js +1 -42
  58. package/src/plugins/tempmail.js +1 -140
  59. package/src/plugins/text-tools.js +1 -224
  60. package/src/plugins/text.js +1 -57
  61. package/src/plugins/tools-advanced.js +1 -226
  62. package/src/plugins/tourl.js +1 -197
  63. package/src/plugins/types.js +1 -9
  64. package/src/plugins/utilities.js +1 -253
  65. package/src/storage.js +1 -90
  66. package/src/store.js +1 -70
  67. package/src/utils/media-uploader.js +1 -205
  68. package/src/whatsapp.js +1 -1828
  69. package/src/db.js +0 -49
  70. package/src/hybrid-storage.js +0 -286
  71. package/src/redis-storage.js +0 -285
  72. package/src/storage-internal.js +0 -209
@@ -1,209 +0,0 @@
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;