Advertisement
agunq

wa-js

Jun 30th, 2021 (edited)
2,781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Client } = require('whatsapp-web.js');
  2. var qrcode = require('qrcode-terminal');
  3.  
  4. const client = new Client();
  5.  
  6. client.on('authenticated', (session) => {
  7.     console.log('AUTHENTICATED', session);
  8. });
  9.  
  10.  
  11. client.on('qr', (qr) => {
  12.         // Generate and scan this code with your phone
  13.         console.log('QR RECEIVED', qr);
  14.  
  15.     qrcode.generate(qr, {small: true}, function (qrcode) {
  16.             console.log(qrcode)
  17.     });
  18.  
  19. });
  20.  
  21. client.on('ready', () => {
  22.     console.log('Client is ready!');
  23. });
  24.  
  25. client.on('message', msg => {
  26.         if (msg.body == '!ping') {
  27.             msg.reply('pong');
  28.         }
  29.  
  30.     if (msg.body == "selamat pagi") {
  31.         client.sendMessage(msg.from, 'selamat pagi juga');
  32.     }
  33.  
  34. });
  35.  
  36. client.initialize();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement