waengine 1.7.3 → 1.7.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.
- package/CHANGELOG.md +29 -0
- package/README.md +34 -3
- package/package.json +3 -2
- package/src/ab-testing.js +698 -0
- package/src/advanced-scheduler.js +577 -0
- package/src/ai-features.js +459 -0
- package/src/ai-integration.js +2 -1
- package/src/analytics-manager.js +458 -0
- package/src/business-manager.js +362 -0
- package/src/client.js +447 -39
- package/src/console-logger.js +256 -0
- package/src/core.js +28 -3
- package/src/cross-platform.js +538 -0
- package/src/database-manager.js +766 -0
- package/src/device-manager.js +1 -1
- package/src/easy-bot-fixed.js +341 -0
- package/src/easy-bot.js +503 -22
- package/src/error-handler.js +230 -0
- package/src/gaming-manager.js +842 -0
- package/src/http-client.js +1 -1
- package/src/index.js +15 -0
- package/src/message.js +197 -94
- package/src/multi-client.js +26 -12
- package/src/plugin-manager.js +59 -10
- package/src/prefix-manager.js +48 -1
- package/src/qr-terminal-fix.js +239 -0
- package/src/qr.js +170 -27
- package/src/quick-bot.js +63 -0
- package/src/reporting-manager.js +867 -0
- package/src/scheduler.js +14 -1
- package/src/security-manager.js +678 -0
- package/src/session-manager-old.js +314 -0
- package/src/session-manager.js +429 -24
- package/src/storage.js +254 -194
- package/src/ui-components.js +560 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ConsoleLogger } from "./console-logger.js";
|
|
2
|
+
|
|
3
|
+
export class ErrorHandler {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.options = {
|
|
6
|
+
supportEmail: options.supportEmail || "support@waengine.dev",
|
|
7
|
+
supportDiscord: options.supportDiscord || "https://discord.gg/waengine",
|
|
8
|
+
supportGitHub: options.supportGitHub || "https://github.com/neotreydel-lab/waengine/issues",
|
|
9
|
+
showSupportInfo: options.showSupportInfo !== false,
|
|
10
|
+
logErrors: options.logErrors !== false,
|
|
11
|
+
sendErrorReports: options.sendErrorReports || false,
|
|
12
|
+
...options
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
this.logger = new ConsoleLogger({ silent: false });
|
|
16
|
+
this.errorCount = 0;
|
|
17
|
+
this.lastError = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Handle any error with support information
|
|
22
|
+
*/
|
|
23
|
+
handleError(error, context = {}) {
|
|
24
|
+
this.errorCount++;
|
|
25
|
+
this.lastError = {
|
|
26
|
+
error: error,
|
|
27
|
+
context: context,
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
count: this.errorCount
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Log error details
|
|
33
|
+
if (this.options.logErrors) {
|
|
34
|
+
console.error(`\n❌ WAEngine Error #${this.errorCount}:`);
|
|
35
|
+
console.error(` Context: ${context.action || 'Unknown'}`);
|
|
36
|
+
console.error(` Message: ${error.message}`);
|
|
37
|
+
if (context.details) {
|
|
38
|
+
console.error(` Details: ${context.details}`);
|
|
39
|
+
}
|
|
40
|
+
console.error(` Time: ${new Date().toLocaleString()}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Show support information
|
|
44
|
+
if (this.options.showSupportInfo) {
|
|
45
|
+
this.showSupportInfo(error, context);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Send error report (if enabled)
|
|
49
|
+
if (this.options.sendErrorReports) {
|
|
50
|
+
this.sendErrorReport(error, context);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return this.lastError;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Show support contact information
|
|
58
|
+
*/
|
|
59
|
+
showSupportInfo(error, context) {
|
|
60
|
+
console.log("\n" + "=".repeat(50));
|
|
61
|
+
console.log("❌ FEHLER AUFGETRETEN!");
|
|
62
|
+
console.log("=".repeat(50));
|
|
63
|
+
|
|
64
|
+
// DEINE EMAIL IMMER ZUERST UND PROMINENT!
|
|
65
|
+
console.log(`📧 Bei Problemen melden: ${this.options.supportEmail}`);
|
|
66
|
+
|
|
67
|
+
if (this.options.supportGitHub) {
|
|
68
|
+
console.log(`🐛 Bug Report: ${this.options.supportGitHub}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`\n🔍 Fehler-Details:`);
|
|
72
|
+
console.log(` • Fehler: ${error.message}`);
|
|
73
|
+
console.log(` • WAEngine Version: ${this.getWAEngineVersion()}`);
|
|
74
|
+
console.log(` • Error ID: WAE-${Date.now()}-${this.errorCount}`);
|
|
75
|
+
|
|
76
|
+
// Kurze, hilfreiche Lösungsvorschläge
|
|
77
|
+
console.log(`\n💡 Schnelle Lösung:`);
|
|
78
|
+
this.showQuickFixes(error, context);
|
|
79
|
+
|
|
80
|
+
console.log("=".repeat(50) + "\n");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Show quick fixes for common errors
|
|
85
|
+
*/
|
|
86
|
+
showQuickFixes(error, context) {
|
|
87
|
+
const message = error.message.toLowerCase();
|
|
88
|
+
|
|
89
|
+
if (message.includes('qr') || message.includes('auth')) {
|
|
90
|
+
console.log(" → Lösche 'auth' Ordner und scanne QR neu");
|
|
91
|
+
}
|
|
92
|
+
else if (message.includes('connection') || message.includes('socket')) {
|
|
93
|
+
console.log(" → Prüfe Internetverbindung und starte Bot neu");
|
|
94
|
+
}
|
|
95
|
+
else if (message.includes('sharp') || message.includes('sticker')) {
|
|
96
|
+
console.log(" → Installiere Sharp: npm install sharp");
|
|
97
|
+
}
|
|
98
|
+
else if (message.includes('plugin')) {
|
|
99
|
+
console.log(" → Installiere Dependencies: npm install --force");
|
|
100
|
+
}
|
|
101
|
+
else if (message.includes('permission') || message.includes('admin')) {
|
|
102
|
+
console.log(" → Bot braucht Admin-Rechte in der Gruppe");
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
console.log(" → Starte Bot neu oder kontaktiere Support");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Send error report to support (if enabled)
|
|
111
|
+
*/
|
|
112
|
+
async sendErrorReport(error, context) {
|
|
113
|
+
try {
|
|
114
|
+
const report = {
|
|
115
|
+
errorId: `WAE-${Date.now()}-${this.errorCount}`,
|
|
116
|
+
message: error.message,
|
|
117
|
+
stack: error.stack,
|
|
118
|
+
context: context,
|
|
119
|
+
version: this.getWAEngineVersion(),
|
|
120
|
+
nodeVersion: process.version,
|
|
121
|
+
platform: process.platform,
|
|
122
|
+
timestamp: new Date().toISOString()
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Hier könntest du den Report an deine API senden
|
|
126
|
+
// await fetch('https://api.waengine.dev/error-reports', {
|
|
127
|
+
// method: 'POST',
|
|
128
|
+
// headers: { 'Content-Type': 'application/json' },
|
|
129
|
+
// body: JSON.stringify(report)
|
|
130
|
+
// });
|
|
131
|
+
|
|
132
|
+
console.log("📤 Fehlerbericht automatisch gesendet (Error ID: " + report.errorId + ")");
|
|
133
|
+
} catch (reportError) {
|
|
134
|
+
console.log("⚠️ Fehlerbericht konnte nicht gesendet werden");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Get WAEngine version
|
|
140
|
+
*/
|
|
141
|
+
async getWAEngineVersion() {
|
|
142
|
+
try {
|
|
143
|
+
const { readFile } = await import('fs/promises');
|
|
144
|
+
const packageData = await readFile('./package.json', 'utf8');
|
|
145
|
+
const packageJson = JSON.parse(packageData);
|
|
146
|
+
return packageJson.version;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error('❌ Error reading package.json:', error);
|
|
149
|
+
return 'Unknown';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Handle connection errors specifically
|
|
155
|
+
*/
|
|
156
|
+
handleConnectionError(error, reconnectAttempt = 0) {
|
|
157
|
+
return this.handleError(error, {
|
|
158
|
+
action: 'connection',
|
|
159
|
+
reconnectAttempt: reconnectAttempt,
|
|
160
|
+
details: `Wiederverbindungsversuch ${reconnectAttempt}`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Handle plugin errors specifically
|
|
166
|
+
*/
|
|
167
|
+
handlePluginError(error, pluginName) {
|
|
168
|
+
return this.handleError(error, {
|
|
169
|
+
action: 'plugin',
|
|
170
|
+
plugin: pluginName,
|
|
171
|
+
details: `Plugin '${pluginName}' Fehler`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Handle command errors specifically
|
|
177
|
+
*/
|
|
178
|
+
handleCommandError(error, command, userId) {
|
|
179
|
+
return this.handleError(error, {
|
|
180
|
+
action: 'command',
|
|
181
|
+
command: command,
|
|
182
|
+
user: userId,
|
|
183
|
+
details: `Command '${command}' Fehler`
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Handle message errors specifically
|
|
189
|
+
*/
|
|
190
|
+
handleMessageError(error, messageType) {
|
|
191
|
+
return this.handleError(error, {
|
|
192
|
+
action: 'message',
|
|
193
|
+
messageType: messageType,
|
|
194
|
+
details: `${messageType} Nachricht Fehler`
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get error statistics
|
|
200
|
+
*/
|
|
201
|
+
getErrorStats() {
|
|
202
|
+
return {
|
|
203
|
+
totalErrors: this.errorCount,
|
|
204
|
+
lastError: this.lastError,
|
|
205
|
+
supportContacts: {
|
|
206
|
+
email: this.options.supportEmail,
|
|
207
|
+
discord: this.options.supportDiscord,
|
|
208
|
+
github: this.options.supportGitHub
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Reset error count
|
|
215
|
+
*/
|
|
216
|
+
resetErrorCount() {
|
|
217
|
+
this.errorCount = 0;
|
|
218
|
+
this.lastError = null;
|
|
219
|
+
console.log("🔄 Error Counter zurückgesetzt");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Default Error Handler Instance - IMMER AKTIV FÜR ALLE USER!
|
|
224
|
+
export const defaultErrorHandler = new ErrorHandler({
|
|
225
|
+
supportEmail: "Liaia@outlook.de",
|
|
226
|
+
supportDiscord: "https://discord.gg/waengine",
|
|
227
|
+
supportGitHub: "https://github.com/neotreydel-lab/waengine/issues",
|
|
228
|
+
showSupportInfo: true, // IMMER anzeigen
|
|
229
|
+
logErrors: true // IMMER loggen
|
|
230
|
+
});
|