@deathnaitsa/wa-api 2.0.3 → 2.0.4

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
@@ -16,20 +16,21 @@ Eine minimalistische, stabile WhatsApp Multi-Device API basierend auf Baileys mi
16
16
  - **Media Support** (Bilder, Videos, GIF-Playback)
17
17
  - **Sticker Support** (Bilder, GIFs, Videos → Sticker mit wa-sticker-formatter)
18
18
  - Media Download
19
+ - **Group Management** (Erstellen, Bearbeiten, Teilnehmer verwalten)
20
+ - **Advanced Messaging** (Audio, Document, Location, Contact, Reactions)
21
+ - **Contact Management** (Kontakte abrufen, Profilbilder, Status)
22
+ - **Presence & Typing** (Tipp-Indikatoren, Aufnahme-Status)
19
23
 
20
24
  ### 🚧 In Entwicklung
21
- - Group Management
22
- - Contact Handling
23
- - Message Reactions
24
- - Status/Story Features
25
- - Typing Indicators
26
-
27
- ### 📋 Geplant
28
- - Auto-Reconnect Optionen
29
25
  - Message Queue System
30
26
  - Rate Limiting
31
27
  - Webhook Support
32
28
 
29
+ ### 📋 Geplant
30
+ - Status/Story Features
31
+ - Broadcast Lists
32
+ - Auto-Reconnect Optionen
33
+
33
34
  ## ✨ Features
34
35
 
35
36
  - 🔄 **Multi-Session Support** - Unbegrenzt viele WhatsApp-Accounts parallel
@@ -47,8 +48,13 @@ Eine minimalistische, stabile WhatsApp Multi-Device API basierend auf Baileys mi
47
48
  npm install
48
49
  ```
49
50
 
51
+ **Unterstützt beide Formate:**
52
+ - ✅ **ES Modules** (import)
53
+ - ✅ **CommonJS** (require)
54
+
50
55
  ## 🚀 Quick Start
51
56
 
57
+ ### ES Modules (empfohlen)
52
58
  ```javascript
53
59
  import { startSession, onMessage, sendText } from '@deathnaitsa/wa-api';
54
60
 
@@ -63,6 +69,23 @@ onMessage(async (msg) => {
63
69
  });
64
70
  ```
65
71
 
72
+ ### CommonJS
73
+ ```javascript
74
+ const { startSession, onMessage, sendText } = require('@deathnaitsa/wa-api');
75
+
76
+ (async () => {
77
+ await startSession('bot');
78
+
79
+ onMessage(async (msg) => {
80
+ console.log(`📨 ${msg.from}: ${msg.message}`);
81
+
82
+ if (msg.message === '!ping') {
83
+ await sendText(msg.sessionId, msg.from, 'Pong! 🏓');
84
+ }
85
+ });
86
+ })();
87
+ ```
88
+
66
89
  ## 📖 API Dokumentation
67
90
 
68
91
  ### Verfügbare Funktionen
@@ -241,22 +264,194 @@ countReceivedMessage('bot1');
241
264
 
242
265
  #### ❌ Noch nicht implementiert
243
266
  ```javascript
244
- // Group Management
245
- // await client.createGroup(sessionId, subject, participants);
246
- // await client.leaveGroup(sessionId, groupJid);
247
- // await client.updateGroupSubject(sessionId, groupJid, subject);
248
-
249
- // Contact Management
250
- // await client.getContacts(sessionId);
251
- // await client.blockUser(sessionId, jid);
252
-
253
267
  // Status/Stories
254
268
  // await client.sendStory(sessionId, content);
255
- // await client.getStatus(sessionId, jid);
269
+
270
+ // Broadcast Lists
271
+ // await client.createBroadcastList(sessionId, name, recipients);
272
+ // await client.sendBroadcast(sessionId, broadcastListId, message);
256
273
 
257
274
  // Advanced Features
