add bot fail exception

This commit is contained in:
SeungJu Lim 2024-02-20 23:30:41 +09:00
parent 59a234ab71
commit 3ff1ddf972
2 changed files with 11 additions and 5 deletions

View File

@ -16,12 +16,18 @@ const bot = new TelegramBot(BOT_TOKEN, { polling: true });
const __INFO__ = async (str) => {
const prefix = '[INFO]'
await bot.sendMessage(BOT_CHATID, `${prefix} ${str}`);
try{
await bot.sendMessage(BOT_CHATID, `${prefix} ${str}`);
}catch(err){
}
console.log(`${prefix} ${str}`);
}
const __ERROR__ = async (str) => {
const prefix = '[ERROR]'
await bot.sendMessage(BOT_CHATID, `${prefix} ${str}`);
try{
await bot.sendMessage(BOT_CHATID, `${prefix} ${str}`);
}catch(err){
}
console.error(`${prefix} ${str}`);
}
@ -176,7 +182,7 @@ class cgvGetter {
await __ERROR__(`사유: 스케줄 추출 작업 에러 / 현재시간: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
return -1
}
// 예외(실험적) - 응답 데이터 구조 확인
if (!result.hasOwnProperty('d')) throw new Error(`\t> Response lacks the expected "d" property`);
const gScheduleList = JSON.parse(result.d);
@ -501,7 +507,7 @@ await (async () => {
/*====== Dev Mode ======*/
case 1:
const result = await CGV.main_dev('20035290', null, moment('2024-03-09', 'YYYY-MM-DD')); // '20035290', null, moment('2024-03-09', 'YYYY-MM-DD' //// '20035479', null, moment('2024-02-16', 'YYYY-MM-DD'
const result = await CGV.main_dev('20035290', null, moment('2024-03-16', 'YYYY-MM-DD')); // '20035290', null, moment('2024-03-09', 'YYYY-MM-DD' //// '20035479', null, moment('2024-02-16', 'YYYY-MM-DD'
if (result === -1) await __ERROR__('예매에 실패했습니다!');
else if (result === 1) await __INFO__(`예매에 성공했습니다!`);
break

View File

@ -2,7 +2,7 @@
"name": "cgv_auto_reserve",
"version": "1.0.0",
"description": "",
"main": "app.js",
"main": "cgvAjax.js",
"scripts": {
"loop": "node ./cgvAjax.js 0",
"dev": "node ./cgvAjax.js 1",