From 473af7cf4d139156e77e3b371e10c325dc05bd3c Mon Sep 17 00:00:00 2001 From: Andrea Date: Sat, 4 Jun 2022 12:42:18 +0200 Subject: [PATCH] [calendar] more resistant bot --- server/calendarBot.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/calendarBot.js b/server/calendarBot.js index 066e9bb4..f23c67f0 100644 --- a/server/calendarBot.js +++ b/server/calendarBot.js @@ -80,9 +80,14 @@ const timer = ms => new Promise( res => setTimeout(res, ms)); console.log('------------'); console.log(locales[locale].name); - const { day, message, image } = await (await fetch(locales[locale].url + '/api/calendar/today')).json(); - console.log('<<<', message, '>>>'); - if (!message) { continue; } + try { + const { day, message, image } = await (await fetch(locales[locale].url + '/api/calendar/today')).json(); + console.log('<<<', message, '>>>'); + if (!message) { continue; } + } catch (e) { + console.error(e); + continue; + } fs.writeFileSync(imageTmpPath, Buffer.from(await (await fetch(image)).arrayBuffer()), {encoding: 'binary'}); let imageStream = null;