@deathnaitsa/wa-api 2.0.29 → 2.1.1

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/README.md CHANGED
@@ -8,8 +8,7 @@ Eine minimalistische, stabile WhatsApp Multi-Device API basierend auf Baileys mi
8
8
  - [Features](#-features)
9
9
  - [Installation](#-installation)
10
10
  - [Quick Start](#-quick-start)
11
- - [ES Modules](#es-modules-empfohlen)
12
- - [CommonJS](#commonjs)
11
+ - [Configuration](#-configuration)
13
12
  - [API Dokumentation](#-api-dokumentation)
14
13
  - [Session Management](#-session-management-implementiert)
15
14
  - [Nachrichten](#-nachrichten-implementiert)
@@ -87,13 +86,46 @@ npm install
87
86
  npm install better-sqlite3
88
87
  ```
89
88
 
89
+ **Config-Datei erstellen (empfohlen)**
90
+ ```bash
91
+ node -e "import('@deathnaitsa/wa-api').then(m => m.initConfig())"
92
+ ```
93
+
94
+ Dies erstellt eine `wa-api.config.js` im Hauptverzeichnis mit allen verfügbaren Einstellungen.
95
+
90
96
  **Unterstützt beide Formate:**
91
97
  - ✅ **ES Modules** (import)
92
98
  - ✅ **CommonJS** (require)
93
99
 
94
100
  ## 🚀 Quick Start
95
101
 
96
- ### ES Modules (empfohlen)
102
+ ### 1. Config erstellen (optional, aber empfohlen)
103
+ ```javascript
104
+ import { initConfig } from '@deathnaitsa/wa-api';
105
+
106
+ // Erstellt wa-api.config.js im Hauptverzeichnis
107
+ initConfig();
108
+ ```
109
+
110
+ Dann in `wa-api.config.js` deine Einstellungen anpassen:
111
+ ```javascript
112
+ export const waApiConfig = {
113
+ session: {
114
+ useSqlByDefault: true, // SQLite als Standard
115
+ printQR: true,
116
+ autoReconnect: true,
117
+ },
118
+ footer: {
119
+ enabled: true, // Footer aktivieren
120
+ text: 'Powered by Nishi API 🚀',
121
+ },
122
+ // ... weitere Einstellungen
123
+ };
124
+ ```
125
+
126
+ ### 2. Session starten
127
+
128
+ #### ES Modules (empfohlen)
97
129
  ```javascript
98
130
  import { startSession, onMessage, sendText } from '@deathnaitsa/wa-api';
99
131
 
@@ -108,7 +140,7 @@ onMessage(async (msg) => {
108
140
  });
109
141
  ```
110
142
 
111
- ### CommonJS
143
+ #### CommonJS
112
144
  ```javascript
113
145
  const { startSession, onMessage, sendText } = require('@deathnaitsa/wa-api');
114
146
 
@@ -193,6 +225,114 @@ await startSession('main', {
193
225
  npm install better-sqlite3
194
226
  ```
195
227
 
228
+ ## ⚙️ Configuration
229
+
230
+ Die Nishi WhatsApp API kann über eine zentrale Config-Datei konfiguriert werden. Dies erspart dir, bei jedem `startSession()` Aufruf die gleichen Optionen anzugeben.
231
+
232
+ ### Config-Datei erstellen
233
+
234
+ ```javascript
235
+ import { initConfig } from '@deathnaitsa/wa-api';
236
+
237
+ initConfig(); // Erstellt wa-api.config.js im Hauptverzeichnis
238
+ ```
239
+
240
+ Oder über CLI:
241
+ ```bash
242
+ node -e "import('@deathnaitsa/wa-api').then(m => m.initConfig())"
243
+ ```
244
+
245
+ ### Verfügbare Config-Optionen
246
+
247
+ ```javascript
248
+ // wa-api.config.js
249
+ export const waApiConfig = {
250
+ // Session-Einstellungen
251
+ session: {
252
+ useSqlByDefault: true, // SQLite statt JSON-Files
253
+ browser: ['Chrome', '120.0.0', 'Windows'],
254
+ printQR: true,
255
+ credentialsDir: './sessions',
256
+ autoReconnect: true,
257
+ logLevel: 'silent', // 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'silent'
258
+ markOnlineOnConnect: false,
259
+ },
260
+
261
+ // Auto-Reconnect Einstellungen
262
+ reconnect: {
263
+ maxRetries: 5,
264
+ initialDelay: 2000,
265
+ maxDelay: 30000,
266
+ multiplier: 2,
267
+ },
268
+
269
+ // Footer/Wasserzeichen für Nachrichten ✨ NEU!
270
+ footer: {
271
+ enabled: true, // Footer aktivieren
272
+ text: 'Powered by Nishi API 🚀', // Footer-Text
273
+ applyToTypes: ['text', 'image', 'video', 'audio', 'document', 'sticker'], // Alle Typen!
274
+ onlyOutgoing: true,
275
+ },
276
+
277
+ // Rate Limiting
278
+ rateLimit: {
279
+ enabled: false,
280
+ maxMessages: 20,
281
+ interval: 60000,
282
+ queueInterval: 1000,
283
+ },
284
+
285
+ // Webhook, Stats, Media, Sticker, Features, Developer...
286
+ // Siehe wa-api.config.js für alle Optionen
287
+ };
288
+ ```
289
+
290
+ ### Config verwenden
291
+
292
+ **Mit Config-Datei:**
293
+ ```javascript
294
+ // wa-api.config.js: useSqlByDefault: true, autoReconnect: true
295
+
296
+ import { startSession } from '@deathnaitsa/wa-api';
297
+
298
+ // Verwendet automatisch SQLite und Auto-Reconnect aus Config
299
+ await startSession('bot1');
300
+ ```
301
+
302
+ **Config überschreiben:**
303
+ ```javascript
304
+ // Config sagt: useSqlByDefault: true
305
+ // Aber für diese Session wollen wir JSON-Files:
306
+ await startSession('bot1', { sql: false });
307
+ ```
308
+
309
+ ### Footer/Wasserzeichen Beispiel
310
+
311
+ ```javascript
312
+ // wa-api.config.js
313
+ footer: {
314
+ enabled: true,
315
+ text: '🤖 Powered by Nishi Bot',
316
+ applyToTypes: ['text'],
317
+ }
318
+ ```
319
+
320
+ Jetzt haben **alle** Text-Nachrichten automatisch einen Footer:
321
+ ```javascript
322
+ await sendText('bot1', jid, 'Hallo Welt!');
323
+ // Wird gesendet mit Footer "🤖 Powered by Nishi Bot"
324
+
325
+ // Funktioniert auch für Media:
326
+ await sendImage('bot1', jid, image, 'Schau mal!');
327
+ // Bild mit Caption + Footer
328
+
329
+ await sendVideo('bot1', jid, video, 'Cool!');
330
+ // Video mit Caption + Footer
331
+
332
+ await sendDocument('bot1', jid, doc);
333
+ // Dokument mit Footer
334
+ ```
335
+
196
336
  #### ✅ Nachrichten (Implementiert)
197
337
  ```javascript
198
338
  import { sendText, onMessage } from '@deathnaitsa/wa-api';