@deathnaitsa/wa-api 2.0.2 → 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
@@ -13,21 +13,24 @@ Eine minimalistische, stabile WhatsApp Multi-Device API basierend auf Baileys mi
13
13
  - Statistik-System mit JSON-Persistenz
14
14
  - Message Parsing mit Mentions & Quoted Messages
15
15
  - Uptime & Performance Tracking
16
+ - **Media Support** (Bilder, Videos, GIF-Playback)
17
+ - **Sticker Support** (Bilder, GIFs, Videos → Sticker mit wa-sticker-formatter)
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)
16
23
 
17
24
  ### 🚧 In Entwicklung
18
- - Media Download/Upload
19
- - Group Management
20
- - Contact Handling
21
- - Message Reactions
22
- - Status/Story Features
23
- - Typing Indicators
24
-
25
- ### 📋 Geplant
26
- - Auto-Reconnect Optionen
27
25
  - Message Queue System
28
26
  - Rate Limiting
29
27
  - Webhook Support
30
28
 
29
+ ### 📋 Geplant
30
+ - Status/Story Features
31
+ - Broadcast Lists
32
+ - Auto-Reconnect Optionen
33
+
31
34
  ## ✨ Features
32
35
 
33
36
  - 🔄 **Multi-Session Support** - Unbegrenzt viele WhatsApp-Accounts parallel
@@ -45,8 +48,13 @@ Eine minimalistische, stabile WhatsApp Multi-Device API basierend auf Baileys mi
45
48
  npm install
46
49
  ```
47
50
 
51
+ **Unterstützt beide Formate:**
52
+ - ✅ **ES Modules** (import)
53
+ - ✅ **CommonJS** (require)
54
+
48
55
  ## 🚀 Quick Start
49
56
 
57
+ ### ES Modules (empfohlen)
50
58
  ```javascript
51
59
  import { startSession, onMessage, sendText } from '@deathnaitsa/wa-api';
52
60
 
@@ -61,6 +69,23 @@ onMessage(async (msg) => {
61
69
  });
62
70
  ```
63
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
+
64
89
  ## 📖 API Dokumentation
65
90
 
66
91
  ### Verfügbare Funktionen
@@ -99,17 +124,79 @@ onMessage((msg) => {
99
124
  });
100
125
  ```
101
126
 
102
- #### 🚧 Media (Teilweise implementiert)
127
+ #### Media & Stickers (Implementiert)
103
128
  ```javascript
104
- import { client } from '@deathnaitsa/wa-api';
129
+ import {
130
+ sendImage,
131
+ sendVideo,
132
+ sendSticker,
133
+ sendImageAsSticker,
134
+ sendGifAsSticker,
135
+ sendVideoAsSticker,
136
+ downloadMedia
137
+ } from '@deathnaitsa/wa-api';
138
+
139
+ // Bilder & Videos senden (✅ Implementiert)
140
+ await sendImage('bot1', '4915123456789@s.whatsapp.net', './photo.jpg', 'Caption');
141
+ await sendVideo('bot1', '4915123456789@s.whatsapp.net', './video.mp4', 'Caption');
142
+ await sendVideo('bot1', '4915123456789@s.whatsapp.net', './gif.mp4', '', true); // GIF-Playback
143
+
144
+ // Sticker senden (✅ Implementiert mit wa-sticker-formatter)
145
+ // Universell - funktioniert mit Bildern, GIFs und Videos
146
+ await sendSticker('bot1', '4915123456789@s.whatsapp.net', './image.png', {
147
+ packname: 'Mein Sticker Pack',
148
+ author: 'Bot Name',
149
+ type: 'default', // 'default', 'crop', 'full', 'circle'
150
+ quality: 100, // 1-100
151
+ categories: ['😂', '🎉']
152
+ });
153
+
154
+ // Spezialisierte Sticker-Funktionen
155
+ await sendImageAsSticker('bot1', 'nummer@s.whatsapp.net', './photo.jpg', {
156
+ packname: 'Foto Pack',
157
+ author: 'Bot',
158
+ type: 'circle' // Runder Sticker
159
+ });
160
+
161
+ await sendGifAsSticker('bot1', 'nummer@s.whatsapp.net', './animation.gif', {
162
+ packname: 'GIF Pack',
163
+ author: 'Bot'
164
+ });
165
+
166
+ await sendVideoAsSticker('bot1', 'nummer@s.whatsapp.net', './video.mp4', {
167
+ packname: 'Video Sticker',
168
+ author: 'Bot',
169
+ type: 'full' // Vollbild ohne Crop
170
+ });
171
+
172
+ // Mit Buffer
173
+ const fs = require('fs');
174
+ const buffer = fs.readFileSync('./sticker.png');
175
+ await sendSticker('bot1', 'nummer@s.whatsapp.net', buffer, {
176
+ packname: 'Buffer Pack',
177
+ author: 'Bot'
178
+ });
179
+
180
+ // Mit URL
181
+ await sendSticker('bot1', 'nummer@s.whatsapp.net', 'https://example.com/image.png', {
182
+ packname: 'Online Pack',
183
+ author: 'Bot'
184
+ });
105
185
 
106
186
  // Download Media (✅ Implementiert)
107
- const buffer = await client.downloadMedia(message);
187
+ const buffer = await downloadMedia(message);
188
+ ```
189
+
190
+ **Sticker-Optionen:**
191
+ - `packname` - Name des Sticker-Packs (Standard: 'Nishi API')
192
+ - `author` - Autor des Stickers (Standard: 'WhatsApp Bot')
193
+ - `type` - Sticker-Typ: `'default'`, `'crop'`, `'full'`, `'circle'`
194
+ - `quality` - Qualität: 1-100 (Standard: 100)
195
+ - `categories` - Array von Emoji-Kategorien z.B. `['😂', '🎉']`
108
196
 
