Skip to content

Commit

Permalink
Check for auth before executing
Browse files Browse the repository at this point in the history
  • Loading branch information
renandecarlo committed Jul 8, 2022
1 parent 61ab06b commit 5e4dbd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/geraldo-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const config = {
message: process.env.MENSAGEM || 'Olá parceiro, você tem um novo pedido (#%pedido_n%) esperando há *%tempo_esperando% minutos*! 🚀'
};

/* Check if user is signed in */
if(!module.parent || !module.parent.signedin) {
console.log(chalk.bgRedBright('-> Não foi possível verificar a assinatura'));
process.exit();
}

(async () => {
/* Set up browser */
const chromePath = ChromeLauncher.Launcher.getInstallations()[0];
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const readline = require('readline');

(async () => {
if(await auth.signin()) {
module.signedin = true;

require('./whatsapp-bot');
require('./geraldo-listener');
}
Expand Down
6 changes: 6 additions & 0 deletions src/whatsapp-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const config = {
sendToEveryone: process.env.ENVIA_MSG_TODOS_NUMEROS == '1' ? true : false,
};

/* Check if user is signed in */
if(!module.parent || !module.parent.signedin) {
console.log(chalk.bgRedBright('-> Não foi possível verificar a assinatura'));
process.exit();
}

/* Start venom browser */
venom
.create('geraldo-bot', false, handleSession, { headless: config.headless, multidevice: true, autoClose: false })
Expand Down

0 comments on commit 5e4dbd7

Please sign in to comment.