waengine 1.8.2 β†’ 1.8.3

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": "1.8.2",
3
+ "version": "1.8.3",
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
@@ -1198,6 +1198,125 @@ export class WhatsAppClient {
1198
1198
  async setPaused(chatId) {
1199
1199
  return await this.setPresence('paused', chatId);
1200
1200
  }
1201
+
1202
+ // ===== SENDCHAT API - Nachrichten an beliebige Chats senden! =====
1203
+
1204
+ /**
1205
+ * Sendet eine Nachricht an einen beliebigen Chat (außerhalb von Message-Context)
1206
+ * @param {string} targetJid - Die JID des Ziel-Chats
1207
+ * @param {string|object} content - Text oder Message-Objekt
1208
+ * @param {object} options - Optionale Einstellungen
1209
+ * @returns {Promise} Gesendete Nachricht
1210
+ */
1211
+ async sendChat(targetJid, content, options = {}) {
1212
+ try {
1213
+ if (!this.socket || !this.isConnected) {
1214
+ throw new Error('❌ Bot ist nicht verbunden!');
1215
+ }
1216
+
1217
+ // Validiere JID Format
1218
+ if (!targetJid || typeof targetJid !== 'string') {
1219
+ throw new Error('❌ Ungültige JID! Format: "nummer@s.whatsapp.net" oder "gruppenid@g.us"');
1220
+ }
1221
+
1222
+ // Normalisiere JID falls nΓΆtig
1223
+ let normalizedJid = targetJid;
1224
+ if (!targetJid.includes('@')) {
1225
+ normalizedJid = `${targetJid}@s.whatsapp.net`;
1226
+ }
1227
+
1228
+ // Erstelle Message-Objekt
1229
+ let messageObj;
1230
+
1231
+ if (typeof content === 'string') {
1232
+ messageObj = { text: content };
1233
+
1234
+ // FΓΌge optionale Features hinzu
1235
+ if (options.mentions && Array.isArray(options.mentions)) {
1236
+ messageObj.mentions = options.mentions;
1237
+ }
1238
+
1239
+ if (options.image) {
1240
+ messageObj.image = { url: options.image };
1241
+ messageObj.caption = content;
1242
+ delete messageObj.text;
1243
+ }
1244
+
1245
+ if (options.video) {
1246
+ messageObj.video = { url: options.video };
1247
+ messageObj.caption = content;
1248
+ delete messageObj.text;
1249
+ }
1250
+
1251
+ if (options.audio) {
1252
+ messageObj.audio = { url: options.audio };
1253
+ messageObj.mimetype = 'audio/mp4';
1254
+ delete messageObj.text;
1255
+ }
1256
+
1257
+ if (options.sticker) {
1258
+ messageObj.sticker = { url: options.sticker };
1259
+ delete messageObj.text;
1260
+ delete messageObj.caption;
1261
+ }
1262
+
1263
+ if (options.document) {
1264
+ messageObj.document = { url: options.document };
1265
+ messageObj.fileName = options.fileName || 'document';
1266
+ messageObj.mimetype = options.mimetype || 'application/octet-stream';
1267
+ if (content) messageObj.caption = content;
1268
+ delete messageObj.text;
1269
+ }
1270
+
1271
+ } else if (typeof content === 'object') {
1272
+ messageObj = content;
1273
+ } else {
1274
+ throw new Error('❌ Content muss String oder Objekt sein');
1275
+ }
1276
+
1277
+ // Sende Nachricht
1278
+ console.log(`πŸ“€ Sende Nachricht an ${normalizedJid}`);
1279
+ const result = await this.socket.sendMessage(normalizedJid, messageObj);
1280
+ console.log('βœ… Nachricht erfolgreich gesendet:', result?.key?.id);
1281
+
1282
+ return result;
1283
+
1284
+ } catch (error) {
1285
+ console.error('❌ Fehler beim Senden an anderen Chat:', error);
1286
+ throw error;
1287
+ }
1288
+ }
1289
+
1290
+ /**
1291
+ * Sendet eine Nachricht an mehrere Chats gleichzeitig (Broadcast)
1292
+ * @param {Array<string>} targetJids - Array von JIDs
1293
+ * @param {string|object} content - Nachricht
1294
+ * @param {object} options - Optionale Einstellungen
1295
+ * @returns {Promise<Array>} Array mit Ergebnissen
1296
+ */
1297
+ async sendToMultipleChats(targetJids, content, options = {}) {
1298
+ if (!Array.isArray(targetJids) || targetJids.length === 0) {
1299
+ throw new Error('❌ targetJids muss ein nicht-leeres Array sein');
1300
+ }
1301
+
1302
+ const results = [];
1303
+ const delay = options.delay || 1000;
1304
+
1305
+ for (const jid of targetJids) {
1306
+ try {
1307
+ const result = await this.sendChat(jid, content, options);
1308
+ results.push({ jid, success: true, result });
1309
+
1310
+ if (delay > 0 && jid !== targetJids[targetJids.length - 1]) {
1311
+ await new Promise(resolve => setTimeout(resolve, delay));
1312
+ }
1313
+ } catch (error) {
1314
+ results.push({ jid, success: false, error: error.message });
1315
+ }
1316
+ }
1317
+
1318
+ return results;
1319
+ }
1201
1320
  }
1202
1321
 
1203
1322
  // ===== DEINE API-KLASSEN =====
