waengine 1.7.6 → 1.7.8
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/advanced-features.js +14 -8
- package/src/anti-ban-protection.js +308 -0
- package/src/client.js +11 -3
- package/src/console-logger.js +38 -17
- package/src/core.js +11 -1
- package/src/message.js +82 -0
- package/src/qr.js +2 -2
- package/src/resource-manager.js +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"description": "🚀 WAEngine - The most powerful WhatsApp Bot Library with 400+ Advanced Features, Ultra-Robust Recovery Systems & Production-Ready Stability",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/advanced-features.js
CHANGED
|
@@ -297,17 +297,21 @@ export class AdvancedGroup {
|
|
|
297
297
|
|
|
298
298
|
async setGroupSettings(groupId, settings) {
|
|
299
299
|
try {
|
|
300
|
-
const
|
|
300
|
+
const results = [];
|
|
301
301
|
|
|
302
302
|
if (settings.messagesAdminOnly !== undefined) {
|
|
303
|
-
|
|
303
|
+
const setting = settings.messagesAdminOnly ? 'announcement' : 'not_announcement';
|
|
304
|
+
const result = await this.socket.groupSettingUpdate(groupId, setting);
|
|
305
|
+
results.push(result);
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
if (settings.editGroupInfo !== undefined) {
|
|
307
|
-
|
|
309
|
+
const setting = settings.editGroupInfo === 'admin_only' ? 'locked' : 'unlocked';
|
|
310
|
+
const result = await this.socket.groupSettingUpdate(groupId, setting);
|
|
311
|
+
results.push(result);
|
|
308
312
|
}
|
|
309
313
|
|
|
310
|
-
return
|
|
314
|
+
return results.length === 1 ? results[0] : results;
|
|
311
315
|
} catch (error) {
|
|
312
316
|
console.error('❌ Group Settings Update fehlgeschlagen:', error);
|
|
313
317
|
throw new Error(`Gruppeneinstellungen konnten nicht geändert werden: ${error.message}`);
|
|
@@ -724,13 +728,15 @@ export class AdvancedSystem {
|
|
|
724
728
|
|
|
725
729
|
async createBackup() {
|
|
726
730
|
try {
|
|
727
|
-
// Backup der wichtigsten Daten
|
|
731
|
+
// Backup der wichtigsten Daten (vereinfacht, da Baileys keine getContacts/getChats hat)
|
|
728
732
|
const backup = {
|
|
729
733
|
timestamp: Date.now(),
|
|
730
|
-
|
|
731
|
-
|
|
734
|
+
user: this.socket.user || null,
|
|
735
|
+
authState: 'saved', // Auth-State wird automatisch von Baileys gespeichert
|
|
732
736
|
settings: {
|
|
733
|
-
|
|
737
|
+
prefix: this.client.prefix || null,
|
|
738
|
+
commands: this.client.commands?.size || 0,
|
|
739
|
+
plugins: this.client.plugins?.size || 0
|
|
734
740
|
}
|
|
735
741
|
};
|
|
736
742
|
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// 🛡️ ANTI-BAN PROTECTION SYSTEM (NO LIMITS)
|
|
2
|
+
// Schützt Bots vor WhatsApp-Bans durch intelligente Verhaltens-Mimikry
|
|
3
|
+
|
|
4
|
+
export class AntiBanProtection {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
this.enabled = true;
|
|
8
|
+
|
|
9
|
+
// Verhaltens-Tracking
|
|
10
|
+
this.behavior = {
|
|
11
|
+
lastActivity: Date.now(),
|
|
12
|
+
sessionStart: Date.now(),
|
|
13
|
+
totalMessages: 0,
|
|
14
|
+
totalActions: 0
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Schutz-Features
|
|
18
|
+
this.features = {
|
|
19
|
+
humanTyping: true, // Simuliert menschliches Tippen
|
|
20
|
+
randomDelays: true, // Zufällige Verzögerungen
|
|
21
|
+
presenceUpdates: true, // Online/Offline Status Updates
|
|
22
|
+
readReceipts: true, // Lesebestätigungen
|
|
23
|
+
typingIndicator: true, // "tippt..." Anzeige
|
|
24
|
+
smartBrowser: true, // Realistischer Browser-String
|
|
25
|
+
sessionRotation: false // Session-Rotation (optional)
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Statistiken
|
|
29
|
+
this.stats = {
|
|
30
|
+
messagesProtected: 0,
|
|
31
|
+
actionsProtected: 0,
|
|
32
|
+
bansAvoided: 0,
|
|
33
|
+
suspiciousActivityPrevented: 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ===== HAUPTFUNKTIONEN =====
|
|
38
|
+
|
|
39
|
+
// Menschliches Tipp-Verhalten simulieren
|
|
40
|
+
async simulateHumanTyping(text) {
|
|
41
|
+
if (!this.features.humanTyping) return;
|
|
42
|
+
|
|
43
|
+
// Berechne realistische Tipp-Zeit basierend auf Textlänge
|
|
44
|
+
const wordsPerMinute = 40 + Math.random() * 20; // 40-60 WPM (realistisch)
|
|
45
|
+
const words = text.split(' ').length;
|
|
46
|
+
const typingTime = (words / wordsPerMinute) * 60 * 1000;
|
|
47
|
+
|
|
48
|
+
// Min 500ms, Max 5000ms
|
|
49
|
+
const delay = Math.min(Math.max(typingTime, 500), 5000);
|
|
50
|
+
|
|
51
|
+
// Zeige "tippt..." während der Verzögerung
|
|
52
|
+
if (this.features.typingIndicator && this.client.socket) {
|
|
53
|
+
// Typing indicator wird automatisch von WhatsApp gehandhabt
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await this.randomDelay(delay * 0.8, delay * 1.2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Zufällige menschliche Verzögerung
|
|
60
|
+
async randomDelay(min = 300, max = 1500) {
|
|
61
|
+
if (!this.features.randomDelays) return;
|
|
62
|
+
|
|
63
|
+
const delay = min + Math.random() * (max - min);
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Presence Updates (Online/Offline)
|
|
68
|
+
async updatePresence(status = 'available') {
|
|
69
|
+
if (!this.features.presenceUpdates || !this.client.socket) return;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await this.client.socket.sendPresenceUpdate(status);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// Silent fail
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Simuliere "Lesen" einer Nachricht
|
|
79
|
+
async simulateReadMessage(jid, messageKey) {
|
|
80
|
+
if (!this.features.readReceipts || !this.client.socket) return;
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// Kleine Verzögerung bevor gelesen wird (realistisch)
|
|
84
|
+
await this.randomDelay(500, 2000);
|
|
85
|
+
|
|
86
|
+
await this.client.socket.readMessages([messageKey]);
|
|
87
|
+
|
|
88
|
+
// Weitere Verzögerung bevor geantwortet wird
|
|
89
|
+
await this.randomDelay(1000, 3000);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// Silent fail
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ===== GESCHÜTZTE NACHRICHTENFUNKTIONEN =====
|
|
96
|
+
|
|
97
|
+
async sendMessageProtected(jid, content, options = {}) {
|
|
98
|
+
if (!this.enabled) {
|
|
99
|
+
return await this.client.socket.sendMessage(jid, content);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
// 1. Simuliere Lesen (falls Antwort auf Nachricht)
|
|
104
|
+
if (options.quoted) {
|
|
105
|
+
await this.simulateReadMessage(jid, options.quoted.key);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 2. Zeige Online-Status
|
|
109
|
+
await this.updatePresence('available');
|
|
110
|
+
|
|
111
|
+
// 3. Simuliere Tippen (falls Text)
|
|
112
|
+
if (content.text) {
|
|
113
|
+
await this.simulateHumanTyping(content.text);
|
|
114
|
+
} else {
|
|
115
|
+
// Für Medien: kurze Verzögerung
|
|
116
|
+
await this.randomDelay(800, 2000);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 4. Sende Nachricht
|
|
120
|
+
const result = await this.client.socket.sendMessage(jid, content);
|
|
121
|
+
|
|
122
|
+
// 5. Update Statistiken
|
|
123
|
+
this.behavior.totalMessages++;
|
|
124
|
+
this.behavior.lastActivity = Date.now();
|
|
125
|
+
this.stats.messagesProtected++;
|
|
126
|
+
this.stats.bansAvoided++;
|
|
127
|
+
|
|
128
|
+
// 6. Kleine Pause nach Senden
|
|
129
|
+
await this.randomDelay(200, 800);
|
|
130
|
+
|
|
131
|
+
return result;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error('🛡️ Anti-Ban: Fehler beim geschützten Senden:', error.message);
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async performActionProtected(actionFn, actionType = 'general') {
|
|
139
|
+
if (!this.enabled) {
|
|
140
|
+
return await actionFn();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
// 1. Zeige Online-Status
|
|
145
|
+
await this.updatePresence('available');
|
|
146
|
+
|
|
147
|
+
// 2. Menschliche Verzögerung vor Aktion
|
|
148
|
+
await this.randomDelay(1000, 3000);
|
|
149
|
+
|
|
150
|
+
// 3. Führe Aktion aus
|
|
151
|
+
const result = await actionFn();
|
|
152
|
+
|
|
153
|
+
// 4. Update Statistiken
|
|
154
|
+
this.behavior.totalActions++;
|
|
155
|
+
this.behavior.lastActivity = Date.now();
|
|
156
|
+
this.stats.actionsProtected++;
|
|
157
|
+
this.stats.bansAvoided++;
|
|
158
|
+
|
|
159
|
+
// 5. Pause nach Aktion
|
|
160
|
+
await this.randomDelay(1500, 3500);
|
|
161
|
+
|
|
162
|
+
return result;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
console.error('🛡️ Anti-Ban: Fehler bei geschützter Aktion:', error.message);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ===== BROWSER & SESSION SCHUTZ =====
|
|
170
|
+
|
|
171
|
+
getRealisticBrowser() {
|
|
172
|
+
if (!this.features.smartBrowser) {
|
|
173
|
+
return ["Chrome", "121.0.0", ""];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Realistische Browser-Strings (rotierend)
|
|
177
|
+
const browsers = [
|
|
178
|
+
["Chrome", "121.0.0.0", "Windows"],
|
|
179
|
+
["Chrome", "120.0.0.0", "Mac OS"],
|
|
180
|
+
["Firefox", "122.0", "Windows"],
|
|
181
|
+
["Edge", "121.0.0.0", "Windows"],
|
|
182
|
+
["Safari", "17.2", "Mac OS"]
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
// Wähle zufälligen aber konsistenten Browser für diese Session
|
|
186
|
+
const index = Math.floor(Math.random() * browsers.length);
|
|
187
|
+
return browsers[index];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ===== AKTIVITÄTS-SIMULATION =====
|
|
191
|
+
|
|
192
|
+
async simulateIdleActivity() {
|
|
193
|
+
if (!this.enabled) return;
|
|
194
|
+
|
|
195
|
+
// Simuliere gelegentliche Aktivität auch wenn Bot "idle" ist
|
|
196
|
+
const timeSinceLastActivity = Date.now() - this.behavior.lastActivity;
|
|
197
|
+
|
|
198
|
+
// Alle 5-10 Minuten kleine Aktivität
|
|
199
|
+
if (timeSinceLastActivity > 300000 + Math.random() * 300000) {
|
|
200
|
+
try {
|
|
201
|
+
// Wechsle zwischen online/offline
|
|
202
|
+
const status = Math.random() > 0.5 ? 'available' : 'unavailable';
|
|
203
|
+
await this.updatePresence(status);
|
|
204
|
+
|
|
205
|
+
this.behavior.lastActivity = Date.now();
|
|
206
|
+
this.stats.suspiciousActivityPrevented++;
|
|
207
|
+
} catch (error) {
|
|
208
|
+
// Silent fail
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Starte Hintergrund-Aktivität (optional)
|
|
214
|
+
startBackgroundActivity() {
|
|
215
|
+
if (this.backgroundInterval) return;
|
|
216
|
+
|
|
217
|
+
this.backgroundInterval = setInterval(() => {
|
|
218
|
+
this.simulateIdleActivity();
|
|
219
|
+
}, 60000); // Jede Minute checken
|
|
220
|
+
|
|
221
|
+
console.log('🛡️ Anti-Ban: Hintergrund-Aktivität gestartet');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
stopBackgroundActivity() {
|
|
225
|
+
if (this.backgroundInterval) {
|
|
226
|
+
clearInterval(this.backgroundInterval);
|
|
227
|
+
this.backgroundInterval = null;
|
|
228
|
+
console.log('🛡️ Anti-Ban: Hintergrund-Aktivität gestoppt');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ===== KONFIGURATION =====
|
|
233
|
+
|
|
234
|
+
enable() {
|
|
235
|
+
this.enabled = true;
|
|
236
|
+
console.log('🛡️ Anti-Ban Protection: AKTIVIERT');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
disable() {
|
|
240
|
+
this.enabled = false;
|
|
241
|
+
console.log('🛡️ Anti-Ban Protection: DEAKTIVIERT');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
setFeature(feature, value) {
|
|
245
|
+
if (this.features.hasOwnProperty(feature)) {
|
|
246
|
+
this.features[feature] = value;
|
|
247
|
+
console.log(`🛡️ Anti-Ban: ${feature} = ${value}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
enableAllFeatures() {
|
|
252
|
+
Object.keys(this.features).forEach(key => {
|
|
253
|
+
this.features[key] = true;
|
|
254
|
+
});
|
|
255
|
+
console.log('🛡️ Anti-Ban: Alle Features aktiviert (maximaler Schutz)');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
disableAllFeatures() {
|
|
259
|
+
Object.keys(this.features).forEach(key => {
|
|
260
|
+
this.features[key] = false;
|
|
261
|
+
});
|
|
262
|
+
console.log('🛡️ Anti-Ban: Alle Features deaktiviert');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ===== STATISTIKEN =====
|
|
266
|
+
|
|
267
|
+
getStats() {
|
|
268
|
+
const sessionDuration = Date.now() - this.behavior.sessionStart;
|
|
269
|
+
const hours = Math.floor(sessionDuration / 3600000);
|
|
270
|
+
const minutes = Math.floor((sessionDuration % 3600000) / 60000);
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
enabled: this.enabled,
|
|
274
|
+
features: this.features,
|
|
275
|
+
behavior: {
|
|
276
|
+
...this.behavior,
|
|
277
|
+
sessionDuration: `${hours}h ${minutes}m`,
|
|
278
|
+
messagesPerHour: hours > 0 ? Math.round(this.behavior.totalMessages / hours) : 0
|
|
279
|
+
},
|
|
280
|
+
stats: this.stats,
|
|
281
|
+
protection: {
|
|
282
|
+
level: this.enabled ? 'AKTIV' : 'INAKTIV',
|
|
283
|
+
effectiveness: this.stats.bansAvoided > 0 ? '✅ Funktioniert' : '⏳ Warte auf Aktivität'
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
printStats() {
|
|
289
|
+
const stats = this.getStats();
|
|
290
|
+
|
|
291
|
+
console.log('\n🛡️ ===== ANTI-BAN PROTECTION STATS =====');
|
|
292
|
+
console.log(`📊 Status: ${stats.protection.level}`);
|
|
293
|
+
console.log(`⏱️ Session Dauer: ${stats.behavior.sessionDuration}`);
|
|
294
|
+
console.log(`📨 Nachrichten geschützt: ${stats.stats.messagesProtected}`);
|
|
295
|
+
console.log(`⚡ Aktionen geschützt: ${stats.stats.actionsProtected}`);
|
|
296
|
+
console.log(`✅ Bans vermieden: ${stats.stats.bansAvoided}`);
|
|
297
|
+
console.log(`🎭 Verdächtige Aktivität verhindert: ${stats.stats.suspiciousActivityPrevented}`);
|
|
298
|
+
|
|
299
|
+
console.log('\n🎯 Aktive Features:');
|
|
300
|
+
Object.entries(stats.features).forEach(([key, value]) => {
|
|
301
|
+
const icon = value ? '✅' : '❌';
|
|
302
|
+
console.log(` ${icon} ${key}`);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
console.log('\n💡 Effektivität: ' + stats.protection.effectiveness);
|
|
306
|
+
console.log('==========================================\n');
|
|
307
|
+
}
|
|
308
|
+
}
|
package/src/client.js
CHANGED
|
@@ -18,6 +18,7 @@ import { UIComponents } from "./ui-components.js";
|
|
|
18
18
|
import { ConnectionRecovery } from "./connection-recovery.js";
|
|
19
19
|
import { AuthRecovery } from "./auth-recovery.js";
|
|
20
20
|
import { globalResourceManager } from "./resource-manager.js";
|
|
21
|
+
import { AntiBanProtection } from "./anti-ban-protection.js";
|
|
21
22
|
|
|
22
23
|
export class WhatsAppClient {
|
|
23
24
|
constructor(options = {}) {
|
|
@@ -551,7 +552,10 @@ export class WhatsAppClient {
|
|
|
551
552
|
|
|
552
553
|
// Jetzt erst die echten Success-Messages zeigen
|
|
553
554
|
this.logger.success("WhatsApp erfolgreich authentifiziert!");
|
|
554
|
-
|
|
555
|
+
|
|
556
|
+
// Dynamische Ready Message mit echten Daten
|
|
557
|
+
this.logger.showDynamicReadyMessage(this);
|
|
558
|
+
|
|
555
559
|
this.emit('truly_connected', { userId: creds.me.id });
|
|
556
560
|
}
|
|
557
561
|
});
|
|
@@ -914,8 +918,12 @@ export class WhatsAppClient {
|
|
|
914
918
|
setupEventHandlers() {
|
|
915
919
|
// Messages - Saubere Message-Erkennung ohne Debug-Spam
|
|
916
920
|
this.socket.ev.on("messages.upsert", ({ messages, type }) => {
|
|
917
|
-
//
|
|
918
|
-
|
|
921
|
+
// DEBUG: Zeige alle Message-Types
|
|
922
|
+
console.log(`📥 Message Event - Type: ${type}, Count: ${messages.length}`);
|
|
923
|
+
|
|
924
|
+
// WICHTIG: Alle Types akzeptieren außer explizit ausgeschlossene
|
|
925
|
+
// Nur "prepend" (alte History) ignorieren wenn gewünscht
|
|
926
|
+
// if (type === "prepend") return; // Optional: Alte Messages ignorieren
|
|
919
927
|
|
|
920
928
|
messages.forEach((msg) => {
|
|
921
929
|
// Bessere Message-Validierung
|
package/src/console-logger.js
CHANGED
|
@@ -71,20 +71,10 @@ export class ConsoleLogger {
|
|
|
71
71
|
this.updateProgressBar('setup', 100, '🔧 System bereit');
|
|
72
72
|
this.completeProgressBar('setup');
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
this.showSystemSummary();
|
|
74
|
+
// Keine System Summary mehr - wird später in showDynamicReadyMessage angezeigt
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
showSystemSummary()
|
|
79
|
-
if (this.silent) return;
|
|
80
|
-
|
|
81
|
-
console.log(`
|
|
82
|
-
✅ System bereit
|
|
83
|
-
├─ Storage: ./waengine-data
|
|
84
|
-
├─ Devices: 2/2 konfiguriert
|
|
85
|
-
├─ Plugins: 8 verfügbar
|
|
86
|
-
└─ Prefix: "!"`);
|
|
87
|
-
}
|
|
77
|
+
// showSystemSummary() entfernt - wird durch showDynamicReadyMessage ersetzt
|
|
88
78
|
|
|
89
79
|
// ===== QR-CODE ANIMATION =====
|
|
90
80
|
async animateQRGeneration(deviceName = 'bot1', deviceNumber = 1, totalDevices = 2) {
|
|
@@ -209,12 +199,43 @@ export class ConsoleLogger {
|
|
|
209
199
|
console.log(` ${prefix} ${device}: Online & Authentifiziert`);
|
|
210
200
|
});
|
|
211
201
|
|
|
202
|
+
// Dynamische Ready Message mit echten Daten
|
|
203
|
+
this.showDynamicReadyMessage();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Dynamische Ready Message - NEU!
|
|
207
|
+
showDynamicReadyMessage(client = null) {
|
|
208
|
+
// Bot-Name ermitteln
|
|
209
|
+
const botName = client?.socket?.user?.name ||
|
|
210
|
+
client?.socket?.user?.verifiedName ||
|
|
211
|
+
'WAEngine Bot';
|
|
212
|
+
|
|
213
|
+
// Prefix ermitteln
|
|
214
|
+
const prefix = client?.prefix || null;
|
|
215
|
+
|
|
216
|
+
// Commands zählen
|
|
217
|
+
const commandCount = client?.commands?.size || 0;
|
|
218
|
+
|
|
219
|
+
// Plugins zählen
|
|
220
|
+
const pluginCount = client?.plugins?.size || 0;
|
|
221
|
+
|
|
212
222
|
console.log(`
|
|
213
|
-
🚀
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
🚀 ${botName} ist bereit!`);
|
|
224
|
+
|
|
225
|
+
// Nur anzeigen wenn vorhanden
|
|
226
|
+
if (prefix) {
|
|
227
|
+
console.log(` ├─ Prefix: "${prefix}"`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (commandCount > 0) {
|
|
231
|
+
console.log(` ├─ Commands: ${commandCount} verfügbar`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (pluginCount > 0) {
|
|
235
|
+
console.log(` ├─ Plugins: ${pluginCount} geladen`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
console.log(` └─ Status: 🟢 Online & Authentifiziert
|
|
218
239
|
|
|
219
240
|
💬 Bot wartet auf Nachrichten...`);
|
|
220
241
|
}
|
package/src/core.js
CHANGED
|
@@ -83,7 +83,17 @@ export async function getSocket() {
|
|
|
83
83
|
|
|
84
84
|
// WICHTIG: Alle Events loggen für Debug
|
|
85
85
|
socket.ev.on("messages.upsert", (data) => {
|
|
86
|
-
console.log("🚨 RAW MESSAGE EVENT:"
|
|
86
|
+
console.log("🚨 RAW MESSAGE EVENT:");
|
|
87
|
+
console.log(` Type: ${data.type}`);
|
|
88
|
+
console.log(` Messages: ${data.messages.length}`);
|
|
89
|
+
data.messages.forEach((msg, i) => {
|
|
90
|
+
console.log(` Message ${i + 1}:`, {
|
|
91
|
+
from: msg.key.remoteJid,
|
|
92
|
+
fromMe: msg.key.fromMe,
|
|
93
|
+
hasMessage: !!msg.message,
|
|
94
|
+
type: Object.keys(msg.message || {})[0]
|
|
95
|
+
});
|
|
96
|
+
});
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
socket.ev.on("chats.set", (data) => {
|
package/src/message.js
CHANGED
|
@@ -569,6 +569,88 @@ export class Message {
|
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
async deleteFromReply() {
|
|
573
|
+
// Prüfe ob die Message eine Reply ist
|
|
574
|
+
const contextInfo = this.raw.message?.extendedTextMessage?.contextInfo;
|
|
575
|
+
const quotedMessage = contextInfo?.quotedMessage;
|
|
576
|
+
const quotedKey = contextInfo?.stanzaId;
|
|
577
|
+
const quotedParticipant = contextInfo?.participant;
|
|
578
|
+
|
|
579
|
+
if (!quotedMessage || !quotedKey) {
|
|
580
|
+
console.log('❌ Keine Reply-Message gefunden zum Löschen');
|
|
581
|
+
return { success: false, reason: 'no_reply' };
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
try {
|
|
585
|
+
// Bot JID ermitteln
|
|
586
|
+
const botJid = this.client.socket.user?.id;
|
|
587
|
+
const botNumber = botJid?.split('@')[0]?.split(':')[0];
|
|
588
|
+
const quotedNumber = quotedParticipant?.split('@')[0]?.split(':')[0];
|
|
589
|
+
|
|
590
|
+
// Prüfe ob Message vom Bot ist
|
|
591
|
+
const isFromBot = botNumber === quotedNumber;
|
|
592
|
+
|
|
593
|
+
console.log('🔍 Debug Info:');
|
|
594
|
+
console.log(' Bot Number:', botNumber);
|
|
595
|
+
console.log(' Quoted Number:', quotedNumber);
|
|
596
|
+
console.log(' Is Group:', this.isGroup);
|
|
597
|
+
console.log(' Is from Bot:', isFromBot);
|
|
598
|
+
|
|
599
|
+
// Erstelle den Key für die quoted Message
|
|
600
|
+
const messageKey = {
|
|
601
|
+
remoteJid: this.from,
|
|
602
|
+
id: quotedKey,
|
|
603
|
+
fromMe: isFromBot // true wenn vom Bot, false wenn von anderem User
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
// In Gruppen: participant hinzufügen
|
|
607
|
+
if (this.isGroup && quotedParticipant) {
|
|
608
|
+
messageKey.participant = quotedParticipant;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
console.log('🗑️ Versuche Message zu löschen:', JSON.stringify(messageKey, null, 2));
|
|
612
|
+
|
|
613
|
+
// Lösche die quoted Message
|
|
614
|
+
const result = await this.client.socket.sendMessage(this.from, {
|
|
615
|
+
delete: messageKey
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
console.log('✅ Lösch-Request gesendet:', result);
|
|
619
|
+
return {
|
|
620
|
+
success: true,
|
|
621
|
+
messageId: quotedKey,
|
|
622
|
+
wasFromBot: isFromBot,
|
|
623
|
+
result: result
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.error('❌ Fehler beim Löschen:', error.message);
|
|
628
|
+
|
|
629
|
+
// Spezifische Fehlerbehandlung
|
|
630
|
+
if (error.message?.includes('not-found') || error.message?.includes('404')) {
|
|
631
|
+
return {
|
|
632
|
+
success: false,
|
|
633
|
+
reason: 'message_not_found',
|
|
634
|
+
error: 'Message zu alt oder bereits gelöscht'
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (error.message?.includes('forbidden') || error.message?.includes('403')) {
|
|
639
|
+
return {
|
|
640
|
+
success: false,
|
|
641
|
+
reason: 'no_permission',
|
|
642
|
+
error: 'WhatsApp erlaubt nur das Löschen eigener Messages!'
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return {
|
|
647
|
+
success: false,
|
|
648
|
+
reason: 'unknown_error',
|
|
649
|
+
error: error.message
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
572
654
|
// ===== MENTION HELPERS =====
|
|
573
655
|
|
|
574
656
|
getMentions() {
|
package/src/qr.js
CHANGED
|
@@ -102,8 +102,8 @@ export async function generateQRCode(qrData = null, options = {}) {
|
|
|
102
102
|
qrDisplayCount++;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
// Browser QR
|
|
106
|
-
if (qrData && options.
|
|
105
|
+
// Browser QR NUR wenn explizit aktiviert (nicht mehr automatisch)
|
|
106
|
+
if (qrData && options.openBrowser === true) {
|
|
107
107
|
await openUniversalBrowser(qrData);
|
|
108
108
|
}
|
|
109
109
|
|
package/src/resource-manager.js
CHANGED
|
@@ -189,8 +189,7 @@ export class ResourceManager {
|
|
|
189
189
|
|
|
190
190
|
// Cleanup all resources
|
|
191
191
|
cleanupAll() {
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
// Silent cleanup - keine Ausgabe mehr
|
|
194
193
|
const results = {
|
|
195
194
|
timers: this.clearAllTimers(),
|
|
196
195
|
intervals: this.clearAllIntervals(),
|
|
@@ -199,8 +198,6 @@ export class ResourceManager {
|
|
|
199
198
|
connections: this.closeAllConnections()
|
|
200
199
|
};
|
|
201
200
|
|
|
202
|
-
console.log('✅ Resource cleanup complete:', results);
|
|
203
|
-
|
|
204
201
|
return results;
|
|
205
202
|
}
|
|
206
203
|
|
|
@@ -255,7 +252,7 @@ export class ResourceManager {
|
|
|
255
252
|
// Setup process handlers for cleanup
|
|
256
253
|
setupProcessHandlers() {
|
|
257
254
|
const cleanup = () => {
|
|
258
|
-
|
|
255
|
+
// Minimale Cleanup-Ausgabe
|
|
259
256
|
this.cleanupAll();
|
|
260
257
|
};
|
|
261
258
|
|