whatsapp-rpc 0.0.12 → 0.0.14
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 +45 -2
- package/configs/config.yaml +8 -1
- package/package.json +2 -1
- package/scripts/cli.js +34 -0
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ Connect via WebSocket to `ws://localhost:9400/ws/rpc` and send JSON-RPC 2.0 requ
|
|
|
106
106
|
| `status` | Get connection status (connected, has_session, running, pairing, device_id) |
|
|
107
107
|
| `start` | Start WhatsApp service |
|
|
108
108
|
| `stop` | Stop WhatsApp service |
|
|
109
|
-
| `restart` | Full reset: logout,
|
|
109
|
+
| `restart` | Full reset: logout, clear all caches, cleanup, start fresh |
|
|
110
110
|
| `reset` | Reset session (logout and delete credentials) |
|
|
111
111
|
| `diagnostics` | Get detailed diagnostics information |
|
|
112
112
|
| `qr` | Get QR code for pairing (code, image_data as base64 PNG) |
|
|
@@ -154,7 +154,7 @@ Connect via WebSocket to `ws://localhost:9400/ws/rpc` and send JSON-RPC 2.0 requ
|
|
|
154
154
|
| `newsletter_follow` | `jid` | Subscribe to a channel |
|
|
155
155
|
| `newsletter_unfollow` | `jid` | Unsubscribe from a channel |
|
|
156
156
|
| `newsletter_mute` | `jid`, `mute` | Mute/unmute a channel |
|
|
157
|
-
| `newsletter_messages` | `jid`, `count`, `before` | Get channel messages |
|
|
157
|
+
| `newsletter_messages` | `jid`, `count`, `offset`, `before`, `since`, `until`, `media_type`, `search`, `refresh` | Get channel messages (lazy cached, filterable) |
|
|
158
158
|
| `newsletter_send` | `group_id`, `type`, `message`/`media_data` | Send to channel (admin only) |
|
|
159
159
|
| `newsletter_mark_viewed` | `jid`, `server_ids[]` | Mark messages as viewed |
|
|
160
160
|
| `newsletter_react` | `jid`, `server_id`, `reaction` | React to a channel message |
|
|
@@ -461,6 +461,48 @@ asyncio.run(main())
|
|
|
461
461
|
|
|
462
462
|
See [src/python/README.md](src/python/README.md) for full Python client documentation.
|
|
463
463
|
|
|
464
|
+
## Android Integration
|
|
465
|
+
|
|
466
|
+
Cross-compile the server for Android and embed it in your app:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
# Build for all platforms including Android
|
|
470
|
+
npm run build-cross
|
|
471
|
+
|
|
472
|
+
# Or manually:
|
|
473
|
+
# arm64 real device
|
|
474
|
+
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -ldflags="-s -w" -o libwhatsapp-rpc.so ./src/go/cmd/server
|
|
475
|
+
|
|
476
|
+
# x86_64 emulator (use GOOS=linux, not android)
|
|
477
|
+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o libwhatsapp-rpc-x86_64.so ./src/go/cmd/server
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
Place binaries in your Android project:
|
|
481
|
+
```
|
|
482
|
+
app/android/app/src/main/jniLibs/
|
|
483
|
+
arm64-v8a/libwhatsapp-rpc.so
|
|
484
|
+
x86_64/libwhatsapp-rpc-x86_64.so
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Required Gradle config (`build.gradle.kts`):
|
|
488
|
+
```kotlin
|
|
489
|
+
android {
|
|
490
|
+
packaging { jniLibs { useLegacyPackaging = true } }
|
|
491
|
+
defaultConfig { ndk { abiFilters += listOf("x86_64", "arm64-v8a") } }
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
Launch from Kotlin:
|
|
496
|
+
```kotlin
|
|
497
|
+
val binary = File(applicationInfo.nativeLibraryDir, "libwhatsapp-rpc.so")
|
|
498
|
+
val pb = ProcessBuilder(binary.absolutePath)
|
|
499
|
+
pb.environment()["SSL_CERT_DIR"] = "/system/etc/security/cacerts"
|
|
500
|
+
pb.environment()["WHATSAPP_RPC_ANDROID"] = "1" // enables Android DNS resolver
|
|
501
|
+
pb.start()
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
Then connect via WebSocket at `ws://127.0.0.1:9400/ws/rpc`.
|
|
505
|
+
|
|
464
506
|
## Requirements
|
|
465
507
|
|
|
466
508
|
- Node.js 18+
|
|
@@ -468,6 +510,7 @@ See [src/python/README.md](src/python/README.md) for full Python client document
|
|
|
468
510
|
- Linux (amd64, arm64)
|
|
469
511
|
- macOS (amd64, arm64)
|
|
470
512
|
- Windows (amd64)
|
|
513
|
+
- Android (arm64, x86_64)
|
|
471
514
|
|
|
472
515
|
## License
|
|
473
516
|
|
package/configs/config.yaml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whatsapp-rpc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "WhatsApp WebSocket RPC Server with JSON-RPC 2.0 protocol",
|
|
6
6
|
"author": "Rohit G <trohitg@gmail.com>",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"web": "node scripts/cli.js web",
|
|
47
47
|
"prebuild": "node -e \"require('fs').existsSync('node_modules') || process.exit(1)\" || npm install",
|
|
48
48
|
"build": "node scripts/cli.js build",
|
|
49
|
+
"build-cross": "node scripts/cli.js build-cross",
|
|
49
50
|
"preclean": "node -e \"require('fs').existsSync('node_modules') || process.exit(1)\" || npm install",
|
|
50
51
|
"clean": "node scripts/cli.js clean"
|
|
51
52
|
},
|
package/scripts/cli.js
CHANGED
|
@@ -162,6 +162,39 @@ async function clean(opts = {}) {
|
|
|
162
162
|
log('Clean complete', 'green');
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
const CROSS_TARGETS = [
|
|
166
|
+
{ goos: 'linux', goarch: 'amd64', output: 'whatsapp-rpc-server-linux-amd64' },
|
|
167
|
+
{ goos: 'linux', goarch: 'arm64', output: 'whatsapp-rpc-server-linux-arm64' },
|
|
168
|
+
{ goos: 'darwin', goarch: 'amd64', output: 'whatsapp-rpc-server-darwin-amd64' },
|
|
169
|
+
{ goos: 'darwin', goarch: 'arm64', output: 'whatsapp-rpc-server-darwin-arm64' },
|
|
170
|
+
{ goos: 'windows', goarch: 'amd64', output: 'whatsapp-rpc-server-windows-amd64.exe' },
|
|
171
|
+
{ goos: 'android', goarch: 'arm64', output: 'libwhatsapp-rpc-android-arm64.so' },
|
|
172
|
+
{ goos: 'linux', goarch: 'amd64', output: 'libwhatsapp-rpc-android-x86_64.so', label: 'android-x86_64' },
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
async function buildCross() {
|
|
176
|
+
if (!hasGo()) {
|
|
177
|
+
log('Go is not installed. Install from: https://go.dev/dl/', 'red');
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
if (!existsSync(BIN_DIR)) {
|
|
181
|
+
mkdirSync(BIN_DIR, { recursive: true });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (const target of CROSS_TARGETS) {
|
|
185
|
+
const label = target.label || `${target.goos}/${target.goarch}`;
|
|
186
|
+
const out = join(BIN_DIR, target.output);
|
|
187
|
+
log(`Building ${label} -> ${target.output}`, 'blue');
|
|
188
|
+
await execa('go', ['build', '-ldflags=-s -w', '-o', out, './src/go/cmd/server'], {
|
|
189
|
+
cwd: ROOT,
|
|
190
|
+
stdio: 'inherit',
|
|
191
|
+
env: { ...process.env, GOOS: target.goos, GOARCH: target.goarch, CGO_ENABLED: '0' },
|
|
192
|
+
});
|
|
193
|
+
log(` ${target.output} (${(statSync(out).size / 1024 / 1024).toFixed(1)}MB)`, 'green');
|
|
194
|
+
}
|
|
195
|
+
log(`All ${CROSS_TARGETS.length} binaries built`, 'green');
|
|
196
|
+
}
|
|
197
|
+
|
|
165
198
|
// Global port option for all commands
|
|
166
199
|
const portOption = ['-p, --port <port>', 'API port (default: 9400, or PORT/WHATSAPP_RPC_PORT env var)'];
|
|
167
200
|
|
|
@@ -172,5 +205,6 @@ program.command('restart').description('Restart API server').option(...portOptio
|
|
|
172
205
|
program.command('status').description('Show server status').option(...portOption).action(status);
|
|
173
206
|
program.command('api').description('Start API server').option('-f, --foreground', 'Run in foreground').option(...portOption).action(api);
|
|
174
207
|
program.command('build').description('Build binary from source (requires Go)').action(build);
|
|
208
|
+
program.command('build-cross').description('Cross-compile binaries for all platforms (desktop + Android)').action(buildCross);
|
|
175
209
|
program.command('clean').description('Full cleanup (stop server, remove bin/, data/, node_modules/)').action(clean);
|
|
176
210
|
program.parse();
|