This commit is contained in:
wisz2021
2021-05-12 11:02:10 +08:00
parent 39d927c2ab
commit 61b4727c6a

View File

@ -51,20 +51,31 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
return; return;
} }
console.log('下一场超级直播间时间:05月11日 20:00直播间地址https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=4085977') console.log('下一场超级直播间时间:05月11日 20:00直播间地址https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=4085977')
$.newAcids = [];
await getRedRain(); await getRedRain();
let nowTs = new Date().getTime() let nowTs = new Date().getTime()
if (!($.st <= nowTs && nowTs < $.ed)) { if (!($.st <= nowTs && nowTs < $.ed)) {
$.log(`\n远程红包雨配置获取错误,尝试从本地读取配置`) $.log(`\n远程红包雨配置获取错误,尝试从本地读取配置`);
let hour = (new Date().getUTCHours() + 8) % 24 $.http.get({url: `https://purge.jsdelivr.net/gh/gitupdate/updateTeam@master/redrain.json`}).then((resp) => {}).catch();
if (ids[hour]) { let hour = (new Date().getUTCHours() + 8) % 24;
$.activityId = ids[hour] let redIds = await getRedRainIds();
$.log(`本地红包雨配置获取成功ID为${$.activityId}\n`) if (!redIds) redIds = await getRedRainIds('https://cdn.jsdelivr.net/gh/gitupdate/updateTeam@master/redrain.json');
$.newAcids = [...(redIds || [])];
if ($.newAcids && $.newAcids.length) {
$.log(`本地红包雨配置获取成功ID为${JSON.stringify($.newAcids)}\n`)
} else { } else {
$.log(`无法从本地读取配置,请检查运行时间(注:非红包雨时间执行出现此提示请忽略!!!!!!!!!!!)`) $.log(`无法从本地读取配置,请检查运行时间(注:非红包雨时间执行出现此提示请忽略!!!!!!!!!!!)`)
$.log(`非红包雨期间出现上面提示请忽略。红包雨期间会正常此脚本提issue打死)`)
return return
} }
// if (ids[hour]) {
// $.activityId = ids[hour]
// $.log(`本地红包雨配置获取成功ID为${$.activityId}\n`)
// } else {
// $.log(`无法从本地读取配置,请检查运行时间(注:非红包雨时间执行出现此提示请忽略!!!!!!!!!!!)`)
// $.log(`非红包雨期间出现上面提示请忽略。红包雨期间会正常此脚本提issue打死)`)
// return
// }
} else { } else {
$.log(`远程红包雨配置获取成功`) $.log(`远程红包雨配置获取成功`)
} }
@ -88,7 +99,10 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
} }
let nowTs = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 let nowTs = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000
// console.log(nowTs, $.startTime, $.endTime) // console.log(nowTs, $.startTime, $.endTime)
await receiveRedRain(); for (let id of $.newAcids) {
// $.activityId = id;
await receiveRedRain(id);
}
// await showMsg(); // await showMsg();
} }
} }
@ -132,7 +146,8 @@ function getRedRain() {
let act = data.data.iconArea.filter(vo => vo['type'] === "platform_red_packege_rain")[0] let act = data.data.iconArea.filter(vo => vo['type'] === "platform_red_packege_rain")[0]
if (act) { if (act) {
let url = act.data.activityUrl let url = act.data.activityUrl
$.activityId = url.substr(url.indexOf("id=") + 3) $.activityId = url.substr(url.indexOf("id=") + 3);
$.newAcids.push($.activityId);
$.st = act.startTime $.st = act.startTime
$.ed = act.endTime $.ed = act.endTime
console.log($.activityId) console.log($.activityId)
@ -156,9 +171,9 @@ function getRedRain() {
}) })
} }
function receiveRedRain() { function receiveRedRain(actId) {
return new Promise(resolve => { return new Promise(resolve => {
const body = {"actId": $.activityId}; const body = { actId };
$.get(taskUrl('noahRedRainLottery', body), (err, resp, data) => { $.get(taskUrl('noahRedRainLottery', body), (err, resp, data) => {
try { try {
if (err) { if (err) {
@ -173,7 +188,7 @@ function receiveRedRain() {
message += `领取成功,获得 ${(data.lotteryResult.jPeasList[0].quantity)}京豆` message += `领取成功,获得 ${(data.lotteryResult.jPeasList[0].quantity)}京豆`
allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n领取成功,获得 ${(data.lotteryResult.jPeasList[0].quantity)}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n领取成功,获得 ${(data.lotteryResult.jPeasList[0].quantity)}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`;
} else if (data.subCode === '8') { } else if (data.subCode === '8') {
console.log(`今日次数已满`) console.log(`领取失败:本场已领过`)
message += `领取失败,本场已领过`; message += `领取失败,本场已领过`;
} else { } else {
console.log(`异常:${JSON.stringify(data)}`) console.log(`异常:${JSON.stringify(data)}`)
@ -239,6 +254,42 @@ function taskUrl(function_id, body = {}) {
} }
} }
function getRedRainIds(url = "https://raw.githubusercontent.com/gitupdate/updateTeam/master/redrain.json") {
return new Promise(async resolve => {
const options = {
url: `${url}?${new Date()}`, "timeout": 10000, headers: {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88"
}
};
if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) {
const tunnel = require("tunnel");
const agent = {
https: tunnel.httpsOverHttp({
proxy: {
host: process.env.TG_PROXY_HOST,
port: process.env.TG_PROXY_PORT * 1
}
})
}
Object.assign(options, { agent })
}
$.get(options, async (err, resp, data) => {
try {
if (err) {
} else {
if (data) data = JSON.parse(data)
}
} catch (e) {
// $.logErr(e, resp)
} finally {
resolve(data);
}
})
await $.wait(10000)
resolve([]);
})
}
function TotalBean() { function TotalBean() {
return new Promise(async resolve => { return new Promise(async resolve => {
const options = { const options = {