waengine 1.1.2 → 1.7.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/FEATURES.md +618 -2
- package/README.md +400 -34
- package/package.json +5 -3
- package/src/advanced-features.js +776 -0
- package/src/client.js +415 -32
- package/src/device-manager.js +35 -10
- package/src/easy-advanced.js +673 -0
- package/src/easy-bot.js +430 -4
- package/src/index.js +17 -0
- package/src/message.js +193 -0
- package/src/multi-client.js +64 -6
- package/src/qr.js +433 -81
package/src/message.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Message-Klasse mit deinen eigenen Funktionen
|
|
2
2
|
import { getStorage } from "./storage.js";
|
|
3
3
|
import { StickerCreator } from "./sticker-creator.js";
|
|
4
|
+
import { AdvancedMessage, AdvancedGroup, AdvancedPrivacy, AdvancedAnalytics, AdvancedStatus, AdvancedBusiness, AdvancedSystem } from "./advanced-features.js";
|
|
4
5
|
|
|
5
6
|
export class Message {
|
|
6
7
|
constructor(client, data) {
|
|
@@ -36,6 +37,24 @@ export class Message {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
};
|
|
40
|
+
|
|
41
|
+
// ===== ADVANCED FEATURES INTEGRATION - NEU! =====
|
|
42
|
+
this.advanced = new AdvancedMessage(this);
|
|
43
|
+
this.forward = this.advanced.forwardMessage.bind(this.advanced);
|
|
44
|
+
this.forwardToMentioned = this.advanced.forwardToMentioned.bind(this.advanced);
|
|
45
|
+
this.forwardToSender = this.advanced.forwardToSender.bind(this.advanced);
|
|
46
|
+
this.edit = this.advanced.editMessage.bind(this.advanced);
|
|
47
|
+
this.pin = this.advanced.pinMessage.bind(this.advanced);
|
|
48
|
+
this.unpin = this.advanced.unpinMessage.bind(this.advanced);
|
|
49
|
+
this.star = this.advanced.starMessage.bind(this.advanced);
|
|
50
|
+
this.unstar = this.advanced.unstarMessage.bind(this.advanced);
|
|
51
|
+
this.replyTo = this.advanced.replyToMessage.bind(this.advanced);
|
|
52
|
+
this.replyToSender = this.advanced.replyToSender.bind(this.advanced);
|
|
53
|
+
this.quote = this.advanced.quoteMessage.bind(this.advanced);
|
|
54
|
+
this.sendButtons = this.advanced.sendButtonMessage.bind(this.advanced);
|
|
55
|
+
this.sendList = this.advanced.sendListMessage.bind(this.advanced);
|
|
56
|
+
this.sendTemplate = this.advanced.sendTemplateMessage.bind(this.advanced);
|
|
57
|
+
this.sendCarousel = this.advanced.sendCarouselMessage.bind(this.advanced);
|
|
39
58
|
}
|
|
40
59
|
|
|
41
60
|
// ===== REPLY FUNCTIONS =====
|
|
@@ -99,6 +118,39 @@ export class Message {
|
|
|
99
118
|
});
|
|
100
119
|
}
|
|
101
120
|
|
|
121
|
+
// ===== PROFILE PICTURE FUNCTIONS - NEU! =====
|
|
122
|
+
|
|
123
|
+
async getProfilePicture(jid) {
|
|
124
|
+
try {
|
|
125
|
+
// Baileys Funktion für Profilbild-URL
|
|
126
|
+
const profilePicUrl = await this.client.socket.profilePictureUrl(jid, 'image');
|
|
127
|
+
return profilePicUrl;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
// Fallback: Kein Profilbild verfügbar
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async sendProfilePicture(jid, caption = "") {
|
|
135
|
+
try {
|
|
136
|
+
const profilePicUrl = await this.getProfilePicture(jid);
|
|
137
|
+
|
|
138
|
+
if (!profilePicUrl) {
|
|
139
|
+
await this.reply(`❌ Kein Profilbild für diesen User verfügbar.`);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Profilbild als Bild senden
|
|
144
|
+
await this.sendImage(profilePicUrl, caption);
|
|
145
|
+
return true;
|
|
146
|
+
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error('❌ Fehler beim Senden des Profilbilds:', error);
|
|
149
|
+
await this.reply(`❌ Fehler beim Laden des Profilbilds: ${error.message}`);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
102
154
|
async sendAudio(audioPath) {
|
|
103
155
|
return await this.client.socket.sendMessage(this.from, {
|
|
104
156
|
audio: { url: audioPath },
|
|
@@ -133,6 +185,147 @@ export class Message {
|
|
|
133
185
|
return await this.client.socket.sendMessage(this.from, message);
|
|
134
186
|
}
|
|
135
187
|
|
|
188
|
+
// ===== ADVANCED MEDIA FEATURES - NEU! =====
|
|
189
|
+
|
|
190
|
+
async sendVoiceMessage(audioPath, mentions = []) {
|
|
191
|
+
const message = {
|
|
192
|
+
audio: { url: audioPath },
|
|
193
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
194
|
+
ptt: true // Push-to-talk (Voice Message)
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
if (mentions.length > 0) {
|
|
198
|
+
message.mentions = mentions;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return await this.client.socket.sendMessage(this.from, message);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async sendVoiceToMentioned(audioPath) {
|
|
205
|
+
const mentions = this.getMentions();
|
|
206
|
+
if (mentions.length === 0) {
|
|
207
|
+
return await this.sendVoiceMessage(audioPath);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const results = [];
|
|
211
|
+
for (const jid of mentions) {
|
|
212
|
+
try {
|
|
213
|
+
const result = await this.client.socket.sendMessage(jid, {
|
|
214
|
+
audio: { url: audioPath },
|
|
215
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
216
|
+
ptt: true
|
|
217
|
+
});
|
|
218
|
+
results.push({ jid, success: true, result });
|
|
219
|
+
} catch (error) {
|
|
220
|
+
results.push({ jid, success: false, error: error.message });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return results;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async sendVideoMessage(videoPath, mentions = []) {
|
|
227
|
+
const message = {
|
|
228
|
+
video: { url: videoPath },
|
|
229
|
+
ptv: true, // Push-to-view (Video Message)
|
|
230
|
+
mimetype: 'video/mp4'
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
if (mentions.length > 0) {
|
|
234
|
+
message.mentions = mentions;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return await this.client.socket.sendMessage(this.from, message);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async sendVideoMessageToMentioned(videoPath) {
|
|
241
|
+
const mentions = this.getMentions();
|
|
242
|
+
if (mentions.length === 0) {
|
|
243
|
+
return await this.sendVideoMessage(videoPath);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const results = [];
|
|
247
|
+
for (const jid of mentions) {
|
|
248
|
+
try {
|
|
249
|
+
const result = await this.client.socket.sendMessage(jid, {
|
|
250
|
+
video: { url: videoPath },
|
|
251
|
+
ptv: true,
|
|
252
|
+
mimetype: 'video/mp4'
|
|
253
|
+
});
|
|
254
|
+
results.push({ jid, success: true, result });
|
|
255
|
+
} catch (error) {
|
|
256
|
+
results.push({ jid, success: false, error: error.message });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return results;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async sendGif(gifPath, caption = "", mentions = []) {
|
|
263
|
+
const message = {
|
|
264
|
+
video: { url: gifPath },
|
|
265
|
+
caption: caption,
|
|
266
|
+
gifPlayback: true,
|
|
267
|
+
mimetype: 'video/mp4'
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
if (mentions.length > 0) {
|
|
271
|
+
message.mentions = mentions;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return await this.client.socket.sendMessage(this.from, message);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async sendGifToMentioned(gifPath, caption = "") {
|
|
278
|
+
const mentions = this.getMentions();
|
|
279
|
+
if (mentions.length === 0) {
|
|
280
|
+
return await this.sendGif(gifPath, caption);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const results = [];
|
|
284
|
+
for (const jid of mentions) {
|
|
285
|
+
try {
|
|
286
|
+
const result = await this.client.socket.sendMessage(jid, {
|
|
287
|
+
video: { url: gifPath },
|
|
288
|
+
caption: caption,
|
|
289
|
+
gifPlayback: true,
|
|
290
|
+
mimetype: 'video/mp4'
|
|
291
|
+
});
|
|
292
|
+
results.push({ jid, success: true, result });
|
|
293
|
+
} catch (error) {
|
|
294
|
+
results.push({ jid, success: false, error: error.message });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return results;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async sendVideoWithThumbnail(videoPath, thumbnailPath, caption = "", mentions = []) {
|
|
301
|
+
const message = {
|
|
302
|
+
video: { url: videoPath },
|
|
303
|
+
caption: caption,
|
|
304
|
+
jpegThumbnail: thumbnailPath,
|
|
305
|
+
mimetype: 'video/mp4'
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
if (mentions.length > 0) {
|
|
309
|
+
message.mentions = mentions;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return await this.client.socket.sendMessage(this.from, message);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async sendImageWithThumbnail(imagePath, thumbnailPath, caption = "", mentions = []) {
|
|
316
|
+
const message = {
|
|
317
|
+
image: { url: imagePath },
|
|
318
|
+
caption: caption,
|
|
319
|
+
jpegThumbnail: thumbnailPath
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
if (mentions.length > 0) {
|
|
323
|
+
message.mentions = mentions;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return await this.client.socket.sendMessage(this.from, message);
|
|
327
|
+
}
|
|
328
|
+
|
|
136
329
|
async sendLocation(latitude, longitude) {
|
|
137
330
|
return await this.client.socket.sendMessage(this.from, {
|
|
138
331
|
location: {
|
package/src/multi-client.js
CHANGED
|
@@ -7,6 +7,16 @@ export class MultiWhatsAppClient {
|
|
|
7
7
|
maxDevices: options.maxDevices || 3,
|
|
8
8
|
loadBalancing: options.loadBalancing || 'round-robin',
|
|
9
9
|
syncEvents: options.syncEvents !== false,
|
|
10
|
+
|
|
11
|
+
// ROBUSTE CONNECTION DEFAULTS - NEU!
|
|
12
|
+
maxReconnectAttempts: options.maxReconnectAttempts || 100,
|
|
13
|
+
reconnectInterval: options.reconnectInterval || 2000,
|
|
14
|
+
exponentialBackoff: options.exponentialBackoff !== false,
|
|
15
|
+
maxBackoffDelay: options.maxBackoffDelay || 30000,
|
|
16
|
+
heartbeatInterval: options.heartbeatInterval || 20000,
|
|
17
|
+
connectionTimeout: options.connectionTimeout || 180000,
|
|
18
|
+
keepAlive: options.keepAlive !== false,
|
|
19
|
+
quietHeartbeat: options.quietHeartbeat !== false, // Heartbeat-Spam deaktivieren
|
|
10
20
|
...options
|
|
11
21
|
});
|
|
12
22
|
|
|
@@ -17,7 +27,7 @@ export class MultiWhatsAppClient {
|
|
|
17
27
|
// Device Manager Events weiterleiten
|
|
18
28
|
this.setupDeviceManagerEvents();
|
|
19
29
|
|
|
20
|
-
console.log("🚀 MultiWhatsAppClient initialisiert");
|
|
30
|
+
console.log("🚀 MultiWhatsAppClient mit robusten Verbindungen initialisiert");
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
// ===== DEVICE MANAGEMENT =====
|
|
@@ -46,13 +56,61 @@ export class MultiWhatsAppClient {
|
|
|
46
56
|
|
|
47
57
|
async connect(deviceIds = null) {
|
|
48
58
|
if (deviceIds) {
|
|
49
|
-
// Spezifische Devices verbinden
|
|
50
|
-
|
|
51
|
-
return await Promise.allSettled(promises);
|
|
59
|
+
// Spezifische Devices sequenziell verbinden
|
|
60
|
+
return await this.connectDevicesSequentially(deviceIds);
|
|
52
61
|
} else {
|
|
53
|
-
// Alle Devices verbinden
|
|
54
|
-
|
|
62
|
+
// Alle Devices sequenziell verbinden
|
|
63
|
+
const allDeviceIds = Array.from(this.deviceManager.devices.keys());
|
|
64
|
+
return await this.connectDevicesSequentially(allDeviceIds);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// NEUE SEQUENZIELLE VERBINDUNG - Ein QR nach dem anderen!
|
|
69
|
+
async connectDevicesSequentially(deviceIds) {
|
|
70
|
+
console.log(`🔄 Sequenzielle Verbindung von ${deviceIds.length} Devices...`);
|
|
71
|
+
console.log("📱 QR-Codes werden nacheinander angezeigt - scanne einen nach dem anderen!");
|
|
72
|
+
|
|
73
|
+
const results = [];
|
|
74
|
+
let connectedCount = 0;
|
|
75
|
+
|
|
76
|
+
for (let i = 0; i < deviceIds.length; i++) {
|
|
77
|
+
const deviceId = deviceIds[i];
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
console.log(`\n📱 Device ${i + 1}/${deviceIds.length}: '${deviceId}'`);
|
|
81
|
+
console.log("⏳ Warte auf QR-Scan für dieses Device...");
|
|
82
|
+
|
|
83
|
+
// Verbinde ein Device und warte bis es fertig ist
|
|
84
|
+
const client = await this.deviceManager.connectDevice(deviceId);
|
|
85
|
+
|
|
86
|
+
console.log(`✅ Device '${deviceId}' erfolgreich verbunden!`);
|
|
87
|
+
connectedCount++;
|
|
88
|
+
results.push({ deviceId, status: 'connected', client });
|
|
89
|
+
|
|
90
|
+
// Kurze Pause zwischen Devices
|
|
91
|
+
if (i < deviceIds.length - 1) {
|
|
92
|
+
console.log("⏸️ Kurze Pause vor nächstem Device...");
|
|
93
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(`❌ Device '${deviceId}' Verbindung fehlgeschlagen:`, error.message);
|
|
98
|
+
results.push({ deviceId, status: 'failed', error: error.message });
|
|
99
|
+
|
|
100
|
+
// Frage ob weiter machen
|
|
101
|
+
console.log("❓ Soll mit dem nächsten Device fortgefahren werden? (Automatisch ja in 5s)");
|
|
102
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
103
|
+
}
|
|
55
104
|
}
|
|
105
|
+
|
|
106
|
+
console.log(`\n🎉 Sequenzielle Verbindung abgeschlossen!`);
|
|
107
|
+
console.log(`✅ ${connectedCount}/${deviceIds.length} Devices erfolgreich verbunden`);
|
|
108
|
+
|
|
109
|
+
if (connectedCount === 0) {
|
|
110
|
+
throw new Error("❌ Keine Devices konnten verbunden werden!");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return results;
|
|
56
114
|
}
|
|
57
115
|
|
|
58
116
|
async disconnect(deviceIds = null) {
|