waengine 1.7.8 → 1.7.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/FEATURES.md +43 -0
- package/package.json +1 -1
- package/src/message.js +81 -0
package/FEATURES.md
CHANGED
|
@@ -243,6 +243,49 @@ await msg.react("😂")
|
|
|
243
243
|
|
|
244
244
|
// Message löschen
|
|
245
245
|
await msg.delete()
|
|
246
|
+
|
|
247
|
+
// Reply-Message löschen (NEU in v1.7.8!)
|
|
248
|
+
const result = await msg.deleteFromReply()
|
|
249
|
+
if (result.success) {
|
|
250
|
+
console.log('✅ Message gelöscht!')
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### **Message Deletion (NEU v1.7.8)**
|
|
255
|
+
```javascript
|
|
256
|
+
// Lösche die Nachricht auf die geantwortet wurde
|
|
257
|
+
client.addCommand('delete', async (msg) => {
|
|
258
|
+
const result = await msg.deleteFromReply();
|
|
259
|
+
|
|
260
|
+
if (result.success) {
|
|
261
|
+
await msg.reply('✅ Nachricht gelöscht!');
|
|
262
|
+
} else {
|
|
263
|
+
// Detaillierte Fehlerbehandlung
|
|
264
|
+
switch (result.reason) {
|
|
265
|
+
case 'no_reply':
|
|
266
|
+
await msg.reply('❌ Bitte antworte auf eine Nachricht!');
|
|
267
|
+
break;
|
|
268
|
+
case 'message_not_found':
|
|
269
|
+
await msg.reply('❌ Nachricht zu alt oder bereits gelöscht');
|
|
270
|
+
break;
|
|
271
|
+
case 'no_permission':
|
|
272
|
+
await msg.reply('❌ Nur Bot-Nachrichten können gelöscht werden');
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Return Object
|
|
279
|
+
{
|
|
280
|
+
success: boolean, // true wenn erfolgreich
|
|
281
|
+
messageId: string, // ID der gelöschten Nachricht
|
|
282
|
+
wasFromBot: boolean, // true wenn Bot-Nachricht
|
|
283
|
+
reason: string, // Fehlergrund
|
|
284
|
+
error: string // Fehlermeldung
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Wichtig:** Nur Bot-Nachrichten können gelöscht werden (WhatsApp API Einschränkung)
|
|
246
289
|
```
|
|
247
290
|
|
|
248
291
|
### **Message Properties**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
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/message.js
CHANGED
|
@@ -651,6 +651,87 @@ export class Message {
|
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// ===== MEDIA DOWNLOAD - NEU in v1.7.9! =====
|
|
655
|
+
|
|
656
|
+
async downloadMedia(options = {}) {
|
|
657
|
+
try {
|
|
658
|
+
// Prüfe ob Message Media enthält
|
|
659
|
+
const messageType = Object.keys(this.raw.message || {})[0];
|
|
660
|
+
const validMediaTypes = ['imageMessage', 'videoMessage', 'audioMessage', 'documentMessage', 'stickerMessage'];
|
|
661
|
+
|
|
662
|
+
if (!validMediaTypes.includes(messageType)) {
|
|
663
|
+
console.log('❌ Keine Media in dieser Message');
|
|
664
|
+
return {
|
|
665
|
+
success: false,
|
|
666
|
+
reason: 'no_media',
|
|
667
|
+
error: 'Diese Nachricht enthält keine Medien'
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
console.log('📥 Lade Media herunter:', messageType);
|
|
672
|
+
|
|
673
|
+
// Importiere downloadMediaMessage von Baileys
|
|
674
|
+
const { downloadMediaMessage } = await import('@whiskeysockets/baileys');
|
|
675
|
+
|
|
676
|
+
// Download Media Buffer
|
|
677
|
+
const buffer = await downloadMediaMessage(
|
|
678
|
+
this.raw,
|
|
679
|
+
'buffer',
|
|
680
|
+
{},
|
|
681
|
+
{
|
|
682
|
+
logger: this.client.socket.logger,
|
|
683
|
+
reuploadRequest: this.client.socket.updateMediaMessage
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
|
|
687
|
+
console.log('✅ Media heruntergeladen:', buffer.length, 'bytes');
|
|
688
|
+
|
|
689
|
+
// Media Info
|
|
690
|
+
const mediaMessage = this.raw.message[messageType];
|
|
691
|
+
const mediaInfo = {
|
|
692
|
+
type: messageType.replace('Message', ''),
|
|
693
|
+
mimetype: mediaMessage.mimetype || 'unknown',
|
|
694
|
+
fileSize: buffer.length,
|
|
695
|
+
fileName: mediaMessage.fileName || `media_${Date.now()}`,
|
|
696
|
+
caption: mediaMessage.caption || null
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// Optional: Speichern wenn savePath angegeben
|
|
700
|
+
if (options.savePath) {
|
|
701
|
+
const fs = await import('fs');
|
|
702
|
+
const path = await import('path');
|
|
703
|
+
|
|
704
|
+
const fileName = options.fileName || mediaInfo.fileName;
|
|
705
|
+
const fullPath = path.join(options.savePath, fileName);
|
|
706
|
+
|
|
707
|
+
await fs.promises.writeFile(fullPath, buffer);
|
|
708
|
+
console.log('💾 Media gespeichert:', fullPath);
|
|
709
|
+
|
|
710
|
+
return {
|
|
711
|
+
success: true,
|
|
712
|
+
buffer: buffer,
|
|
713
|
+
info: mediaInfo,
|
|
714
|
+
savedPath: fullPath
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
return {
|
|
719
|
+
success: true,
|
|
720
|
+
buffer: buffer,
|
|
721
|
+
info: mediaInfo
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
} catch (error) {
|
|
725
|
+
console.error('❌ Fehler beim Media-Download:', error);
|
|
726
|
+
|
|
727
|
+
return {
|
|
728
|
+
success: false,
|
|
729
|
+
reason: 'download_failed',
|
|
730
|
+
error: error.message
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
654
735
|
// ===== MENTION HELPERS =====
|
|
655
736
|
|
|
656
737
|
getMentions() {
|