From c2067ff0b775d3969e3d2a060150a4bcf7af64e9 Mon Sep 17 00:00:00 2001 From: Adrien Nunes <adrien.nunes@ensiie.fr> Date: Sun, 19 Dec 2021 14:35:07 +0100 Subject: [PATCH] Fix while loop --- notobot.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/notobot.js b/notobot.js index ba20bff..4cfb181 100644 --- a/notobot.js +++ b/notobot.js @@ -226,20 +226,25 @@ async function start(){ console.log("username, password ou webhook est manquant dans conf.json"); process.exit(-1); } - try{ - while(true){ + while(true){ + try{ + const date = new Date(); + console.log(`[START] \t => \t ${date.toLocaleTimeString('fr')} : ${date.toLocaleDateString('fr')}`); + const execution = await getExecution(); await login(execution); await lookForGrades(); + }catch(e){ + if(e.response && e.response.statusCode === 401){ + console.error('[ERROR 401] -> Bad password / username ?'); + }else{ + console.error(e); + } + }finally{ await new Promise(resolve => setTimeout(resolve,1000*60*15)); //Attente de 15 min } - }catch(e){ - if(e.response && e.response.statusCode === 401){ - console.error('[ERROR 401] -> Bad password / username ?'); - }else{ - console.error(e); - } } + } start(); -- GitLab