[集鞭炮赢京豆]

新增 满足兑换 FIRECRACKERS_NOTITY_BEAN 个京豆时进行 notify 通知
新增 黑号自动跳过任务执行
This commit is contained in:
guyuexuan
2021-01-25 16:12:20 +08:00
parent dd72d6e1bc
commit 8a325497c8
5 changed files with 58 additions and 27 deletions

View File

@@ -166,3 +166,5 @@ jobs:
SERVERLESS_PLATFORM_VENDOR: tencent
TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}
TENCENT_REGION: ${{ secrets.SCF_REGION }}
TENCENT_FUNCTION_NAME: ${{ secrets.TENCENT_FUNCTION_NAME }}

File diff suppressed because one or more lines are too long

View File

@@ -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(`任务完成失败,原因未知`)
}

View File

@@ -9,17 +9,17 @@
============Quantumultx===============
[task_local]
#京东炸年兽🧨
10 * * * * https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js, tag=京东炸年兽🧨, img-url=https://raw.githubusercontent.com/yogayyy/Scripts/main/Icon/lxk0301/jd_nian.png, enabled=true
0 9,12,20 * * * https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js, tag=京东炸年兽🧨, img-url=https://raw.githubusercontent.com/yogayyy/Scripts/main/Icon/lxk0301/jd_nian.png, enabled=true
================Loon==============
[Script]
cron "10 * * * *" script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js,tag=京东炸年兽🧨
cron "0 9,12,20 * * *" script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js,tag=京东炸年兽🧨
===============Surge=================
京东炸年兽🧨 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js
京东炸年兽🧨 = type=cron,cronexp="0 9,12,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js
============小火箭=========
京东炸年兽🧨 = type=cron,script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js, cronexpr="10 * * * *", timeout=3600, enable=true
京东炸年兽🧨 = type=cron,script-path=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_nian.js, cronexpr="0 9,12,20 * * *", timeout=3600, enable=true
*/
const $ = new Env('京东炸年兽🧨');
@@ -50,7 +50,7 @@ const inviteCodes = [
`cgxZaDXWZPCmiUa2akPVmFMI27K6antJzucULQPYNim_BPEW1Dwd@cgxZdTXtIrPYuAqfDgSpusxr97nagU6hwFa3TXxnqM95u3ib-xt4nWqZdz8@cgxZdTXtIO-O6QmYDVf67KCEJ19JcybuMB2_hYu8NSNQg0oS2Z_FpMce45g@cgxZdTXtILiLvg7OAASp61meehou4OeZvqbjghsZlc3rI5SBk7b3InUqSQ0@cgxZdTXtIumO4w2cDgSqvYcqHwjaAzLxu0S371Dh_fctFJtN0tXYzdR7JaY`
];
const pkInviteCodes = [
'IgNWdiLGaPadvlqJQnnKp27-YpAvKvSYNTSkTGvZylf_0wcvqD9EMkohEd8@IgNWdiLGaPaZskfACQyhgLSpZWps-WtQEW3McifV@IgNWdiLGaPaAvmHPAQf769XqjJjMyRirPzN9-AS-WHY9Y_G7t9Cwe5gdiI2qEvHZ',
'IgNWdiLGaPadvlqJQnnKp27-YpAvKvSYNTSkTGvZylf_0wcvqD9EMkohEd8@IgNWdiLGaPaZskfACQyhgLSpZWps-WtQEW3McifV@IgNWdiLGaPaAvmHPAQf769XqjJjMyRirPzN9-AS-WHY9Y_G7t9Cwe5gdiI2qEvHZ@IgNWdiLGaPYCeJUfsq18UNi5ln9xEZSPRdOue8Wl3hJTS2SQzU0vulL0fHeULJaIfgqHFd7f_Ks',
'IgNWdiLGaPadvlqJQnnKp27-YpAvKvSYNTSkTGvZylf_0wcvqD9EMkohEd8@IgNWdiLGaPaZskfACQyhgLSpZWps-WtQEW3McifV@IgNWdiLGaPaAvmHPAQf769XqjJjMyRirPzN9-AS-WHY9Y_G7t9Cwe5gdiI2qEvHZ'
]
!(async () => {
@@ -78,7 +78,7 @@ const pkInviteCodes = [
continue
}
await shareCodesFormat();
// await shareCodesFormatPk()
await shareCodesFormatPk()
await jdNian()
}
}
@@ -99,7 +99,7 @@ async function jdNian() {
$.hasGroup = false
await pkTaskDetail()
if ($.hasGroup) await pkInfo()
// await helpFriendsPK()
await helpFriendsPK()
}
await $.wait(2000)
await killCouponList()

View File

@@ -11,7 +11,7 @@ const clientConfig = {
secretId: process.env.TENCENT_SECRET_ID,
secretKey: process.env.TENCENT_SECRET_KEY,
},
region: "ap-hongkong",
region: process.env.TENCENT_REGION, // 区域参考https://cloud.tencent.com/document/product/213/6091
profile: {
httpProfile: {
endpoint: "scf.tencentcloudapi.com",
@@ -22,7 +22,7 @@ const clientConfig = {
const client = new ScfClient(clientConfig);
const params = {
"Handler": "index.main_handler",
"FunctionName": "jd",
"FunctionName": process.env.TENCENT_FUNCTION_NAME, // 云函数程序名,例如 jd_scripts
"ZipFile": contents_in_base64
};
client.UpdateFunctionCode(params).then(