waengine 1.8.2 β 1.8.9
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 +8 -1
- package/src/client.js +200 -119
- package/src/console-logger.js +1 -1
- package/src/message.js +64 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
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",
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
"example:easy": "node examples/easy-bot-examples.js vollstΓ€ndig"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
+
"best-libary",
|
|
16
|
+
"Library",
|
|
17
|
+
"whatsapp-bot-libary",
|
|
18
|
+
"Whatsapp-libary",
|
|
19
|
+
"npm",
|
|
20
|
+
"npm-install-waengine",
|
|
21
|
+
"api",
|
|
15
22
|
"mention",
|
|
16
23
|
"waengine",
|
|
17
24
|
"hidetag",
|
package/src/client.js
CHANGED
|
@@ -1198,6 +1198,206 @@ 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
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// ===== CONTACT INFO API =====
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Holt erweiterte Kontakt-Informationen
|
|
1325
|
+
* @param {string} jid - Die JID des Kontakts
|
|
1326
|
+
* @returns {Promise<object>} Kontakt-Informationen
|
|
1327
|
+
*/
|
|
1328
|
+
async getContactInfo(jid) {
|
|
1329
|
+
try {
|
|
1330
|
+
// Normalisiere JID
|
|
1331
|
+
let normalizedJid = jid;
|
|
1332
|
+
if (!jid.includes('@')) {
|
|
1333
|
+
normalizedJid = `${jid}@s.whatsapp.net`;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// Basis-Info: PrΓΌfe ob Nummer auf WhatsApp ist
|
|
1337
|
+
const onWhatsAppCheck = await this.socket.onWhatsApp(normalizedJid);
|
|
1338
|
+
|
|
1339
|
+
if (!onWhatsAppCheck || onWhatsAppCheck.length === 0) {
|
|
1340
|
+
return {
|
|
1341
|
+
exists: false,
|
|
1342
|
+
jid: normalizedJid,
|
|
1343
|
+
number: jid.split('@')[0]
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
const baseInfo = onWhatsAppCheck[0];
|
|
1348
|
+
|
|
1349
|
+
// Erweiterte Kontakt-Informationen sammeln
|
|
1350
|
+
const contactInfo = {
|
|
1351
|
+
exists: baseInfo.exists,
|
|
1352
|
+
jid: baseInfo.jid,
|
|
1353
|
+
number: baseInfo.jid.split('@')[0],
|
|
1354
|
+
isBusiness: baseInfo.isBusiness || false,
|
|
1355
|
+
name: null,
|
|
1356
|
+
notify: null,
|
|
1357
|
+
verifiedName: null,
|
|
1358
|
+
status: null,
|
|
1359
|
+
profilePicture: null
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
try {
|
|
1363
|
+
// Versuche Profilbild abzurufen
|
|
1364
|
+
const profilePicUrl = await this.socket.profilePictureUrl(normalizedJid, 'image');
|
|
1365
|
+
contactInfo.profilePicture = profilePicUrl;
|
|
1366
|
+
} catch (error) {
|
|
1367
|
+
// Kein Profilbild verfΓΌgbar
|
|
1368
|
+
contactInfo.profilePicture = null;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
try {
|
|
1372
|
+
// Versuche Status abzurufen
|
|
1373
|
+
const status = await this.socket.fetchStatus(normalizedJid);
|
|
1374
|
+
contactInfo.status = status?.status || null;
|
|
1375
|
+
contactInfo.statusTimestamp = status?.setAt || null;
|
|
1376
|
+
} catch (error) {
|
|
1377
|
+
// Status nicht verfΓΌgbar
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// Versuche Name aus dem Store zu holen (wenn verfΓΌgbar)
|
|
1381
|
+
try {
|
|
1382
|
+
if (this.socket.store && this.socket.store.contacts) {
|
|
1383
|
+
const storeContact = this.socket.store.contacts[normalizedJid];
|
|
1384
|
+
if (storeContact) {
|
|
1385
|
+
contactInfo.name = storeContact.name || storeContact.notify || null;
|
|
1386
|
+
contactInfo.notify = storeContact.notify || null;
|
|
1387
|
+
contactInfo.verifiedName = storeContact.verifiedName || null;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
} catch (error) {
|
|
1391
|
+
// Store nicht verfΓΌgbar
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
return contactInfo;
|
|
1395
|
+
|
|
1396
|
+
} catch (error) {
|
|
1397
|
+
console.error('β Fehler beim Abrufen der Kontakt-Info:', error);
|
|
1398
|
+
return null;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1201
1401
|
}
|
|
1202
1402
|
|
|
1203
1403
|
// ===== DEINE API-KLASSEN =====
|
|
@@ -1413,125 +1613,6 @@ class DemoteAPI {
|
|
|
1413
1613
|
});
|
|
1414
1614
|
}
|
|
1415
1615
|
|
|
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
1616
|
// ===== ERROR RECOVERY =====
|
|
1536
1617
|
|
|
1537
1618
|
async recoverFromError(error) {
|
package/src/console-logger.js
CHANGED
|
@@ -13,7 +13,7 @@ export class ConsoleLogger {
|
|
|
13
13
|
|
|
14
14
|
console.log(`
|
|
15
15
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
16
|
-
β π WAEngine v1.
|
|
16
|
+
β π WAEngine v1.8.9 β
|
|
17
17
|
β Advanced WhatsApp Bot Framework β
|
|
18
18
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ`);
|
|
19
19
|
}
|
package/src/message.js
CHANGED
|
@@ -1558,16 +1558,72 @@ export class Message {
|
|
|
1558
1558
|
|
|
1559
1559
|
async getContactInfo(jid) {
|
|
1560
1560
|
try {
|
|
1561
|
-
//
|
|
1562
|
-
|
|
1563
|
-
if (
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1561
|
+
// Normalisiere JID
|
|
1562
|
+
let normalizedJid = jid;
|
|
1563
|
+
if (!jid.includes('@')) {
|
|
1564
|
+
normalizedJid = `${jid}@s.whatsapp.net`;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// Basis-Info: PrΓΌfe ob Nummer auf WhatsApp ist
|
|
1568
|
+
const onWhatsAppCheck = await this.client.socket.onWhatsApp(normalizedJid);
|
|
1569
|
+
|
|
1570
|
+
if (!onWhatsAppCheck || onWhatsAppCheck.length === 0) {
|
|
1571
|
+
return {
|
|
1572
|
+
exists: false,
|
|
1573
|
+
jid: normalizedJid,
|
|
1574
|
+
number: jid.split('@')[0]
|
|
1568
1575
|
};
|
|
1569
1576
|
}
|
|
1570
|
-
|
|
1577
|
+
|
|
1578
|
+
const baseInfo = onWhatsAppCheck[0];
|
|
1579
|
+
|
|
1580
|
+
// Erweiterte Kontakt-Informationen sammeln
|
|
1581
|
+
const contactInfo = {
|
|
1582
|
+
exists: baseInfo.exists,
|
|
1583
|
+
jid: baseInfo.jid,
|
|
1584
|
+
number: baseInfo.jid.split('@')[0],
|
|
1585
|
+
isBusiness: baseInfo.isBusiness || false,
|
|
1586
|
+
name: null,
|
|
1587
|
+
notify: null,
|
|
1588
|
+
verifiedName: null,
|
|
1589
|
+
status: null,
|
|
1590
|
+
profilePicture: null
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
try {
|
|
1594
|
+
// Versuche Profilbild abzurufen
|
|
1595
|
+
const profilePicUrl = await this.client.socket.profilePictureUrl(normalizedJid, 'image');
|
|
1596
|
+
contactInfo.profilePicture = profilePicUrl;
|
|
1597
|
+
} catch (error) {
|
|
1598
|
+
// Kein Profilbild verfΓΌgbar
|
|
1599
|
+
contactInfo.profilePicture = null;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
try {
|
|
1603
|
+
// Versuche Status abzurufen
|
|
1604
|
+
const status = await this.client.socket.fetchStatus(normalizedJid);
|
|
1605
|
+
contactInfo.status = status?.status || null;
|
|
1606
|
+
contactInfo.statusTimestamp = status?.setAt || null;
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
// Status nicht verfΓΌgbar
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
// Versuche Name aus dem Store zu holen (wenn verfΓΌgbar)
|
|
1612
|
+
try {
|
|
1613
|
+
if (this.client.socket.store && this.client.socket.store.contacts) {
|
|
1614
|
+
const storeContact = this.client.socket.store.contacts[normalizedJid];
|
|
1615
|
+
if (storeContact) {
|
|
1616
|
+
contactInfo.name = storeContact.name || storeContact.notify || null;
|
|
1617
|
+
contactInfo.notify = storeContact.notify || null;
|
|
1618
|
+
contactInfo.verifiedName = storeContact.verifiedName || null;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
} catch (error) {
|
|
1622
|
+
// Store nicht verfΓΌgbar
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
return contactInfo;
|
|
1626
|
+
|
|
1571
1627
|
} catch (error) {
|
|
1572
1628
|
console.error('β Fehler beim Abrufen der Kontakt-Info:', error);
|
|
1573
1629
|
return null;
|