@deathnaitsa/wa-api 2.0.28 → 2.0.29

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
@@ -132,18 +132,27 @@ const { startSession, onMessage, sendText } = require('@deathnaitsa/wa-api');
132
132
  #### ✅ Session Management (Implementiert)
133
133
  ```javascript
134
134
  import {
135
- startSession, // Session starten
136
- stopSession, // Session stoppen
137
- restartSession, // Session neu starten
138
- client // Direct client access
135
+ startSession, // Session starten (mit QR-Code)
136
+ startSessionWithPairingCode,// Session mit Pairing Code starten
137
+ stopSession, // Session stoppen
138
+ restartSession, // Session neu starten
139
+ client // Direct client access
139
140
  } from '@deathnaitsa/wa-api';
140
141
 
141
- // Standard Session (JSON-Files)
142
+ // Standard Session mit QR-Code (JSON-Files)
142
143
  await startSession('bot1');
143
144
 
145
+ // Session mit Pairing Code (Alternative zu QR-Code)
146
+ const { code } = await startSessionWithPairingCode('bot1', '491234567890');
147
+ console.log('Gib diesen Code in WhatsApp ein:', code);
148
+ // Telefonnummer ohne +, z.B. "491234567890" statt "+49 123 456 7890"
149
+
144
150
  // Session mit SQLite Auth (empfohlen für Production!)
145
151
  await startSession('bot1', { sql: true });
146
152
 
153
+ // Pairing Code mit SQLite
154
+ await startSessionWithPairingCode('bot1', '491234567890', { sql: true });
155
+
147
156
  // Weitere Optionen
148
157
  await startSession('bot1', {
149
158
  sql: true, // ✅ SQLite statt JSON-Files
@@ -355,7 +364,13 @@ const buffer = await downloadMedia(message);
355
364
 
356
365
  #### ✅ Events (Implementiert)
357
366
  ```javascript
358
- import { onMessage, onConnected, onDisconnected, onQRUpdate } from '@deathnaitsa/wa-api';
367
+ import {
368
+ onMessage,
369
+ onConnected,
370
+ onDisconnected,
371
+ onQRUpdate,
372
+ onPairingCode
373
+ } from '@deathnaitsa/wa-api';
359
374
 
360
375
  onMessage((msg) => {
361
376
  // Neue Nachricht empfangen
@@ -369,7 +384,7 @@ onDisconnected(({ sessionId, reason }) => {
369
384
  console.log(`${sessionId} getrennt: ${reason}`);
370
385
  });
371
386
 
372
- // QR-Code Updates (✅ Neu!)
387
+ // QR-Code Updates
373
388
  onQRUpdate(({ sessionId, qr }) => {
374
389
  console.log(`📱 QR-Code für Session ${sessionId} generiert!`);
375
390
  console.log(`QR-String: ${qr}`);
@@ -381,6 +396,17 @@ onQRUpdate(({ sessionId, qr }) => {
381
396
  // 4. In Datenbank speichern
382
397
  });
383
398
 
399
+ // Pairing Code Updates (✅ Neu!)
400
+ onPairingCode(({ sessionId, phoneNumber, code }) => {
401
+ console.log(`🔐 Pairing Code für ${sessionId} (${phoneNumber}): ${code}`);
402
+
403
+ // Beispiele für die Verwendung:
404
+ // 1. Code an Frontend/User anzeigen
405
+ // 2. Per SMS/Email versenden
406
+ // 3. In Datenbank speichern
407
+ // 4. Per WebSocket an Client schicken
408
+ });
409
+
384
410
  // Weitere Events über Client:
385
411
  client.on('groups:update', ({ sessionId, updates }) => {});
386
412
  client.on('presence', ({ sessionId, id, presences }) => {});