[calendar] more resistant bot

This commit is contained in:
Andrea 2022-06-04 12:42:18 +02:00
parent 64f24b73a7
commit 473af7cf4d
1 changed files with 8 additions and 3 deletions

View File

@ -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;