优化jd_bean_sign.js,JD_DailyBonus.js 文件下载异常时直接停止运行,并且发送推送通知提醒用户(只发送一次)
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
活动入口:各处的签到汇总
|
活动入口:各处的签到汇总
|
||||||
Node.JS专用
|
Node.JS专用
|
||||||
IOS软件用户请使用 https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js
|
IOS软件用户请使用 https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js
|
||||||
更新时间:2021-3-20
|
更新时间:2021-3-27
|
||||||
推送通知默认简洁模式(多账号只发送一次)。如需详细通知,设置环境变量 JD_BEAN_SIGN_NOTIFY_SIMPLE 为false即可(N账号推送N次通知)。
|
推送通知默认简洁模式(多账号只发送一次)。如需详细通知,设置环境变量 JD_BEAN_SIGN_NOTIFY_SIMPLE 为false即可(N账号推送N次通知)。
|
||||||
Modified From github https://github.com/ruicky/jd_sign_bot
|
Modified From github https://github.com/ruicky/jd_sign_bot
|
||||||
*/
|
*/
|
||||||
@@ -38,6 +38,11 @@ if ($.isNode()) {
|
|||||||
await requireConfig();
|
await requireConfig();
|
||||||
// 下载最新代码
|
// 下载最新代码
|
||||||
await downFile();
|
await downFile();
|
||||||
|
if (!await fs.existsSync(JD_DailyBonusPath)) {
|
||||||
|
console.log(`\nJD_DailyBonus.js 文件不存在,停止执行${$.name}\n`);
|
||||||
|
await notify.sendNotify($.name, `本次执行${$.name}失败,JD_DailyBonus.js 文件下载异常,详情请查看日志`)
|
||||||
|
return
|
||||||
|
}
|
||||||
const content = await fs.readFileSync(JD_DailyBonusPath, 'utf8')
|
const content = await fs.readFileSync(JD_DailyBonusPath, 'utf8')
|
||||||
for (let i =0; i < cookiesArr.length; i++) {
|
for (let i =0; i < cookiesArr.length; i++) {
|
||||||
cookie = cookiesArr[i];
|
cookie = cookiesArr[i];
|
||||||
@@ -69,7 +74,6 @@ async function execSign() {
|
|||||||
// console.log('没有提供通知推送,则打印脚本执行日志')
|
// console.log('没有提供通知推送,则打印脚本执行日志')
|
||||||
// await exec(`${process.execPath} ${JD_DailyBonusPath}`, { stdio: "inherit" });
|
// await exec(`${process.execPath} ${JD_DailyBonusPath}`, { stdio: "inherit" });
|
||||||
// }
|
// }
|
||||||
if (await fs.existsSync(JD_DailyBonusPath)) {
|
|
||||||
await exec(`${process.execPath} ${JD_DailyBonusPath} >> ${resultPath}`);
|
await exec(`${process.execPath} ${JD_DailyBonusPath} >> ${resultPath}`);
|
||||||
const notifyContent = await fs.readFileSync(resultPath, "utf8");
|
const notifyContent = await fs.readFileSync(resultPath, "utf8");
|
||||||
console.log(`👇👇👇👇👇👇👇👇👇👇👇LOG记录👇👇👇👇👇👇👇👇👇👇👇\n${notifyContent}\n👆👆👆👆👆👆👆👆👆LOG记录👆👆👆👆👆👆👆👆👆👆👆`);
|
console.log(`👇👇👇👇👇👇👇👇👇👇👇LOG记录👇👇👇👇👇👇👇👇👇👇👇\n${notifyContent}\n👆👆👆👆👆👆👆👆👆LOG记录👆👆👆👆👆👆👆👆👆👆👆`);
|
||||||
@@ -106,9 +110,6 @@ async function execSign() {
|
|||||||
//运行完成后,删除下载的文件
|
//运行完成后,删除下载的文件
|
||||||
await deleteFile(resultPath);//删除result.txt
|
await deleteFile(resultPath);//删除result.txt
|
||||||
console.log(`\n\n*****************京东账号${$.index} ${$.nickName || $.UserName}京豆签到完成*******************\n\n`);
|
console.log(`\n\n*****************京东账号${$.index} ${$.nickName || $.UserName}京豆签到完成*******************\n\n`);
|
||||||
} else {
|
|
||||||
console.log(`\nJD_DailyBonus.js文件不存在\n`)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("京东签到脚本执行异常:" + e);
|
console.log("京东签到脚本执行异常:" + e);
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ async function downFile () {
|
|||||||
await download(url, outPutUrl, options);
|
await download(url, outPutUrl, options);
|
||||||
console.log(`JD_DailyBonus.js文件下载完毕\n\n`);
|
console.log(`JD_DailyBonus.js文件下载完毕\n\n`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("文件下载异常:" + e);
|
console.log("JD_DailyBonus.js 文件下载异常:" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -193,7 +193,7 @@ function serverNotify(text, desp, timeout = 2100) {
|
|||||||
})
|
})
|
||||||
}, timeout)
|
}, timeout)
|
||||||
} else {
|
} else {
|
||||||
console.log('您未提供server酱的SCKEY,取消微信推送消息通知🚫\n');
|
console.log('\n\n您未提供server酱的SCKEY,取消微信推送消息通知🚫\n');
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user