wppconnect
wppconnect copied to clipboard
Loading Session Already Paired
Hello guys,
Already completed a robot in WPPConnect and it works.
The only problem is when I do some update on WPPConnect or from time to time the compared devices fall and need to scan or QRCode again. This without anyone disconnecting or deleting the device's pairing.
I create a .js file for each client, that is, each file creates a startCLIENTNAME(client). Temporary solution.
Tokens created and organized automatically by Wpp are correct in the masses, however, they do not load.
Here's my code:
const NOMESESSAO = 'stafocher';
wppconnect.create({
session: NOMESESSAO,
//Exportando QRCode de validação do whatsapp
catchQR: (base64Qr, asciiQR) => {
console.log(asciiQR); // Optional to log the QR in the terminal
var matches = base64Qr.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/),
response = {};
if (matches.length !== 3) {
return new Error('[MSG4] Erro de entrada de String.');
}
response.type = matches[1];
response.data = new Buffer.from(matches[2], 'base64');
var imageBuffer = response;
require('fs').writeFile(
'/home/hyperbytetec/public_html/hyperwhats/qrcode/' + NOMESESSAO + '_out.png',
imageBuffer['data'],
'binary',
function (err) {
if (err != null) {
console.log(err);
}
}
);
},
logQR: false, //Exibir QRCode no terminal? = true (sim) - false (não)
////////////////////////////////////////////
autoClose: false,
useChrome: false,
puppeteerOptions: { args: ['--no-sandbox'] },
statusFind: (statusSession, session) => {
console.log('[MSG5] WPPConnect iniciado com sucesso para ' + NOMESESSAO);
//Criando arquivo contendo o status da conexão do QRCode
if (statusSession == 'inChat'){
//fs.rm('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + NOMESESSAO + '_out.png', { recursive:true }, (err) => {});
const myConsole = new console.Console(fs.createWriteStream('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + element.NOMESESSAO + '_log_conect.txt'));
myConsole.log('Status da conexão: Conectado!'); //Salvando status da sessão no arquivo txt
}else{
const myConsole = new console.Console(fs.createWriteStream('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + element.NOMESESSAO + '_log_conect.txt'));
myConsole.log('Status da conexão: Aguardando você scannear o QRCode...'); //Salvando status da sessão no arquivo txt
}
console.log('Status Session: ', statusSession);
console.log('Session name: ', session);
},
multidevice: true,
folderNameToken: 'tokens',
devtools: false,
debug: false,
headless: true, //False abre no Chrome - True abre no console
//browserSessionToken: browserSessionToken,
})
.then(async (client) => start1a99(client)) //INICIANDO ROBÔ NO LUGAR DE START(CLIENTE)
.catch((error) => console.log(error));
See that the tokens were created correctly
How to inject the token created when creating the client without having to AGAIN Scan the QRCode?
See in the image that even with the token created properly, it keeps asking for the QRCode.
Thanks in advance guys for the help!
Can anyone help me?
In fact, I have same problem with you, it will be needed to scan QR code randomly...
Is there no way to reuse a previously paired session? The customer did nothing! Didn't even unplug the device.
I actually want instructions to load that token. I'm not getting.
More detailed information about loading token applied to the example should do the trick.
Somebody?
7 / 5 000 Somebody?
nobody?
what version of wppconnect you use?