waengine 2.3.5 → 2.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waengine",
3
- "version": "2.3.5",
3
+ "version": "2.3.8",
4
4
  "description": "🚀 WAEngine - The most powerful WhatsApp Bot Library with 860+ Working Features, Complete Baileys Integration & Production-Ready Stability",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/client.js CHANGED
@@ -138,12 +138,19 @@ export class WhatsAppClient {
138
138
  this.ui = new UIComponents(this);
139
139
 
140
140
  // Offline Message Ignore System - NEU!
141
- this.ignoreOfflineMessages = false;
141
+ // Automatisch aktivieren wenn Environment-Variable gesetzt ist
142
+ this.ignoreOfflineMessages = process.env.WAENGINE_IGNORE_OFFLINE_MESSAGES === 'true' || false;
142
143
  this.lastOnlineTimestamp = Date.now();
143
144
  this.connectionStartTime = null;
144
145
  this.ignoredMessagesCount = 0; // Counter für ignorierte Messages
145
146
  this.offlineMessageTimer = null; // Timer für finale Zusammenfassung
146
147
 
148
+ // Log wenn automatisch aktiviert
149
+ if (this.ignoreOfflineMessages) {
150
+ console.log('\n📵 Offline Message Ignore: AUTOMATISCH AKTIVIERT');
151
+ console.log(' └─ Grund: Session über Session Menu gestartet\n');
152
+ }
153
+
147
154
  // ===== GLOBAL VISUAL TYPING/RECORDING SYSTEM - NEU! =====
148
155
  this.globalVisualTyping = false; // Global aktiviert/deaktiviert
149
156
  this.globalVisualRecord = false; // Global aktiviert/deaktiviert
@@ -372,8 +379,9 @@ export class WhatsAppClient {
372
379
  syncFullHistory: true, // Wichtig für Message-Empfang
373
380
  markOnlineOnConnect: true,
374
381
  getMessage: async (key) => {
375
- // Wichtig für Message-Handling
376
- return { conversation: "Message not found" };
382
+ // WICHTIG: undefined zurückgeben statt "Message not found"
383
+ // Sonst wird es als echte Nachricht behandelt und spammt!
384
+ return undefined;
377
385
  },
378
386
  shouldIgnoreJid: jid => isJidBroadcast(jid),
379
387
  // Bessere Message-Synchronisation
@@ -392,8 +400,9 @@ export class WhatsAppClient {
392
400
  syncFullHistory: true, // Wichtig für Message-Empfang
393
401
  markOnlineOnConnect: true,
394
402
  getMessage: async (key) => {
395
- // Wichtig für Message-Handling
396
- return { conversation: "Message not found" };
403
+ // WICHTIG: undefined zurückgeben statt "Message not found"
404
+ // Sonst wird es als echte Nachricht behandelt und spammt!
405
+ return undefined;
397
406
  },
398
407
  shouldIgnoreJid: jid => isJidBroadcast(jid),
399
408
  // Bessere Message-Synchronisation
@@ -561,7 +570,9 @@ export class WhatsAppClient {
561
570
  // Connection Start Time für Offline Message Ignore setzen
562
571
  this.connectionStartTime = Date.now();
563
572
  if (this.ignoreOfflineMessages) {
564
- this.logger.info(`Offline Messages werden ignoriert (seit ${new Date(this.connectionStartTime).toLocaleString()})`);
573
+ console.log(`\n📵 Offline Message Ignore: AKTIV`);
574
+ console.log(` ├─ Verbunden seit: ${new Date(this.connectionStartTime).toLocaleString()}`);
575
+ console.log(` └─ Alle Messages vor diesem Zeitpunkt werden ignoriert\n`);
565
576
  }
566
577
 
567
578
  await closeBrowser(); // QR Browser schließen
@@ -968,17 +979,31 @@ export class WhatsAppClient {
968
979
  // DEBUG: Zeige alle Message-Types
969
980
  console.log(`📥 Message Event - Type: ${type}, Count: ${messages.length}`);
970
981
 
971
- // WICHTIG: Alle Types akzeptieren außer explizit ausgeschlossene
972
- // Nur "prepend" (alte History) ignorieren wenn gewünscht
973
- // if (type === "prepend") return; // Optional: Alte Messages ignorieren
982
+ // WICHTIG: Alte History-Messages ignorieren (prepend)
983
+ if (type === "prepend") {
984
+ console.log(`⏭️ Ignoriere ${messages.length} History Messages (prepend)`);
985
+ return;
986
+ }
974
987
 
975
988
  messages.forEach((msg) => {
989
+ // KRITISCHE VALIDIERUNG: Prüfe ob Message-Key existiert
990
+ if (!msg.key || !msg.key.remoteJid || !msg.key.id) {
991
+ console.log(`⚠️ Ungültige Message ohne Key - ignoriert`);
992
+ return;
993
+ }
994
+
976
995
  // Bessere Message-Validierung
977
996
  if (!msg.message || msg.key.fromMe) return;
978
997
 
979
998
  // OFFLINE MESSAGE IGNORE - DEINE NEUE FUNKTION!
980
999
  if (this.ignoreOfflineMessages && this.connectionStartTime) {
981
- const messageTimestamp = msg.messageTimestamp * 1000; // Convert to milliseconds
1000
+ // messageTimestamp kann in Sekunden oder Millisekunden sein
1001
+ let messageTimestamp = msg.messageTimestamp;
1002
+
1003
+ // Wenn Timestamp in Sekunden (< Jahr 2000 in Millisekunden), konvertiere zu Millisekunden
1004
+ if (messageTimestamp < 946684800000) {
1005
+ messageTimestamp = messageTimestamp * 1000;
1006
+ }
982
1007
 
983
1008
  // Ignoriere Messages die vor der Verbindung gesendet wurden
984
1009
  if (messageTimestamp < this.connectionStartTime) {
@@ -997,7 +1022,7 @@ export class WhatsAppClient {
997
1022
  }
998
1023
  }, 3000);
999
1024
 
1000
- return;
1025
+ return; // WICHTIG: Beende hier - verarbeite Message NICHT weiter!
1001
1026
  }
1002
1027
  }
1003
1028
 
@@ -163,7 +163,8 @@ const botProcess = spawn('node', ['${this.userStartCommand}'], {
163
163
  ...process.env,
164
164
  WAENGINE_AUTH_DIR: '${session.authDir.replace(/\\/g, '/')}',
165
165
  WAENGINE_SESSION_NAME: '${sessionName}',
166
- __WAENGINE_SKIP_SESSION_MENU__: 'true'
166
+ __WAENGINE_SKIP_SESSION_MENU__: 'true',
167
+ WAENGINE_IGNORE_OFFLINE_MESSAGES: 'true' // Ignoriere Offline-Nachrichten automatisch
167
168
  },
168
169
  stdio: 'inherit'
169
170
  });