Log out detection

This commit is contained in:
Adhiraj
2020-07-13 14:42:37 +05:30
parent 8eca142186
commit 8b859b9376
2 changed files with 9 additions and 5 deletions

View File

@@ -27,9 +27,13 @@ async function example() {
fs.writeFileSync('./auth_info.json', JSON.stringify(authInfo, null, '\t')) // save this info to a file
/* Note: one can take this auth_info.json file and login again from any computer without having to scan the QR code,
and get full access to one's WhatsApp. Despite the convenience, be careful with this file */
client.setOnTakenOver (async () => {
// uncomment to reconnect whenever the connection gets taken over from somewhere else
// await client.connect ()
client.setOnDisconnect (async kind => {
if (kind === 'replaced') {
// uncomment to reconnect whenever the connection gets taken over from somewhere else
// await client.connect ()
} else {
console.log ('oh no got logged out!')
}
})
client.setOnPresenceUpdate(json => console.log(json.id + ' presence is ' + json.type))
client.setOnMessageStatusChange(json => {