waengine 1.0.2 → 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.
- package/package.json +2 -1
- package/src/client.js +155 -23
- package/src/qr.js +132 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "🚀 WAEngine - The most powerful WhatsApp Bot Library with Multi-Device Support & EasyBot API",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
|
50
50
|
"pino": "^8.0.0",
|
|
51
51
|
"playwright": "^1.58.1",
|
|
52
|
+
"qrcode": "^1.5.4",
|
|
52
53
|
"qrcode-terminal": "^0.12.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
package/src/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeWASocket, useMultiFileAuthState, DisconnectReason, fetchLatestBaileysVersion } from "@whiskeysockets/baileys";
|
|
1
|
+
import { makeWASocket, useMultiFileAuthState, DisconnectReason, fetchLatestBaileysVersion, isJidBroadcast } from "@whiskeysockets/baileys";
|
|
2
2
|
import pino from "pino";
|
|
3
3
|
import { generateQRCode, closeBrowser } from "./qr.js";
|
|
4
4
|
import { Message } from "./message.js";
|
|
@@ -48,22 +48,42 @@ export class WhatsAppClient {
|
|
|
48
48
|
this.socket = makeWASocket({
|
|
49
49
|
version,
|
|
50
50
|
auth: state,
|
|
51
|
-
printQRInTerminal: this.options.printQR,
|
|
52
51
|
logger: pino({ level: this.options.logLevel }),
|
|
53
52
|
browser: this.options.browser,
|
|
54
53
|
generateHighQualityLinkPreview: true,
|
|
55
|
-
syncFullHistory:
|
|
56
|
-
markOnlineOnConnect: true
|
|
54
|
+
syncFullHistory: true, // Wichtig für Message-Empfang
|
|
55
|
+
markOnlineOnConnect: true,
|
|
56
|
+
getMessage: async (key) => {
|
|
57
|
+
// Wichtig für Message-Handling
|
|
58
|
+
return { conversation: "Message not found" };
|
|
59
|
+
},
|
|
60
|
+
shouldIgnoreJid: jid => isJidBroadcast(jid),
|
|
61
|
+
// Bessere Message-Synchronisation
|
|
62
|
+
emitOwnEvents: true,
|
|
63
|
+
fireInitQueries: true,
|
|
64
|
+
shouldSyncHistoryMessage: msg => {
|
|
65
|
+
return !!msg.message && !msg.key.fromMe;
|
|
66
|
+
}
|
|
57
67
|
});
|
|
58
68
|
} catch (versionError) {
|
|
59
69
|
this.socket = makeWASocket({
|
|
60
70
|
auth: state,
|
|
61
|
-
printQRInTerminal: this.options.printQR,
|
|
62
71
|
logger: pino({ level: this.options.logLevel }),
|
|
63
72
|
browser: this.options.browser,
|
|
64
73
|
generateHighQualityLinkPreview: true,
|
|
65
|
-
syncFullHistory:
|
|
66
|
-
markOnlineOnConnect: true
|
|
74
|
+
syncFullHistory: true, // Wichtig für Message-Empfang
|
|
75
|
+
markOnlineOnConnect: true,
|
|
76
|
+
getMessage: async (key) => {
|
|
77
|
+
// Wichtig für Message-Handling
|
|
78
|
+
return { conversation: "Message not found" };
|
|
79
|
+
},
|
|
80
|
+
shouldIgnoreJid: jid => isJidBroadcast(jid),
|
|
81
|
+
// Bessere Message-Synchronisation
|
|
82
|
+
emitOwnEvents: true,
|
|
83
|
+
fireInitQueries: true,
|
|
84
|
+
shouldSyncHistoryMessage: msg => {
|
|
85
|
+
return !!msg.message && !msg.key.fromMe;
|
|
86
|
+
}
|
|
67
87
|
});
|
|
68
88
|
}
|
|
69
89
|
|
|
@@ -75,20 +95,44 @@ export class WhatsAppClient {
|
|
|
75
95
|
}
|
|
76
96
|
|
|
77
97
|
return new Promise((resolve, reject) => {
|
|
98
|
+
// Event-Handler SOFORT registrieren, nicht erst bei "open"
|
|
99
|
+
this.setupEventHandlers();
|
|
100
|
+
|
|
78
101
|
this.socket.ev.on("connection.update", async ({ connection, lastDisconnect, qr }) => {
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
console.log(`🔄 Connection Update: ${connection}`);
|
|
103
|
+
|
|
104
|
+
if (qr) {
|
|
105
|
+
console.log("📱 QR-Code empfangen");
|
|
106
|
+
if (this.options.printQR) {
|
|
107
|
+
// Terminal QR
|
|
108
|
+
console.log("\n📱 QR-CODE IM TERMINAL:");
|
|
109
|
+
console.log("─".repeat(50));
|
|
110
|
+
const qrcode = await import("qrcode-terminal");
|
|
111
|
+
qrcode.default.generate(qr, { small: true });
|
|
112
|
+
console.log("─".repeat(50));
|
|
113
|
+
console.log("📲 Scanne den QR-Code mit WhatsApp!");
|
|
114
|
+
} else {
|
|
115
|
+
// Browser QR
|
|
116
|
+
await generateQRCode(qr);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (connection === "connecting") {
|
|
121
|
+
console.log("🔄 Verbinde mit WhatsApp...");
|
|
81
122
|
}
|
|
82
123
|
|
|
83
124
|
if (connection === "close") {
|
|
125
|
+
console.log("🔴 Verbindung geschlossen");
|
|
84
126
|
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
85
127
|
const shouldReconnect = statusCode !== DisconnectReason.loggedOut;
|
|
86
128
|
|
|
87
129
|
if (shouldReconnect) {
|
|
130
|
+
console.log("🔄 Wiederverbindung in 3 Sekunden...");
|
|
88
131
|
this.isConnected = false;
|
|
89
132
|
this.socket = null;
|
|
90
133
|
setTimeout(() => this.connect().then(resolve).catch(reject), 3000);
|
|
91
134
|
} else {
|
|
135
|
+
console.log("👋 Ausgeloggt");
|
|
92
136
|
await closeBrowser();
|
|
93
137
|
this.emit('disconnected', { reason: 'logged_out' });
|
|
94
138
|
reject(new Error('Logged out'));
|
|
@@ -96,7 +140,7 @@ export class WhatsAppClient {
|
|
|
96
140
|
} else if (connection === "open") {
|
|
97
141
|
console.log("✅ WhatsApp verbunden!");
|
|
98
142
|
this.isConnected = true;
|
|
99
|
-
|
|
143
|
+
await closeBrowser(); // QR Browser schließen
|
|
100
144
|
this.emit('connected');
|
|
101
145
|
resolve(this);
|
|
102
146
|
}
|
|
@@ -157,14 +201,51 @@ export class WhatsAppClient {
|
|
|
157
201
|
}
|
|
158
202
|
|
|
159
203
|
setupEventHandlers() {
|
|
160
|
-
|
|
204
|
+
console.log("🔧 Registriere Event-Handler...");
|
|
205
|
+
|
|
206
|
+
// Messages - Verbesserte Message-Erkennung
|
|
161
207
|
this.socket.ev.on("messages.upsert", ({ messages, type }) => {
|
|
162
|
-
|
|
208
|
+
console.log(`📨 Messages.upsert - Type: ${type}, Count: ${messages.length}`);
|
|
209
|
+
|
|
210
|
+
// Alle Message-Types verarbeiten, nicht nur "notify"
|
|
211
|
+
if (type !== "notify" && type !== "append") {
|
|
212
|
+
console.log(`⚠️ Ignoriere Message-Type: ${type}`);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
163
215
|
|
|
164
|
-
messages.forEach(msg => {
|
|
165
|
-
|
|
216
|
+
messages.forEach((msg, index) => {
|
|
217
|
+
console.log(`🔍 Processing message ${index + 1}/${messages.length}`);
|
|
218
|
+
console.log(` - From: ${msg.key.remoteJid}`);
|
|
219
|
+
console.log(` - FromMe: ${msg.key.fromMe}`);
|
|
220
|
+
console.log(` - Message Keys: ${Object.keys(msg.message || {}).join(', ')}`);
|
|
221
|
+
|
|
222
|
+
// Bessere Message-Validierung
|
|
223
|
+
if (!msg.message) {
|
|
224
|
+
console.log(" ❌ Keine Message-Daten");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (msg.key.fromMe) {
|
|
229
|
+
console.log(" ❌ Eigene Nachricht - ignoriert");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Ignoriere Broadcast-Messages
|
|
234
|
+
if (msg.key.remoteJid && isJidBroadcast(msg.key.remoteJid)) {
|
|
235
|
+
console.log(" ❌ Broadcast-Message - ignoriert");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
166
238
|
|
|
167
239
|
const messageData = this.parseMessage(msg);
|
|
240
|
+
console.log(` ✅ Text extrahiert: "${messageData.text}"`);
|
|
241
|
+
console.log(` ✅ Type: ${messageData.type}`);
|
|
242
|
+
|
|
243
|
+
// Nur verarbeiten wenn Text vorhanden oder andere unterstützte Typen
|
|
244
|
+
if (!messageData.text && messageData.type === 'unknown') {
|
|
245
|
+
console.log(" ❌ Kein Text und unbekannter Typ");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
168
249
|
const messageObj = new Message(this, messageData);
|
|
169
250
|
|
|
170
251
|
// Prefix System - Command Check
|
|
@@ -172,6 +253,8 @@ export class WhatsAppClient {
|
|
|
172
253
|
const commandText = messageData.text.slice(this.prefix.length).trim();
|
|
173
254
|
const [command, ...args] = commandText.split(' ');
|
|
174
255
|
|
|
256
|
+
console.log(` ⚡ Command erkannt: ${command}`);
|
|
257
|
+
|
|
175
258
|
messageObj.isCommand = true;
|
|
176
259
|
messageObj.command = command.toLowerCase();
|
|
177
260
|
messageObj.args = args;
|
|
@@ -183,40 +266,82 @@ export class WhatsAppClient {
|
|
|
183
266
|
// Spezifischen Command Handler aufrufen falls vorhanden
|
|
184
267
|
if (this.commands.has(command.toLowerCase())) {
|
|
185
268
|
const handler = this.commands.get(command.toLowerCase());
|
|
269
|
+
console.log(` 🎯 Führe Command-Handler aus: ${command}`);
|
|
186
270
|
try {
|
|
187
271
|
handler(messageObj, args);
|
|
188
272
|
} catch (error) {
|
|
189
273
|
console.error(`❌ Fehler in Command '${command}':`, error);
|
|
190
274
|
}
|
|
275
|
+
} else {
|
|
276
|
+
console.log(` ❓ Kein Handler für Command: ${command}`);
|
|
191
277
|
}
|
|
192
278
|
} else {
|
|
193
279
|
messageObj.isCommand = false;
|
|
194
280
|
messageObj.command = null;
|
|
195
281
|
messageObj.args = [];
|
|
282
|
+
console.log(" 📝 Normale Nachricht");
|
|
196
283
|
}
|
|
197
284
|
|
|
285
|
+
console.log(" 📤 Emittiere Message-Event");
|
|
198
286
|
this.emit('message', messageObj);
|
|
287
|
+
console.log(" ✅ Message verarbeitet");
|
|
199
288
|
});
|
|
200
289
|
});
|
|
201
290
|
|
|
291
|
+
// Zusätzliche Events für bessere Kompatibilität
|
|
292
|
+
this.socket.ev.on("messages.update", (updates) => {
|
|
293
|
+
console.log(`📝 Messages.update - Count: ${updates.length}`);
|
|
294
|
+
this.emit('messages.update', updates);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Bessere Presence-Handling
|
|
298
|
+
this.socket.ev.on("presence.update", (update) => {
|
|
299
|
+
console.log(`👤 Presence.update - ID: ${update.id}`);
|
|
300
|
+
this.emit('presence.update', update);
|
|
301
|
+
});
|
|
302
|
+
|
|
202
303
|
// Group updates
|
|
203
304
|
this.socket.ev.on("group-participants.update", (update) => {
|
|
305
|
+
console.log(`👥 Group-participants.update - Group: ${update.id}`);
|
|
204
306
|
this.emit('group.participants.update', update);
|
|
205
307
|
});
|
|
206
308
|
|
|
207
|
-
//
|
|
208
|
-
this.socket.ev.on("
|
|
209
|
-
|
|
309
|
+
// Chats updates für bessere Synchronisation
|
|
310
|
+
this.socket.ev.on("chats.upsert", (chats) => {
|
|
311
|
+
console.log(`💬 Chats.upsert - Count: ${chats.length}`);
|
|
312
|
+
this.emit('chats.upsert', chats);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Contacts updates
|
|
316
|
+
this.socket.ev.on("contacts.upsert", (contacts) => {
|
|
317
|
+
console.log(`📞 Contacts.upsert - Count: ${contacts.length}`);
|
|
318
|
+
this.emit('contacts.upsert', contacts);
|
|
210
319
|
});
|
|
320
|
+
|
|
321
|
+
console.log("✅ Event-Handler registriert!");
|
|
211
322
|
}
|
|
212
323
|
|
|
213
324
|
parseMessage(msg) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
msg.message.
|
|
219
|
-
|
|
325
|
+
// Erweiterte Text-Extraktion für verschiedene Message-Typen
|
|
326
|
+
let text = null;
|
|
327
|
+
|
|
328
|
+
if (msg.message.conversation) {
|
|
329
|
+
text = msg.message.conversation;
|
|
330
|
+
} else if (msg.message.extendedTextMessage?.text) {
|
|
331
|
+
text = msg.message.extendedTextMessage.text;
|
|
332
|
+
} else if (msg.message.imageMessage?.caption) {
|
|
333
|
+
text = msg.message.imageMessage.caption;
|
|
334
|
+
} else if (msg.message.videoMessage?.caption) {
|
|
335
|
+
text = msg.message.videoMessage.caption;
|
|
336
|
+
} else if (msg.message.documentMessage?.caption) {
|
|
337
|
+
text = msg.message.documentMessage.caption;
|
|
338
|
+
} else if (msg.message.buttonsResponseMessage?.selectedButtonId) {
|
|
339
|
+
text = msg.message.buttonsResponseMessage.selectedButtonId;
|
|
340
|
+
} else if (msg.message.listResponseMessage?.singleSelectReply?.selectedRowId) {
|
|
341
|
+
text = msg.message.listResponseMessage.singleSelectReply.selectedRowId;
|
|
342
|
+
} else if (msg.message.templateButtonReplyMessage?.selectedId) {
|
|
343
|
+
text = msg.message.templateButtonReplyMessage.selectedId;
|
|
344
|
+
}
|
|
220
345
|
|
|
221
346
|
return {
|
|
222
347
|
id: msg.key.id,
|
|
@@ -226,12 +351,14 @@ export class WhatsAppClient {
|
|
|
226
351
|
timestamp: msg.messageTimestamp,
|
|
227
352
|
type: this.getMessageType(msg.message),
|
|
228
353
|
isGroup: msg.key.remoteJid?.includes("@g.us"),
|
|
354
|
+
participant: msg.key.participant, // Wichtig für Gruppen
|
|
229
355
|
raw: msg
|
|
230
356
|
};
|
|
231
357
|
}
|
|
232
358
|
|
|
233
359
|
getMessageType(message) {
|
|
234
360
|
if (message.conversation) return 'text';
|
|
361
|
+
if (message.extendedTextMessage) return 'text';
|
|
235
362
|
if (message.imageMessage) return 'image';
|
|
236
363
|
if (message.videoMessage) return 'video';
|
|
237
364
|
if (message.audioMessage) return 'audio';
|
|
@@ -239,6 +366,11 @@ export class WhatsAppClient {
|
|
|
239
366
|
if (message.stickerMessage) return 'sticker';
|
|
240
367
|
if (message.locationMessage) return 'location';
|
|
241
368
|
if (message.contactMessage) return 'contact';
|
|
369
|
+
if (message.buttonsResponseMessage) return 'button_response';
|
|
370
|
+
if (message.listResponseMessage) return 'list_response';
|
|
371
|
+
if (message.templateButtonReplyMessage) return 'template_button_reply';
|
|
372
|
+
if (message.pollCreationMessage) return 'poll';
|
|
373
|
+
if (message.pollUpdateMessage) return 'poll_update';
|
|
242
374
|
return 'unknown';
|
|
243
375
|
}
|
|
244
376
|
|
package/src/qr.js
CHANGED
|
@@ -6,26 +6,10 @@ let page = null;
|
|
|
6
6
|
|
|
7
7
|
export async function generateQRCode(qrData = null) {
|
|
8
8
|
try {
|
|
9
|
-
//
|
|
10
|
-
if (!browser) {
|
|
11
|
-
console.log("🌐 Öffne Microsoft Edge...");
|
|
12
|
-
browser = await chromium.launch({
|
|
13
|
-
channel: "msedge",
|
|
14
|
-
headless: false
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Neue Seite öffnen falls noch nicht vorhanden
|
|
19
|
-
if (!page) {
|
|
20
|
-
page = await browser.newPage();
|
|
21
|
-
await page.goto("https://web.whatsapp.com");
|
|
22
|
-
console.log("🌐 Microsoft Edge mit WhatsApp Web geöffnet");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// QR-Code anzeigen falls vorhanden
|
|
9
|
+
// QR-Code im Terminal anzeigen falls vorhanden
|
|
26
10
|
if (qrData) {
|
|
27
11
|
console.log("\n📱 QR-CODE GENERIERT!");
|
|
28
|
-
console.log("👆 Scanne den QR-Code
|
|
12
|
+
console.log("👆 Scanne den QR-Code hier im Terminal:");
|
|
29
13
|
console.log("─".repeat(50));
|
|
30
14
|
|
|
31
15
|
// QR-Code im Terminal anzeigen
|
|
@@ -36,22 +20,147 @@ export async function generateQRCode(qrData = null) {
|
|
|
36
20
|
console.log(" 1. Gehe zu Einstellungen");
|
|
37
21
|
console.log(" 2. Tippe auf 'Verknüpfte Geräte'");
|
|
38
22
|
console.log(" 3. Tippe auf 'Gerät verknüpfen'");
|
|
39
|
-
console.log(" 4. Scanne den QR-Code");
|
|
23
|
+
console.log(" 4. Scanne den QR-Code OBEN im Terminal");
|
|
40
24
|
console.log("⏳ Warte auf QR-Scan...");
|
|
41
25
|
}
|
|
42
26
|
|
|
27
|
+
// Browser öffnen und den richtigen QR-Code anzeigen
|
|
28
|
+
if (!browser && qrData) {
|
|
29
|
+
console.log("🌐 Öffne Browser mit korrektem QR-Code...");
|
|
30
|
+
browser = await chromium.launch({
|
|
31
|
+
channel: "msedge",
|
|
32
|
+
headless: false
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
page = await browser.newPage();
|
|
36
|
+
|
|
37
|
+
// Custom HTML-Seite mit dem richtigen QR-Code erstellen
|
|
38
|
+
const qrCodeDataURL = await generateQRCodeDataURL(qrData);
|
|
39
|
+
const html = `
|
|
40
|
+
<!DOCTYPE html>
|
|
41
|
+
<html>
|
|
42
|
+
<head>
|
|
43
|
+
<title>WAEngine - QR Code Scanner</title>
|
|
44
|
+
<style>
|
|
45
|
+
body {
|
|
46
|
+
font-family: Arial, sans-serif;
|
|
47
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 20px;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
min-height: 100vh;
|
|
55
|
+
color: white;
|
|
56
|
+
}
|
|
57
|
+
.container {
|
|
58
|
+
background: rgba(255, 255, 255, 0.1);
|
|
59
|
+
backdrop-filter: blur(10px);
|
|
60
|
+
border-radius: 20px;
|
|
61
|
+
padding: 40px;
|
|
62
|
+
text-align: center;
|
|
63
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
64
|
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
65
|
+
}
|
|
66
|
+
h1 {
|
|
67
|
+
margin-bottom: 20px;
|
|
68
|
+
font-size: 2.5em;
|
|
69
|
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
|
70
|
+
}
|
|
71
|
+
.qr-container {
|
|
72
|
+
background: white;
|
|
73
|
+
padding: 20px;
|
|
74
|
+
border-radius: 15px;
|
|
75
|
+
margin: 20px 0;
|
|
76
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
|
|
77
|
+
}
|
|
78
|
+
.qr-code {
|
|
79
|
+
max-width: 300px;
|
|
80
|
+
height: auto;
|
|
81
|
+
}
|
|
82
|
+
.instructions {
|
|
83
|
+
font-size: 1.2em;
|
|
84
|
+
line-height: 1.6;
|
|
85
|
+
margin-top: 20px;
|
|
86
|
+
}
|
|
87
|
+
.step {
|
|
88
|
+
margin: 10px 0;
|
|
89
|
+
padding: 10px;
|
|
90
|
+
background: rgba(255, 255, 255, 0.1);
|
|
91
|
+
border-radius: 10px;
|
|
92
|
+
}
|
|
93
|
+
.warning {
|
|
94
|
+
background: rgba(255, 193, 7, 0.2);
|
|
95
|
+
border: 2px solid #ffc107;
|
|
96
|
+
border-radius: 10px;
|
|
97
|
+
padding: 15px;
|
|
98
|
+
margin: 20px 0;
|
|
99
|
+
font-weight: bold;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
</head>
|
|
103
|
+
<body>
|
|
104
|
+
<div class="container">
|
|
105
|
+
<h1>🚀 WAEngine QR Scanner</h1>
|
|
106
|
+
<div class="qr-container">
|
|
107
|
+
<img src="${qrCodeDataURL}" alt="QR Code" class="qr-code" />
|
|
108
|
+
</div>
|
|
109
|
+
<div class="warning">
|
|
110
|
+
⚠️ Scanne NUR diesen QR-Code!<br>
|
|
111
|
+
Nicht den Standard WhatsApp Web QR-Code!
|
|
112
|
+
</div>
|
|
113
|
+
<div class="instructions">
|
|
114
|
+
<div class="step">📱 1. Öffne WhatsApp auf deinem Handy</div>
|
|
115
|
+
<div class="step">⚙️ 2. Gehe zu Einstellungen</div>
|
|
116
|
+
<div class="step">🔗 3. Tippe auf "Verknüpfte Geräte"</div>
|
|
117
|
+
<div class="step">📷 4. Tippe auf "Gerät verknüpfen"</div>
|
|
118
|
+
<div class="step">🎯 5. Scanne den QR-Code oben</div>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
<script>
|
|
122
|
+
// Auto-refresh QR code every 30 seconds
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
location.reload();
|
|
125
|
+
}, 30000);
|
|
126
|
+
</script>
|
|
127
|
+
</body>
|
|
128
|
+
</html>`;
|
|
129
|
+
|
|
130
|
+
await page.setContent(html);
|
|
131
|
+
console.log("✅ Browser mit korrektem QR-Code geöffnet!");
|
|
132
|
+
}
|
|
133
|
+
|
|
43
134
|
return { browser, page };
|
|
44
135
|
|
|
45
136
|
} catch (error) {
|
|
46
|
-
console.error("❌ Fehler beim
|
|
137
|
+
console.error("❌ Fehler beim QR-Code Browser:", error);
|
|
47
138
|
|
|
48
139
|
// Fallback: QR nur im Terminal
|
|
49
140
|
if (qrData) {
|
|
50
|
-
console.log("📱 Fallback - QR-Code im Terminal:");
|
|
141
|
+
console.log("📱 Fallback - QR-Code nur im Terminal:");
|
|
51
142
|
qrcode.generate(qrData, { small: true });
|
|
52
143
|
}
|
|
53
144
|
|
|
54
|
-
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Hilfsfunktion um QR-Code als Data URL zu generieren
|
|
150
|
+
async function generateQRCodeDataURL(qrData) {
|
|
151
|
+
try {
|
|
152
|
+
const QRCode = await import('qrcode');
|
|
153
|
+
return await QRCode.toDataURL(qrData, {
|
|
154
|
+
width: 300,
|
|
155
|
+
margin: 2,
|
|
156
|
+
color: {
|
|
157
|
+
dark: '#000000',
|
|
158
|
+
light: '#FFFFFF'
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error("❌ Fehler beim QR-Code DataURL:", error);
|
|
163
|
+
return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAwIiBoZWlnaHQ9IjMwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMzAwIiBoZWlnaHQ9IjMwMCIgZmlsbD0iI2Y4ZjlmYSIvPjx0ZXh0IHg9IjE1MCIgeT0iMTUwIiBmb250LWZhbWlseT0iQXJpYWwiIGZvbnQtc2l6ZT0iMTYiIGZpbGw9IiM2NjY2NjYiIHRleHQtYW5jaG9yPSJtaWRkbGUiPkVycm9yPC90ZXh0Pjwvc3ZnPg==';
|
|
55
164
|
}
|
|
56
165
|
}
|
|
57
166
|
|
|
@@ -62,4 +171,4 @@ export async function closeBrowser() {
|
|
|
62
171
|
page = null;
|
|
63
172
|
console.log("🔴 Browser geschlossen");
|
|
64
173
|
}
|
|
65
|
-
}
|
|
174
|
+
}
|