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
package/src/device-manager.js
CHANGED
|
@@ -16,7 +16,7 @@ export class DeviceManager {
|
|
|
16
16
|
this.currentDeviceIndex = 0;
|
|
17
17
|
this.eventHandlers = new Map();
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Schöne Console ist jetzt Standard - keine Logs mehr hier
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// ===== DEVICE MANAGEMENT =====
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { WhatsAppClient } from "./client.js";
|
|
2
|
+
import { MultiWhatsAppClient } from "./multi-client.js";
|
|
3
|
+
import { EasyAdvanced, EasyAdvancedRule } from "./easy-advanced.js";
|
|
4
|
+
import { ConsoleLogger } from "./console-logger.js";
|
|
5
|
+
import { ErrorHandler } from "./error-handler.js";
|
|
6
|
+
|
|
7
|
+
// ===== CHAIN-PROXY PATTERN =====
|
|
8
|
+
// Lösung: Alle Methoden sind sowohl auf EasyBot als auch EasyRule verfügbar
|
|
9
|
+
// und geben ein Proxy-Objekt zurück, das beide APIs unterstützt
|
|
10
|
+
|
|
11
|
+
class EasyChain {
|
|
12
|
+
constructor(bot) {
|
|
13
|
+
this.bot = bot;
|
|
14
|
+
this.currentRule = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ===== RULE METHODS =====
|
|
18
|
+
when(trigger) {
|
|
19
|
+
const rule = new EasyRule(trigger, this.bot);
|
|
20
|
+
this.bot.rules.push(rule);
|
|
21
|
+
this.currentRule = rule;
|
|
22
|
+
return this; // Gibt EasyChain zurück
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
reply(text) {
|
|
26
|
+
if (this.currentRule) {
|
|
27
|
+
this.currentRule.actions.push({ type: 'reply', value: text });
|
|
28
|
+
}
|
|
29
|
+
return this; // Für weitere Chaining
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
send(text) {
|
|
33
|
+
if (this.currentRule) {
|
|
34
|
+
this.currentRule.actions.push({ type: 'reply', value: text });
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
react(emoji) {
|
|
40
|
+
if (this.currentRule) {
|
|
41
|
+
this.currentRule.actions.push({ type: 'react', value: emoji });
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type(seconds = 2) {
|
|
47
|
+
if (this.currentRule) {
|
|
48
|
+
this.currentRule.actions.push({ type: 'type', value: seconds * 1000 });
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ===== BOT CONTROL METHODS =====
|
|
54
|
+
start() {
|
|
55
|
+
return this.bot.start();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
stop() {
|
|
59
|
+
return this.bot.stop();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
status() {
|
|
63
|
+
return this.bot.status();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ===== ADVANCED METHODS =====
|
|
67
|
+
enableAI() {
|
|
68
|
+
this.bot.enableAI();
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
enableAll() {
|
|
73
|
+
this.bot.enableAll();
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
enableDefaults() {
|
|
78
|
+
this.bot.enableDefaults();
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class EasyBot {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.client = null;
|
|
86
|
+
this.multiClient = null;
|
|
87
|
+
this.rules = [];
|
|
88
|
+
this.commands = new Map();
|
|
89
|
+
this.templates = new Map();
|
|
90
|
+
this.autoResponses = new Map();
|
|
91
|
+
this.isRunning = false;
|
|
92
|
+
this.isMultiDevice = false;
|
|
93
|
+
|
|
94
|
+
// Easy settings
|
|
95
|
+
this.settings = {
|
|
96
|
+
autoGreeting: true,
|
|
97
|
+
autoHelp: true,
|
|
98
|
+
typingEnabled: true,
|
|
99
|
+
reactionsEnabled: true
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Advanced features integration
|
|
103
|
+
this.advanced = null;
|
|
104
|
+
|
|
105
|
+
// Chain-Proxy für Fluent API
|
|
106
|
+
this.chain = new EasyChain(this);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ===== FACTORY METHODS =====
|
|
110
|
+
|
|
111
|
+
static create(options = {}) {
|
|
112
|
+
const bot = new EasyBot();
|
|
113
|
+
bot.client = new WhatsAppClient({
|
|
114
|
+
authDir: "./auth",
|
|
115
|
+
logLevel: "silent",
|
|
116
|
+
|
|
117
|
+
// CLEAN QR DEFAULTS
|
|
118
|
+
printQR: false,
|
|
119
|
+
qrSpamPrevention: true,
|
|
120
|
+
qrDisplayInterval: 30000,
|
|
121
|
+
qrMaxDisplays: 3,
|
|
122
|
+
clearTerminalOnQR: true,
|
|
123
|
+
|
|
124
|
+
// ROBUSTE CONNECTION DEFAULTS
|
|
125
|
+
maxReconnectAttempts: 100,
|
|
126
|
+
reconnectInterval: 2000,
|
|
127
|
+
exponentialBackoff: true,
|
|
128
|
+
maxBackoffDelay: 30000,
|
|
129
|
+
heartbeatInterval: 20000,
|
|
130
|
+
|
|
131
|
+
// ADVANCED DEFAULTS
|
|
132
|
+
enableAdvancedFeatures: true,
|
|
133
|
+
enableAnalytics: true,
|
|
134
|
+
enableStorage: true,
|
|
135
|
+
enableScheduler: true,
|
|
136
|
+
enableErrorHandling: true,
|
|
137
|
+
|
|
138
|
+
...options
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Advanced features initialisieren
|
|
142
|
+
bot.advanced = new EasyAdvanced(bot);
|
|
143
|
+
|
|
144
|
+
return bot.chain; // ✅ Gibt Chain-Proxy zurück!
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ===== SIMPLE RULES =====
|
|
148
|
+
|
|
149
|
+
when(trigger) {
|
|
150
|
+
const rule = new EasyRule(trigger, this);
|
|
151
|
+
this.rules.push(rule);
|
|
152
|
+
return rule;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ===== BOT CONTROL =====
|
|
156
|
+
|
|
157
|
+
async start() {
|
|
158
|
+
if (this.isRunning) {
|
|
159
|
+
console.log('⚠️ Bot läuft bereits');
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
console.log('🚀 Starte EasyBot...');
|
|
165
|
+
|
|
166
|
+
// Client verbinden
|
|
167
|
+
await this.client.connect();
|
|
168
|
+
|
|
169
|
+
// Message Handler registrieren
|
|
170
|
+
this.client.on('message', async (msg) => {
|
|
171
|
+
await this.handleMessage(msg);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
this.isRunning = true;
|
|
175
|
+
console.log('✅ EasyBot gestartet!');
|
|
176
|
+
console.log(`📝 ${this.rules.length} Regeln geladen`);
|
|
177
|
+
console.log(`⚡ ${this.commands.size} Commands verfügbar`);
|
|
178
|
+
|
|
179
|
+
return this;
|
|
180
|
+
|
|
181
|
+
} catch (error) {
|
|
182
|
+
console.error('❌ EasyBot Start-Fehler:', error);
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async stop() {
|
|
188
|
+
if (!this.isRunning) {
|
|
189
|
+
console.log('⚠️ Bot läuft nicht');
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
console.log('🛑 Stoppe EasyBot...');
|
|
195
|
+
|
|
196
|
+
if (this.client) {
|
|
197
|
+
await this.client.gracefulShutdown();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
this.isRunning = false;
|
|
201
|
+
console.log('✅ EasyBot gestoppt');
|
|
202
|
+
|
|
203
|
+
return this;
|
|
204
|
+
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error('❌ EasyBot Stop-Fehler:', error);
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ===== MESSAGE HANDLING =====
|
|
212
|
+
|
|
213
|
+
async handleMessage(msg) {
|
|
214
|
+
try {
|
|
215
|
+
const text = msg.body?.toLowerCase() || '';
|
|
216
|
+
|
|
217
|
+
// Rules durchgehen
|
|
218
|
+
for (const rule of this.rules) {
|
|
219
|
+
if (this.matchesRule(text, rule.trigger)) {
|
|
220
|
+
await rule.execute(msg);
|
|
221
|
+
break; // Nur erste passende Rule ausführen
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Commands prüfen
|
|
226
|
+
for (const [cmd, response] of this.commands) {
|
|
227
|
+
if (text === cmd.toLowerCase()) {
|
|
228
|
+
await msg.reply(response);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Auto-Responses prüfen
|
|
234
|
+
for (const [trigger, response] of this.autoResponses) {
|
|
235
|
+
if (text.includes(trigger.toLowerCase())) {
|
|
236
|
+
await msg.reply(response);
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.error('❌ Message handling error:', error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
matchesRule(text, trigger) {
|
|
247
|
+
if (typeof trigger === 'string') {
|
|
248
|
+
return text.includes(trigger.toLowerCase());
|
|
249
|
+
} else if (trigger instanceof RegExp) {
|
|
250
|
+
return trigger.test(text);
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ===== UTILITY METHODS =====
|
|
256
|
+
|
|
257
|
+
status() {
|
|
258
|
+
return {
|
|
259
|
+
running: this.isRunning,
|
|
260
|
+
rules: this.rules.length,
|
|
261
|
+
commands: this.commands.size,
|
|
262
|
+
autoResponses: this.autoResponses.size,
|
|
263
|
+
multiDevice: this.isMultiDevice
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ===== ADVANCED FEATURES =====
|
|
268
|
+
|
|
269
|
+
enableAI() {
|
|
270
|
+
if (this.client) {
|
|
271
|
+
this.client.enableAI();
|
|
272
|
+
}
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
enableAll() {
|
|
277
|
+
this.enableDefaults();
|
|
278
|
+
this.enableAI();
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
enableDefaults() {
|
|
283
|
+
this.settings.autoGreeting = true;
|
|
284
|
+
this.settings.autoHelp = true;
|
|
285
|
+
this.settings.typingEnabled = true;
|
|
286
|
+
this.settings.reactionsEnabled = true;
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ===== EASY RULE CLASS =====
|
|
292
|
+
|
|
293
|
+
class EasyRule {
|
|
294
|
+
constructor(trigger, bot) {
|
|
295
|
+
this.trigger = trigger;
|
|
296
|
+
this.bot = bot;
|
|
297
|
+
this.actions = [];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Actions - Return this for action chaining within rule
|
|
301
|
+
reply(text) {
|
|
302
|
+
this.actions.push({ type: 'reply', value: text });
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
send(text) {
|
|
307
|
+
this.actions.push({ type: 'reply', value: text });
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
react(emoji) {
|
|
312
|
+
this.actions.push({ type: 'react', value: emoji });
|
|
313
|
+
return this;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
type(seconds = 2) {
|
|
317
|
+
this.actions.push({ type: 'type', value: seconds * 1000 });
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Execute all actions
|
|
322
|
+
async execute(msg) {
|
|
323
|
+
try {
|
|
324
|
+
for (const action of this.actions) {
|
|
325
|
+
switch (action.type) {
|
|
326
|
+
case 'reply':
|
|
327
|
+
await msg.reply(action.value);
|
|
328
|
+
break;
|
|
329
|
+
case 'react':
|
|
330
|
+
await msg.react(action.value);
|
|
331
|
+
break;
|
|
332
|
+
case 'type':
|
|
333
|
+
await new Promise(resolve => setTimeout(resolve, action.value));
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
} catch (error) {
|
|
338
|
+
console.error('❌ Rule execution error:', error);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|