109
- // Send Media (❌ Noch nicht implementiert)
110
- // await client.sendImage(sessionId, jid, buffer, caption);
111
- // await client.sendVideo(sessionId, jid, buffer, caption);
112
- // await client.sendAudio(sessionId, jid, buffer);
197
+ **Unterstützte Formate:**
198
+ - Bilder: PNG, JPG, JPEG, WEBP
199
+ - Animiert: GIF, MP4 (max. 10 Sekunden empfohlen)
113
200
  ```
114
201
 
115
202
  #### ✅ Events (Implementiert)
@@ -177,22 +264,194 @@ countReceivedMessage('bot1');
177
264
 
178
265
  #### ❌ Noch nicht implementiert
179
266
  ```javascript
180
- // Group Management
181
- // await client.createGroup(sessionId, subject, participants);
182
- // await client.leaveGroup(sessionId, groupJid);
183
- // await client.updateGroupSubject(sessionId, groupJid, subject);
184
-
185
- // Contact Management
186
- // await client.getContacts(sessionId);
187
- // await client.blockUser(sessionId, jid);
188
-
189
267
  // Status/Stories
190
268
  // await client.sendStory(sessionId, content);
191
- // await client.getStatus(sessionId, jid);
269
+
270
+ // Broadcast Lists
271
+ // await client.createBroadcastList(sessionId, name, recipients);
272
+ // await client.sendBroadcast(sessionId, broadcastListId, message);
192
273
 
193
274
  // Advanced Features
194
- // await client.sendReaction(sessionId, messageKey, emoji);
195
- // 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]);
196
455
  ```
197
456
 
198
457
  ## 🎮 Bot-Beispiel
@@ -200,7 +459,12 @@ countReceivedMessage('bot1');
200
459
  Siehe `socket.js` für ein vollständiges Bot-Beispiel mit:
201
460
  - Chat-Assignment System (keine Doppel-Antworten bei mehreren Sessions)
202
461
  - Command-Lock System (keine Race-Conditions)
203
- - 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
204
468
  - Session-Control Commands
205
469
  - Latenz-Messung
206
470
 
@@ -288,7 +552,8 @@ wa_credentials/ # Session-Daten
288
552
 
289
553
  ## 🔧 Technologie
290
554
 
291
- - **Baileys v6.7.9** - WhatsApp Multi-Device API
555
+ - **Baileys v7.0.0** - WhatsApp Multi-Device API
556
+ - **wa-sticker-formatter v4.4.4** - Sticker-Konvertierung
292
557
  - **Node.js v22+** - ES Modules
293
558
  - **Pino** - Logger (Silent Mode)
294
559
  - **QRCode-Terminal** - QR-Code Anzeige
@@ -302,28 +567,32 @@ wa_credentials/ # Session-Daten
302
567
 
303
568
  ## 🛠️ Bekannte Einschränkungen & Design-Entscheidungen
304
569
 
305
- ### Nicht implementiert (Stand: November 2024)
306
- - ❌ Media Upload (Send Image/Video/Audio)
307
- - ❌ Group Management (Create/Leave/Update Groups)
308
- - ❌ Contact Management (Block/Unblock)
309
- - ❌ Status/Story Features
310
- - ❌ Message Reactions
311
- - ❌ Typing Indicators
312
- - ❌ Presence Updates (Online/Offline Status)
570
+ ### Nicht implementiert (Stand: Dezember 2024)
571
+ - ❌ Status/Story Features (Upload/View/Delete Stories)
572
+ - ❌ Broadcast Lists
313
573
  - ❌ Auto-Reconnect (bewusst einfach gehalten)
314
574
  - ❌ Message Queue/Rate Limiting
315
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)
316
585
 
317
586
  ### Design-Philosophie
318
587
  - **Einfachheit über Features** - Lieber stabil als feature-reich
319
588
  - **Kein Auto-Reconnect** - Manuelles Management für mehr Kontrolle
320
- - **Minimale Dependencies** - Nur Baileys, Pino, QRCode-Terminal
589
+ - **Minimale Dependencies** - Nur Baileys, Pino, QRCode-Terminal, wa-sticker-formatter
321
590
  - **Event-Driven** - Keine Polling, nur Events
322
591
  - **Map-basiert** - Schnelle Session-Lookups
323
592
 
324
593
  ### Performance-Charakteristiken
325
594
  - ✅ Sehr schnelle Session-Switches
326
- - ✅ Geringer Memory-Footprint (~50MB pro Session)
595
+ - ✅ Geringer Memory-Footprint (~50-80MB pro Session)
327
596
  - ✅ Keine Blocking Operations
328
597
  - ⚠️ Kein Built-in Rate Limiting (muss selbst implementiert werden)
329
598