waengine 1.0.8 → 1.0.10

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/src/message.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Message-Klasse mit deinen eigenen Funktionen
2
2
  import { getStorage } from "./storage.js";
3
+ import { StickerCreator } from "./sticker-creator.js";
3
4
 
4
5
  export class Message {
5
6
  constructor(client, data) {
@@ -39,7 +40,34 @@ export class Message {
39
40
 
40
41
  // ===== REPLY FUNCTIONS =====
41
42
 
42
- async reply(text, mentions = []) {
43
+ async reply(text, mentions = [], options = {}) {
44
+ // Hidetag Feature - DEINE COOLE API!
45
+ if (options.hidetag) {
46
+ if (!this.isGroup) {
47
+ throw new Error('Hidetag funktioniert nur in Gruppen');
48
+ }
49
+
50
+ let hiddenMentions = [];
51
+
52
+ if (options.hidetag === 'all') {
53
+ // Alle Gruppenmitglieder erwähnen (unsichtbar)
54
+ const groupMetadata = await this.client.get.GroupMetadata(this.from);
55
+ hiddenMentions = groupMetadata.participants.map(p => p.id);
56
+ } else if (options.hidetag === 'sender') {
57
+ // Nur den Sender erwähnen (unsichtbar)
58
+ hiddenMentions = [this.getSender()];
59
+ } else if (typeof options.hidetag === 'string' && options.hidetag.includes('@')) {
60
+ // Spezifische JID erwähnen (unsichtbar)
61
+ hiddenMentions = [options.hidetag];
62
+ }
63
+
64
+ return await this.client.socket.sendMessage(this.from, {
65
+ text: text,
66
+ mentions: [...mentions, ...hiddenMentions]
67
+ });
68
+ }
69
+
70
+ // Normale Reply
43
71
  if (mentions.length > 0) {
44
72
  return await this.client.socket.sendMessage(this.from, {
45
73
  text: text,
@@ -384,6 +412,86 @@ export class Message {
384
412
  return this.raw.key.participant || this.raw.key.remoteJid;
385
413
  }
386
414
 
415
+ // ===== STICKER CREATION SYSTEM =====
416
+
417
+ get create() {
418
+ return new StickerCreator(this);
419
+ }
420
+
421
+ // ===== VISUAL RECORDING SYSTEM =====
422
+
423
+ async startRecording() {
424
+ try {
425
+ await this.client.socket.sendPresenceUpdate('recording', this.from);
426
+ console.log('🎤 Recording indicator gestartet');
427
+ return true;
428
+ } catch (error) {
429
+ console.error('❌ Fehler beim Starten des Recording:', error);
430
+ return false;
431
+ }
432
+ }
433
+
434
+ async stopRecording() {
435
+ try {
436
+ await this.client.socket.sendPresenceUpdate('paused', this.from);
437
+ console.log('⏹️ Recording indicator gestoppt');
438
+ return true;
439
+ } catch (error) {
440
+ console.error('❌ Fehler beim Stoppen des Recording:', error);
441
+ return false;
442
+ }
443
+ }
444
+
445
+ async visualRecord(isRecording = true) {
446
+ try {
447
+ if (isRecording) {
448
+ await this.client.socket.sendPresenceUpdate('recording', this.from);
449
+ console.log('🎤 Recording indicator gestartet');
450
+ } else {
451
+ await this.client.socket.sendPresenceUpdate('paused', this.from);
452
+ console.log('⏹️ Recording indicator gestoppt');
453
+ }
454
+ } catch (error) {
455
+ console.error('❌ Fehler beim Recording Indicator:', error);
456
+ }
457
+ }
458
+
459
+ async recordAndSend(messageFunction, recordingDuration = 3000) {
460
+ try {
461
+ // Starte Recording
462
+ await this.visualRecord(true);
463
+
464
+ // Warte die angegebene Zeit
465
+ await new Promise(resolve => setTimeout(resolve, recordingDuration));
466
+
467
+ // Stoppe Recording
468
+ await this.visualRecord(false);
469
+
470
+ // Kurze Pause für Realismus
471
+ await new Promise(resolve => setTimeout(resolve, 300));
472
+
473
+ // Führe die Message-Funktion aus
474
+ return await messageFunction();
475
+
476
+ } catch (error) {
477
+ console.error('❌ Fehler beim recordAndSend:', error);
478
+ return await messageFunction();
479
+ }
480
+ }
481
+
482
+ async recordAndReply(text, recordingDuration = 3000, mentions = []) {
483
+ return await this.recordAndSend(
484
+ () => this.reply(text, mentions),
485
+ recordingDuration
486
+ );
487
+ }
488
+
489
+ async simulateRecording(duration = 3000) {
490
+ await this.visualRecord(true);
491
+ await new Promise(resolve => setTimeout(resolve, duration));
492
+ await this.visualRecord(false);
493
+ }
494
+
387
495
  // ===== STATISTICS SYSTEM =====
388
496
 
389
497
  get stats() {
@@ -0,0 +1,116 @@
1
+ // 🔌 WAEngine Plugin Manager - Auto-Plugin System
2
+ import { existsSync, mkdirSync } from 'fs';
3
+ import { join } from 'path';
4
+ import { pathToFileURL } from 'url';
5
+
6
+ export class PluginManager {
7
+ constructor(client) {
8
+ this.client = client;
9
+ this.plugins = new Map();
10
+ this.pluginsDir = './plugins';
11
+ this.availablePlugins = [
12
+ 'economy-system',
13
+ 'games-plugin',
14
+ 'music-plugin',
15
+ 'travel-plugin',
16
+ 'education-plugin',
17
+ 'moderation-plugin',
18
+ 'creative-plugin',
19
+ 'analytics-plugin'
20
+ ];
21
+
22
+ this.ensurePluginsDirectory();
23
+ }
24
+
25
+ ensurePluginsDirectory() {
26
+ if (!existsSync(this.pluginsDir)) {
27
+ mkdirSync(this.pluginsDir, { recursive: true });
28
+ console.log('📁 Plugins Ordner erstellt');
29
+ }
30
+ }
31
+
32
+ async load(pluginName) {
33
+ try {
34
+ console.log(`🔌 Lade Plugin: ${pluginName}`);
35
+
36
+ // Plugin importieren mit korrekter Windows file:// URL
37
+ const pluginPath = join(process.cwd(), this.pluginsDir, pluginName, 'index.js');
38
+
39
+ if (!existsSync(pluginPath)) {
40
+ console.log(`📝 Plugin ${pluginName} nicht gefunden - wird übersprungen`);
41
+ return null;
42
+ }
43
+
44
+ // Windows-kompatible file:// URL erstellen
45
+ const pluginUrl = pathToFileURL(pluginPath).href;
46
+ console.log(`📂 Plugin Pfad: ${pluginUrl}`);
47
+
48
+ const { default: PluginClass } = await import(pluginUrl);
49
+
50
+ // Plugin instanziieren
51
+ const plugin = new PluginClass(this.client);
52
+ this.plugins.set(pluginName, plugin);
53
+
54
+ // Commands registrieren
55
+ await this.registerPluginCommands(plugin);
56
+
57
+ console.log(`✅ Plugin geladen: ${pluginName} v${plugin.version}`);
58
+ return plugin;
59
+
60
+ } catch (error) {
61
+ console.error(`❌ Plugin Fehler: ${pluginName}`, error.message);
62
+ return null;
63
+ }
64
+ }
65
+
66
+ async loadAllPlugins() {
67
+ console.log('🚀 Lade alle verfügbaren Plugins...');
68
+
69
+ for (const pluginName of this.availablePlugins) {
70
+ await this.load(pluginName);
71
+ }
72
+
73
+ console.log(`✅ ${this.plugins.size} Plugins geladen`);
74
+ }
75
+
76
+ async registerPluginCommands(plugin) {
77
+ const commands = plugin.getCommands();
78
+
79
+ Object.entries(commands).forEach(([commandName, handler]) => {
80
+ this.client.addCommand(commandName, async (msg, args) => {
81
+ try {
82
+ // Plugin-Context zu Message hinzufügen
83
+ msg.plugin = this.getPluginContext();
84
+ await handler(msg, args);
85
+ } catch (error) {
86
+ console.error(`❌ Plugin Command Fehler: ${commandName}`, error);
87
+ await msg.reply(`❌ Plugin Fehler: ${error.message}`);
88
+ }
89
+ });
90
+ });
91
+ }
92
+
93
+ getPluginContext() {
94
+ const context = {};
95
+ this.plugins.forEach((plugin, name) => {
96
+ context[name.replace('-', '_')] = plugin;
97
+ });
98
+ return context;
99
+ }
100
+
101
+ get(pluginName) {
102
+ return this.plugins.get(pluginName);
103
+ }
104
+
105
+ list() {
106
+ return Array.from(this.plugins.keys());
107
+ }
108
+
109
+ getStats() {
110
+ return {
111
+ loaded: this.plugins.size,
112
+ available: this.availablePlugins.length,
113
+ plugins: this.list()
114
+ };
115
+ }
116
+ }
@@ -0,0 +1,105 @@
1
+ // 🔌 WAEngine Plugin Manager - Auto-Plugin System
2
+ import { existsSync, mkdirSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ export class PluginManager {
6
+ constructor(client) {
7
+ this.client = client;
8
+ this.plugins = new Map();
9
+ this.pluginsDir = './plugins';
10
+ this.availablePlugins = [
11
+ 'economy-system',
12
+ 'games-plugin'
13
+ ];
14
+
15
+ this.ensurePluginsDirectory();
16
+ }
17
+
18
+ ensurePluginsDirectory() {
19
+ if (!existsSync(this.pluginsDir)) {
20
+ mkdirSync(this.pluginsDir, { recursive: true });
21
+ console.log('📁 Plugins Ordner erstellt');
22
+ }
23
+ }
24
+
25
+ async load(pluginName) {
26
+ try {
27
+ console.log(`🔌 Lade Plugin: ${pluginName}`);
28
+
29
+ // Plugin importieren
30
+ const pluginPath = join(process.cwd(), this.pluginsDir, pluginName, 'index.js');
31
+
32
+ if (!existsSync(pluginPath)) {
33
+ console.log(`📝 Plugin ${pluginName} nicht gefunden - wird übersprungen`);
34
+ return null;
35
+ }
36
+
37
+ const { default: PluginClass } = await import(pluginPath);
38
+
39
+ // Plugin instanziieren
40
+ const plugin = new PluginClass(this.client);
41
+ this.plugins.set(pluginName, plugin);
42
+
43
+ // Commands registrieren
44
+ await this.registerPluginCommands(plugin);
45
+
46
+ console.log(`✅ Plugin geladen: ${pluginName} v${plugin.version}`);
47
+ return plugin;
48
+
49
+ } catch (error) {
50
+ console.error(`❌ Plugin Fehler: ${pluginName}`, error.message);
51
+ return null;
52
+ }
53
+ }
54
+
55
+ async loadAllPlugins() {
56
+ console.log('🚀 Lade alle verfügbaren Plugins...');
57
+
58
+ for (const pluginName of this.availablePlugins) {
59
+ await this.load(pluginName);
60
+ }
61
+
62
+ console.log(`✅ ${this.plugins.size} Plugins geladen`);
63
+ }
64
+
65
+ async registerPluginCommands(plugin) {
66
+ const commands = plugin.getCommands();
67
+
68
+ Object.entries(commands).forEach(([commandName, handler]) => {
69
+ this.client.addCommand(commandName, async (msg, args) => {
70
+ try {
71
+ // Plugin-Context zu Message hinzufügen
72
+ msg.plugin = this.getPluginContext();
73
+ await handler(msg, args);
74
+ } catch (error) {
75
+ console.error(`❌ Plugin Command Fehler: ${commandName}`, error);
76
+ await msg.reply(`❌ Plugin Fehler: ${error.message}`);
77
+ }
78
+ });
79
+ });
80
+ }
81
+
82
+ getPluginContext() {
83
+ const context = {};
84
+ this.plugins.forEach((plugin, name) => {
85
+ context[name.replace('-', '_')] = plugin;
86
+ });
87
+ return context;
88
+ }
89
+
90
+ get(pluginName) {
91
+ return this.plugins.get(pluginName);
92
+ }
93
+
94
+ list() {
95
+ return Array.from(this.plugins.keys());
96
+ }
97
+
98
+ getStats() {
99
+ return {
100
+ loaded: this.plugins.size,
101
+ available: this.availablePlugins.length,
102
+ plugins: this.list()
103
+ };
104
+ }
105
+ }