This commit is contained in:
lxk0301
2021-03-10 09:41:12 +08:00
parent b5cfc4ada9
commit 7566c1115d

View File

@@ -1,12 +1,12 @@
/* /*
* @Author: LXK9301 https://github.com/LXK9301 * @Author: lxk0301 https://gitee.com/lxk0301
*/ */
/* /*
签到,自用,可N个京东账号 东多合一签到,自用,可N个京东账号
活动入口:各处的签到汇总 活动入口:各处的签到汇总
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-2-27 更新时间2021-3-10
Modified From github https://github.com/ruicky/jd_sign_bot Modified From github https://github.com/ruicky/jd_sign_bot
*/ */
const $ = new Env('京东多合一签到'); const $ = new Env('京东多合一签到');
@@ -50,6 +50,7 @@ if ($.isNode()) {
await execSign(); await execSign();
} }
} }
await deleteFile(JD_DailyBonusPath);//删除下载的JD_DailyBonus.js文件
if ($.isNode() && allMessage && process.env.JD_BEAN_SIGN_NOTIFY_SIMPLE === 'true') { if ($.isNode() && allMessage && process.env.JD_BEAN_SIGN_NOTIFY_SIMPLE === 'true') {
await notify.sendNotify(`${$.name}`, `${allMessage}`) await notify.sendNotify(`${$.name}`, `${allMessage}`)
} }
@@ -67,17 +68,15 @@ async function execSign() {
// console.log('没有提供通知推送,则打印脚本执行日志') // console.log('没有提供通知推送,则打印脚本执行日志')
// await exec(`${process.execPath} ${JD_DailyBonusPath}`, { stdio: "inherit" }); // await exec(`${process.execPath} ${JD_DailyBonusPath}`, { stdio: "inherit" });
// } // }
await exec(`${process.execPath} ${JD_DailyBonusPath} >> ${resultPath}`); if (await fs.existsSync(JD_DailyBonusPath)) {
const notifyContent = await fs.readFileSync(resultPath, "utf8"); await exec(`${process.execPath} ${JD_DailyBonusPath} >> ${resultPath}`);
console.log(`👇👇👇👇👇👇👇👇👇👇👇LOG记录👇👇👇👇👇👇👇👇👇👇👇\n${notifyContent}\n👆👆👆👆👆👆👆👆👆LOG记录👆👆👆👆👆👆👆👆👆👆👆`); const notifyContent = await fs.readFileSync(resultPath, "utf8");
// await exec("node JD_DailyBonus.js", { stdio: "inherit" }); console.log(`👇👇👇👇👇👇👇👇👇👇👇LOG记录👇👇👇👇👇👇👇👇👇👇👇\n${notifyContent}\n👆👆👆👆👆👆👆👆👆LOG记录👆👆👆👆👆👆👆👆👆👆👆`);
// console.log('执行完毕', new Date(new Date().getTime() + 8 * 3600000).toLocaleDateString()) // await exec("node JD_DailyBonus.js", { stdio: "inherit" });
//发送通知 // console.log('执行完毕', new Date(new Date().getTime() + 8 * 3600000).toLocaleDateString())
if ($.isNode()) { //发送通知
let notifyContent = "";
let BarkContent = ''; let BarkContent = '';
if (fs.existsSync(resultPath)) { if (fs.existsSync(resultPath)) {
notifyContent = await fs.readFileSync(resultPath, "utf8");
const barkContentStart = notifyContent.indexOf('【签到概览】') const barkContentStart = notifyContent.indexOf('【签到概览】')
const barkContentEnd = notifyContent.length; const barkContentEnd = notifyContent.length;
if (process.env.JD_BEAN_SIGN_STOP_NOTIFY === 'true') return if (process.env.JD_BEAN_SIGN_STOP_NOTIFY === 'true') return
@@ -103,12 +102,12 @@ async function execSign() {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}`, `【签到号 ${$.index}】: ${$.nickName || $.UserName}\n【签到时间】: ${$.beanSignTime}\n${BarkContent}`); await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}`, `【签到号 ${$.index}】: ${$.nickName || $.UserName}\n【签到时间】: ${$.beanSignTime}\n${BarkContent}`);
} }
} }
//运行完成后,删除下载的文件
await deleteFile(resultPath);//删除result.txt
console.log(`*****************京东账号${$.index} ${$.nickName || $.UserName}京豆签到完成*******************\n`);
} else {
console.log(`\nJD_DailyBonus.js文件不存在\n`)
} }
//运行完成后,删除下载的文件
console.log('运行完成后,删除下载的文件\n')
await deleteFile(resultPath);//删除result.txt
await deleteFile(JD_DailyBonusPath);//删除JD_DailyBonus.js
console.log(`*****************京东账号${$.index} ${$.nickName || $.UserName}京豆签到完成*******************\n`);
} catch (e) { } catch (e) {
console.log("京东签到脚本执行异常:" + e); console.log("京东签到脚本执行异常:" + e);
} }
@@ -129,7 +128,7 @@ async function downFile () {
url = 'https://cdn.jsdelivr.net/gh/NobyDa/Script@master/JD-DailyBonus/JD_DailyBonus.js'; url = 'https://cdn.jsdelivr.net/gh/NobyDa/Script@master/JD-DailyBonus/JD_DailyBonus.js';
} }
try { try {
const options = {} const options = { "timeout": 10000 }
if (process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { if (process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) {
const tunnel = require("tunnel"); const tunnel = require("tunnel");
const agent = { const agent = {
@@ -143,7 +142,7 @@ async function downFile () {
Object.assign(options, { agent }) Object.assign(options, { agent })
} }
await download(url, outPutUrl, options); await download(url, outPutUrl, options);
console.log('文件下载完毕'); console.log(`JD_DailyBonus.js文件下载完毕\n\n`);
} catch (e) { } catch (e) {
console.log("文件下载异常:" + e); console.log("文件下载异常:" + e);
} }
@@ -190,7 +189,8 @@ function TotalBean() {
"Cookie": cookie, "Cookie": cookie,
"Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0")
} },
"timeout": 10000
} }
$.post(options, (err, resp, data) => { $.post(options, (err, resp, data) => {
try { try {
@@ -223,7 +223,7 @@ function TotalBean() {
} }
function downloadUrl(url = 'https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js') { function downloadUrl(url = 'https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js') {
return new Promise(resolve => { return new Promise(resolve => {
const options = { url }; const options = { url, "timeout": 10000 };
if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) {
const tunnel = require("tunnel"); const tunnel = require("tunnel");
const agent = { const agent = {
@@ -239,8 +239,8 @@ function downloadUrl(url = 'https://raw.githubusercontent.com/NobyDa/Script/mast
$.get(options, async (err, resp, data) => { $.get(options, async (err, resp, data) => {
try { try {
if (err) { if (err) {
console.log(`${JSON.stringify(err)}`) // console.log(`${JSON.stringify(err)}`)
console.log(`检测到您不能访问外网,将使用CDN下载JD_DailyBonus.js文件`) console.log(`检测到您当前网络环境不能访问外网,将使用CDN下载JD_DailyBonus.js文件`)
} else { } else {
$.body = data; $.body = data;
} }