From 4f9e87ad1f80e6a4cf9ba555900960d3313ed0dc Mon Sep 17 00:00:00 2001 From: guyuexuan <2651919937@qq.com> Date: Mon, 25 Jan 2021 16:12:20 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=9B=86=E9=9E=AD=E7=82=AE=E8=B5=A2=E4=BA=AC?= =?UTF-8?q?=E8=B1=86]=20=E6=96=B0=E5=A2=9E=20=E6=BB=A1=E8=B6=B3=E5=85=91?= =?UTF-8?q?=E6=8D=A2=20FIRECRACKERS=5FNOTITY=5FBEAN=20=E4=B8=AA=E4=BA=AC?= =?UTF-8?q?=E8=B1=86=E6=97=B6=E8=BF=9B=E8=A1=8C=20notify=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20=E6=96=B0=E5=A2=9E=20=E9=BB=91=E5=8F=B7=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=B7=B3=E8=BF=87=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_firecrackers.js | 57 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/jd_firecrackers.js b/jd_firecrackers.js index d5a67b79..7fef4878 100644 --- a/jd_firecrackers.js +++ b/jd_firecrackers.js @@ -26,6 +26,7 @@ cron "10 8,21 * * *" script-path=https://raw.githubusercontent.com/LXK9301/jd_sc */ const $ = new Env('集鞭炮赢京豆'); const notify = $.isNode() ? require('./sendNotify') : ''; +let notifyBean = $.isNode() ? process.env.FIRECRACKERS_NOTITY_BEAN || 0 : 0; // 账号满足兑换多少京豆时提示 默认 0 不提示,格式:120 表示能兑换 120 豆子发出通知; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; //Node.js用户请在jdCookie.js处填写京东ck; //IOS等用户直接用NobyDa的jd cookie @@ -92,9 +93,25 @@ async function jdFamily() { } function showMsg() { - return new Promise(resolve => { - message += `本次运行获得鞭炮${$.earn},共计${$.total}🧨` - $.log($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + return new Promise(async resolve => { + subTitle = `【京东账号${$.index}】${$.nickName}`; + message += `【鞭炮🧨】本次获得 ${$.earn},共计${$.total}\n` + if ($.total && notifyBean) { + for (let item of $.prize) { + if (notifyBean >= item.beansPerNum) { // 符合预定的京豆档位 + if ($.total >= item.prizerank) { // 当前鞭炮满足兑换 + message += `【京豆】请手动兑换 ${item.beansPerNum} 个京豆,需消耗花费🧨 ${item.prizerank}` + $.msg($.name, subTitle, message); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`); + resolve(); + return; + } + } + } + } + } + $.log(`${$.name}\n\n账号${$.index} - ${$.nickName}\n${subTitle}\n${message}`); resolve() }) } @@ -130,17 +147,22 @@ function getUserInfo(info = false) { $.userInfo = JSON.parse(data.match(/query\((.*)\n/)[1]) if (info) { $.earn = $.userInfo.tatalprofits - $.total - } else for (let task of $.info.config.tasks) { - let vo = $.userInfo.tasklist.filter(vo => vo.taskid === task['_id']) - if (vo.length > 0) { - vo = vo[0] - if (vo['isdo'] === 1) { - if (vo['times'] === 0) { - console.log(`去做任务${task['_id']}`) - await doTask(task['_id']) - await $.wait(3000) - } else { - console.log(`${Math.trunc(vo['times'] / 60)}分钟可后做任务${task['_id']}`) + } else { + for (let task of $.info.config.tasks) { + let vo = $.userInfo.tasklist.filter(vo => vo.taskid === task['_id']) + if (vo.length > 0) { + vo = vo[0] + if (vo['isdo'] === 1) { + if (vo['times'] === 0) { + console.log(`去做任务${task['_id']}`) + let res = await doTask(task['_id']) + if (!res) { // 黑号,不再继续执行任务 + break; + } + await $.wait(3000) + } else { + console.log(`${Math.trunc(vo['times'] / 60)}分钟可后做任务${task['_id']}`) + } } } } @@ -165,9 +187,14 @@ function doTask(taskId) { console.log(`${err},${jsonParse(resp.body)['message']}`) console.log(`${$.name} API请求失败,请检查网路重试`) } else { - data = JSON.parse(data.match(/query\((.*)\n/)[1]) + let res = data.match(/query\((.*)\n/)[1]; + data = JSON.parse(res); if (data.ret === 0) { console.log(`任务完成成功`) + } else if (data.ret === 1001) { + console.log(`任务完成失败,原因:这个账号黑号了!!!`) + resolve(false); + return; } else { console.log(`任务完成失败,原因未知`) }