mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 11:39:14 +00:00
27 lines
497 B
JavaScript
27 lines
497 B
JavaScript
const { Client } = require('./src')
|
|
|
|
const client = new Client({puppeteer: {headless: false}});
|
|
|
|
client.initialize();
|
|
|
|
client.on('qr', (qr) => {
|
|
console.log('QR RECEIVED', qr);
|
|
});
|
|
|
|
client.on('authenticated', () => {
|
|
console.log('AUTHENTICATED');
|
|
});
|
|
|
|
client.on('ready', () => {
|
|
console.log('READY');
|
|
});
|
|
|
|
client.on('message', (msg) => {
|
|
console.log('MESSAGE RECEIVED', msg);
|
|
|
|
if (!msg.id.fromMe && msg.body == 'ping') {
|
|
client.sendMessage(msg.from, 'pong');
|
|
}
|
|
})
|
|
|