WAWEB-phi
WAWEB-phi is library for controlling whatsapp web for nodejs,
inspired from whatsapp-web.js and WAPI.js
What is the difference? This library uses wapi.js which contains features such as sending pictures, sending to numbers that are not in the contact list
and many more
Installation
NPM
npm install waweb-phi
YARN
yarn add waweb-phi
Usage
const wa = require('waweb-phi')
const client = new wa({
puppeteer: { headless: false }
});
client.initialize();
Example
const wa = require('waweb-phi')
const client = new wa({
puppeteer: { headless: false },
authTimeout: 30000,
});
client.initialize();
client.on('qr', (qr) => {
console.log('QR RECEIVED', qr);
});
client.on('authenticated', (session) => {
console.log('AUTHENTICATED', session);
});
client.on('auth_failure', msg => {
console.error('AUTHENTICATION FAILURE', msg);
})
client.on('ready', () => {
console.log('READY');
client.sendMessage("628950609xxxx@c.us", `test`).then((r) => {
console.log("sendMessage",r)
})
let base64file = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAA4CAQAAAAoPwI6AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAZUSURBVHjanNhpV1NnFwbg/OECIQwCgswgUpxAHKhDldYJh6poXfatZdW2UrVWWxUUrVIVB0DCEDik63o/5BiSEAi69gcWT85zn33uPe9IYDlHglX/BwWeyC+ByEYv5HtBoTuRjemwvtZrnUU2BhpskI7s74kUulIINsjzXUF4viFaNmaDYG2DFtIp/8n63xfJ/WktgGCVBQpLpJDFg090v09yxaCAQ358YTKUQMK8BYsrtAR5NQ4EFi1l/Z5My8rzS5Ysmhc36ZUxz0xKrKV56mpg0YJ5cxKWQu3+S0vSf5ICgUDCnCmvPfa7y04a9FRcMh/4vEnP3feb66664oprhtx0xz0PjXjsicdGPHTfH4b97AeXnHLEXjt1OGLIVIqWTE9ZNOu1vw0576i9durUoUOX3fb5ytf6nUhLv6MO2qfbdu0abVajXpcLHkmkwj+T7TkvDDmkTaVSxYoUKfKFLxQpFhVVKqZUqZiYUlEl6aeKlarV7QfPL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36oZB3znvnLNOO+kbRxzQrUuLupDrkjzlcJcfzWVwkNW3LJj23O+uGnDSN4454qADenXbYasWW1QrX0VIyhFrnEi3Qzl+Pu+9f9z1o3OO2W+3Tlu1ataoXm2a67KsnuajlKrR40YYoUE2+Lx/3XDcjowYjIqmQ6VkjZYo1S6VqLXHL17lFLrIskVv3DJgp0aVadiYmLKwFapQrjzUOlPvqDLVmvU4bdirjF4rBE94b1i/VlWqVNuiUZttuuzSrUevvXrt0WO37Tq1adGoIWwydvjKKUNGfchpLpYti0y5Z79Gm7WEj17yP7+6474Rj40ZM+aJUQ/cddN1V1xwzgVXDLnrmfcZ+SQbPvLKsLPO+t4v7nroqX9NeGvKB3Fxs6HEzZjyzoSXxr0w7qU3psxZXHM3EHnngT+Nem06/WCygKw9wOTQsighCIeQTxtrC0+rkXxz59onwToD7uppL/Jpk+X603awGjz37cEnrRnWm6s/e5lTeKOx4U1RsK4tPmuZ8zn7l+V8WfHTHDB3jM9/HinkgsFnL3OWCy1zNrr0y7+r+f8A+ZxMd2rKwo4AAAAASUVORK5CYII=`
client.sendAttach(base64file,'caption','namafile.png',"628950609xxxx@c.us").then((r) => {
console.log("sendMessage",r)
})
client.deviceInfo().then((r) => {
console.log("deviceInfo", r)
})
client.sendSeen('628950609xxxx@c.us').then((r) => {
console.log("sendSeen", r)
})
client.getBatteryLevel().then((r) => {
console.log("getBatteryLevel", r)
})
let number = "628950609xxxx@c.us"
client.checkNumberStatus(number).then((r) => {
console.log("NumberStatus", r)
})
});
client.on('message', async msg => {
console.log('MESSAGE RECEIVED', msg);
});
client.on('disconnected', () => {
console.log('Client was logged out');
})
Note
Update
- 19/02/2020 (v0.1.14) Add SendImageToID + fix SendImage + add sendSeen + add deviceInfo
- 27/01/2020 (v0.1.12 > v0.1.13) add authTimeout option + change default authTimeout value from 5000ms to 10000ms , for detail check example.js
- 17/01/2020 (v0.1.11) fix selector qr/qrvalue/keep phoneimage update
Todo
Legal
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk. Commercial use of this code/repo is strictly prohibited.
License
APACHE v2
made with 💗