258
- // await client.sendReaction(sessionId, messageKey, emoji);
259
- // await client.sendPresenceUpdate(sessionId, type);
275
+ // await client.queueMessage(sessionId, to, message, priority);
276
+ // await client.setRateLimit(sessionId, messagesPerMinute);
277
+ ```
278
+
279
+ ## 🚀 Neue Features in v2.0
280
+
281
+ ### ✅ Group Management (Implementiert)
282
+ ```javascript
283
+ import {
284
+ createGroup,
285
+ getGroupMetadata,
286
+ updateGroupSubject,
287
+ updateGroupDescription,
288
+ addParticipants,
289
+ removeParticipants,
290
+ promoteParticipants,
291
+ demoteParticipants,
292
+ leaveGroup,
293
+ getGroupInviteCode,
294
+ acceptGroupInvite,
295
+ updateGroupSettings
296
+ } from '@deathnaitsa/wa-api';
297
+
298
+ // Gruppe erstellen
299
+ const group = await createGroup('bot1', 'Meine Gruppe', [
300
+ '4915123456789@s.whatsapp.net',
301
+ '4915987654321@s.whatsapp.net'
302
+ ]);
303
+
304
+ // Gruppen-Metadaten abrufen
305
+ const metadata = await getGroupMetadata('bot1', 'groupId@g.us');
306
+ console.log(metadata.subject, metadata.participants.length);
307
+
308
+ // Gruppennamen ändern
309
+ await updateGroupSubject('bot1', 'groupId@g.us', 'Neuer Name');
310
+
311
+ // Beschreibung ändern
312
+ await updateGroupDescription('bot1', 'groupId@g.us', 'Neue Beschreibung');
313
+
314
+ // Teilnehmer hinzufügen
315
+ await addParticipants('bot1', 'groupId@g.us', ['4915123456789@s.whatsapp.net']);
316
+
317
+ // Teilnehmer entfernen
318
+ await removeParticipants('bot1', 'groupId@g.us', ['4915123456789@s.whatsapp.net']);
319
+
320
+ // Zum Admin machen
321
+ await promoteParticipants('bot1', 'groupId@g.us', ['4915123456789@s.whatsapp.net']);
322
+
323
+ // Admin-Rechte entfernen
324
+ await demoteParticipants('bot1', 'groupId@g.us', ['4915123456789@s.whatsapp.net']);
325
+
326
+ // Gruppe verlassen
327
+ await leaveGroup('bot1', 'groupId@g.us');
328
+
329
+ // Einladungslink erhalten
330
+ const code = await getGroupInviteCode('bot1', 'groupId@g.us');
331
+ console.log(`https://chat.whatsapp.com/${code}`);
332
+
333
+ // Gruppe über Link beitreten
334
+ await acceptGroupInvite('bot1', 'inviteCode');
335
+
336
+ // Gruppen-Einstellungen (nur Admins können schreiben)
337
+ await updateGroupSettings('bot1', 'groupId@g.us', 'announcement');
338
+ // Alle können schreiben
339
+ await updateGroupSettings('bot1', 'groupId@g.us', 'not_announcement');
340
+ ```
341
+
342
+ ### ✅ Advanced Messaging (Implementiert)
343
+ ```javascript
344
+ import {
345
+ sendAudio,
346
+ sendDocument,
347
+ sendLocation,
348
+ sendContact,
349
+ sendReaction,
350
+ deleteMessage
351
+ } from '@deathnaitsa/wa-api';
352
+
353
+ // Audio senden (Voice Message)
354
+ await sendAudio('bot1', 'nummer@s.whatsapp.net', './audio.mp3', true);
355
+
356
+ // Audio senden (normaler Audio-File)
357
+ await sendAudio('bot1', 'nummer@s.whatsapp.net', './song.mp3', false);
358
+
359
+ // Dokument senden
360
+ await sendDocument('bot1', 'nummer@s.whatsapp.net',
361
+ './file.pdf',
362
+ 'Dokument.pdf',
363
+ 'application/pdf',
364
+ 'Hier ist das Dokument'
365
+ );
366
+
367
+ // Standort senden
368
+ await sendLocation('bot1', 'nummer@s.whatsapp.net', 52.520008, 13.404954, 'Berlin');
369
+
370
+ // Kontakt senden
371
+ await sendContact('bot1', 'nummer@s.whatsapp.net', [
372
+ {
373
+ displayName: 'Max Mustermann',
374
+ vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:Max Mustermann\nTEL:+4915123456789\nEND:VCARD'
375
+ }
376
+ ]);
377
+
378
+ // Reaktion senden
379
+ await sendReaction('bot1', 'chatId@s.whatsapp.net', 'messageId', '👍');
380
+
381
+ // Reaktion entfernen
382
+ await sendReaction('bot1', 'chatId@s.whatsapp.net', 'messageId', '');
383
+
384
+ // Nachricht löschen
385
+ await deleteMessage('bot1', messageKey);
386
+ ```
387
+
388
+ ### ✅ Contact Management (Implementiert)
389
+ ```javascript
390
+ import {
391
+ getProfilePicture,
392
+ getContact,
393
+ checkNumbersOnWhatsApp,
394
+ blockContact,
395
+ unblockContact,
396
+ getBusinessProfile,
397
+ getStatus
398
+ } from '@deathnaitsa/wa-api';
399
+
400
+ // Profilbild URL abrufen
401
+ const url = await getProfilePicture('bot1', '4915123456789@s.whatsapp.net');
402
+
403
+ // Kontaktinfo
404
+ const contact = await getContact('bot1', '4915123456789@s.whatsapp.net');
405
+
406
+ // Nummern auf WhatsApp prüfen
407
+ const results = await checkNumbersOnWhatsApp('bot1', ['4915123456789', '4915987654321']);
408
+
409
+ // Kontakt blockieren
410
+ await blockContact('bot1', '4915123456789@s.whatsapp.net');
411
+
412
+ // Kontakt entblocken
413
+ await unblockContact('bot1', '4915123456789@s.whatsapp.net');
414
+
415
+ // Business-Profil abrufen
416
+ const business = await getBusinessProfile('bot1', 'businessNumber@s.whatsapp.net');
417
+
418
+ // Status/About abrufen
419
+ const status = await getStatus('bot1', '4915123456789@s.whatsapp.net');
420
+ console.log(status?.status);
421
+ ```
422
+
423
+ ### ✅ Presence & Typing (Implementiert)
424
+ ```javascript
425
+ import {
426
+ sendTyping,
427
+ sendRecording,
428
+ updateProfileStatus,
429
+ updateProfileName,
430
+ setProfilePicture,
431
+ markChatRead
432
+ } from '@deathnaitsa/wa-api';
433
+
434
+ // Tipp-Indikator anzeigen
435
+ await sendTyping('bot1', 'chatId@s.whatsapp.net', true);
436
+ // Stoppen
437
+ await sendTyping('bot1', 'chatId@s.whatsapp.net', false);
438
+
439
+ // Aufnahme-Indikator anzeigen
440
+ await sendRecording('bot1', 'chatId@s.whatsapp.net', true);
441
+ // Stoppen
442
+ await sendRecording('bot1', 'chatId@s.whatsapp.net', false);
443
+
444
+ // Eigenen Status ändern
445
+ await updateProfileStatus('bot1', 'Verfügbar 🟢');
446
+
447
+ // Eigenen Namen ändern
448
+ await updateProfileName('bot1', 'Neuer Name');
449
+
450
+ // Profilbild setzen
451
+ await setProfilePicture('bot1', './profile.jpg');
452
+
453
+ // Chat als gelesen markieren
454
+ await markChatRead('bot1', 'chatId@s.whatsapp.net', [messageKey1, messageKey2]);
260
455
  ```
261
456
 
262
457
  ## 🎮 Bot-Beispiel
@@ -264,7 +459,12 @@ countReceivedMessage('bot1');
264
459
  Siehe `socket.js` für ein vollständiges Bot-Beispiel mit:
265
460
  - Chat-Assignment System (keine Doppel-Antworten bei mehreren Sessions)
266
461
  - Command-Lock System (keine Race-Conditions)
267
- - Deutsche Befehle (!ping, !stats, !gesamtstats, !neustart, etc.)
462
+ - Deutsche Befehle
463
+ - **Basis**: !ping, !info, !liste, !stats, !gesamtstats
464
+ - **Gruppen**: !gruppeninfo, !gruppenlink, !gruppenname, !gruppenbio, !hinzufügen, !entfernen, !promoten, !demoten
465
+ - **Nachrichten**: !ort, !reaktion, !tippen, !aufnehmen
466
+ - **Profil & Kontakt**: !profilbild, !status, !kontakt, !meinestatus
467
+ - **Session**: !neustart, !pause, !fortsetzen, !stopp, !löschen, !start, !zuweisen, !zuweisungen
268
468
  - Session-Control Commands
269
469
  - Latenz-Messung
270
470
 
@@ -368,28 +568,31 @@ wa_credentials/ # Session-Daten
368
568
  ## 🛠️ Bekannte Einschränkungen & Design-Entscheidungen
369
569
 
370
570
  ### Nicht implementiert (Stand: Dezember 2024)
371
- - ❌ Audio/Voice Messages
372
- - ❌ Document/PDF Upload
373
- - ❌ Group Management (Create/Leave/Update Groups)
374
- - ❌ Contact Management (Block/Unblock)
375
- - ❌ Status/Story Features
376
- - ❌ Message Reactions
377
- - ❌ Typing Indicators
378
- - ❌ Presence Updates (Online/Offline Status)
571
+ - ❌ Status/Story Features (Upload/View/Delete Stories)
572
+ - ❌ Broadcast Lists
379
573
  - ❌ Auto-Reconnect (bewusst einfach gehalten)
380
574
  - ❌ Message Queue/Rate Limiting
381
575
  - ❌ Webhook Support
576
+ - ❌ Poll Messages
577
+ - ❌ Chat Archive/Mute/Pin Features
578
+
579
+ ### Neu implementiert in v2.0 ✅
580
+ - ✅ Group Management (Complete)
581
+ - ✅ Advanced Messaging (Audio, Document, Location, Contact, Reactions)
582
+ - ✅ Contact Management (Profile Pictures, Status, Block/Unblock)
583
+ - ✅ Presence & Typing Indicators
584
+ - ✅ Profile Updates (Status, Name, Picture)
382
585
 
383
586
  ### Design-Philosophie
384
587
  - **Einfachheit über Features** - Lieber stabil als feature-reich
385
588
  - **Kein Auto-Reconnect** - Manuelles Management für mehr Kontrolle
386
- - **Minimale Dependencies** - Nur Baileys, Pino, QRCode-Terminal
589
+ - **Minimale Dependencies** - Nur Baileys, Pino, QRCode-Terminal, wa-sticker-formatter
387
590
  - **Event-Driven** - Keine Polling, nur Events
388
591
  - **Map-basiert** - Schnelle Session-Lookups
389
592
 
390
593
  ### Performance-Charakteristiken
391
594
  - ✅ Sehr schnelle Session-Switches
392
- - ✅ Geringer Memory-Footprint (~50MB pro Session)
595
+ - ✅ Geringer Memory-Footprint (~50-80MB pro Session)
393
596
  - ✅ Keine Blocking Operations
394
597
  - ⚠️ Kein Built-in Rate Limiting (muss selbst implementiert werden)
395
598