@@ -1413,125 +1532,6 @@ class DemoteAPI {
1413
1532
  });
1414
1533
  }
1415
1534
 
1416
- // ===== SENDCHAT API - Nachrichten an beliebige Chats senden! =====
1417
-
1418
- /**
1419
- * Sendet eine Nachricht an einen beliebigen Chat (außerhalb von Message-Context)
1420
- * @param {string} targetJid - Die JID des Ziel-Chats
1421
- * @param {string|object} content - Text oder Message-Objekt
1422
- * @param {object} options - Optionale Einstellungen
1423
- * @returns {Promise} Gesendete Nachricht
1424
- */
1425
- async sendChat(targetJid, content, options = {}) {
1426
- try {
1427
- if (!this.socket || !this.isConnected) {
1428
- throw new Error('❌ Bot ist nicht verbunden!');
1429
- }
1430
-
1431
- // Validiere JID Format
1432
- if (!targetJid || typeof targetJid !== 'string') {
1433
- throw new Error('❌ Ungültige JID! Format: "nummer@s.whatsapp.net" oder "gruppenid@g.us"');
1434
- }
1435
-
1436
- // Normalisiere JID falls nΓΆtig
1437
- let normalizedJid = targetJid;
1438
- if (!targetJid.includes('@')) {
1439
- normalizedJid = `${targetJid}@s.whatsapp.net`;
1440
- }
1441
-
1442
- // Erstelle Message-Objekt
1443
- let messageObj;
1444
-
1445
- if (typeof content === 'string') {
1446
- messageObj = { text: content };
1447
-
1448
- // FΓΌge optionale Features hinzu
1449
- if (options.mentions && Array.isArray(options.mentions)) {
1450
- messageObj.mentions = options.mentions;
1451
- }
1452
-
1453
- if (options.image) {
1454
- messageObj.image = { url: options.image };
1455
- messageObj.caption = content;
1456
- delete messageObj.text;
1457
- }
1458
-
1459
- if (options.video) {
1460
- messageObj.video = { url: options.video };
1461
- messageObj.caption = content;
1462
- delete messageObj.text;
1463
- }
1464
-
1465
- if (options.audio) {
1466
- messageObj.audio = { url: options.audio };
1467
- messageObj.mimetype = 'audio/mp4';
1468
- delete messageObj.text;
1469
- }
1470
-
1471
- if (options.sticker) {
1472
- messageObj.sticker = { url: options.sticker };
1473
- delete messageObj.text;
1474
- delete messageObj.caption;
1475
- }
1476
-
1477
- if (options.document) {
1478
- messageObj.document = { url: options.document };
1479
- messageObj.fileName = options.fileName || 'document';
1480
- messageObj.mimetype = options.mimetype || 'application/octet-stream';
1481
- if (content) messageObj.caption = content;
1482
- delete messageObj.text;
1483
- }
1484
-
1485
- } else if (typeof content === 'object') {
1486
- messageObj = content;
1487
- } else {
1488
- throw new Error('❌ Content muss String oder Objekt sein');
1489
- }
1490
-
1491
- // Sende Nachricht
1492
- console.log(`πŸ“€ Sende Nachricht an ${normalizedJid}`);
1493
- const result = await this.socket.sendMessage(normalizedJid, messageObj);
1494
- console.log('βœ… Nachricht erfolgreich gesendet:', result?.key?.id);
1495
-
1496
- return result;
1497
-
1498
- } catch (error) {
1499
- console.error('❌ Fehler beim Senden an anderen Chat:', error);
1500
- throw error;
1501
- }
1502
- }
1503
-
1504
- /**
1505
- * Sendet eine Nachricht an mehrere Chats gleichzeitig (Broadcast)
1506
- * @param {Array<string>} targetJids - Array von JIDs
1507
- * @param {string|object} content - Nachricht
1508
- * @param {object} options - Optionale Einstellungen
1509
- * @returns {Promise<Array>} Array mit Ergebnissen
1510
- */
1511
- async sendToMultipleChats(targetJids, content, options = {}) {
1512
- if (!Array.isArray(targetJids) || targetJids.length === 0) {
1513
- throw new Error('❌ targetJids muss ein nicht-leeres Array sein');
1514
- }
1515
-
1516
- const results = [];
1517
- const delay = options.delay || 1000;
1518
-
1519
- for (const jid of targetJids) {
1520
- try {
1521
- const result = await this.sendChat(jid, content, options);
1522
- results.push({ jid, success: true, result });
1523
-
1524
- if (delay > 0 && jid !== targetJids[targetJids.length - 1]) {
1525
- await new Promise(resolve => setTimeout(resolve, delay));
1526
- }
1527
- } catch (error) {
1528
- results.push({ jid, success: false, error: error.message });
1529
- }
1530
- }
1531
-
1532
- return results;
1533
- }
1534
-
1535
1535
  // ===== ERROR RECOVERY =====
1536
1536
 
1537
1537
  async recoverFromError(error) {
@@ -13,7 +13,7 @@ export class ConsoleLogger {
13
13
 
14
14
  console.log(`
15
15
  ╔══════════════════════════════════════════════════════════════╗
16
- β•‘ πŸš€ WAEngine v1.7.4 β•‘
16
+ β•‘ πŸš€ WAEngine v1.8.3 β•‘
17
17
  β•‘ Advanced WhatsApp Bot Framework β•‘
18
18
  β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•`);
19
19
  }