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,239 @@
|
|
|
1
|
+
// 🔧 ROBUSTE QR-CODE TERMINAL LÖSUNG - VERBESSERT!
|
|
2
|
+
// Behebt abgeschnittene QR-Codes und Terminal-Probleme
|
|
3
|
+
|
|
4
|
+
import qrcode from "qrcode-terminal";
|
|
5
|
+
import os from "os";
|
|
6
|
+
|
|
7
|
+
// QR-Code mit automatischer Terminal-Anpassung - VERBESSERT!
|
|
8
|
+
export function generateTerminalQR(qrData, options = {}) {
|
|
9
|
+
try {
|
|
10
|
+
// Terminal-Informationen sammeln
|
|
11
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
12
|
+
const terminalHeight = process.stdout.rows || 24;
|
|
13
|
+
const platform = os.platform();
|
|
14
|
+
|
|
15
|
+
// Terminal leeren für saubere Anzeige (falls gewünscht)
|
|
16
|
+
if (!options.skipClear) {
|
|
17
|
+
console.clear();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Dynamische QR-Größe basierend auf Terminal - EXTRA KLEIN!
|
|
21
|
+
let qrOptions = { small: true }; // IMMER klein wegen "zu groß" Problem
|
|
22
|
+
let borderSize = 40;
|
|
23
|
+
let qrSize = "extra klein";
|
|
24
|
+
|
|
25
|
+
// Auch bei großen Terminals klein halten
|
|
26
|
+
if (terminalWidth >= 120 && terminalHeight >= 35) {
|
|
27
|
+
// Großes Terminal - trotzdem kleine QR-Größe
|
|
28
|
+
qrOptions = { small: true }; // War: { small: false }
|
|
29
|
+
borderSize = 50;
|
|
30
|
+
qrSize = "klein (angepasst)";
|
|
31
|
+
} else if (terminalWidth >= 80 && terminalHeight >= 25) {
|
|
32
|
+
// Mittleres Terminal - kleine QR-Größe
|
|
33
|
+
qrOptions = { small: true };
|
|
34
|
+
borderSize = 45;
|
|
35
|
+
qrSize = "klein";
|
|
36
|
+
} else {
|
|
37
|
+
// Kleines Terminal - extra kleine QR-Größe
|
|
38
|
+
qrOptions = { small: true };
|
|
39
|
+
borderSize = Math.min(terminalWidth - 4, 35);
|
|
40
|
+
qrSize = "extra klein";
|
|
41
|
+
|
|
42
|
+
if (terminalWidth < 50) {
|
|
43
|
+
console.log("⚠️ WARNUNG: Terminal ist sehr schmal!");
|
|
44
|
+
console.log("💡 QR-Code wird extra klein angezeigt");
|
|
45
|
+
console.log("");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Header mit dynamischer Breite
|
|
50
|
+
const border = "=".repeat(Math.min(borderSize, terminalWidth - 2));
|
|
51
|
+
console.log("\n" + border);
|
|
52
|
+
console.log("📱 WAEngine QR-Code - Einmal scannen und fertig!");
|
|
53
|
+
console.log(border);
|
|
54
|
+
console.log(`🖥️ Terminal: ${terminalWidth}x${terminalHeight} (${platform})`);
|
|
55
|
+
console.log(`📏 QR-Größe: ${qrSize}`);
|
|
56
|
+
console.log("");
|
|
57
|
+
|
|
58
|
+
// QR-Code generieren mit Fehlerbehandlung
|
|
59
|
+
try {
|
|
60
|
+
qrcode.generate(qrData, qrOptions);
|
|
61
|
+
console.log("");
|
|
62
|
+
console.log("✅ QR-Code erfolgreich angezeigt");
|
|
63
|
+
} catch (qrError) {
|
|
64
|
+
console.error("❌ QR-Code Generierung fehlgeschlagen:", qrError.message);
|
|
65
|
+
|
|
66
|
+
// Fallback: QR-Daten als Text
|
|
67
|
+
console.log("📋 QR-Daten (für externe QR-Apps):");
|
|
68
|
+
console.log(qrData);
|
|
69
|
+
console.log("💡 Kopiere die Daten in eine QR-Generator App oder Website");
|
|
70
|
+
|
|
71
|
+
return { success: false, fallback: true };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log(border);
|
|
75
|
+
console.log("📲 WhatsApp Anleitung:");
|
|
76
|
+
console.log(" 1. Öffne WhatsApp auf deinem Handy");
|
|
77
|
+
console.log(" 2. Gehe zu Einstellungen (⚙️)");
|
|
78
|
+
console.log(" 3. Tippe auf 'Verknüpfte Geräte'");
|
|
79
|
+
console.log(" 4. Tippe auf 'Gerät verknüpfen'");
|
|
80
|
+
console.log(" 5. Scanne den QR-Code OBEN");
|
|
81
|
+
console.log(border);
|
|
82
|
+
console.log("⏳ Warte auf QR-Scan...");
|
|
83
|
+
|
|
84
|
+
// Terminal-spezifische Tipps - VERBESSERT!
|
|
85
|
+
if (terminalWidth < 60) {
|
|
86
|
+
console.log("");
|
|
87
|
+
console.log("💡 TERMINAL-TIPPS:");
|
|
88
|
+
console.log(" • Vergrößere das Terminal-Fenster");
|
|
89
|
+
console.log(" • Verwende Vollbild-Modus");
|
|
90
|
+
console.log(" • Reduziere die Schriftgröße");
|
|
91
|
+
console.log(" • Nutze Browser QR als Alternative");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
qrSize: qrSize,
|
|
97
|
+
terminalSize: `${terminalWidth}x${terminalHeight}`,
|
|
98
|
+
platform: platform
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error("❌ Terminal QR-Code Fehler:", error.message);
|
|
103
|
+
|
|
104
|
+
// Fallback: Minimale QR-Anzeige
|
|
105
|
+
try {
|
|
106
|
+
console.log("🔄 Versuche Fallback QR-Code...");
|
|
107
|
+
qrcode.generate(qrData, { small: true });
|
|
108
|
+
console.log("✅ Fallback QR-Code angezeigt");
|
|
109
|
+
return { success: true, fallback: true };
|
|
110
|
+
} catch (fallbackError) {
|
|
111
|
+
console.log("❌ Auch Fallback fehlgeschlagen");
|
|
112
|
+
console.log("📋 QR-Daten:", qrData);
|
|
113
|
+
return { success: false, error: error.message };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// QR-Code mit Retry-Mechanismus - VERBESSERT!
|
|
119
|
+
export async function generateQRWithRetry(qrData, maxRetries = 2) {
|
|
120
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
121
|
+
try {
|
|
122
|
+
console.log(`🔄 QR-Code Versuch ${attempt}/${maxRetries}...`);
|
|
123
|
+
|
|
124
|
+
const result = generateTerminalQR(qrData, {
|
|
125
|
+
skipClear: attempt > 1 // Nur beim ersten Mal Terminal leeren
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (result.success) {
|
|
129
|
+
console.log(`✅ QR-Code erfolgreich beim ${attempt}. Versuch`);
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (attempt < maxRetries) {
|
|
134
|
+
console.log(`⚠️ Versuch ${attempt} fehlgeschlagen, versuche erneut...`);
|
|
135
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error(`❌ QR-Code Versuch ${attempt} Fehler:`, error.message);
|
|
140
|
+
|
|
141
|
+
if (attempt === maxRetries) {
|
|
142
|
+
throw new Error(`QR-Code nach ${maxRetries} Versuchen fehlgeschlagen: ${error.message}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
throw new Error(`QR-Code nach ${maxRetries} Versuchen fehlgeschlagen`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Terminal-Kompatibilität prüfen - VERBESSERT!
|
|
151
|
+
export function checkTerminalQRCompatibility() {
|
|
152
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
153
|
+
const terminalHeight = process.stdout.rows || 24;
|
|
154
|
+
const platform = os.platform();
|
|
155
|
+
const nodeVersion = process.version;
|
|
156
|
+
|
|
157
|
+
const compatibility = {
|
|
158
|
+
platform: platform,
|
|
159
|
+
terminalSize: `${terminalWidth}x${terminalHeight}`,
|
|
160
|
+
nodeVersion: nodeVersion,
|
|
161
|
+
issues: [],
|
|
162
|
+
recommendations: [],
|
|
163
|
+
score: 100
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Terminal-Größe prüfen
|
|
167
|
+
if (terminalWidth < 50) {
|
|
168
|
+
compatibility.issues.push("Terminal zu schmal für QR-Code");
|
|
169
|
+
compatibility.recommendations.push("Vergrößere das Terminal-Fenster");
|
|
170
|
+
compatibility.score -= 30;
|
|
171
|
+
} else if (terminalWidth < 80) {
|
|
172
|
+
compatibility.issues.push("Terminal schmal - QR könnte abgeschnitten sein");
|
|
173
|
+
compatibility.recommendations.push("Vergrößere das Terminal für bessere Anzeige");
|
|
174
|
+
compatibility.score -= 15;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (terminalHeight < 20) {
|
|
178
|
+
compatibility.issues.push("Terminal zu niedrig für QR-Code");
|
|
179
|
+
compatibility.recommendations.push("Vergrößere das Terminal vertikal");
|
|
180
|
+
compatibility.score -= 20;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Plattform-spezifische Checks
|
|
184
|
+
switch (platform) {
|
|
185
|
+
case 'win32':
|
|
186
|
+
if (process.env.TERM_PROGRAM !== 'vscode') {
|
|
187
|
+
compatibility.recommendations.push("Verwende Windows Terminal oder VS Code Terminal");
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
|
|
191
|
+
case 'darwin':
|
|
192
|
+
compatibility.recommendations.push("iTerm2 oder Terminal.app funktionieren optimal");
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
case 'linux':
|
|
196
|
+
compatibility.recommendations.push("Gnome Terminal oder Konsole empfohlen");
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Node.js Version prüfen
|
|
201
|
+
const majorVersion = parseInt(nodeVersion.split('.')[0].substring(1));
|
|
202
|
+
if (majorVersion < 16) {
|
|
203
|
+
compatibility.issues.push("Node.js Version könnte zu alt sein");
|
|
204
|
+
compatibility.recommendations.push("Aktualisiere auf Node.js 16+");
|
|
205
|
+
compatibility.score -= 10;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return compatibility;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Debug-Informationen für QR-System - VERBESSERT!
|
|
212
|
+
export function debugQRSystem() {
|
|
213
|
+
const compatibility = checkTerminalQRCompatibility();
|
|
214
|
+
|
|
215
|
+
console.log("🔍 QR-SYSTEM DEBUG INFO:");
|
|
216
|
+
console.log("=".repeat(40));
|
|
217
|
+
console.log(`🖥️ Plattform: ${compatibility.platform}`);
|
|
218
|
+
console.log(`📏 Terminal: ${compatibility.terminalSize}`);
|
|
219
|
+
console.log(`📦 Node.js: ${compatibility.nodeVersion}`);
|
|
220
|
+
console.log(`⭐ Score: ${compatibility.score}/100`);
|
|
221
|
+
|
|
222
|
+
if (compatibility.issues.length > 0) {
|
|
223
|
+
console.log("\n⚠️ GEFUNDENE PROBLEME:");
|
|
224
|
+
compatibility.issues.forEach((issue, index) => {
|
|
225
|
+
console.log(` ${index + 1}. ${issue}`);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (compatibility.recommendations.length > 0) {
|
|
230
|
+
console.log("\n💡 EMPFEHLUNGEN:");
|
|
231
|
+
compatibility.recommendations.forEach((rec, index) => {
|
|
232
|
+
console.log(` ${index + 1}. ${rec}`);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
console.log("=".repeat(40));
|
|
237
|
+
|
|
238
|
+
return compatibility;
|
|
239
|
+
}
|
package/src/qr.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import qrcode from "qrcode-terminal";
|
|
2
2
|
import { exec } from "child_process";
|
|
3
3
|
import { promisify } from "util";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
4
|
import os from "os";
|
|
5
|
+
import { generateTerminalQR, generateQRWithRetry, checkTerminalQRCompatibility, debugQRSystem as debugQRSystemFromFix } from "./qr-terminal-fix.js";
|
|
7
6
|
|
|
8
7
|
const execAsync = promisify(exec);
|
|
9
8
|
|
|
@@ -12,7 +11,6 @@ let page = null;
|
|
|
12
11
|
let httpServer = null;
|
|
13
12
|
let lastQRTime = 0;
|
|
14
13
|
let qrDisplayCount = 0;
|
|
15
|
-
let isQRDisplayed = false;
|
|
16
14
|
|
|
17
15
|
// Cross-Platform Browser Detection
|
|
18
16
|
const BROWSERS = {
|
|
@@ -40,45 +38,70 @@ const BROWSERS = {
|
|
|
40
38
|
]
|
|
41
39
|
};
|
|
42
40
|
|
|
43
|
-
export async function generateQRCode(qrData = null) {
|
|
41
|
+
export async function generateQRCode(qrData = null, options = {}) {
|
|
44
42
|
try {
|
|
45
43
|
// QR-Spam Prevention - nur alle 30 Sekunden im Terminal anzeigen
|
|
46
44
|
const now = Date.now();
|
|
47
45
|
const timeSinceLastQR = now - lastQRTime;
|
|
48
46
|
const shouldShowTerminalQR = timeSinceLastQR > 30000 || qrDisplayCount === 0;
|
|
49
47
|
|
|
48
|
+
// Terminal-Größe prüfen für bessere QR-Anzeige
|
|
49
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
50
|
+
const terminalHeight = process.stdout.rows || 24;
|
|
51
|
+
|
|
50
52
|
if (qrData && shouldShowTerminalQR) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// Terminal leeren für saubere QR-Anzeige
|
|
54
|
+
if (options.clearTerminal !== false) {
|
|
55
|
+
console.clear();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log("📱 WAEngine QR-Code - Einmal scannen und fertig!");
|
|
59
|
+
console.log("=".repeat(Math.min(50, terminalWidth - 2)));
|
|
60
|
+
console.log(`🖥️ Terminal: ${terminalWidth}x${terminalHeight}`);
|
|
55
61
|
|
|
56
|
-
//
|
|
57
|
-
|
|
62
|
+
// Warnung bei kleinem Terminal
|
|
63
|
+
if (terminalWidth < 60) {
|
|
64
|
+
console.log("⚠️ TERMINAL ZU SCHMAL - QR extra klein angezeigt!");
|
|
65
|
+
console.log("💡 Vergrößere das Terminal-Fenster für bessere QR-Anzeige");
|
|
66
|
+
console.log("");
|
|
67
|
+
}
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
try {
|
|
70
|
+
// IMMER kleine QR-Größe verwenden (wegen "zu groß" Problem)
|
|
71
|
+
let qrOptions = { small: true }; // IMMER klein!
|
|
72
|
+
|
|
73
|
+
console.log("📱 Verwende extra kleine QR-Größe");
|
|
74
|
+
console.log("");
|
|
75
|
+
qrcode.generate(qrData, qrOptions);
|
|
76
|
+
console.log("");
|
|
77
|
+
console.log("✅ QR-Code erfolgreich angezeigt (extra klein)");
|
|
78
|
+
|
|
79
|
+
} catch (qrError) {
|
|
80
|
+
console.error("❌ QR-Code Generierung fehlgeschlagen:", qrError.message);
|
|
81
|
+
console.log("📋 QR-Daten für externe QR-App:");
|
|
82
|
+
console.log(qrData);
|
|
83
|
+
console.log("💡 Kopiere die Daten in eine QR-Generator Website");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log("=".repeat(Math.min(50, terminalWidth - 2)));
|
|
60
87
|
console.log("📲 WhatsApp Anleitung:");
|
|
61
88
|
console.log(" 1. Öffne WhatsApp auf deinem Handy");
|
|
62
|
-
console.log(" 2. Gehe zu Einstellungen
|
|
63
|
-
console.log(" 3. Tippe auf '
|
|
64
|
-
console.log(" 4.
|
|
65
|
-
console.log("
|
|
66
|
-
console.log("
|
|
67
|
-
console.log(`⏳ Warte auf QR-Scan... (${qrDisplayCount + 1}. Versuch)`);
|
|
68
|
-
console.log("💡 QR-Code wird auch im Browser angezeigt!");
|
|
69
|
-
console.log("");
|
|
89
|
+
console.log(" 2. Gehe zu Einstellungen → Verknüpfte Geräte");
|
|
90
|
+
console.log(" 3. Tippe auf 'Gerät verknüpfen'");
|
|
91
|
+
console.log(" 4. Scanne den QR-Code OBEN");
|
|
92
|
+
console.log("=".repeat(Math.min(50, terminalWidth - 2)));
|
|
93
|
+
console.log("⏳ Warte auf QR-Scan...");
|
|
70
94
|
|
|
71
95
|
lastQRTime = now;
|
|
72
96
|
qrDisplayCount++;
|
|
73
|
-
isQRDisplayed = true;
|
|
74
97
|
} else if (qrData && !shouldShowTerminalQR) {
|
|
75
98
|
// Nur kurze Info ohne QR-Spam
|
|
76
99
|
console.log(`🔄 QR-Code aktualisiert (${qrDisplayCount + 1}. Mal) - Browser verwenden oder 30s warten`);
|
|
77
100
|
qrDisplayCount++;
|
|
78
101
|
}
|
|
79
102
|
|
|
80
|
-
// Browser QR
|
|
81
|
-
if (qrData) {
|
|
103
|
+
// Browser QR nur versuchen wenn nicht explizit deaktiviert
|
|
104
|
+
if (qrData && options.skipBrowser !== true) {
|
|
82
105
|
await openUniversalBrowser(qrData);
|
|
83
106
|
}
|
|
84
107
|
|
|
@@ -87,9 +110,18 @@ export async function generateQRCode(qrData = null) {
|
|
|
87
110
|
} catch (error) {
|
|
88
111
|
console.error("❌ QR-System Fehler:", error.message);
|
|
89
112
|
|
|
90
|
-
// Fallback
|
|
113
|
+
// Robuster Fallback
|
|
91
114
|
if (qrData && qrDisplayCount === 0) {
|
|
92
|
-
console.log("📱
|
|
115
|
+
console.log("📱 Fallback: Einfacher QR-Code");
|
|
116
|
+
try {
|
|
117
|
+
// Minimaler QR-Code als Fallback
|
|
118
|
+
qrcode.generate(qrData, { small: true });
|
|
119
|
+
console.log("📱 Terminal QR-Code verfügbar (siehe oben)");
|
|
120
|
+
} catch (fallbackError) {
|
|
121
|
+
console.log("❌ Auch Fallback-QR fehlgeschlagen");
|
|
122
|
+
console.log("🌐 Verwende Browser oder externe QR-App");
|
|
123
|
+
console.log(`📋 QR-Daten: ${qrData}`);
|
|
124
|
+
}
|
|
93
125
|
qrDisplayCount++;
|
|
94
126
|
}
|
|
95
127
|
|
|
@@ -101,7 +133,6 @@ export async function generateQRCode(qrData = null) {
|
|
|
101
133
|
export function resetQRStatus() {
|
|
102
134
|
lastQRTime = 0;
|
|
103
135
|
qrDisplayCount = 0;
|
|
104
|
-
isQRDisplayed = false;
|
|
105
136
|
console.log("🔄 QR-Status zurückgesetzt");
|
|
106
137
|
}
|
|
107
138
|
|
|
@@ -507,7 +538,7 @@ export async function closeBrowser() {
|
|
|
507
538
|
}
|
|
508
539
|
}
|
|
509
540
|
|
|
510
|
-
// Hilfsfunktion um QR-Code als Data URL zu generieren (
|
|
541
|
+
// Hilfsfunktion um QR-Code als Data URL zu generieren (für zukünftige Features)
|
|
511
542
|
async function generateQRCodeDataURL(qrData) {
|
|
512
543
|
try {
|
|
513
544
|
const QRCode = await import('qrcode');
|
|
@@ -523,4 +554,116 @@ async function generateQRCodeDataURL(qrData) {
|
|
|
523
554
|
console.error("❌ Fehler beim QR-Code DataURL:", error);
|
|
524
555
|
return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0iI2Y4ZjlmYSIvPjx0ZXh0IHg9IjIwMCIgeT0iMjAwIiBmb250LWZhbWlseT0iQXJpYWwiIGZvbnQtc2l6ZT0iMjAiIGZpbGw9IiM2NjY2NjYiIHRleHQtYW5jaG9yPSJtaWRkbGUiPkVycm9yPC90ZXh0Pjwvc3ZnPg==';
|
|
525
556
|
}
|
|
526
|
-
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// Export für zukünftige Verwendung
|
|
560
|
+
export { generateQRCodeDataURL, checkTerminalQRCompatibility, debugQRSystemFromFix as debugQRSystem, generateTerminalQR };
|
|
561
|
+
// ===== ERWEITERTE QR-CODE FUNKTIONEN =====
|
|
562
|
+
|
|
563
|
+
// Terminal-Kompatibilität prüfen
|
|
564
|
+
export function checkTerminalCompatibility() {
|
|
565
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
566
|
+
const terminalHeight = process.stdout.rows || 24;
|
|
567
|
+
const platform = os.platform();
|
|
568
|
+
|
|
569
|
+
const compatibility = {
|
|
570
|
+
width: terminalWidth,
|
|
571
|
+
height: terminalHeight,
|
|
572
|
+
platform: platform,
|
|
573
|
+
supportsQR: terminalWidth >= 40 && terminalHeight >= 15,
|
|
574
|
+
recommendedSize: terminalWidth >= 100 ? 'normal' : 'small',
|
|
575
|
+
issues: []
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
if (terminalWidth < 40) {
|
|
579
|
+
compatibility.issues.push('Terminal zu schmal für QR-Code');
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if (terminalHeight < 15) {
|
|
583
|
+
compatibility.issues.push('Terminal zu niedrig für QR-Code');
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (platform === 'win32' && !process.env.WT_SESSION) {
|
|
587
|
+
compatibility.issues.push('Windows CMD hat begrenzte QR-Unterstützung');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return compatibility;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// QR-Code mit Fallback-Strategien
|
|
594
|
+
export async function generateRobustQR(qrData, options = {}) {
|
|
595
|
+
const compatibility = checkTerminalCompatibility();
|
|
596
|
+
|
|
597
|
+
console.log(`🖥️ Terminal: ${compatibility.width}x${compatibility.height} (${compatibility.platform})`);
|
|
598
|
+
|
|
599
|
+
if (compatibility.issues.length > 0) {
|
|
600
|
+
console.log("⚠️ Terminal-Probleme erkannt:");
|
|
601
|
+
compatibility.issues.forEach(issue => console.log(` • ${issue}`));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Strategie 1: Terminal QR (wenn kompatibel)
|
|
605
|
+
if (compatibility.supportsQR && !options.skipTerminal) {
|
|
606
|
+
try {
|
|
607
|
+
const qrOptions = {
|
|
608
|
+
small: compatibility.recommendedSize === 'small'
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
console.log("📱 QR-Code im Terminal:");
|
|
612
|
+
qrcode.generate(qrData, qrOptions);
|
|
613
|
+
console.log("✅ Terminal QR-Code angezeigt");
|
|
614
|
+
|
|
615
|
+
} catch (terminalError) {
|
|
616
|
+
console.log("❌ Terminal QR-Code fehlgeschlagen:", terminalError.message);
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
console.log("⚠️ Terminal nicht kompatibel für QR-Code");
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Strategie 2: Browser QR (immer versuchen)
|
|
623
|
+
try {
|
|
624
|
+
await openUniversalBrowser(qrData);
|
|
625
|
+
console.log("✅ Browser QR-Code geöffnet");
|
|
626
|
+
} catch (browserError) {
|
|
627
|
+
console.log("❌ Browser QR-Code fehlgeschlagen:", browserError.message);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Strategie 3: QR-Daten als Text (Fallback)
|
|
631
|
+
if (!compatibility.supportsQR || options.showData) {
|
|
632
|
+
console.log("📋 QR-Daten (für externe QR-Apps):");
|
|
633
|
+
console.log(qrData);
|
|
634
|
+
console.log("💡 Kopiere die Daten in eine QR-Generator App");
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return {
|
|
638
|
+
terminalShown: compatibility.supportsQR,
|
|
639
|
+
browserAttempted: true,
|
|
640
|
+
compatibility: compatibility
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// QR-Code Debugging-Informationen (verwende die aus qr-terminal-fix.js)
|
|
645
|
+
// export function debugQRSystem() {
|
|
646
|
+
// const compatibility = checkTerminalCompatibility();
|
|
647
|
+
// console.log("\n🔍 QR-SYSTEM DEBUG INFO:");
|
|
648
|
+
// console.log("=".repeat(50));
|
|
649
|
+
// console.log(`Platform: ${compatibility.platform}`);
|
|
650
|
+
// console.log(`Terminal: ${compatibility.width}x${compatibility.height}`);
|
|
651
|
+
// console.log(`QR Support: ${compatibility.supportsQR ? '✅' : '❌'}`);
|
|
652
|
+
// console.log(`Recommended Size: ${compatibility.recommendedSize}`);
|
|
653
|
+
//
|
|
654
|
+
// if (compatibility.issues.length > 0) {
|
|
655
|
+
// console.log("Issues:");
|
|
656
|
+
// compatibility.issues.forEach(issue => console.log(` • ${issue}`));
|
|
657
|
+
// }
|
|
658
|
+
//
|
|
659
|
+
// console.log(`Node Version: ${process.version}`);
|
|
660
|
+
// console.log(`Environment: ${process.env.NODE_ENV || 'development'}`);
|
|
661
|
+
// console.log(`Terminal Type: ${process.env.TERM || 'unknown'}`);
|
|
662
|
+
// console.log(`Windows Terminal: ${process.env.WT_SESSION ? 'Yes' : 'No'}`);
|
|
663
|
+
// console.log("=".repeat(50));
|
|
664
|
+
//
|
|
665
|
+
// return compatibility;
|
|
666
|
+
// }
|
|
667
|
+
|
|
668
|
+
// QR-Code mit Retry-Mechanismus (aus qr-terminal-fix.js importiert)
|
|
669
|
+
// Diese Funktion ist bereits in qr-terminal-fix.js definiert
|
package/src/quick-bot.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// 🚀 QuickBot - WIRKLICH einfache WhatsApp Bot API
|
|
2
|
+
import { WhatsAppClient } from "./client.js";
|
|
3
|
+
|
|
4
|
+
export class QuickBot {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.client = new WhatsAppClient({
|
|
7
|
+
authDir: './auth',
|
|
8
|
+
quietHeartbeat: true,
|
|
9
|
+
logLevel: 'silent'
|
|
10
|
+
});
|
|
11
|
+
this.responses = new Map();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Einfache Antworten
|
|
15
|
+
when(trigger, response) {
|
|
16
|
+
this.responses.set(trigger.toLowerCase(), response);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Alias für when
|
|
21
|
+
on(trigger, response) {
|
|
22
|
+
return this.when(trigger, response);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Bot starten
|
|
26
|
+
async start() {
|
|
27
|
+
// Message Handler
|
|
28
|
+
this.client.on('message', async (msg) => {
|
|
29
|
+
if (msg.isCommand) return; // Skip commands
|
|
30
|
+
|
|
31
|
+
const text = msg.text?.toLowerCase() || '';
|
|
32
|
+
|
|
33
|
+
// Check responses
|
|
34
|
+
for (const [trigger, response] of this.responses) {
|
|
35
|
+
if (text === trigger || text.includes(trigger)) {
|
|
36
|
+
const reply = typeof response === 'function' ? await response(msg) : response;
|
|
37
|
+
await msg.reply(reply);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await this.client.connect();
|
|
44
|
+
console.log('🚀 QuickBot started!');
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Bot stoppen
|
|
49
|
+
async stop() {
|
|
50
|
+
await this.client.disconnect();
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Factory function für noch einfachere Verwendung
|
|
56
|
+
export function quickBot() {
|
|
57
|
+
return new QuickBot();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Super einfache One-Liner API
|
|
61
|
+
export function createBot() {
|
|
62
|
+
return new QuickBot();
|
|
63
|
+
}
|