mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
* auth strategies * default to no auth * rename base auth strategy * rename base strategy cont. * refactor auth strategy methods and LocalAuth * activate old session options even if is falsy value * move restartOnAuthFail to LegacyAuthStrategy option * add link to guide item * update example/shell * types
37 lines
824 B
JavaScript
37 lines
824 B
JavaScript
/**
|
|
* ==== wwebjs-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, LocalAuth } = require('./index');
|
|
|
|
const client = new Client({
|
|
puppeteer: { headless: false },
|
|
authStrategy: new LocalAuth()
|
|
});
|
|
|
|
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('wwebjs> ');
|
|
shell.context.client = client;
|
|
shell.on('exit', async () => {
|
|
await client.destroy();
|
|
});
|
|
});
|