@deathnaitsa/wa-api 2.0.4 → 2.0.6
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 +429 -64
- package/dist/WhatsAppClient.cjs +1 -1
- package/dist/WhatsAppClient.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/publish.bat +105 -0
- package/socket.js +193 -0
package/publish.bat
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
chcp 65001 >nul
|
|
3
|
+
setlocal enabledelayedexpansion
|
|
4
|
+
|
|
5
|
+
echo.
|
|
6
|
+
echo ╔═══════════════════════════════════════════════════════════════╗
|
|
7
|
+
echo ║ 🚀 WhatsApp API Auto Deploy Script 🚀 ║
|
|
8
|
+
echo ╚═══════════════════════════════════════════════════════════════╝
|
|
9
|
+
echo.
|
|
10
|
+
|
|
11
|
+
:: Farben für die Ausgabe
|
|
12
|
+
set "GREEN=[92m"
|
|
13
|
+
set "RED=[91m"
|
|
14
|
+
set "YELLOW=[93m"
|
|
15
|
+
set "BLUE=[94m"
|
|
16
|
+
set "RESET=[0m"
|
|
17
|
+
|
|
18
|
+
:: Prüfe ob wir in einem UNC-Pfad sind und nutze WSL
|
|
19
|
+
echo %CD% | findstr /C:"\\wsl.localhost" >nul
|
|
20
|
+
if %errorlevel% equ 0 (
|
|
21
|
+
echo %YELLOW%📍 Detected WSL path, using WSL bash for execution...%RESET%
|
|
22
|
+
wsl bash -c "cd '/home/seblo/Nishi API/wa-api' && ./publish.sh"
|
|
23
|
+
pause
|
|
24
|
+
exit /b %errorlevel%
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
:: Ins Skript-Verzeichnis wechseln
|
|
28
|
+
cd /d "%~dp0"
|
|
29
|
+
|
|
30
|
+
:: Schritt 1: NPM Build
|
|
31
|
+
echo %BLUE%[1/5] 📦 Building project...%RESET%
|
|
32
|
+
call npm run build
|
|
33
|
+
if errorlevel 1 (
|
|
34
|
+
echo %RED%❌ Build failed! Please fix errors and try again.%RESET%
|
|
35
|
+
pause
|
|
36
|
+
exit /b 1
|
|
37
|
+
)
|
|
38
|
+
echo %GREEN%✅ Build successful!%RESET%
|
|
39
|
+
echo.
|
|
40
|
+
|
|
41
|
+
:: Schritt 2: Git Status prüfen
|
|
42
|
+
echo %BLUE%[2/5] 📋 Checking Git status...%RESET%
|
|
43
|
+
git status --short
|
|
44
|
+
echo.
|
|
45
|
+
|
|
46
|
+
:: Schritt 3: Commit Message eingeben
|
|
47
|
+
set /p "commit_msg=%YELLOW%💬 Enter commit message (or press Enter for default): %RESET%"
|
|
48
|
+
if "!commit_msg!"=="" (
|
|
49
|
+
set "commit_msg=Update wa-api with new features"
|
|
50
|
+
)
|
|
51
|
+
echo.
|
|
52
|
+
|
|
53
|
+
:: Schritt 4: Git Add, Commit, Push
|
|
54
|
+
echo %BLUE%[3/5] 📤 Committing and pushing to Git...%RESET%
|
|
55
|
+
git add .
|
|
56
|
+
git commit -m "!commit_msg!"
|
|
57
|
+
if errorlevel 1 (
|
|
58
|
+
echo %YELLOW%⚠️ Nothing to commit or commit failed%RESET%
|
|
59
|
+
) else (
|
|
60
|
+
echo %GREEN%✅ Committed successfully!%RESET%
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
git push
|
|
64
|
+
if errorlevel 1 (
|
|
65
|
+
echo %RED%❌ Git push failed!%RESET%
|
|
66
|
+
pause
|
|
67
|
+
exit /b 1
|
|
68
|
+
)
|
|
69
|
+
echo %GREEN%✅ Pushed to Git successfully!%RESET%
|
|
70
|
+
echo.
|
|
71
|
+
|
|
72
|
+
:: Schritt 5: NPM Publish (optional)
|
|
73
|
+
echo %BLUE%[4/5] 📢 NPM Publish%RESET%
|
|
74
|
+
set /p "do_publish=%YELLOW%Do you want to publish to NPM? (y/N): %RESET%"
|
|
75
|
+
if /i "!do_publish!"=="y" (
|
|
76
|
+
echo %BLUE%Publishing to NPM...%RESET%
|
|
77
|
+
npm publish --access public
|
|
78
|
+
if errorlevel 1 (
|
|
79
|
+
echo %RED%❌ NPM publish failed!%RESET%
|
|
80
|
+
echo %YELLOW%💡 Tip: Make sure you're logged in with 'npm login'%RESET%
|
|
81
|
+
pause
|
|
82
|
+
exit /b 1
|
|
83
|
+
)
|
|
84
|
+
echo %GREEN%✅ Published to NPM successfully!%RESET%
|
|
85
|
+
) else (
|
|
86
|
+
echo %YELLOW%⏭️ Skipping NPM publish%RESET%
|
|
87
|
+
)
|
|
88
|
+
echo.
|
|
89
|
+
|
|
90
|
+
:: Fertig
|
|
91
|
+
echo.
|
|
92
|
+
echo %GREEN%╔═══════════════════════════════════════════════════════════════╗%RESET%
|
|
93
|
+
echo %GREEN%║ ✨ Deployment Complete! ✨ ║%RESET%
|
|
94
|
+
echo %GREEN%╚═══════════════════════════════════════════════════════════════╝%RESET%
|
|
95
|
+
echo.
|
|
96
|
+
echo %BLUE%Summary:%RESET%
|
|
97
|
+
echo • Build: %GREEN%✓%RESET%
|
|
98
|
+
echo • Git Push: %GREEN%✓%RESET%
|
|
99
|
+
if /i "!do_publish!"=="y" (
|
|
100
|
+
echo • NPM Publish: %GREEN%✓%RESET%
|
|
101
|
+
) else (
|
|
102
|
+
echo • NPM Publish: %YELLOW%Skipped%RESET%
|
|
103
|
+
)
|
|
104
|
+
echo.
|
|
105
|
+
pause
|
package/socket.js
CHANGED
|
@@ -9,6 +9,17 @@ import {
|
|
|
9
9
|
sendReaction,
|
|
10
10
|
sendTyping,
|
|
11
11
|
sendRecording,
|
|
12
|
+
sendPoll,
|
|
13
|
+
uploadStatus,
|
|
14
|
+
sendBroadcast,
|
|
15
|
+
queueMessage,
|
|
16
|
+
getQueueStatus,
|
|
17
|
+
clearQueue,
|
|
18
|
+
pauseQueue,
|
|
19
|
+
resumeQueue,
|
|
20
|
+
setRateLimit,
|
|
21
|
+
setAutoReconnect,
|
|
22
|
+
getConnectionHealth,
|
|
12
23
|
createGroup,
|
|
13
24
|
getGroupMetadata,
|
|
14
25
|
updateGroupSubject,
|
|
@@ -116,6 +127,44 @@ console.log(' !ort <lat> <lon> - Standort senden');
|
|
|
116
127
|
console.log(' !reaktion <emoji> - Auf letzte Nachricht reagieren');
|
|
117
128
|
console.log(' !tippen - Tipp-Indikator anzeigen');
|
|
118
129
|
console.log(' !aufnehmen - Aufnahme-Indikator anzeigen');
|
|
130
|
+
console.log(' !umfrage <frage> - Umfrage erstellen');
|
|
131
|
+
console.log(' !broadcast <text> - Broadcast senden');
|
|
132
|
+
console.log('');
|
|
133
|
+
console.log(' 📱 Status & Queue:');
|
|
134
|
+
console.log(' !status <text> - Status hochladen');
|
|
135
|
+
console.log(' !queue <text> - Nachricht in Queue');
|
|
136
|
+
console.log(' !queuestatus - Queue Status anzeigen');
|
|
137
|
+
console.log(' !clearqueue - Queue leeren');
|
|
138
|
+
console.log(' !ratelimit <n> - Rate Limit setzen (n/min)');
|
|
139
|
+
console.log('');
|
|
140
|
+
console.log(' 👤 Profil & Kontakt:');
|
|
141
|
+
console.log(' !profilbild - Profilbild des Absenders');
|
|
142
|
+
console.log(' !status - Status des Absenders');
|
|
143
|
+
console.log(' !kontakt - Kontaktinfo');
|
|
144
|
+
console.log(' !meinestatus <t> - Eigenen Status ändern');
|
|
145
|
+
console.log('');
|
|
146
|
+
console.log(' 🔄 Verbindung:');
|
|
147
|
+
console.log(' !autoreconnect - Auto-Reconnect aktivieren');
|
|
148
|
+
console.log(' !health - Verbindungs-Status');
|
|
149
|
+
console.log('');
|
|
150
|
+
console.log(' ⚙️ Session:');
|
|
151
|
+
console.log(' !neustart <id> - Session neu starten');
|
|
152
|
+
console.log(' !pause <id> - Session pausieren');
|
|
153
|
+
console.log(' !fortsetzen <id> - Session fortsetzen');
|
|
154
|
+
console.log(' !stopp <id> - Session stoppen');
|
|
155
|
+
console.log(' !löschen <id> - Session-Daten löschen');
|
|
156
|
+
console.log(' !start <id> - Neue Session starten');
|
|
157
|
+
console.log(' !zuweisen <id> - Diesen Chat einer Session zuweisen');
|
|
158
|
+
console.log(' !zuweisungen - Alle Chat-Zuweisungen anzeigen\n');
|
|
159
|
+
console.log(' !entfernen <nr> - Teilnehmer entfernen');
|
|
160
|
+
console.log(' !promoten <nr> - Zum Admin machen');
|
|
161
|
+
console.log(' !demoten <nr> - Admin entfernen');
|
|
162
|
+
console.log('');
|
|
163
|
+
console.log(' 📧 Nachrichten:');
|
|
164
|
+
console.log(' !ort <lat> <lon> - Standort senden');
|
|
165
|
+
console.log(' !reaktion <emoji> - Auf letzte Nachricht reagieren');
|
|
166
|
+
console.log(' !tippen - Tipp-Indikator anzeigen');
|
|
167
|
+
console.log(' !aufnehmen - Aufnahme-Indikator anzeigen');
|
|
119
168
|
console.log('');
|
|
120
169
|
console.log(' 👤 Profil & Kontakt:');
|
|
121
170
|
console.log(' !profilbild - Profilbild des Absenders');
|
|
@@ -592,6 +641,150 @@ onMessage(async (msg) => {
|
|
|
592
641
|
}
|
|
593
642
|
break;
|
|
594
643
|
|
|
644
|
+
// ===========================================
|
|
645
|
+
// POLL, BROADCAST, QUEUE & STATUS COMMANDS
|
|
646
|
+
// ===========================================
|
|
647
|
+
|
|
648
|
+
case '!umfrage':
|
|
649
|
+
const pollQuestion = args.join(' ');
|
|
650
|
+
if (!pollQuestion || !pollQuestion.includes('|')) {
|
|
651
|
+
await safeSend('❌ Verwendung: !umfrage Frage|Option1|Option2|Option3\nBeispiel: !umfrage Pizza oder Pasta?|Pizza|Pasta');
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
try {
|
|
656
|
+
const [question, ...options] = pollQuestion.split('|').map(s => s.trim());
|
|
657
|
+
await sendPoll(msg.sessionId, msg.from, question, options);
|
|
658
|
+
await safeSend('✅ Umfrage gesendet!');
|
|
659
|
+
} catch (e) {
|
|
660
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
661
|
+
}
|
|
662
|
+
break;
|
|
663
|
+
|
|
664
|
+
case '!broadcast':
|
|
665
|
+
const broadcastText = args.join(' ');
|
|
666
|
+
if (!broadcastText) {
|
|
667
|
+
await safeSend('❌ Verwendung: !broadcast <Text>');
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
try {
|
|
672
|
+
// Example: broadcast to first 3 contacts (customize as needed)
|
|
673
|
+
const sessions = client.getAllSessions();
|
|
674
|
+
const recipients = ['491234567890@s.whatsapp.net']; // Add real numbers
|
|
675
|
+
|
|
676
|
+
await safeSend('📢 Sende Broadcast...');
|
|
677
|
+
const results = await sendBroadcast(msg.sessionId, recipients, { text: broadcastText });
|
|
678
|
+
|
|
679
|
+
const successful = results.filter(r => r.success).length;
|
|
680
|
+
await safeSend(`✅ Broadcast: ${successful}/${results.length} erfolgreich`);
|
|
681
|
+
} catch (e) {
|
|
682
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
683
|
+
}
|
|
684
|
+
break;
|
|
685
|
+
|
|
686
|
+
case '!status':
|
|
687
|
+
const statusText = args.join(' ');
|
|
688
|
+
if (!statusText) {
|
|
689
|
+
await safeSend('❌ Verwendung: !status <Text>');
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
try {
|
|
694
|
+
await uploadStatus(msg.sessionId, { text: statusText });
|
|
695
|
+
await safeSend('✅ Status hochgeladen!');
|
|
696
|
+
} catch (e) {
|
|
697
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
698
|
+
}
|
|
699
|
+
break;
|
|
700
|
+
|
|
701
|
+
case '!queue':
|
|
702
|
+
const queueText = args.join(' ');
|
|
703
|
+
if (!queueText) {
|
|
704
|
+
await safeSend('❌ Verwendung: !queue <Text>');
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
try {
|
|
709
|
+
queueMessage(msg.sessionId, msg.from, { text: queueText }, 0);
|
|
710
|
+
await safeSend('✅ Nachricht zur Queue hinzugefügt');
|
|
711
|
+
} catch (e) {
|
|
712
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
713
|
+
}
|
|
714
|
+
break;
|
|
715
|
+
|
|
716
|
+
case '!queuestatus':
|
|
717
|
+
try {
|
|
718
|
+
const queueStatus = getQueueStatus(msg.sessionId);
|
|
719
|
+
let queueInfo = `📊 *Queue Status*\n\n`;
|
|
720
|
+
queueInfo += `Warteschlange: ${queueStatus.queueLength} Nachrichten\n`;
|
|
721
|
+
|
|
722
|
+
if (queueStatus.rateLimit) {
|
|
723
|
+
queueInfo += `Rate Limit: ${queueStatus.rateLimit.count}/${queueStatus.rateLimit.limit}\n`;
|
|
724
|
+
queueInfo += `Reset in: ${Math.round(queueStatus.rateLimit.resetIn / 1000)}s\n`;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
await safeSend(queueInfo);
|
|
728
|
+
} catch (e) {
|
|
729
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
730
|
+
}
|
|
731
|
+
break;
|
|
732
|
+
|
|
733
|
+
case '!clearqueue':
|
|
734
|
+
try {
|
|
735
|
+
clearQueue(msg.sessionId);
|
|
736
|
+
await safeSend('✅ Queue geleert');
|
|
737
|
+
} catch (e) {
|
|
738
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
739
|
+
}
|
|
740
|
+
break;
|
|
741
|
+
|
|
742
|
+
case '!ratelimit':
|
|
743
|
+
const limit = parseInt(args[0]);
|
|
744
|
+
if (isNaN(limit) || limit < 1) {
|
|
745
|
+
await safeSend('❌ Verwendung: !ratelimit <Anzahl pro Minute>\nBeispiel: !ratelimit 30');
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
try {
|
|
750
|
+
setRateLimit(msg.sessionId, limit);
|
|
751
|
+
await safeSend(`✅ Rate Limit gesetzt: ${limit} Nachrichten/Minute`);
|
|
752
|
+
} catch (e) {
|
|
753
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
754
|
+
}
|
|
755
|
+
break;
|
|
756
|
+
|
|
757
|
+
// ===========================================
|
|
758
|
+
// CONNECTION HEALTH & AUTO-RECONNECT
|
|
759
|
+
// ===========================================
|
|
760
|
+
|
|
761
|
+
case '!autoreconnect':
|
|
762
|
+
try {
|
|
763
|
+
setAutoReconnect(msg.sessionId, true, 5, 2);
|
|
764
|
+
await safeSend('✅ Auto-Reconnect aktiviert\n- Max Retries: 5\n- Backoff: 2x');
|
|
765
|
+
} catch (e) {
|
|
766
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
767
|
+
}
|
|
768
|
+
break;
|
|
769
|
+
|
|
770
|
+
case '!health':
|
|
771
|
+
try {
|
|
772
|
+
const health = getConnectionHealth(msg.sessionId);
|
|
773
|
+
let healthInfo = `🏥 *Connection Health*\n\n`;
|
|
774
|
+
healthInfo += `Status: ${health.connected ? '🟢 Verbunden' : '🔴 Getrennt'}\n`;
|
|
775
|
+
healthInfo += `Uptime: ${Math.round(health.uptime / 1000)}s\n`;
|
|
776
|
+
healthInfo += `Auto-Reconnect: ${health.autoReconnect ? 'Aktiv' : 'Inaktiv'}\n`;
|
|
777
|
+
|
|
778
|
+
if (health.autoReconnect) {
|
|
779
|
+
healthInfo += `Retries: ${health.retryCount}/${health.maxRetries}\n`;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
await safeSend(healthInfo);
|
|
783
|
+
} catch (e) {
|
|
784
|
+
await safeSend(`❌ Fehler: ${e.message}`);
|
|
785
|
+
}
|
|
786
|
+
break;
|
|
787
|
+
|
|
595
788
|
// ===========================================
|
|
596
789
|
// SESSION MANAGEMENT COMMANDS
|
|
597
790
|
// ===========================================
|