mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
Get and send messages
This commit is contained in:
11
example.js
11
example.js
@@ -1,6 +1,6 @@
|
||||
const { Client } = require('./src')
|
||||
|
||||
const client = new Client();
|
||||
const client = new Client({puppeteer: {headless: false}});
|
||||
|
||||
client.initialize();
|
||||
|
||||
@@ -14,6 +14,13 @@ client.on('authenticated', () => {
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('READY');
|
||||
client.destroy();
|
||||
});
|
||||
|
||||
client.on('message', (msg) => {
|
||||
console.log('MESSAGE RECEIVED', msg);
|
||||
|
||||
if (!msg.id.fromMe && msg.body == 'ping') {
|
||||
client.sendMessage(msg.from, 'pong');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user