-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
shell.js
37 lines (30 loc) · 811 Bytes
/
shell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* ==== WAJS-shell ====
* Used for quickly testing library features
*
* Running `npm run shell` will start WhatsApp Web with headless=false
* and then drop you into Node REPL with `client` in its context.
*/
const repl = require('repl');
const { Client } = require('./index');
const client = new Client({
sessionName: 'hisoka',
playwright: {
headless: false
}
});
console.log('Initializing...');
client.initialize();
client.on('qr', () => {
console.log('Please scan the QR code on the browser.');
});
client.on('authenticated', (session) => {
console.log(JSON.stringify(session));
});
client.on('ready', () => {
const shell = repl.start('wajs>');
shell.context.client = client;
shell.on('exit', async () => {
await client.destroy();
});
});