waengine 2.4.6 β 2.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/box-console.js +347 -0
- package/src/client.js +0 -15
- package/src/console-renderer.js +23 -23
- package/src/storage.js +33 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.9",
|
|
4
4
|
"description": "π WAEngine - The most powerful WhatsApp Bot Library with 860+ Working Features, Complete Baileys Integration & Production-Ready Stability",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// ===== BOX CONSOLE - SchΓΆne detaillierte Message Boxes =====
|
|
2
|
+
|
|
3
|
+
export class BoxConsole {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
this.enabled = false;
|
|
7
|
+
|
|
8
|
+
// Speichere originale Console-Funktionen
|
|
9
|
+
this.originalLog = console.log.bind(console);
|
|
10
|
+
this.originalWarn = console.warn.bind(console);
|
|
11
|
+
this.originalError = console.error.bind(console);
|
|
12
|
+
|
|
13
|
+
// Flag ob Console bereits gepatcht wurde
|
|
14
|
+
this.isPatched = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Aktiviere/Deaktiviere Box Console
|
|
18
|
+
enable(enabled = true) {
|
|
19
|
+
this.enabled = enabled;
|
|
20
|
+
|
|
21
|
+
if (enabled && !this.isPatched) {
|
|
22
|
+
// Patche Console-Funktionen
|
|
23
|
+
this.patchConsole();
|
|
24
|
+
this.originalLog('\nβ
Box Console aktiviert - Normale Message-Logs deaktiviert\n');
|
|
25
|
+
} else if (!enabled && this.isPatched) {
|
|
26
|
+
// Stelle originale Console wieder her
|
|
27
|
+
this.unpatchConsole();
|
|
28
|
+
this.originalLog('\nβ Box Console deaktiviert - Normale Logs reaktiviert\n');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
patchConsole() {
|
|
33
|
+
const self = this;
|
|
34
|
+
|
|
35
|
+
// Patche console.warn
|
|
36
|
+
console.warn = function(...args) {
|
|
37
|
+
if (self.enabled) {
|
|
38
|
+
// Zeige Warning in Box
|
|
39
|
+
const warningText = args.join(' ');
|
|
40
|
+
self.showWarningBox(warningText);
|
|
41
|
+
} else {
|
|
42
|
+
self.originalWarn(...args);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Patche console.error
|
|
47
|
+
console.error = function(...args) {
|
|
48
|
+
if (self.enabled) {
|
|
49
|
+
// Zeige Error in Box
|
|
50
|
+
const errorText = args.join(' ');
|
|
51
|
+
const error = args[0] instanceof Error ? args[0] : new Error(errorText);
|
|
52
|
+
self.showErrorBox(error);
|
|
53
|
+
} else {
|
|
54
|
+
self.originalError(...args);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.isPatched = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
unpatchConsole() {
|
|
62
|
+
// Stelle originale Funktionen wieder her
|
|
63
|
+
console.warn = this.originalWarn;
|
|
64
|
+
console.error = this.originalError;
|
|
65
|
+
|
|
66
|
+
this.isPatched = false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Zeige Message Box
|
|
70
|
+
showMessageBox(msg) {
|
|
71
|
+
if (!this.enabled) return;
|
|
72
|
+
|
|
73
|
+
const box = this.createMessageBox(msg);
|
|
74
|
+
this.originalLog(box);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Erstelle Message Box
|
|
78
|
+
createMessageBox(msg) {
|
|
79
|
+
// Extrahiere alle Infos
|
|
80
|
+
const name = msg.pushName || msg.verifiedBizName || 'Unbekannt';
|
|
81
|
+
const text = msg.body || msg.text || msg.message?.conversation || '[Keine Text-Nachricht]';
|
|
82
|
+
const device = this.detectDevice(msg);
|
|
83
|
+
const jid = msg.from || msg.key?.remoteJid || 'N/A';
|
|
84
|
+
const lid = msg.key?.participant?.split('@')[0] || jid.split('@')[0] || 'N/A';
|
|
85
|
+
const phone = this.extractPhoneNumber(jid);
|
|
86
|
+
const isCommand = this.isCommand(text);
|
|
87
|
+
const chatType = this.getChatType(jid);
|
|
88
|
+
const messageType = this.getMessageType(msg);
|
|
89
|
+
const userRole = this.getUserRole(msg, jid);
|
|
90
|
+
|
|
91
|
+
// Erstelle Box
|
|
92
|
+
const width = 70;
|
|
93
|
+
const line = 'β'.repeat(width);
|
|
94
|
+
|
|
95
|
+
let box = `\nβ${line}β\n`;
|
|
96
|
+
box += this.boxLine('π¨ NEUE NACHRICHT', width, 'center');
|
|
97
|
+
box += `β ${line}β£\n`;
|
|
98
|
+
|
|
99
|
+
// User Info
|
|
100
|
+
box += this.boxLine(`π€ Name: ${name}`, width);
|
|
101
|
+
box += this.boxLine(`π± Telefon: ${phone}`, width);
|
|
102
|
+
box += this.boxLine(`π JID: ${jid}`, width);
|
|
103
|
+
box += this.boxLine(`π’ LID: ${lid}`, width);
|
|
104
|
+
|
|
105
|
+
box += `β ${line}β£\n`;
|
|
106
|
+
|
|
107
|
+
// Message Info
|
|
108
|
+
box += this.boxLine(`π¬ Nachricht: ${this.truncate(text, 50)}`, width);
|
|
109
|
+
box += this.boxLine(`π Typ: ${messageType}`, width);
|
|
110
|
+
box += this.boxLine(`π» GerΓ€t: ${device}`, width);
|
|
111
|
+
box += this.boxLine(`β‘ Command: ${isCommand ? 'Ja β
' : 'Nein β'}`, width);
|
|
112
|
+
|
|
113
|
+
box += `β ${line}β£\n`;
|
|
114
|
+
|
|
115
|
+
// Chat Info
|
|
116
|
+
box += this.boxLine(`π Chat-Typ: ${chatType}`, width);
|
|
117
|
+
if (chatType === 'Gruppe') {
|
|
118
|
+
box += this.boxLine(`π Rolle: ${userRole}`, width);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
box += `β${line}β\n`;
|
|
122
|
+
|
|
123
|
+
return box;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Zeige Error Box
|
|
127
|
+
showErrorBox(error, context = '') {
|
|
128
|
+
const box = this.createErrorBox(error, context);
|
|
129
|
+
this.originalError(box);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
createErrorBox(error, context) {
|
|
133
|
+
const width = 70;
|
|
134
|
+
const line = 'β'.repeat(width);
|
|
135
|
+
|
|
136
|
+
let box = `\nβ${line}β\n`;
|
|
137
|
+
box += this.boxLine('β FEHLER', width, 'center');
|
|
138
|
+
box += `β ${line}β£\n`;
|
|
139
|
+
|
|
140
|
+
const errorMsg = error.message || String(error);
|
|
141
|
+
box += this.boxLine(`π΄ Fehler: ${this.truncate(errorMsg, 60)}`, width);
|
|
142
|
+
|
|
143
|
+
if (context) {
|
|
144
|
+
box += this.boxLine(`π Kontext: ${this.truncate(context, 60)}`, width);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (error.stack) {
|
|
148
|
+
const stackLines = error.stack.split('\n').slice(0, 3);
|
|
149
|
+
box += `β ${line}β£\n`;
|
|
150
|
+
box += this.boxLine('π Stack Trace:', width);
|
|
151
|
+
stackLines.forEach(line => {
|
|
152
|
+
box += this.boxLine(` ${this.truncate(line.trim(), 65)}`, width);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
box += `β${line}β\n`;
|
|
157
|
+
|
|
158
|
+
return box;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Zeige Warning Box
|
|
162
|
+
showWarningBox(warning, context = '') {
|
|
163
|
+
const box = this.createWarningBox(warning, context);
|
|
164
|
+
this.originalWarn(box);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
createWarningBox(warning, context) {
|
|
168
|
+
const width = 70;
|
|
169
|
+
const line = 'β'.repeat(width);
|
|
170
|
+
|
|
171
|
+
let box = `\nβ${line}β\n`;
|
|
172
|
+
box += this.boxLine('β οΈ WARNUNG', width, 'center');
|
|
173
|
+
box += `β ${line}β£\n`;
|
|
174
|
+
|
|
175
|
+
box += this.boxLine(`π‘ Warnung: ${this.truncate(String(warning), 60)}`, width);
|
|
176
|
+
|
|
177
|
+
if (context) {
|
|
178
|
+
box += this.boxLine(`π Kontext: ${this.truncate(context, 60)}`, width);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
box += `β${line}β\n`;
|
|
182
|
+
|
|
183
|
+
return box;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Helper: Box Line
|
|
187
|
+
boxLine(text, width, align = 'left') {
|
|
188
|
+
const maxTextWidth = width - 4;
|
|
189
|
+
const truncated = this.truncate(text, maxTextWidth);
|
|
190
|
+
|
|
191
|
+
let line = 'β ';
|
|
192
|
+
|
|
193
|
+
if (align === 'center') {
|
|
194
|
+
const padding = Math.floor((maxTextWidth - truncated.length) / 2);
|
|
195
|
+
line += ' '.repeat(padding) + truncated + ' '.repeat(maxTextWidth - truncated.length - padding);
|
|
196
|
+
} else {
|
|
197
|
+
line += truncated + ' '.repeat(maxTextWidth - truncated.length);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
line += ' β\n';
|
|
201
|
+
return line;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Helper: Truncate Text
|
|
205
|
+
truncate(text, maxLength) {
|
|
206
|
+
if (!text) return '';
|
|
207
|
+
text = String(text);
|
|
208
|
+
if (text.length <= maxLength) return text;
|
|
209
|
+
return text.substring(0, maxLength - 3) + '...';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Detect Device
|
|
213
|
+
detectDevice(msg) {
|
|
214
|
+
// Nutze device-detector falls verfΓΌgbar
|
|
215
|
+
try {
|
|
216
|
+
const messageId = msg.key?.id || msg.id;
|
|
217
|
+
if (messageId) {
|
|
218
|
+
const { DeviceDetector } = require('./device-detector.js');
|
|
219
|
+
const detector = new DeviceDetector();
|
|
220
|
+
const detection = detector.detectDevice(messageId);
|
|
221
|
+
|
|
222
|
+
const deviceNames = {
|
|
223
|
+
'web': 'π WhatsApp Web',
|
|
224
|
+
'iphone': 'π± iPhone',
|
|
225
|
+
'android': 'π€ Android',
|
|
226
|
+
'desktop': 'π» Desktop',
|
|
227
|
+
'business': 'πΌ Business',
|
|
228
|
+
'unknown': 'β Unbekannt'
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
return deviceNames[detection.deviceType] || 'β Unbekannt';
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
// Fallback
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return 'β Unbekannt';
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Extract Phone Number
|
|
241
|
+
extractPhoneNumber(jid) {
|
|
242
|
+
if (!jid) return 'N/A';
|
|
243
|
+
|
|
244
|
+
// Format: 491234567890@s.whatsapp.net
|
|
245
|
+
const match = jid.match(/^(\d+)@/);
|
|
246
|
+
if (match) {
|
|
247
|
+
const number = match[1];
|
|
248
|
+
// Formatiere: +49 123 4567890
|
|
249
|
+
if (number.length > 10) {
|
|
250
|
+
return `+${number.substring(0, 2)} ${number.substring(2, 5)} ${number.substring(5)}`;
|
|
251
|
+
}
|
|
252
|
+
return `+${number}`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return jid.split('@')[0] || 'N/A';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Check if Command
|
|
259
|
+
isCommand(text) {
|
|
260
|
+
if (!text) return false;
|
|
261
|
+
|
|
262
|
+
// PrΓΌfe ob Text mit Prefix startet
|
|
263
|
+
const prefix = this.client.prefix || '!';
|
|
264
|
+
return text.trim().startsWith(prefix);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Get Chat Type
|
|
268
|
+
getChatType(jid) {
|
|
269
|
+
if (!jid) return 'Unbekannt';
|
|
270
|
+
|
|
271
|
+
if (jid.endsWith('@g.us')) return 'Gruppe';
|
|
272
|
+
if (jid.endsWith('@s.whatsapp.net')) return 'Privat';
|
|
273
|
+
if (jid.endsWith('@broadcast')) return 'Broadcast';
|
|
274
|
+
if (jid === 'status@broadcast') return 'Status';
|
|
275
|
+
|
|
276
|
+
return 'Unbekannt';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Get Message Type
|
|
280
|
+
getMessageType(msg) {
|
|
281
|
+
const message = msg.message;
|
|
282
|
+
if (!message) return 'Text';
|
|
283
|
+
|
|
284
|
+
if (message.conversation) return 'Text';
|
|
285
|
+
if (message.extendedTextMessage) return 'Text (Extended)';
|
|
286
|
+
if (message.imageMessage) return 'Bild οΏ½οΈ';
|
|
287
|
+
if (message.videoMessage) return 'Video π₯';
|
|
288
|
+
if (message.audioMessage) return 'Audio π΅';
|
|
289
|
+
if (message.documentMessage) return 'Dokument οΏ½';
|
|
290
|
+
if (message.stickerMessage) return 'Sticker π';
|
|
291
|
+
if (message.locationMessage) return 'Standort π';
|
|
292
|
+
if (message.contactMessage) return 'Kontakt π€';
|
|
293
|
+
if (message.pollCreationMessage) return 'Umfrage π';
|
|
294
|
+
if (message.reactionMessage) return 'Reaktion β€οΈ';
|
|
295
|
+
if (message.viewOnceMessage) return 'View Once ποΈ';
|
|
296
|
+
|
|
297
|
+
return 'Text';
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Get User Role (in Groups)
|
|
301
|
+
async getUserRole(msg, jid) {
|
|
302
|
+
// Nur fΓΌr Gruppen
|
|
303
|
+
if (!jid || !jid.endsWith('@g.us')) {
|
|
304
|
+
return 'N/A';
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
const participant = msg.key?.participant;
|
|
309
|
+
if (!participant || !this.client.socket) {
|
|
310
|
+
return 'Mitglied οΏ½';
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Hole Gruppen-Metadaten
|
|
314
|
+
const groupMetadata = await this.client.socket.groupMetadata(jid);
|
|
315
|
+
|
|
316
|
+
if (!groupMetadata || !groupMetadata.participants) {
|
|
317
|
+
return 'Mitglied οΏ½';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Finde Participant
|
|
321
|
+
const participantData = groupMetadata.participants.find(p => p.id === participant);
|
|
322
|
+
|
|
323
|
+
if (!participantData) {
|
|
324
|
+
return 'Mitglied π€';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// PrΓΌfe Rolle
|
|
328
|
+
if (participantData.admin === 'superadmin') {
|
|
329
|
+
return 'Superadmin π (Ersteller)';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (participantData.admin === 'admin') {
|
|
333
|
+
return 'Admin π‘οΈ';
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return 'Mitglied π€';
|
|
337
|
+
|
|
338
|
+
} catch (error) {
|
|
339
|
+
return 'Mitglied π€';
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Export fΓΌr einfache Nutzung
|
|
345
|
+
export function createBoxConsole(client) {
|
|
346
|
+
return new BoxConsole(client);
|
|
347
|
+
}
|
package/src/client.js
CHANGED
|
@@ -152,12 +152,6 @@ export class WhatsAppClient {
|
|
|
152
152
|
// FromMe Ignore System - NEUE GLOBALE API!
|
|
153
153
|
this.ignoreFromMe = true; // Standard: Bot ignoriert sich selbst
|
|
154
154
|
|
|
155
|
-
// Log wenn automatisch aktiviert
|
|
156
|
-
if (this.ignoreOfflineMessages) {
|
|
157
|
-
console.log('\nπ΅ Offline Message Ignore: AUTOMATISCH AKTIVIERT');
|
|
158
|
-
console.log(' ββ Grund: Session ΓΌber Session Menu gestartet\n');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
155
|
// ===== GLOBAL VISUAL TYPING/RECORDING SYSTEM - NEU! =====
|
|
162
156
|
this.globalVisualTyping = false; // Global aktiviert/deaktiviert
|
|
163
157
|
this.globalVisualRecord = false; // Global aktiviert/deaktiviert
|
|
@@ -168,11 +162,8 @@ export class WhatsAppClient {
|
|
|
168
162
|
this.load = {
|
|
169
163
|
Plugins: async (pluginName) => {
|
|
170
164
|
if (pluginName === 'all') {
|
|
171
|
-
console.log('π Lade alle Plugins...');
|
|
172
165
|
await this.plugins.loadAllPlugins();
|
|
173
|
-
console.log('β
Alle Plugins geladen!');
|
|
174
166
|
} else {
|
|
175
|
-
console.log(`π Lade Plugin: ${pluginName}`);
|
|
176
167
|
await this.plugins.load(pluginName);
|
|
177
168
|
}
|
|
178
169
|
}
|
|
@@ -183,12 +174,10 @@ export class WhatsAppClient {
|
|
|
183
174
|
message: {
|
|
184
175
|
offline: (enabled = true) => {
|
|
185
176
|
this.ignoreOfflineMessages = enabled;
|
|
186
|
-
console.log(`π΅ Offline Message Ignore: ${enabled ? 'AKTIVIERT' : 'DEAKTIVIERT'}`);
|
|
187
177
|
return this;
|
|
188
178
|
},
|
|
189
179
|
FromMe: (enabled = true) => {
|
|
190
180
|
this.ignoreFromMe = enabled;
|
|
191
|
-
console.log(`π€ FromMe Ignore: ${enabled ? 'AKTIVIERT (Bot ignoriert sich selbst)' : 'DEAKTIVIERT (Bot reagiert auf eigene Messages)'}`);
|
|
192
181
|
return this;
|
|
193
182
|
}
|
|
194
183
|
}
|
|
@@ -198,7 +187,6 @@ export class WhatsAppClient {
|
|
|
198
187
|
this.info = {
|
|
199
188
|
Console: (enabled = true) => {
|
|
200
189
|
this.consoleVerbose = enabled;
|
|
201
|
-
console.log(`π Console Info Mode: ${enabled ? 'VERBOSE (Alle Details)' : 'NORMAL (Nur wichtige Infos)'}`);
|
|
202
190
|
return this;
|
|
203
191
|
}
|
|
204
192
|
};
|
|
@@ -206,7 +194,6 @@ export class WhatsAppClient {
|
|
|
206
194
|
this.silent = {
|
|
207
195
|
Console: (enabled = true) => {
|
|
208
196
|
this.consoleSilent = enabled;
|
|
209
|
-
console.log(`π Console Silent Mode: ${enabled ? 'AKTIVIERT (Nur gesendete Messages)' : 'DEAKTIVIERT (Normal)'}`);
|
|
210
197
|
return this;
|
|
211
198
|
}
|
|
212
199
|
};
|
|
@@ -216,12 +203,10 @@ export class WhatsAppClient {
|
|
|
216
203
|
this.set = {
|
|
217
204
|
Visualtyping: (ms) => {
|
|
218
205
|
this.visualTypingDuration = ms;
|
|
219
|
-
console.log(`β¨οΈ Visual Typing Dauer: ${ms}ms`);
|
|
220
206
|
return this;
|
|
221
207
|
},
|
|
222
208
|
Visualrecord: (ms) => {
|
|
223
209
|
this.visualRecordDuration = ms;
|
|
224
|
-
console.log(`π€ Visual Record Dauer: ${ms}ms`);
|
|
225
210
|
return this;
|
|
226
211
|
}
|
|
227
212
|
};
|
package/src/console-renderer.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// ===== CONSOLE RENDERER - SchΓΆne Console Outputs mit Prefix & Farben =====
|
|
2
2
|
|
|
3
|
+
// PrΓΌfe ob wir im Session Menu sind (kein Prefix) oder im Bot-Terminal (mit Prefix)
|
|
4
|
+
const isSessionMenu = !process.env.__WAENGINE_SKIP_SESSION_MENU__;
|
|
5
|
+
|
|
3
6
|
// ANSI Color Codes
|
|
4
7
|
const colors = {
|
|
5
8
|
// Basic Colors
|
|
@@ -89,6 +92,11 @@ console.log = function(...args) {
|
|
|
89
92
|
return originalConsole.log(...args);
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
// WICHTIG: Kein Prefix im Session Menu!
|
|
96
|
+
if (isSessionMenu) {
|
|
97
|
+
return originalConsole.log(...args);
|
|
98
|
+
}
|
|
99
|
+
|
|
92
100
|
const prefix = formatPrefix(globalConfig.prefix, globalConfig.prefixColor);
|
|
93
101
|
const colorCode = getColor(globalConfig.defaultColor);
|
|
94
102
|
|
|
@@ -105,6 +113,11 @@ console.error = function(...args) {
|
|
|
105
113
|
return originalConsole.error(...args);
|
|
106
114
|
}
|
|
107
115
|
|
|
116
|
+
// WICHTIG: Kein Prefix im Session Menu!
|
|
117
|
+
if (isSessionMenu) {
|
|
118
|
+
return originalConsole.error(...args);
|
|
119
|
+
}
|
|
120
|
+
|
|
108
121
|
const prefix = formatPrefix(globalConfig.prefix, globalConfig.prefixColor);
|
|
109
122
|
const colorCode = getColor(globalConfig.errorColor);
|
|
110
123
|
|
|
@@ -121,6 +134,11 @@ console.warn = function(...args) {
|
|
|
121
134
|
return originalConsole.warn(...args);
|
|
122
135
|
}
|
|
123
136
|
|
|
137
|
+
// WICHTIG: Kein Prefix im Session Menu!
|
|
138
|
+
if (isSessionMenu) {
|
|
139
|
+
return originalConsole.warn(...args);
|
|
140
|
+
}
|
|
141
|
+
|
|
124
142
|
const prefix = formatPrefix(globalConfig.prefix, globalConfig.prefixColor);
|
|
125
143
|
const colorCode = getColor(globalConfig.warnColor);
|
|
126
144
|
|
|
@@ -137,6 +155,11 @@ console.info = function(...args) {
|
|
|
137
155
|
return originalConsole.info(...args);
|
|
138
156
|
}
|
|
139
157
|
|
|
158
|
+
// WICHTIG: Kein Prefix im Session Menu!
|
|
159
|
+
if (isSessionMenu) {
|
|
160
|
+
return originalConsole.info(...args);
|
|
161
|
+
}
|
|
162
|
+
|
|
140
163
|
const prefix = formatPrefix(globalConfig.prefix, globalConfig.prefixColor);
|
|
141
164
|
const colorCode = getColor(globalConfig.infoColor);
|
|
142
165
|
|
|
@@ -153,68 +176,55 @@ export const render = {
|
|
|
153
176
|
// Set prefix name
|
|
154
177
|
consolePrefix(name) {
|
|
155
178
|
globalConfig.prefix = name;
|
|
156
|
-
console.log(`β
Console Prefix gesetzt: [${name}]`);
|
|
157
179
|
},
|
|
158
180
|
|
|
159
181
|
// Set prefix color
|
|
160
182
|
consolePrefixColor(color) {
|
|
161
183
|
if (!colors[color]) {
|
|
162
|
-
console.warn(`β οΈ Unbekannte Farbe: ${color}`);
|
|
163
184
|
return;
|
|
164
185
|
}
|
|
165
186
|
globalConfig.prefixColor = color;
|
|
166
|
-
console.log(`π¨ Prefix Farbe gesetzt: ${color}`);
|
|
167
187
|
},
|
|
168
188
|
|
|
169
189
|
// Set default console.log color
|
|
170
190
|
consoleColor(color) {
|
|
171
191
|
if (!colors[color]) {
|
|
172
|
-
console.warn(`β οΈ Unbekannte Farbe: ${color}`);
|
|
173
192
|
return;
|
|
174
193
|
}
|
|
175
194
|
globalConfig.defaultColor = color;
|
|
176
|
-
console.log(`π¨ Console Farbe gesetzt: ${color}`);
|
|
177
195
|
},
|
|
178
196
|
|
|
179
197
|
// Set console.error color
|
|
180
198
|
consoleError(color) {
|
|
181
199
|
if (!colors[color]) {
|
|
182
|
-
console.warn(`β οΈ Unbekannte Farbe: ${color}`);
|
|
183
200
|
return;
|
|
184
201
|
}
|
|
185
202
|
globalConfig.errorColor = color;
|
|
186
|
-
console.log(`π¨ Error Farbe gesetzt: ${color}`);
|
|
187
203
|
},
|
|
188
204
|
|
|
189
205
|
// Set console.warn color
|
|
190
206
|
consoleWarn(color) {
|
|
191
207
|
if (!colors[color]) {
|
|
192
|
-
console.warn(`β οΈ Unbekannte Farbe: ${color}`);
|
|
193
208
|
return;
|
|
194
209
|
}
|
|
195
210
|
globalConfig.warnColor = color;
|
|
196
|
-
console.log(`π¨ Warn Farbe gesetzt: ${color}`);
|
|
197
211
|
},
|
|
198
212
|
|
|
199
213
|
// Set console.info color
|
|
200
214
|
consoleInfo(color) {
|
|
201
215
|
if (!colors[color]) {
|
|
202
|
-
console.warn(`β οΈ Unbekannte Farbe: ${color}`);
|
|
203
216
|
return;
|
|
204
217
|
}
|
|
205
218
|
globalConfig.infoColor = color;
|
|
206
|
-
console.log(`π¨ Info Farbe gesetzt: ${color}`);
|
|
207
219
|
},
|
|
208
220
|
|
|
209
221
|
// Enable/Disable rendering
|
|
210
222
|
enable() {
|
|
211
223
|
globalConfig.enabled = true;
|
|
212
|
-
console.log('β
Console Rendering aktiviert');
|
|
213
224
|
},
|
|
214
225
|
|
|
215
226
|
disable() {
|
|
216
227
|
globalConfig.enabled = false;
|
|
217
|
-
originalConsole.log('β οΈ Console Rendering deaktiviert');
|
|
218
228
|
},
|
|
219
229
|
|
|
220
230
|
// Reset to defaults
|
|
@@ -229,7 +239,6 @@ export const render = {
|
|
|
229
239
|
successColor: 'green',
|
|
230
240
|
enabled: true
|
|
231
241
|
};
|
|
232
|
-
console.log('π Console Rendering zurΓΌckgesetzt');
|
|
233
242
|
},
|
|
234
243
|
|
|
235
244
|
// Get current config
|
|
@@ -271,12 +280,3 @@ export const render = {
|
|
|
271
280
|
|
|
272
281
|
// Export colors for direct use
|
|
273
282
|
export { colors };
|
|
274
|
-
|
|
275
|
-
// Auto-initialize message
|
|
276
|
-
if (globalConfig.enabled) {
|
|
277
|
-
originalConsole.log(
|
|
278
|
-
`${colors.brightCyan}ββββββββββββββββββββββββββββββββββββββββββ${colors.reset}\n` +
|
|
279
|
-
`${colors.brightCyan}β π¨ Console Renderer aktiviert! β${colors.reset}\n` +
|
|
280
|
-
`${colors.brightCyan}ββββββββββββββββββββββββββββββββββββββββββ${colors.reset}`
|
|
281
|
-
);
|
|
282
|
-
}
|
package/src/storage.js
CHANGED
|
@@ -165,15 +165,45 @@ export class WAStorage {
|
|
|
165
165
|
// Schreibe in temporΓ€re Datei
|
|
166
166
|
fs.writeFileSync(tempFilePath, jsonData);
|
|
167
167
|
|
|
168
|
-
// Atomare Umbenennung
|
|
169
|
-
|
|
168
|
+
// Atomare Umbenennung mit Retry fΓΌr Windows EPERM
|
|
169
|
+
let renamed = false;
|
|
170
|
+
let lastError = null;
|
|
171
|
+
const maxRetries = 3;
|
|
172
|
+
const retryDelays = [50, 100, 150]; // ms
|
|
173
|
+
|
|
174
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
175
|
+
try {
|
|
176
|
+
fs.renameSync(tempFilePath, filePath);
|
|
177
|
+
renamed = true;
|
|
178
|
+
break;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
lastError = error;
|
|
181
|
+
if (error.code === 'EPERM' && attempt < maxRetries - 1) {
|
|
182
|
+
// Wait before retry (Windows file lock issue)
|
|
183
|
+
const delay = retryDelays[attempt];
|
|
184
|
+
const start = Date.now();
|
|
185
|
+
while (Date.now() - start < delay) {
|
|
186
|
+
// Busy wait
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!renamed) {
|
|
195
|
+
throw lastError || new Error('Rename failed');
|
|
196
|
+
}
|
|
170
197
|
|
|
171
198
|
// Cache mit GrΓΆΓenlimit aktualisieren
|
|
172
199
|
this.updateCache(fileName, data);
|
|
173
200
|
|
|
174
201
|
return true;
|
|
175
202
|
} catch (error) {
|
|
176
|
-
|
|
203
|
+
// Suppress EPERM error logging (too noisy on Windows)
|
|
204
|
+
if (error.code !== 'EPERM') {
|
|
205
|
+
console.error(`β Fehler beim Schreiben in ${fileName}:`, error);
|
|
206
|
+
}
|
|
177
207
|
|
|
178
208
|
// Cleanup temporΓ€re Datei
|
|
179
209
|
try {
|