mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Log out detection
This commit is contained in:
@@ -27,9 +27,13 @@ async function example() {
|
|||||||
fs.writeFileSync('./auth_info.json', JSON.stringify(authInfo, null, '\t')) // save this info to a file
|
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,
|
/* 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 */
|
and get full access to one's WhatsApp. Despite the convenience, be careful with this file */
|
||||||
client.setOnTakenOver (async () => {
|
client.setOnDisconnect (async kind => {
|
||||||
// uncomment to reconnect whenever the connection gets taken over from somewhere else
|
if (kind === 'replaced') {
|
||||||
// await client.connect ()
|
// 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.setOnPresenceUpdate(json => console.log(json.id + ' presence is ' + json.type))
|
||||||
client.setOnMessageStatusChange(json => {
|
client.setOnMessageStatusChange(json => {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import {
|
|||||||
import { generateMessageTag } from '../WAConnection/Utils'
|
import { generateMessageTag } from '../WAConnection/Utils'
|
||||||
|
|
||||||
export default class WhatsAppWebBase extends WAConnection {
|
export default class WhatsAppWebBase extends WAConnection {
|
||||||
/** Set the callback for when the connection is taken over somewhere else */
|
/** Set the callback for when the connection is taken over somewhere else or logged out */
|
||||||
setOnTakenOver(callback: (kind: 'replaced' | string | null) => void) {
|
setOnDisconnect(callback: (kind: 'replaced' | string | null) => void) {
|
||||||
this.registerCallback (['Cmd', 'type:disconnect'], json => {
|
this.registerCallback (['Cmd', 'type:disconnect'], json => {
|
||||||
this.log ('connection taken over elsewhere')
|
this.log ('connection taken over elsewhere')
|
||||||
this.close ()
|
this.close ()
|
||||||
|
|||||||
Reference in New Issue
Block a user