mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
助力池
This commit is contained in:
parent
5c3dc3efd4
commit
9d7aba3e55
130
jd_fruit.js
130
jd_fruit.js
@ -25,7 +25,8 @@ export DO_TEN_WATER_AGAIN="" 默认再次浇水
|
||||
*/
|
||||
|
||||
|
||||
const $ = new Env("东东农场");
|
||||
const $ = new Env("东东农场助力池版");
|
||||
let codeType = 0;
|
||||
let cookiesArr = [],
|
||||
cookie = "",
|
||||
jdFruitShareArr = [],
|
||||
@ -55,6 +56,8 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
|
||||
// const { randomString } = require("./utils/mainUtils");
|
||||
let sid;
|
||||
let version = 18;
|
||||
const JD_ZLC_URL = process.env.JD_ZLC_URL ? process.env.JD_ZLC_URL : "https://zlc1.chaoyi996.com";
|
||||
|
||||
!(async () => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
@ -107,6 +110,7 @@ async function jdFruit() {
|
||||
// option['media-url'] = $.farmInfo.farmUserPro.goodsImage;
|
||||
message = `【水果名称】${$.farmInfo.farmUserPro.name}\n`;
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`);
|
||||
jdFruitShareArr.push($.farmInfo.farmUserPro.shareCode)
|
||||
console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`);
|
||||
message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`;
|
||||
await masterHelpShare(); //助力好友
|
||||
@ -557,14 +561,14 @@ async function turntableFarm() {
|
||||
}
|
||||
$.lotteryMasterHelpRes = await doApi("initForFarm", { shareCode: code + "-3", sid, version, channel: 1, babelChannel: 0 }, 0);
|
||||
// console.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult)
|
||||
if ($.lotteryMasterHelpRes.helpResult.code === "0") {
|
||||
console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`);
|
||||
} else if ($.lotteryMasterHelpRes.helpResult.code === "11") {
|
||||
console.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`);
|
||||
} else if ($.lotteryMasterHelpRes.helpResult.code === "13") {
|
||||
console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`);
|
||||
break;
|
||||
}
|
||||
// if ($.lotteryMasterHelpRes.helpResult.code === "0") {
|
||||
// console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`);
|
||||
// } else if ($.lotteryMasterHelpRes.helpResult.code === "11") {
|
||||
// console.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`);
|
||||
// } else if ($.lotteryMasterHelpRes.helpResult.code === "13") {
|
||||
// console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
console.log(`---天天抽奖次数remainLotteryTimes----${remainLotteryTimes}次`);
|
||||
//抽奖
|
||||
@ -691,6 +695,13 @@ async function masterHelpShare() {
|
||||
let helpSuccessPeoples = ""; //成功助力好友
|
||||
console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`);
|
||||
|
||||
helpStatisticArr = {}
|
||||
helpStatisticArr['fromCode'] = $.farmInfo.farmUserPro.shareCode
|
||||
helpStatisticArr['codeType'] = codeType;
|
||||
helpStatisticArr['results'] = {};
|
||||
|
||||
helpStatisticStatus = 2
|
||||
helpStatisticRemark = ''
|
||||
for (let code of newShareCodes) {
|
||||
console.log(`开始助力京东账号${$.index} - ${$.nickName || $.UserName}的好友: ${code}`);
|
||||
if (!code) continue;
|
||||
@ -702,29 +713,65 @@ async function masterHelpShare() {
|
||||
if ($.helpResult.code === "0") {
|
||||
if ($.helpResult.helpResult.code === "0") {
|
||||
//助力成功
|
||||
helpStatisticStatus = 1;
|
||||
salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater;
|
||||
console.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`);
|
||||
console.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`);
|
||||
helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || "匿名用户") + ",";
|
||||
} else if ($.helpResult.helpResult.code === "8") {
|
||||
helpStatisticStatus = 3;
|
||||
console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`);
|
||||
} else if ($.helpResult.helpResult.code === "9") {
|
||||
helpStatisticStatus = 5;
|
||||
console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`);
|
||||
} else if ($.helpResult.helpResult.code === "10") {
|
||||
helpStatisticStatus = 4;
|
||||
console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`);
|
||||
} else {
|
||||
helpStatisticStatus = 6;
|
||||
helpStatisticRemark = JSON.stringify($.helpResult.helpResult)
|
||||
console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`);
|
||||
}
|
||||
console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`);
|
||||
remainTimes = $.helpResult.helpResult.remainTimes;
|
||||
if ($.helpResult.helpResult.remainTimes === 0) {
|
||||
console.log(`您当前助力次数已耗尽,跳出助力`);
|
||||
if (!(helpStatisticStatus in helpStatisticArr['results'])) {
|
||||
helpStatisticArr['results'][helpStatisticStatus] = [code]
|
||||
} else {
|
||||
helpStatisticArr['results'][helpStatisticStatus].push(code)
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
helpStatisticStatus = 2;
|
||||
helpStatisticRemark = JSON.stringify($.helpResult.helpResult)
|
||||
console.log(`助力失败::${JSON.stringify($.helpResult)}`);
|
||||
}
|
||||
if (!(helpStatisticStatus in helpStatisticArr['results'])) {
|
||||
helpStatisticArr['results'][helpStatisticStatus] = [code]
|
||||
} else {
|
||||
helpStatisticArr['results'][helpStatisticStatus].push(code)
|
||||
}
|
||||
}
|
||||
helpStatisticArr['Remark'] = helpStatisticRemark;
|
||||
console.log(`当前使用助力池${JD_ZLC_URL}`)
|
||||
r = { url: `https://zlc1.chaoyi996.com/api/app/booster-code/submit-real-contribution`, body: JSON.stringify(helpStatisticArr), headers: { "Content-Type": "application/json" } };
|
||||
$.post(r, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} 提交助力结果API请求失败`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`提交成功`)
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
}
|
||||
})
|
||||
if ($.isLoon() || $.isQuanX() || $.isSurge()) {
|
||||
let helpSuccessPeoplesKey = timeFormat() + $.farmInfo.farmUserPro.shareCode;
|
||||
if (!$.getdata(helpSuccessPeoplesKey)) {
|
||||
@ -1179,46 +1226,39 @@ function timeFormat(time) {
|
||||
}
|
||||
return date.getFullYear() + "-" + (date.getMonth() + 1 >= 10 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1)) + "-" + (date.getDate() >= 10 ? date.getDate() : "0" + date.getDate());
|
||||
}
|
||||
function readShareCode() {
|
||||
return new Promise(async (resolve) => {
|
||||
$.get({ url: `http://transfer.nz.lu/farm`, timeout: 10000 }, (err, resp, data) => {
|
||||
function readShareCode(code) {
|
||||
return new Promise(async resolve => {
|
||||
console.log(`当前使用助力池${JD_ZLC_URL}`)
|
||||
$.get({ url: JD_ZLC_URL + `/farm?code=` + code, timeout: 10000, }, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(JSON.stringify(err));
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`);
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`);
|
||||
console.log(`随机取20个码来助力`)
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
await $.wait(10000);
|
||||
resolve();
|
||||
});
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function shareCodesFormat() {
|
||||
return new Promise(async (resolve) => {
|
||||
// console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`)
|
||||
newShareCodes = [];
|
||||
if ($.shareCodesArr[$.index - 1]) {
|
||||
newShareCodes = $.shareCodesArr[$.index - 1].split("@");
|
||||
} else {
|
||||
console.log(`由于您第${$.index}个京东账号未提供shareCode,脚本无内置助力码,放心使用\n`);
|
||||
const tempIndex = $.index > shareCodes.length ? shareCodes.length - 1 : $.index - 1;
|
||||
newShareCodes = shareCodes[tempIndex].split("@");
|
||||
const readShareCodeRes = await readShareCode(jdFruitShareArr[$.index - 1]);
|
||||
if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])];
|
||||
}
|
||||
// const readShareCodeRes = await readShareCode();
|
||||
// if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
// // newShareCodes = newShareCodes.concat(readShareCodeRes.data || []);
|
||||
// newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])];
|
||||
// }
|
||||
console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`);
|
||||
console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`)
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
@ -1228,7 +1268,7 @@ function requireConfig() {
|
||||
notify = $.isNode() ? require("./sendNotify") : "";
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require("./jdCookie.js") : "";
|
||||
const jdFruitShareCodes = $.isNode() ? require("./jdFruitShareCodes.js") : "";
|
||||
// const jdFruitShareCodes = $.isNode() ? require("./jdFruitShareCodes.js") : "";
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
@ -1242,19 +1282,19 @@ function requireConfig() {
|
||||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`);
|
||||
$.shareCodesArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdFruitShareCodes).forEach((item) => {
|
||||
if (jdFruitShareCodes[item]) {
|
||||
$.shareCodesArr.push(jdFruitShareCodes[item]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if ($.getdata("jd_fruit_inviter"))
|
||||
$.shareCodesArr = $.getdata("jd_fruit_inviter")
|
||||
.split("\n")
|
||||
.filter((item) => !!item);
|
||||
console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata("jd_fruit_inviter") ? $.getdata("jd_fruit_inviter") : "暂无"}\n`);
|
||||
}
|
||||
// if ($.isNode()) {
|
||||
// Object.keys(jdFruitShareCodes).forEach((item) => {
|
||||
// // if (jdFruitShareCodes[item]) {
|
||||
// // $.shareCodesArr.push(jdFruitShareCodes[item]);
|
||||
// // }
|
||||
// });
|
||||
// } else {
|
||||
// if ($.getdata("jd_fruit_inviter"))
|
||||
// $.shareCodesArr = $.getdata("jd_fruit_inviter")
|
||||
// .split("\n")
|
||||
// .filter((item) => !!item);
|
||||
// console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata("jd_fruit_inviter") ? $.getdata("jd_fruit_inviter") : "暂无"}\n`);
|
||||
// }
|
||||
// console.log(`$.shareCodesArr::${JSON.stringify($.shareCodesArr)}`)
|
||||
// console.log(`jdFruitShareArr账号长度::${$.shareCodesArr.length}`)
|
||||
console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`);
|
||||
|
Loading…
Reference in New Issue
Block a user