Files
Java_utils_enhance/src/main/resources/test_fruit.js
T

1629 lines
77 KiB
JavaScript
Raw Normal View History

2021-11-13 15:40:21 +08:00
let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify;
let newShareCodes = [];
2021-11-13 02:24:38 +08:00
//助力好友分享码(最多4个,否则后面的助力失败),原因:动动农场每人每天只有四次助力机会
//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一动动账号的好友互助码请使用@符号隔开。
//下面给出两个账号的填写示例(iOS只支持2个动动账号)
let shareCodes =
[ // 这个列表填入你要助力的好友的shareCode
]
2021-11-13 01:41:22 +08:00
2021-11-08 09:11:51 +08:00
let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0"
2021-11-12 23:53:38 +08:00
let dingtalk2 = "https://oapi.dingtalk.com/robot/send?access_token=1832f969da101ef8273e8ba2258f06f15ec34bc22282066b28ab617042a7a9b6";
let getManName = ""
let roleMap = {
"jd_4521b375ebb5d": "锟子怪",
"jd_542c10c0222bc": "康子怪",
"jd_66dcb31363ef6": "涛子怪",
2021-11-18 22:09:51 +08:00
"jd_45d917547c763": "跑腿小怪C",
2021-11-12 23:53:38 +08:00
"417040678_m": "斌子怪",
"jd_73d88459d908e": "杰杰子",
"381550701lol": "漪漪子",
"jd_4333d5dc1ac5f": "舒楠子",
2021-11-18 22:09:51 +08:00
"jd_66ea783827d30": "跑腿小怪A",
"jd_4311ac0ff4456": "跑腿小怪B"
2021-11-12 23:53:38 +08:00
}
let message = '', subTitle = '', option = {}, isFruitFinished = false;
2021-10-26 19:20:52 +08:00
const retainWater = 100;//保留水滴大于多少g,默认100g;
let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送
let jdFruitBeanCard = false;//农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水
2021-11-13 02:24:38 +08:00
let randomCount = $.isNode() ? 0 : 0;
2021-10-26 19:20:52 +08:00
const JD_API_HOST = 'https://api.m.jd.com/client.action';
const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`;
!(async () => {
2021-11-12 23:53:38 +08:00
await requireConfig();
2021-11-13 02:24:38 +08:00
message += "<font color=\'#FFA500\'>[通知] </font><font color=\'#006400\' size='3'>动动农场</font> \n\n --- \n\n"
2021-11-12 23:53:38 +08:00
if (!cookiesArr[0]) {
2021-11-13 02:24:38 +08:00
$.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
2021-11-12 23:53:38 +08:00
return;
}
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
2021-11-13 02:24:38 +08:00
$.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1])
2021-11-12 23:53:38 +08:00
$.index = i + 1;
$.isLogin = true;
$.nickName = '';
await TotalBean();
username = $.UserName
if (roleMap[username] != undefined) {
username = roleMap[username]
}
getManName = username
2021-11-09 14:13:03 +08:00
2021-11-13 02:24:38 +08:00
2021-11-12 23:53:38 +08:00
//加上名称
message = message + "<font color=\'#778899\' size=2>【羊毛姐妹】<font color=\'#FFA500\' size=3>" + username + " </font> </font> \n\n "
2021-11-13 02:24:38 +08:00
that.log(`\n开始【动动账号${$.index}${$.nickName || $.UserName}\n`);
2021-11-12 23:53:38 +08:00
if (!$.isLogin) {
2021-11-13 02:24:38 +08:00
$.msg($.name, `【提示】cookie已失效`, `动动账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `动动账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
2021-11-12 23:53:38 +08:00
}
continue
}
subTitle = '';
option = {};
await jdFruit();
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
message += "----\n\n"
2021-10-26 19:20:52 +08:00
}
2021-11-09 14:13:03 +08:00
2021-11-13 02:24:38 +08:00
that.log(message)
2021-11-13 14:44:52 +08:00
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
2021-11-13 15:40:21 +08:00
cookie = cookiesArr[i];
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
$.index = i + 1;
$.isLogin = true;
$.nickName = '';
await TotalBean();
console.log(`\n开始【京东账号${$.index}${$.nickName || $.UserName}\n`);
if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
}
continue
2021-11-13 14:44:52 +08:00
}
2021-11-13 15:40:21 +08:00
await masterHelpShare();//助力好友
//互助 账号内部互助
2021-11-13 14:44:52 +08:00
}
2021-11-13 15:40:21 +08:00
}
2021-11-13 14:44:52 +08:00
2021-10-26 19:20:52 +08:00
})()
2021-11-12 23:53:38 +08:00
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
2021-11-13 02:24:38 +08:00
that.log(message)
message = message + getPic()
2021-11-13 01:41:22 +08:00
postToDingTalk(message)
2021-11-13 02:24:38 +08:00
$.done();
2021-11-12 23:53:38 +08:00
})
2021-10-26 19:20:52 +08:00
2021-11-13 02:24:38 +08:00
2021-10-26 19:20:52 +08:00
async function jdFruit() {
2021-11-13 02:24:38 +08:00
subTitle = `【动动账号${$.index}${$.nickName}`;
2021-11-12 23:53:38 +08:00
try {
await initForFarm();
if ($.farmInfo.farmUserPro) {
// option['media-url'] = $.farmInfo.farmUserPro.goodsImage;
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>【水果名称】 " + `${$.farmInfo.farmUserPro.name}` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
message += "<font color=\'#778899\' size=2>【已兑换水果】" + `${$.farmInfo.farmUserPro.winTimes}` + "次</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`\n【动动账号${$.index}${$.nickName || $.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`);
that.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}\n`);
2021-11-13 14:44:52 +08:00
newShareCodes.push($.farmInfo.farmUserPro.shareCode);
await setHelp();
await setHelp();
2021-11-12 23:53:38 +08:00
await setHelp();
if ($.farmInfo.treeState === 2 || $.farmInfo.treeState === 3) {
option['open-url'] = urlSchema;
2021-11-13 02:24:38 +08:00
2021-11-13 14:44:52 +08:00
mes = "<font color=\'#778899\' size=2> " + `${getManName}` + ",你好\n\n【提醒⏰】" + fruitName + "已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达</font>"
2021-11-12 23:53:38 +08:00
postToDingTalk2(mes)
2021-11-13 02:24:38 +08:00
$.msg($.name, ``, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达`, option);
2021-11-12 23:53:38 +08:00
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看`);
2021-11-12 23:53:38 +08:00
}
return
} else if ($.farmInfo.treeState === 1) {
2021-11-13 02:24:38 +08:00
that.log(`\n${$.farmInfo.farmUserPro.name}种植中...\n`)
2021-11-12 23:53:38 +08:00
} else if ($.farmInfo.treeState === 0) {
//已下单购买, 但未开始种植新的水果
option['open-url'] = urlSchema;
2021-11-13 02:24:38 +08:00
$.msg($.name, ``, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去动动APP或微信小程序选购并种植新的水果\n点击弹窗即达`, option);
2021-11-13 14:44:52 +08:00
mes = "<font color=\'#778899\' size=2> " + `${getManName}` + ",你好\n\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果</font>"
2021-11-13 01:41:22 +08:00
postToDingTalk2(mes)
2021-11-13 02:24:38 +08:00
2021-11-12 23:53:38 +08:00
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 您忘了种植新的水果`, `动动账号${$.index} ${$.nickName}\n【提醒⏰】您忘了种植新的水果\n请去动动APP或微信小程序选购并种植新的水果`);
2021-11-12 23:53:38 +08:00
}
return
}
await doDailyTask();
await doTenWater();//浇水十次
await getFirstWaterAward();//领取首次浇水奖励
await getTenWaterAward();//领取10浇水奖励
await getWaterFriendGotAward();//领取为2好友浇水奖励
await duck();
2021-11-13 02:24:38 +08:00
await doTenWaterAgain();//再次浇水
2021-11-12 23:53:38 +08:00
await predictionFruit();//预测水果成熟时间
message = message + "----\n\n"
} else {
2021-11-13 02:24:38 +08:00
that.log(`初始化农场数据异常, 请登录动动 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify($.farmInfo)}`);
2021-11-12 23:53:38 +08:00
message = message + "<font color=\'#778899\' size=2> " + `初始化农场数据异常, 请登录动动 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify($.farmInfo)}` + "</font>\n\n";
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
} catch (e) {
2021-11-13 02:24:38 +08:00
that.log(`任务执行异常,请检查执行日志 ‼️‼️`);
2021-11-12 23:53:38 +08:00
message = message + "<font color=\'#778899\' size=2> " + `任务执行异常,请检查执行日志 ‼️‼️` + e + "</font>\n\n";
2021-11-13 02:24:38 +08:00
$.logErr(e);
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
await showMsg();
2021-10-26 19:20:52 +08:00
}
async function doDailyTask() {
2021-11-12 23:53:38 +08:00
await taskInitForFarm();
2021-11-13 02:24:38 +08:00
that.log(`开始签到`);
2021-11-12 23:53:38 +08:00
if (!$.farmTask.signInit.todaySigned) {
await signForFarm(); //签到
if ($.signResult.code === "0") {
2021-11-13 02:24:38 +08:00
that.log(`【签到成功】获得${$.signResult.amount}g💧\\n`)
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【签到成功】获得${$.signResult.amount}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
//message += `【签到成功】获得${$.signResult.amount}g💧\n`//连续签到${signResult.signDay}天
} else {
// message += `签到失败,详询日志\n`;
2021-11-13 02:24:38 +08:00
that.log(`签到结果: ${JSON.stringify($.signResult)}`);
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
} else {
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`今天已签到,连续签到${$.farmTask.signInit.totalSigned},下次签到可得${$.farmTask.signInit.signEnergyEachAmount}g` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`今天已签到,连续签到${$.farmTask.signInit.totalSigned},下次签到可得${$.farmTask.signInit.signEnergyEachAmount}g\n`);
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
// 被水滴砸中
2021-11-13 02:24:38 +08:00
that.log(`被水滴砸中: ${$.farmInfo.todayGotWaterGoalTask.canPop ? '是' : '否'}`);
2021-11-12 23:53:38 +08:00
if ($.farmInfo.todayGotWaterGoalTask.canPop) {
await gotWaterGoalTaskForFarm();
if ($.goalResult.code === '0') {
2021-11-19 09:53:32 +08:00
// message += "<font color=\'#778899\' size=2>" +`【被水滴砸中】获得${$.goalResult.addEnergy}g💧` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`【被水滴砸中】获得${$.goalResult.addEnergy}g💧\\n`);
2021-11-12 23:53:38 +08:00
// message += `【被水滴砸中】获得${$.goalResult.addEnergy}g💧\n`
}
2021-10-26 19:20:52 +08:00
}
2021-11-13 02:24:38 +08:00
that.log(`签到结束,开始广告浏览任务`);
2021-11-12 23:53:38 +08:00
if (!$.farmTask.gotBrowseTaskAdInit.f) {
let adverts = $.farmTask.gotBrowseTaskAdInit.userBrowseTaskAds
let browseReward = 0
let browseSuccess = 0
let browseFail = 0
for (let advert of adverts) { //开始浏览广告
if (advert.limit <= advert.hadFinishedTimes) {
// browseReward+=advert.reward
2021-11-13 02:24:38 +08:00
that.log(`${advert.mainTitle}+ ' 已完成`);//,获得${advert.reward}g
2021-11-12 23:53:38 +08:00
continue;
}
2021-11-13 02:24:38 +08:00
that.log('正在进行广告浏览任务: ' + advert.mainTitle);
2021-11-12 23:53:38 +08:00
await browseAdTaskForFarm(advert.advertId, 0);
if ($.browseResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`${advert.mainTitle}浏览任务完成`);
2021-11-12 23:53:38 +08:00
//领取奖励
await browseAdTaskForFarm(advert.advertId, 1);
if ($.browseRwardResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`领取浏览${advert.mainTitle}广告奖励成功,获得${$.browseRwardResult.amount}g`)
2021-11-12 23:53:38 +08:00
browseReward += $.browseRwardResult.amount
browseSuccess++
} else {
browseFail++
2021-11-18 22:09:51 +08:00
// message += "<font color=\'#778899\' size=2>" +`领取浏览广告奖励结果: ${JSON.stringify($.browseRwardResult)}` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`领取浏览广告奖励结果: ${JSON.stringify($.browseRwardResult)}`)
2021-11-12 23:53:38 +08:00
}
} else {
browseFail++
2021-11-13 02:24:38 +08:00
that.log(`广告浏览任务结果: ${JSON.stringify($.browseResult)}`);
2021-11-12 23:53:38 +08:00
}
}
if (browseFail > 0) {
2021-11-13 02:24:38 +08:00
that.log(`【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
// message += `【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\n`;
2021-10-26 19:20:52 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log(`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
// message += `【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`;
2021-10-26 19:20:52 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`今天已经做过浏览广告任务\n`);
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
//定时领水
if (!$.farmTask.gotThreeMealInit.f) {
//
await gotThreeMealForFarm();
if ($.threeMeal.code === "0") {
2021-11-13 02:24:38 +08:00
that.log(`【定时领水】获得${$.threeMeal.amount}g💧\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【定时领水】获得${$.threeMeal.amount}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
// message += `【定时领水】获得${$.threeMeal.amount}g💧\n`;
} else {
// message += `【定时领水】失败,详询日志\n`;
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`定时领水成功结果: ${JSON.stringify($.threeMeal)}` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`定时领水成功结果: ${JSON.stringify($.threeMeal)}`);
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log('当前不在定时领水时间断或者已经领过\n')
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
//给好友浇水
if (!$.farmTask.waterFriendTaskInit.f) {
if ($.farmTask.waterFriendTaskInit.waterFriendCountKey < $.farmTask.waterFriendTaskInit.waterFriendMax) {
await doFriendsWater();
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成\n`)
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成` + "</font>\n\n";
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
// await Promise.all([
// clockInIn(),//打卡领水
// executeWaterRains(),//水滴雨
// masterHelpShare(),//助力好友
// getExtraAward(),//领取额外水滴奖励
// turntableFarm()//天天抽奖得好礼
// ])
2021-11-13 14:44:52 +08:00
await getAwardInviteFriend();
2021-11-12 23:53:38 +08:00
await clockInIn();//打卡领水
await executeWaterRains();//水滴雨
await getExtraAward();//领取额外水滴奖励
await turntableFarm()//天天抽奖得好礼
2021-10-26 19:20:52 +08:00
}
async function predictionFruit() {
2021-11-13 02:24:38 +08:00
that.log('开始预测水果成熟时间\n');
2021-11-12 23:53:38 +08:00
await initForFarm();
await taskInitForFarm();
let waterEveryDayT = $.farmTask.totalWaterTaskInit.totalWaterTaskTimes;//今天到到目前为止,浇了多少次水
message += "<font color=\'#778899\' size=2>【今日共浇水】" + `${waterEveryDayT}` + "次 </font>\n\n"
message += "<font color=\'#778899\' size=2>【剩余 水滴】" + `${$.farmInfo.farmUserPro.totalEnergy}` + "g💧 </font> \n\n"
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `${(($.farmInfo.farmUserPro.treeEnergy /
$.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}` + "%,已浇水" + `${$.farmInfo.farmUserPro.treeEnergy / 10}` + "次,还需" + `${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}` + "次 </font> \n\n"
if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n\n` + "</font>\n\n"
} else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n\n` + "</font>\n\n"
}
// 预测n天后水果课可兑换功能
let waterTotalT = ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy - $.farmInfo.farmUserPro.totalEnergy) / 10;//一共还需浇多少次水
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
let waterD = Math.ceil(waterTotalT / waterEveryDayT);
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
message = message + "<font color=\'#BA55D3\' size=2>" + `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉` + "</font>\n\n";
2021-10-26 19:20:52 +08:00
}
//浇水十次
async function doTenWater() {
2021-11-12 23:53:38 +08:00
jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard;
if ($.isNode() && process.env.FRUIT_BEAN_CARD) {
jdFruitBeanCard = process.env.FRUIT_BEAN_CARD;
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
await myCardInfoForFarm();
const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes;
if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match(`限时翻倍`) && beanCard > 0) {
2021-11-13 02:24:38 +08:00
that.log(`您设置的是使用水滴换豆卡,且背包有水滴换豆卡${beanCard}张, 跳过10次浇水任务`)
2021-11-12 23:53:38 +08:00
return
}
if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
2021-11-13 02:24:38 +08:00
that.log(`\n准备浇水十次`);
2021-11-12 23:53:38 +08:00
let waterCount = 0;
isFruitFinished = false;
for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; waterCount++) {
2021-11-13 02:24:38 +08:00
that.log(`${waterCount + 1}次浇水`);
2021-11-12 23:53:38 +08:00
await waterGoodForFarm();
2021-11-13 02:24:38 +08:00
that.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`);
2021-11-12 23:53:38 +08:00
if ($.waterResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`剩余水滴${$.waterResult.totalEnergy}g`);
2021-11-12 23:53:38 +08:00
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
if ($.waterResult.totalEnergy < 10) {
2021-11-13 02:24:38 +08:00
that.log(`水滴不够,结束浇水`)
2021-11-12 23:53:38 +08:00
break
}
await gotStageAward();//领取阶段性水滴奖励
}
} else {
2021-11-13 02:24:38 +08:00
that.log('浇水出现失败异常,跳出不在继续浇水')
2021-11-12 23:53:38 +08:00
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
2021-11-13 02:24:38 +08:00
$.msg($.name, ``, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达`, option);
2021-11-12 23:53:38 +08:00
$.done();
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `动动账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`);
2021-11-12 23:53:38 +08:00
}
}
} else {
2021-11-13 02:24:38 +08:00
that.log('\n今日已完成10次浇水任务\n');
2021-10-26 19:20:52 +08:00
}
}
//领取首次浇水奖励
async function getFirstWaterAward() {
2021-11-12 23:53:38 +08:00
await taskInitForFarm();
//领取首次浇水奖励
if (!$.farmTask.firstWaterInit.f && $.farmTask.firstWaterInit.totalWaterTimes > 0) {
await firstWaterTaskForFarm();
if ($.firstWaterReward.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`);
2021-11-12 23:53:38 +08:00
// message += `【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`;
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【首次浇水奖励】获得${$.firstWaterReward.amount}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
} else {
// message += '【首次浇水奖励】领取奖励失败,详询日志\n';
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +'【首次浇水奖励】领取奖励失败,详询日志' + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`领取首次浇水奖励结果: ${JSON.stringify($.firstWaterReward)}`);
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log('首次浇水奖励已领取\n')
2021-10-26 19:20:52 +08:00
}
}
//领取十次浇水奖励
async function getTenWaterAward() {
2021-11-12 23:53:38 +08:00
//领取10次浇水奖励
if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.totalWaterTaskInit.totalWaterTaskTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
await totalWaterTaskForFarm();
if ($.totalWaterReward.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`);
2021-11-12 23:53:38 +08:00
// message += `【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`;
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
} else {
// message += '【十次浇水奖励】领取奖励失败,详询日志\n';
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}`);
2021-11-12 23:53:38 +08:00
}
} else if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
// message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`;
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}` + "</font>\n\n";
2021-11-13 02:24:38 +08:00
that.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}\n`);
2021-10-26 19:20:52 +08:00
}
2021-11-13 02:24:38 +08:00
that.log('finished 水果任务完成!');
2021-10-26 19:20:52 +08:00
}
//再次浇水
async function doTenWaterAgain() {
2021-11-13 02:24:38 +08:00
that.log('开始检查剩余水滴能否再次浇水再次浇水\n');
2021-10-26 19:20:52 +08:00
await initForFarm();
2021-11-12 23:53:38 +08:00
let totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
2021-11-13 02:24:38 +08:00
that.log(`剩余水滴${totalEnergy}g\n`);
2021-11-12 23:53:38 +08:00
await myCardInfoForFarm();
const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes;
2021-11-13 02:24:38 +08:00
that.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁' : fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁' : doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`)
2021-11-12 23:53:38 +08:00
if (totalEnergy >= 100 && doubleCard > 0) {
//使用翻倍水滴卡
for (let i = 0; i < new Array(doubleCard).fill('').length; i++) {
await userMyCardForFarm('doubleCard');
2021-11-13 02:24:38 +08:00
that.log(`使用翻倍水滴卡结果:${JSON.stringify($.userMyCardRes)}`);
2021-11-12 23:53:38 +08:00
}
await initForFarm();
totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
if (signCard > 0) {
//使用加签卡
for (let i = 0; i < new Array(signCard).fill('').length; i++) {
await userMyCardForFarm('signCard');
2021-11-13 02:24:38 +08:00
that.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`);
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
await initForFarm();
totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard;
if ($.isNode() && process.env.FRUIT_BEAN_CARD) {
jdFruitBeanCard = process.env.FRUIT_BEAN_CARD;
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match('限时翻倍')) {
2021-11-13 02:24:38 +08:00
that.log(`\n您设置的是水滴换豆功能,现在为您换豆`);
2021-11-12 23:53:38 +08:00
if (totalEnergy >= 100 && $.myCardInfoRes.beanCard > 0) {
//使用水滴换豆卡
await userMyCardForFarm('beanCard');
2021-11-13 02:24:38 +08:00
that.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`);
2021-11-12 23:53:38 +08:00
if ($.userMyCardRes.code === '0') {
2021-11-13 02:24:38 +08:00
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
return
}
2021-10-26 19:20:52 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`)
2021-10-26 19:20:52 +08:00
}
}
2021-11-12 23:53:38 +08:00
// if (totalEnergy > 100 && $.myCardInfoRes.fastCard > 0) {
// //使用快速浇水卡
// await userMyCardForFarm('fastCard');
2021-11-13 02:24:38 +08:00
// that.log(`使用快速浇水卡结果:${JSON.stringify($.userMyCardRes)}`);
2021-11-12 23:53:38 +08:00
// if ($.userMyCardRes.code === '0') {
2021-11-13 02:24:38 +08:00
// that.log(`已使用快速浇水卡浇水${$.userMyCardRes.waterEnergy}g`);
2021-11-12 23:53:38 +08:00
// }
// await initForFarm();
// totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
// }
// 所有的浇水(10次浇水)任务,获取水滴任务完成后,如果剩余水滴大于等于60g,则继续浇水(保留部分水滴是用于完成第二天的浇水10次的任务)
let overageEnergy = totalEnergy - retainWater;
if (totalEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) {
//如果现有的水滴,大于水果可兑换所需的对滴(也就是把水滴浇完,水果就能兑换了)
isFruitFinished = false;
for (let i = 0; i < ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10; i++) {
await waterGoodForFarm();
2021-11-13 02:24:38 +08:00
that.log(`本次浇水结果(水果马上就可兑换了): ${JSON.stringify($.waterResult)}`);
2021-11-12 23:53:38 +08:00
if ($.waterResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log('\n浇水10g成功\n');
2021-11-12 23:53:38 +08:00
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
2021-11-13 02:24:38 +08:00
that.log(`目前水滴【${$.waterResult.totalEnergy}】g,继续浇水,水果马上就可以兑换了`)
2021-11-12 23:53:38 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log('浇水出现失败异常,跳出不在继续浇水')
2021-11-12 23:53:38 +08:00
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
2021-11-13 02:24:38 +08:00
$.msg($.name, ``, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达`, option);
2021-11-12 23:53:38 +08:00
$.done();
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `动动账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`);
2021-11-12 23:53:38 +08:00
}
}
} else if (overageEnergy >= 10) {
2021-11-13 02:24:38 +08:00
that.log("目前剩余水滴:【" + totalEnergy + "】g,可继续浇水");
2021-11-12 23:53:38 +08:00
isFruitFinished = false;
for (let i = 0; i < parseInt(overageEnergy / 10); i++) {
await waterGoodForFarm();
2021-11-13 02:24:38 +08:00
that.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`);
2021-11-12 23:53:38 +08:00
if ($.waterResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`\n浇水10g成功,剩余${$.waterResult.totalEnergy}\n`)
2021-11-12 23:53:38 +08:00
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
await gotStageAward()
}
} else {
2021-11-13 02:24:38 +08:00
that.log('浇水出现失败异常,跳出不在继续浇水')
2021-11-12 23:53:38 +08:00
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
2021-11-13 02:24:38 +08:00
$.msg($.name, ``, `【动动账号${$.index}${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达`, option);
2021-11-12 23:53:38 +08:00
$.done();
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `动动账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`);
2021-11-12 23:53:38 +08:00
}
}
} else {
2021-11-13 02:24:38 +08:00
that.log("目前剩余水滴:【" + totalEnergy + "】g,不再继续浇水,保留部分水滴用于完成第二天【十次浇水得水滴】任务")
2021-10-26 19:20:52 +08:00
}
}
//领取阶段性水滴奖励
function gotStageAward() {
2021-11-12 23:53:38 +08:00
return new Promise(async resolve => {
if ($.waterResult.waterStatus === 0 && $.waterResult.treeEnergy === 10) {
2021-11-13 02:24:38 +08:00
that.log('果树发芽了,奖励30g水滴');
2021-11-12 23:53:38 +08:00
await gotStageAwardForFarm('1');
2021-11-13 02:24:38 +08:00
that.log(`浇水阶段奖励1领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`);
2021-11-12 23:53:38 +08:00
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`;
2021-11-13 02:24:38 +08:00
that.log(`【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" + `【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
}
} else if ($.waterResult.waterStatus === 1) {
2021-11-13 02:24:38 +08:00
that.log('果树开花了,奖励40g水滴');
2021-11-12 23:53:38 +08:00
await gotStageAwardForFarm('2');
2021-11-13 02:24:38 +08:00
that.log(`浇水阶段奖励2领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`);
2021-11-12 23:53:38 +08:00
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`;
2021-11-13 02:24:38 +08:00
that.log(`【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
}
} else if ($.waterResult.waterStatus === 2) {
2021-11-13 02:24:38 +08:00
that.log('果树长出小果子啦, 奖励50g水滴');
2021-11-12 23:53:38 +08:00
await gotStageAwardForFarm('3');
2021-11-13 02:24:38 +08:00
that.log(`浇水阶段奖励3领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`)
2021-11-12 23:53:38 +08:00
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`;
2021-11-13 02:24:38 +08:00
that.log(`【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`);
2021-11-18 22:09:51 +08:00
message += "<font color=\'#778899\' size=2>" +`【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
}
}
resolve()
})
2021-10-26 19:20:52 +08:00
}
//天天抽奖活动
async function turntableFarm() {
2021-11-12 23:53:38 +08:00
await initForTurntableFarm();
if ($.initForTurntableFarmRes.code === '0') {
//领取定时奖励 //4小时一次
let { timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos } = $.initForTurntableFarmRes;
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
if (!timingGotStatus) {
2021-11-13 02:24:38 +08:00
that.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`)
2021-11-12 23:53:38 +08:00
if (sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)) {
await timingAwardForTurntableFarm();
2021-11-13 02:24:38 +08:00
that.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`);
2021-11-12 23:53:38 +08:00
await initForTurntableFarm();
remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes;
} else {
2021-11-13 02:24:38 +08:00
that.log(`免费赠送的抽奖机会未到时间`)
2021-10-26 19:20:52 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log('4小时候免费赠送的抽奖机会已领取')
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
if ($.initForTurntableFarmRes.turntableBrowserAds && $.initForTurntableFarmRes.turntableBrowserAds.length > 0) {
for (let index = 0; index < $.initForTurntableFarmRes.turntableBrowserAds.length; index++) {
if (!$.initForTurntableFarmRes.turntableBrowserAds[index].status) {
2021-11-13 02:24:38 +08:00
that.log(`开始浏览天天抽奖的第${index + 1}个逛会场任务`)
2021-11-12 23:53:38 +08:00
await browserForTurntableFarm(1, $.initForTurntableFarmRes.turntableBrowserAds[index].adId);
if ($.browserForTurntableFarmRes.code === '0' && $.browserForTurntableFarmRes.status) {
2021-11-13 02:24:38 +08:00
that.log(`${index + 1}个逛会场任务完成,开始领取水滴奖励\n`)
2021-11-12 23:53:38 +08:00
await browserForTurntableFarm(2, $.initForTurntableFarmRes.turntableBrowserAds[index].adId);
if ($.browserForTurntableFarmRes.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`${index + 1}个逛会场任务领取水滴奖励完成\n`)
2021-11-12 23:53:38 +08:00
await initForTurntableFarm();
remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes;
}
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`浏览天天抽奖的第${index + 1}个逛会场任务已完成`)
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
}
}
2021-11-12 23:53:38 +08:00
//天天抽奖助力
2021-11-13 02:24:38 +08:00
that.log('开始天天抽奖--好友助力--每人每天只有三次助力机会.')
2021-11-12 23:53:38 +08:00
for (let code of newShareCodes) {
if (code === $.farmInfo.farmUserPro.shareCode) {
2021-11-13 02:24:38 +08:00
that.log('天天抽奖-不能自己给自己助力\n')
2021-11-12 23:53:38 +08:00
continue
}
await lotteryMasterHelp(code);
2021-11-13 02:24:38 +08:00
// that.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult)
2021-11-12 23:53:38 +08:00
if ($.lotteryMasterHelpRes.helpResult.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`)
2021-11-12 23:53:38 +08:00
} else if ($.lotteryMasterHelpRes.helpResult.code === '13') {
2021-11-13 02:24:38 +08:00
that.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`);
2021-11-12 23:53:38 +08:00
break;
2021-11-13 23:34:32 +08:00
} else if ($.lotteryMasterHelpRes.helpResult.code === '11') {
that.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`)
2021-11-12 23:53:38 +08:00
}
}
2021-11-13 02:24:38 +08:00
that.log(`---天天抽奖次数remainLotteryTimes----${remainLotteryTimes}`)
2021-11-12 23:53:38 +08:00
//抽奖
if (remainLotteryTimes > 0) {
2021-11-13 02:24:38 +08:00
that.log('开始抽奖')
2021-11-12 23:53:38 +08:00
let lotteryResult = '';
for (let i = 0; i < new Array(remainLotteryTimes).fill('').length; i++) {
await lotteryForTurntableFarm()
2021-11-13 02:24:38 +08:00
that.log(`${i + 1}次抽奖结果${JSON.stringify($.lotteryRes)}`);
2021-11-12 23:53:38 +08:00
if ($.lotteryRes.code === '0') {
turntableInfos.map((item) => {
if (item.type === $.lotteryRes.type) {
2021-11-13 02:24:38 +08:00
that.log(`lotteryRes.type${$.lotteryRes.type}`);
2021-11-12 23:53:38 +08:00
if ($.lotteryRes.type.match(/bean/g) && $.lotteryRes.type.match(/bean/g)[0] === 'bean') {
lotteryResult += `${item.name}个,`;
} else if ($.lotteryRes.type.match(/water/g) && $.lotteryRes.type.match(/water/g)[0] === 'water') {
lotteryResult += `${item.name}`;
} else {
lotteryResult += `${item.name}`;
}
}
})
//没有次数了
if ($.lotteryRes.remainLotteryTimes === 0) {
break
}
}
}
if (lotteryResult) {
2021-11-13 02:24:38 +08:00
that.log(`【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`)
2021-11-19 09:53:32 +08:00
// message += "<font color=\'#778899\' size=2>" + `【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}` + "</font>\n\n";
2021-11-12 23:53:38 +08:00
// message += `【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`;
}
} else {
2021-11-13 02:24:38 +08:00
that.log('天天抽奖--抽奖机会为0次')
2021-11-12 23:53:38 +08:00
}
2021-11-09 14:13:03 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log('初始化天天抽奖得好礼失败')
2021-10-26 19:20:52 +08:00
}
}
//领取额外奖励水滴
async function getExtraAward() {
2021-11-12 23:53:38 +08:00
await masterHelpTaskInitForFarm();
2021-11-18 22:09:51 +08:00
await masterGotFinishedTaskForFarm();
2021-11-19 09:53:32 +08:00
console.log(JSON.stringify($.masterHelpResult))
2021-11-19 10:04:47 +08:00
message += "<font color=\'#778899\' size=2>【额外奖励】" + `${JSON.stringify($.masterHelpResult)}` + "g水领取成功</font>\n\n";
message += "<font color=\'#778899\' size=2>【额外奖励】" + `${JSON.stringify($.masterGotFinished)}` + "g水领取成功</font>\n\n";
2021-11-19 10:00:41 +08:00
2021-11-18 22:09:51 +08:00
//修改为一定会去尝试领取额外奖励
if ($.masterGotFinished.code === '0') {
that.log(`已成功领取好友助力奖励:【${$.masterGotFinished.amount}】g水`);
message += "<font color=\'#778899\' size=2>【额外奖励】" + `${$.masterGotFinished.amount}` + "g水领取成功</font>\n\n";
}
if ($.masterHelpResult.masterGotFinal) {
that.log("已经领取过5好友助力额外奖励");
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【额外奖励】已被领取过\n` + "</font>\n\n";
}
if ($.masterHelpResult.code != '0') {
that.log("助力好友未达到5个");
message += "<font color=\'#778899\' size=2>【额外奖励】领取失败,原因:给您助力的人未达5个</font>\n\n";
}
if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length > 0) {
let str = '';
$.masterHelpResult.masterHelpPeoples.map((item, index) => {
if (index === ($.masterHelpResult.masterHelpPeoples.length - 1)) {
str += item.nickName || "匿名用户";
2021-11-12 23:53:38 +08:00
} else {
2021-11-18 22:09:51 +08:00
str += (item.nickName || "匿名用户") + ',';
2021-11-12 23:53:38 +08:00
}
2021-11-18 22:09:51 +08:00
let date = new Date(item.time);
let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
that.log(`\n动动昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
})
message += "<font color=\'#778899\' size=2>【助力您的好友】 " + `${str}` + "</font>\n\n"
2021-10-26 19:20:52 +08:00
}
2021-11-18 22:09:51 +08:00
that.log('领取额外奖励水滴结束\n');
// if ($.masterHelpResult.code === '0') {
// if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length >= 5) {
// // 已有五人助力。领取助力后的奖励
// if (!$.masterHelpResult.masterGotFinal) {
// await masterGotFinishedTaskForFarm();
// if ($.masterGotFinished.code === '0') {
// that.log(`已成功领取好友助力奖励:【${$.masterGotFinished.amount}】g水`);
// message += "<font color=\'#778899\' size=2>【额外奖励】" + `${$.masterGotFinished.amount}` + "g水领取成功</font>\n\n";
// }
// } else {
// that.log("已经领取过5好友助力额外奖励");
// message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【额外奖励】已被领取过\n` + "</font>\n\n";
// }
// } else {
// that.log("助力好友未达到5个");
// message += "<font color=\'#778899\' size=2>【额外奖励】领取失败,原因:给您助力的人未达5个</font>\n\n";
// }
// if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length > 0) {
// let str = '';
// $.masterHelpResult.masterHelpPeoples.map((item, index) => {
// if (index === ($.masterHelpResult.masterHelpPeoples.length - 1)) {
// str += item.nickName || "匿名用户";
// } else {
// str += (item.nickName || "匿名用户") + ',';
// }
// let date = new Date(item.time);
// let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
// that.log(`\n动动昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
// })
// message += "<font color=\'#778899\' size=2>【助力您的好友】 " + `${str}` + "</font>\n\n"
// }
// that.log('领取额外奖励水滴结束\n');
// }
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
function getHelp() {
2021-11-13 02:24:38 +08:00
newShareCodes = [];
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
$.get({
url: "http://api.tyh52.com/act/get/jd_fruit/3"
}, (err, resp, data) => {
try {
if (data) {
data = JSON.parse(data);
if (data.code == 1) {
let list = data.data;
if (!(list instanceof Array)) {
list = JSON.parse(list);
}
if (list.length > 0) {
for (var i in list) {
newShareCodes.push(list[i]);
}
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve(data);
2021-11-09 14:13:03 +08:00
}
2021-11-12 23:53:38 +08:00
})
});
2021-11-09 14:13:03 +08:00
}
2021-10-26 19:20:52 +08:00
2021-11-09 14:13:03 +08:00
function setHelp() {
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
if ($.farmInfo.farmUserPro.shareCode) {
$.get({
url: "http://api.tyh52.com/act/set/jd_fruit/" + $.farmInfo.farmUserPro.shareCode
}, (err, resp, data) => {
try {
if (data) {
data = JSON.parse(data);
if (data.code == 1) {
that.log("提交自己的邀請碼成功");
} else {
that.log("提交邀请码失败," + data.message);
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve(data);
}
})
} else {
resolve();
2021-11-09 14:13:03 +08:00
}
2021-11-12 23:53:38 +08:00
});
2021-11-09 14:13:03 +08:00
}
2021-11-13 02:24:38 +08:00
//助力好友
async function masterHelpShare() {
that.log('开始助力好友')
let salveHelpAddWater = 0;
let remainTimes = 4;//今日剩余助力次数,默认4次(动动农场每人每天4次助力机会)。
let helpSuccessPeoples = '';//成功助力好友
that.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`);
for (let code of newShareCodes) {
that.log(`开始助力动动账号${$.index} - ${$.nickName}的好友: ${code}`);
if (!code) continue;
if (code === $.farmInfo.farmUserPro.shareCode) {
that.log('不能为自己助力哦,跳过自己的shareCode\n')
continue
}
await masterHelp(code);
if ($.helpResult.code === '0') {
if ($.helpResult.helpResult.code === '0') {
//助力成功
salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater;
2021-11-13 15:40:21 +08:00
message += "<font color=\'#FFA500\'>" + `【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力` + "</font> \n\n "
2021-11-13 02:24:38 +08:00
that.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`);
that.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`)
helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || '匿名用户') + ',';
} else if ($.helpResult.helpResult.code === '8') {
that.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`);
} else if ($.helpResult.helpResult.code === '9') {
that.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`);
} else if ($.helpResult.helpResult.code === '10') {
that.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`);
} else {
that.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`);
}
that.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}\n`);
remainTimes = $.helpResult.helpResult.remainTimes;
if ($.helpResult.helpResult.remainTimes === 0) {
that.log(`您当前助力次数已耗尽,跳出助力`);
break
}
} else {
that.log(`助力失败::${JSON.stringify($.helpResult)}`);
}
}
if (helpSuccessPeoples && helpSuccessPeoples.length > 0) {
message += "<font color=\'#778899\' size=2> " + `【您助力的好友👬】${helpSuccessPeoples.substr(0, helpSuccessPeoples.length - 1)}\n` + "</font>\n\n";
}
if (salveHelpAddWater > 0) {
// message += `【助力好友👬】获得${salveHelpAddWater}g💧\n`;
that.log(`【助力好友👬】获得${salveHelpAddWater}g💧\n`);
}
message += "<font color=\'#778899\' size=2>" + `【今日剩余助力👬】${remainTimes}\n` + "</font>\n\n";
that.log('助力好友结束,即将开始领取额外水滴奖励\n');
}
2021-10-26 19:20:52 +08:00
//水滴雨
async function executeWaterRains() {
2021-11-12 23:53:38 +08:00
let executeWaterRain = !$.farmTask.waterRainInit.f;
2021-10-26 19:20:52 +08:00
if (executeWaterRain) {
2021-11-13 02:24:38 +08:00
that.log(`水滴雨任务,每天两次,最多可得10g水滴`);
that.log(`两次水滴雨任务是否全部完成:${$.farmTask.waterRainInit.f ? '是' : '否'}`);
2021-11-12 23:53:38 +08:00
if ($.farmTask.waterRainInit.lastTime) {
if (Date.now() < ($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000)) {
executeWaterRain = false;
// message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`;
2021-11-13 02:24:38 +08:00
that.log(`\`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`);
2021-11-12 23:53:38 +08:00
}
}
if (executeWaterRain) {
2021-11-13 02:24:38 +08:00
that.log(`开始水滴雨任务,这是第${$.farmTask.waterRainInit.winTimes + 1}次,剩余${2 - ($.farmTask.waterRainInit.winTimes + 1)}`);
2021-11-12 23:53:38 +08:00
await waterRainForFarm();
2021-11-13 02:24:38 +08:00
that.log('水滴雨waterRain');
2021-11-12 23:53:38 +08:00
if ($.waterRain.code === '0') {
2021-11-13 02:24:38 +08:00
that.log('水滴雨任务执行成功,获得水滴:' + $.waterRain.addEnergy + 'g');
that.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`);
2021-11-12 23:53:38 +08:00
// message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`;
}
}
} else {
// message += `【水滴雨】已全部完成,获得20g💧\n`;
2021-10-26 19:20:52 +08:00
}
}
//打卡领水活动
async function clockInIn() {
2021-11-13 02:24:38 +08:00
that.log('开始打卡领水活动(签到,关注,领券)');
2021-11-12 23:53:38 +08:00
await clockInInitForFarm();
if ($.clockInInit.code === '0') {
// 签到得水滴
if (!$.clockInInit.todaySigned) {
2021-11-13 02:24:38 +08:00
that.log('开始今日签到');
2021-11-12 23:53:38 +08:00
await clockInForFarm();
2021-11-13 02:24:38 +08:00
that.log(`打卡结果${JSON.stringify($.clockInForFarmRes)}`);
2021-11-12 23:53:38 +08:00
if ($.clockInForFarmRes.code === '0') {
// message += `【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`;
2021-11-13 02:24:38 +08:00
that.log(`【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`)
2021-11-12 23:53:38 +08:00
if ($.clockInForFarmRes.signDay === 7) {
//可以领取惊喜礼包
2021-11-13 02:24:38 +08:00
that.log('开始领取--惊喜礼包38g水滴');
2021-11-12 23:53:38 +08:00
await gotClockInGift();
if ($.gotClockInGiftRes.code === '0') {
// message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`;
2021-11-13 02:24:38 +08:00
that.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`);
2021-11-12 23:53:38 +08:00
}
}
}
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
if ($.clockInInit.todaySigned && $.clockInInit.totalSigned === 7) {
2021-11-13 02:24:38 +08:00
that.log('开始领取--惊喜礼包38g水滴');
2021-11-12 23:53:38 +08:00
await gotClockInGift();
if ($.gotClockInGiftRes.code === '0') {
// message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`;
2021-11-13 02:24:38 +08:00
that.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`);
2021-10-26 19:20:52 +08:00
}
}
2021-11-12 23:53:38 +08:00
// 限时关注得水滴
if ($.clockInInit.themes && $.clockInInit.themes.length > 0) {
for (let item of $.clockInInit.themes) {
if (!item.hadGot) {
2021-11-13 02:24:38 +08:00
that.log(`关注ID${item.id}`);
2021-11-12 23:53:38 +08:00
await clockInFollowForFarm(item.id, "theme", "1");
2021-11-13 02:24:38 +08:00
that.log(`themeStep1--结果${JSON.stringify($.themeStep1)}`);
2021-11-12 23:53:38 +08:00
if ($.themeStep1.code === '0') {
await clockInFollowForFarm(item.id, "theme", "2");
2021-11-13 02:24:38 +08:00
that.log(`themeStep2--结果${JSON.stringify($.themeStep2)}`);
2021-11-12 23:53:38 +08:00
if ($.themeStep2.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`关注${item.name},获得水滴${$.themeStep2.amount}g`);
2021-11-12 23:53:38 +08:00
}
}
}
}
}
// 限时领券得水滴
if ($.clockInInit.venderCoupons && $.clockInInit.venderCoupons.length > 0) {
for (let item of $.clockInInit.venderCoupons) {
if (!item.hadGot) {
2021-11-13 02:24:38 +08:00
that.log(`领券的ID${item.id}`);
2021-11-12 23:53:38 +08:00
await clockInFollowForFarm(item.id, "venderCoupon", "1");
2021-11-13 02:24:38 +08:00
that.log(`venderCouponStep1--结果${JSON.stringify($.venderCouponStep1)}`);
2021-11-12 23:53:38 +08:00
if ($.venderCouponStep1.code === '0') {
await clockInFollowForFarm(item.id, "venderCoupon", "2");
if ($.venderCouponStep2.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`venderCouponStep2--结果${JSON.stringify($.venderCouponStep2)}`);
that.log(`${item.name}领券,获得水滴${$.venderCouponStep2.amount}g`);
2021-11-12 23:53:38 +08:00
}
}
}
2021-10-26 19:20:52 +08:00
}
}
}
2021-11-13 02:24:38 +08:00
that.log('开始打卡领水活动(签到,关注,领券)结束\n');
2021-10-26 19:20:52 +08:00
}
//
async function getAwardInviteFriend() {
2021-11-12 23:53:38 +08:00
await friendListInitForFarm();//查询好友列表
2021-11-13 02:24:38 +08:00
that.log(`查询好友列表数据:\n`)
2021-11-12 23:53:38 +08:00
if ($.friendList) {
2021-11-13 02:24:38 +08:00
that.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}`);
that.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`);
2021-11-12 23:53:38 +08:00
if ($.friendList.friends && $.friendList.friends.length > 0) {
for (let friend of $.friendList.friends) {
2021-11-13 02:24:38 +08:00
that.log(`\n开始删除好友 [${friend.shareCode}]`);
2021-11-12 23:53:38 +08:00
const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`, "version": 8, "channel": 1 });
if (deleteFriendForFarm && deleteFriendForFarm.code === '0') {
2021-11-13 02:24:38 +08:00
that.log(`删除好友 [${friend.shareCode}] 成功\n`);
2021-11-12 23:53:38 +08:00
}
}
}
await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友
if ($.friendList.inviteFriendCount > 0) {
if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) {
2021-11-13 02:24:38 +08:00
that.log('开始领取邀请好友的奖励');
2021-11-12 23:53:38 +08:00
await awardInviteFriendForFarm();
2021-11-13 02:24:38 +08:00
that.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`);
2021-11-12 23:53:38 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log('今日未邀请过好友')
2021-10-26 19:20:52 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`查询好友列表失败\n`);
2021-10-26 19:20:52 +08:00
}
}
//给好友浇水
async function doFriendsWater() {
2021-11-12 23:53:38 +08:00
await friendListInitForFarm();
2021-11-13 02:24:38 +08:00
that.log('开始给好友浇水...');
2021-11-12 23:53:38 +08:00
await taskInitForFarm();
const { waterFriendCountKey, waterFriendMax } = $.farmTask.waterFriendTaskInit;
2021-11-13 02:24:38 +08:00
that.log(`今日已给${waterFriendCountKey}个好友浇水`);
2021-11-12 23:53:38 +08:00
if (waterFriendCountKey < waterFriendMax) {
let needWaterFriends = [];
if ($.friendList.friends && $.friendList.friends.length > 0) {
$.friendList.friends.map((item, index) => {
if (item.friendState === 1) {
if (needWaterFriends.length < (waterFriendMax - waterFriendCountKey)) {
needWaterFriends.push(item.shareCode);
}
}
});
2021-11-13 02:24:38 +08:00
//TODO ,发现bug,github action运行发现有些账号第一次没有给3个好友浇水
that.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`);
2021-11-12 23:53:38 +08:00
let waterFriendsCount = 0, cardInfoStr = '';
for (let index = 0; index < needWaterFriends.length; index++) {
await waterFriendForFarm(needWaterFriends[index]);
2021-11-13 02:24:38 +08:00
that.log(`为第${index + 1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`)
2021-11-12 23:53:38 +08:00
if ($.waterFriendForFarmRes.code === '0') {
waterFriendsCount++;
if ($.waterFriendForFarmRes.cardInfo) {
2021-11-13 02:24:38 +08:00
that.log('为好友浇水获得道具了');
2021-11-12 23:53:38 +08:00
if ($.waterFriendForFarmRes.cardInfo.type === 'beanCard') {
2021-11-13 02:24:38 +08:00
that.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`);
2021-11-12 23:53:38 +08:00
cardInfoStr += `水滴换豆卡,`;
} else if ($.waterFriendForFarmRes.cardInfo.type === 'fastCard') {
2021-11-13 02:24:38 +08:00
that.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`);
2021-11-12 23:53:38 +08:00
cardInfoStr += `快速浇水卡,`;
} else if ($.waterFriendForFarmRes.cardInfo.type === 'doubleCard') {
2021-11-13 02:24:38 +08:00
that.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`);
2021-11-12 23:53:38 +08:00
cardInfoStr += `水滴翻倍卡,`;
} else if ($.waterFriendForFarmRes.cardInfo.type === 'signCard') {
2021-11-13 02:24:38 +08:00
that.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`);
2021-11-12 23:53:38 +08:00
cardInfoStr += `加签卡,`;
}
}
} else if ($.waterFriendForFarmRes.code === '11') {
2021-11-13 02:24:38 +08:00
that.log('水滴不够,跳出浇水')
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
// message += `【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`;
2021-11-13 02:24:38 +08:00
that.log(`【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`);
2021-11-12 23:53:38 +08:00
if (cardInfoStr && cardInfoStr.length > 0) {
// message += `【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`;
2021-11-13 02:24:38 +08:00
that.log(`【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`);
2021-11-12 23:53:38 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log('您的好友列表暂无好友,快去邀请您的好友吧!')
2021-10-26 19:20:52 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`今日已为好友浇水量已达${waterFriendMax}`)
2021-10-26 19:20:52 +08:00
}
}
//领取给3个好友浇水后的奖励水滴
async function getWaterFriendGotAward() {
2021-11-12 23:53:38 +08:00
await taskInitForFarm();
const { waterFriendCountKey, waterFriendMax, waterFriendSendWater, waterFriendGotAward } = $.farmTask.waterFriendTaskInit
if (waterFriendCountKey >= waterFriendMax) {
if (!waterFriendGotAward) {
await waterFriendGotAwardForFarm();
2021-11-13 02:24:38 +08:00
that.log(`领取给${waterFriendMax}个好友浇水后的奖励水滴::${JSON.stringify($.waterFriendGotAwardRes)}`)
2021-11-12 23:53:38 +08:00
if ($.waterFriendGotAwardRes.code === '0') {
// message += `【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`;
2021-11-13 02:24:38 +08:00
that.log(`【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`);
2021-11-12 23:53:38 +08:00
}
} else {
2021-11-13 02:24:38 +08:00
that.log(`给好友浇水的${waterFriendSendWater}g水滴奖励已领取\n`);
2021-11-12 23:53:38 +08:00
// message += `【给${waterFriendMax}好友浇水】奖励${waterFriendSendWater}g水滴已领取\n`;
}
2021-10-26 19:20:52 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log(`暂未给${waterFriendMax}个好友浇水\n`);
2021-10-26 19:20:52 +08:00
}
}
//接收成为对方好友的邀请
async function receiveFriendInvite() {
2021-11-12 23:53:38 +08:00
for (let code of newShareCodes) {
if (code === $.farmInfo.farmUserPro.shareCode) {
2021-11-13 02:24:38 +08:00
that.log('自己不能邀请自己成为好友噢\n')
2021-11-12 23:53:38 +08:00
continue
}
await inviteFriend(code);
2021-11-13 02:24:38 +08:00
// that.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`)
if ($.inviteFriendRes.helpResult.code === '0') {
that.log(`接收邀请成为好友结果成功,您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`)
} else if ($.inviteFriendRes.helpResult.code === '17') {
that.log(`接收邀请成为好友结果失败,对方已是您的好友`)
2021-11-12 23:53:38 +08:00
}
2021-10-26 19:20:52 +08:00
}
2021-11-13 02:24:38 +08:00
// that.log(`开始接受6fbd26cc27ac44d6a7fed34092453f77的邀请\n`)
2021-11-12 23:53:38 +08:00
// await inviteFriend('6fbd26cc27ac44d6a7fed34092453f77');
2021-11-13 02:24:38 +08:00
// that.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`)
2021-11-12 23:53:38 +08:00
// if ($.inviteFriendRes.helpResult.code === '0') {
2021-11-13 02:24:38 +08:00
// that.log(`您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`)
2021-11-12 23:53:38 +08:00
// } else if ($.inviteFriendRes.helpResult.code === '17') {
2021-11-13 02:24:38 +08:00
// that.log(`对方已是您的好友`)
2021-11-12 23:53:38 +08:00
// }
2021-10-26 19:20:52 +08:00
}
async function duck() {
2021-11-12 23:53:38 +08:00
for (let i = 0; i < 10; i++) {
//这里循环十次
await getFullCollectionReward();
if ($.duckRes.code === '0') {
if (!$.duckRes.hasLimit) {
2021-11-13 02:24:38 +08:00
that.log(`小鸭子游戏:${$.duckRes.title}`);
2021-11-12 23:53:38 +08:00
// if ($.duckRes.type !== 3) {
2021-11-13 02:24:38 +08:00
// that.log(`${$.duckRes.title}`);
2021-11-12 23:53:38 +08:00
// if ($.duckRes.type === 1) {
// message += `【小鸭子】为你带回了水滴\n`;
// } else if ($.duckRes.type === 2) {
// message += `【小鸭子】为你带回快速浇水卡\n`
// }
// }
} else {
2021-11-13 02:24:38 +08:00
that.log(`${$.duckRes.title}`)
2021-11-12 23:53:38 +08:00
break;
}
} else if ($.duckRes.code === '10') {
2021-11-13 02:24:38 +08:00
that.log(`小鸭子游戏达到上限`)
2021-11-12 23:53:38 +08:00
break;
}
2021-10-26 19:20:52 +08:00
}
}
// ========================API调用接口========================
//鸭子,点我有惊喜
async function getFullCollectionReward() {
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
const body = { "type": 2, "version": 6, "channel": 2 };
$.post(taskUrl("getFullCollectionReward", body), (err, resp, data) => {
try {
if (err) {
2021-11-13 02:24:38 +08:00
that.log('\n动动农场: API查询请求失败 ‼️‼️');
that.log(JSON.stringify(err));
2021-11-12 23:53:38 +08:00
$.logErr(err);
} else {
if (safeGet(data)) {
$.duckRes = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
})
2021-10-26 19:20:52 +08:00
})
}
/**
* 领取10次浇水奖励API
*/
async function totalWaterTaskForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'totalWaterTaskForFarm';
2021-11-12 23:53:38 +08:00
$.totalWaterReward = await request(functionId);
2021-10-26 19:20:52 +08:00
}
//领取首次浇水奖励API
async function firstWaterTaskForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'firstWaterTaskForFarm';
2021-11-12 23:53:38 +08:00
$.firstWaterReward = await request(functionId);
2021-10-26 19:20:52 +08:00
}
//领取给3个好友浇水后的奖励水滴API
async function waterFriendGotAwardForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'waterFriendGotAwardForFarm';
2021-11-12 23:53:38 +08:00
$.waterFriendGotAwardRes = await request(functionId, { "version": 4, "channel": 1 });
2021-10-26 19:20:52 +08:00
}
// 查询背包道具卡API
async function myCardInfoForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'myCardInfoForFarm';
2021-11-12 23:53:38 +08:00
$.myCardInfoRes = await request(functionId, { "version": 5, "channel": 1 });
2021-10-26 19:20:52 +08:00
}
//使用道具卡API
async function userMyCardForFarm(cardType) {
2021-11-13 02:24:38 +08:00
const functionId = 'userMyCardForFarm';
2021-11-12 23:53:38 +08:00
$.userMyCardRes = await request(functionId, { "cardType": cardType });
2021-10-26 19:20:52 +08:00
}
/**
* 领取浇水过程中的阶段性奖励
* @param type
* @returns {Promise<void>}
*/
async function gotStageAwardForFarm(type) {
2021-11-13 02:24:38 +08:00
$.gotStageAwardForFarmRes = await request('gotStageAwardForFarm', { 'type': type });
2021-10-26 19:20:52 +08:00
}
//浇水API
async function waterGoodForFarm() {
2021-11-12 23:53:38 +08:00
await $.wait(1000);
2021-11-13 02:24:38 +08:00
that.log('等待了1秒');
2021-10-26 19:20:52 +08:00
2021-11-13 02:24:38 +08:00
const functionId = 'waterGoodForFarm';
2021-11-12 23:53:38 +08:00
$.waterResult = await request(functionId);
2021-10-26 19:20:52 +08:00
}
// 初始化集卡抽奖活动数据API
async function initForTurntableFarm() {
2021-11-13 02:24:38 +08:00
$.initForTurntableFarmRes = await request('initForTurntableFarm', { version: 4, channel: 1 });
2021-10-26 19:20:52 +08:00
}
async function lotteryForTurntableFarm() {
2021-11-12 23:53:38 +08:00
await $.wait(2000);
2021-11-13 02:24:38 +08:00
that.log('等待了2秒');
$.lotteryRes = await request('lotteryForTurntableFarm', { type: 1, version: 4, channel: 1 });
2021-10-26 19:20:52 +08:00
}
async function timingAwardForTurntableFarm() {
2021-11-13 02:24:38 +08:00
$.timingAwardRes = await request('timingAwardForTurntableFarm', { version: 4, channel: 1 });
2021-10-26 19:20:52 +08:00
}
async function browserForTurntableFarm(type, adId) {
2021-11-12 23:53:38 +08:00
if (type === 1) {
2021-11-13 02:24:38 +08:00
that.log('浏览爆品会场');
2021-11-12 23:53:38 +08:00
}
if (type === 2) {
2021-11-13 02:24:38 +08:00
that.log('天天抽奖浏览任务领取水滴');
2021-11-12 23:53:38 +08:00
}
const body = { "type": type, "adId": adId, "version": 4, "channel": 1 };
2021-11-13 02:24:38 +08:00
$.browserForTurntableFarmRes = await request('browserForTurntableFarm', body);
2021-11-12 23:53:38 +08:00
// 浏览爆品会场8秒
2021-10-26 19:20:52 +08:00
}
//天天抽奖浏览任务领取水滴API
async function browserForTurntableFarm2(type) {
2021-11-12 23:53:38 +08:00
const body = { "type": 2, "adId": type, "version": 4, "channel": 1 };
$.browserForTurntableFarm2Res = await request('browserForTurntableFarm', body);
2021-10-26 19:20:52 +08:00
}
/**
* 天天抽奖拿好礼-助力API(每人每天三次助力机会)
*/
async function lotteryMasterHelp() {
2021-11-12 23:53:38 +08:00
$.lotteryMasterHelpRes = await request(`initForFarm`, {
imageUrl: "",
nickName: "",
shareCode: arguments[0] + '-3',
babelChannel: "3",
version: 4,
channel: 1
});
2021-10-26 19:20:52 +08:00
}
//领取5人助力后的额外奖励API
async function masterGotFinishedTaskForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'masterGotFinishedTaskForFarm';
2021-11-12 23:53:38 +08:00
$.masterGotFinished = await request(functionId);
2021-10-26 19:20:52 +08:00
}
//助力好友信息API
async function masterHelpTaskInitForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'masterHelpTaskInitForFarm';
2021-11-12 23:53:38 +08:00
$.masterHelpResult = await request(functionId);
2021-10-26 19:20:52 +08:00
}
//接受对方邀请,成为对方好友的API
async function inviteFriend() {
2021-11-12 23:53:38 +08:00
$.inviteFriendRes = await request(`initForFarm`, {
imageUrl: "",
nickName: "",
shareCode: arguments[0] + '-inviteFriend',
version: 4,
channel: 2
});
2021-10-26 19:20:52 +08:00
}
// 助力好友API
async function masterHelp() {
2021-11-12 23:53:38 +08:00
$.helpResult = await request(`initForFarm`, {
imageUrl: "",
nickName: "",
shareCode: arguments[0],
babelChannel: "3",
version: 2,
channel: 1
});
2021-10-26 19:20:52 +08:00
}
/**
* 水滴雨API
*/
async function waterRainForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'waterRainForFarm';
2021-11-12 23:53:38 +08:00
const body = { "type": 1, "hongBaoTimes": 100, "version": 3 };
$.waterRain = await request(functionId, body);
2021-10-26 19:20:52 +08:00
}
/**
* 打卡领水API
*/
async function clockInInitForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'clockInInitForFarm';
2021-11-12 23:53:38 +08:00
$.clockInInit = await request(functionId);
2021-10-26 19:20:52 +08:00
}
// 连续签到API
async function clockInForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'clockInForFarm';
2021-11-12 23:53:38 +08:00
$.clockInForFarmRes = await request(functionId, { "type": 1 });
2021-10-26 19:20:52 +08:00
}
//关注,领券等API
async function clockInFollowForFarm(id, type, step) {
2021-11-13 02:24:38 +08:00
const functionId = 'clockInFollowForFarm';
2021-11-12 23:53:38 +08:00
let body = {
id,
type,
step
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
if (type === 'theme') {
if (step === '1') {
$.themeStep1 = await request(functionId, body);
} else if (step === '2') {
$.themeStep2 = await request(functionId, body);
}
} else if (type === 'venderCoupon') {
if (step === '1') {
$.venderCouponStep1 = await request(functionId, body);
} else if (step === '2') {
$.venderCouponStep2 = await request(functionId, body);
}
2021-10-26 19:20:52 +08:00
}
}
// 领取连续签到7天的惊喜礼包API
async function gotClockInGift() {
2021-11-12 23:53:38 +08:00
$.gotClockInGiftRes = await request('clockInForFarm', { "type": 2 })
2021-10-26 19:20:52 +08:00
}
//定时领水API
async function gotThreeMealForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'gotThreeMealForFarm';
2021-11-12 23:53:38 +08:00
$.threeMeal = await request(functionId);
2021-10-26 19:20:52 +08:00
}
/**
* 浏览广告任务API
* type为0时, 完成浏览任务
* type为1时, 领取浏览任务奖励
*/
async function browseAdTaskForFarm(advertId, type) {
2021-11-13 02:24:38 +08:00
const functionId = 'browseAdTaskForFarm';
2021-11-12 23:53:38 +08:00
if (type === 0) {
$.browseResult = await request(functionId, { advertId, type });
} else if (type === 1) {
$.browseRwardResult = await request(functionId, { advertId, type });
}
2021-10-26 19:20:52 +08:00
}
// 被水滴砸中API
async function gotWaterGoalTaskForFarm() {
2021-11-13 02:24:38 +08:00
$.goalResult = await request('gotWaterGoalTaskForFarm', { type: 3 });
2021-10-26 19:20:52 +08:00
}
//签到API
async function signForFarm() {
2021-11-13 02:24:38 +08:00
const functionId = 'signForFarm';
2021-11-12 23:53:38 +08:00
$.signResult = await request(functionId);
2021-10-26 19:20:52 +08:00
}
/**
* 初始化农场, 可获取果树及用户信息API
*/
async function initForFarm() {
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
const option = {
url: `${JD_API_HOST}?functionId=initForFarm`,
body: `body=${escape(JSON.stringify({ "version": 4 }))}&appid=wh5&clientVersion=9.1.0`,
headers: {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"cookie": cookie,
"origin": "https://home.m.jd.com",
"pragma": "no-cache",
"referer": "https://home.m.jd.com/myJd/newhome.action",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
2021-11-13 02:24:38 +08:00
"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"),
2021-11-12 23:53:38 +08:00
"Content-Type": "application/x-www-form-urlencoded"
},
timeout: 10000,
};
$.post(option, (err, resp, data) => {
try {
if (err) {
2021-11-13 02:24:38 +08:00
that.log('\n动动农场: API查询请求失败 ‼️‼️');
that.log(JSON.stringify(err));
2021-11-12 23:53:38 +08:00
$.logErr(err);
} else {
if (safeGet(data)) {
$.farmInfo = JSON.parse(data)
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
})
2021-10-26 19:20:52 +08:00
})
}
// 初始化任务列表API
async function taskInitForFarm() {
2021-11-13 02:24:38 +08:00
that.log('\n初始化任务列表')
const functionId = 'taskInitForFarm';
$.farmTask = await request(functionId);
2021-10-26 19:20:52 +08:00
}
//获取好友列表API
async function friendListInitForFarm() {
2021-11-12 23:53:38 +08:00
$.friendList = await request('friendListInitForFarm', { "version": 4, "channel": 1 });
2021-11-13 02:24:38 +08:00
// that.log('aa', aa);
2021-10-26 19:20:52 +08:00
}
// 领取邀请好友的奖励API
async function awardInviteFriendForFarm() {
2021-11-12 23:53:38 +08:00
$.awardInviteFriendRes = await request('awardInviteFriendForFarm');
2021-10-26 19:20:52 +08:00
}
//为好友浇水API
async function waterFriendForFarm(shareCode) {
2021-11-12 23:53:38 +08:00
const body = { "shareCode": shareCode, "version": 6, "channel": 1 }
$.waterFriendForFarmRes = await request('waterFriendForFarm', body);
2021-10-26 19:20:52 +08:00
}
async function showMsg() {
2021-11-13 02:24:38 +08:00
let ctrTemp;
2021-11-12 23:53:38 +08:00
if ($.isNode() && process.env.FRUIT_NOTIFY_CONTROL) {
2021-11-13 02:24:38 +08:00
ctrTemp = `${process.env.FRUIT_NOTIFY_CONTROL}` === 'false';
2021-11-12 23:53:38 +08:00
} else if ($.getdata('jdFruitNotify')) {
2021-11-13 02:24:38 +08:00
ctrTemp = $.getdata('jdFruitNotify') === 'false';
2021-11-12 23:53:38 +08:00
} else {
2021-11-13 02:24:38 +08:00
ctrTemp = `${jdNotify}` === 'false';
2021-11-12 23:53:38 +08:00
}
2021-11-13 02:24:38 +08:00
if (ctrTemp) {
2021-11-12 23:53:38 +08:00
$.msg($.name, subTitle, message, option);
if ($.isNode()) {
2021-11-13 02:24:38 +08:00
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`);
2021-11-12 23:53:38 +08:00
}
} else {
$.log(`\n${message}\n`);
2021-10-26 19:20:52 +08:00
}
}
function timeFormat(time) {
2021-11-12 23:53:38 +08:00
let date;
if (time) {
date = new Date(time)
} else {
date = new Date();
}
return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate());
2021-10-26 19:20:52 +08:00
}
function readShareCode() {
2021-11-12 23:53:38 +08:00
return new Promise(async resolve => {
2021-11-13 02:24:38 +08:00
$.get({ url: `http://jd.turinglabs.net/api/v2/jd/farm/read/${randomCount}/`, timeout: 10000, }, (err, resp, data) => {
2021-11-12 23:53:38 +08:00
try {
if (err) {
2021-11-13 02:24:38 +08:00
that.log(`${JSON.stringify(err)}`)
that.log(`${$.name} API请求失败,请检查网路重试`)
2021-11-12 23:53:38 +08:00
} else {
if (data) {
2021-11-13 02:24:38 +08:00
that.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`)
2021-11-12 23:53:38 +08:00
data = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
await $.wait(10000);
resolve()
2021-10-26 19:20:52 +08:00
})
}
2021-11-13 14:44:52 +08:00
2021-10-26 19:20:52 +08:00
function requireConfig() {
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
2021-11-13 02:24:38 +08:00
that.log('开始获取配置文件\n')
2021-11-12 23:53:38 +08:00
notify = $.isNode() ? require('./sendNotify') : '';
2021-11-13 02:24:38 +08:00
//Node.js用户请在jdCookie.js处填写动动ck;
2021-11-12 23:53:38 +08:00
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
const jdFruitShareCodes = $.isNode() ? require('./jdFruitShareCodes.js') : '';
//IOS等用户直接用NobyDa的jd cookie
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
if (jdCookieNode[item]) {
cookiesArr.push(jdCookieNode[item])
}
})
2021-11-13 02:24:38 +08:00
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => { };
2021-11-12 23:53:38 +08:00
} else {
2021-11-13 02:24:38 +08:00
let cookiesData = $.getdata('CookiesJD') || "[]";
cookiesData = jsonParse(cookiesData);
cookiesArr = cookiesData.map(item => item.cookie);
cookiesArr.reverse();
cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]);
cookiesArr.reverse();
cookiesArr = cookiesArr.filter(item => item !== "" && item !== null && item !== undefined);
2021-10-26 19:20:52 +08:00
}
2021-11-13 02:24:38 +08:00
that.log(`${cookiesArr.length}个动动账号\n`)
2021-11-12 23:53:38 +08:00
resolve()
})
2021-10-26 19:20:52 +08:00
}
function TotalBean() {
2021-11-12 23:53:38 +08:00
return new Promise(async resolve => {
const options = {
"url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`,
"headers": {
"Accept": "application/json,text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-cn",
"Connection": "keep-alive",
"Cookie": cookie,
"Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
2021-11-13 02:24:38 +08:00
"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,
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
$.post(options, (err, resp, data) => {
try {
if (err) {
2021-11-13 02:24:38 +08:00
that.log(`${JSON.stringify(err)}`)
that.log(`${$.name} API请求失败,请检查网路重试`)
2021-11-12 23:53:38 +08:00
} else {
if (data) {
data = JSON.parse(data);
if (data['retcode'] === 13) {
$.isLogin = false; //cookie过期
return
}
2021-11-13 02:24:38 +08:00
//$.nickName = data['base'].nickname;
2021-11-12 23:53:38 +08:00
} else {
2021-11-13 02:24:38 +08:00
that.log(`动动服务器返回空数据`)
2021-11-12 23:53:38 +08:00
}
}
} catch (e) {
2021-11-13 02:24:38 +08:00
$.logErr(e, resp)
2021-11-12 23:53:38 +08:00
} finally {
resolve();
}
})
2021-10-26 19:20:52 +08:00
})
}
2021-11-09 14:13:03 +08:00
function request(function_id, body = {}, timeout = 1000) {
2021-11-12 23:53:38 +08:00
return new Promise(resolve => {
setTimeout(() => {
$.get(taskUrl(function_id, body), (err, resp, data) => {
try {
if (err) {
2021-11-13 02:24:38 +08:00
that.log('\n动动农场: API查询请求失败 ‼️‼️')
that.log(JSON.stringify(err));
that.log(`function_id:${function_id}`)
2021-11-12 23:53:38 +08:00
$.logErr(err);
} else {
if (safeGet(data)) {
data = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve(data);
}
})
}, timeout)
})
2021-10-26 19:20:52 +08:00
}
function safeGet(data) {
2021-11-12 23:53:38 +08:00
try {
if (typeof JSON.parse(data) == "object") {
return true;
}
} catch (e) {
2021-11-13 02:24:38 +08:00
that.log(e);
that.log(`动动服务器访问数据为空,请检查自身设备网络情况`);
2021-11-12 23:53:38 +08:00
return false;
2021-10-26 19:20:52 +08:00
}
}
function taskUrl(function_id, body = {}) {
2021-11-12 23:53:38 +08:00
return {
url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&body=${escape(JSON.stringify(body))}`,
headers: {
Cookie: cookie,
2021-11-13 02:24:38 +08:00
UserAgent: $.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"),
2021-11-12 23:53:38 +08:00
},
timeout: 10000,
}
2021-10-26 19:20:52 +08:00
}
function jsonParse(str) {
2021-11-12 23:53:38 +08:00
if (typeof str == "string") {
try {
return JSON.parse(str);
} catch (e) {
2021-11-13 02:24:38 +08:00
that.log(e);
2021-11-12 23:53:38 +08:00
$.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
return [];
}
2021-10-26 19:20:52 +08:00
}
}
2021-11-12 23:53:38 +08:00
2021-10-26 19:20:52 +08:00
2021-11-13 01:41:22 +08:00
2021-10-26 19:20:52 +08:00
//我加的函数
function postToDingTalk(messgae) {
2021-11-12 23:53:38 +08:00
const message1 = "" + messgae
that.log(messgae)
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
const body = {
"msgtype": "markdown",
"markdown": {
"title": "动动农场",
"text": message1
},
"at": {
"atMobiles": [],
"isAtAll": false
}
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
$.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => {
try {
that.log(resp)
that.log(data)
if (err) {
that.log(JSON.stringify(err));
$.logErr(err);
} else {
if (safeGet(data)) {
$.duckRes = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
2021-10-26 19:20:52 +08:00
}
2021-11-12 23:53:38 +08:00
}, "json")
2021-10-26 19:20:52 +08:00
}
function toDingtalk(urlmain, bodyMain) {
2021-11-12 23:53:38 +08:00
return {
url: urlmain,
body: bodyMain,
headers: { 'Content-Type': 'application/json;charset=utf-8' },
timeout: 10000,
}
2021-10-26 19:20:52 +08:00
}
2021-11-09 14:13:03 +08:00
function getPic() {
2021-11-12 23:53:38 +08:00
let code = ["1.gif", "2.png", "3.png", "4.png", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.png", "11.png"]
let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/"
pos = parseInt(11 * Math.random())
address = address + code[pos] + ")"
return address
}
function postToDingTalk2(messgae) {
const message1 = "" + messgae
// that.log(messgae)
2021-10-26 19:20:52 +08:00
2021-11-12 23:53:38 +08:00
const body = {
"msgtype": "markdown",
"markdown": {
"title": "水果领取",
"text": "水果领取\n\n" + message1
},
"at": {
"atMobiles": [],
"isAtAll": true
}
}
$.post(toDingtalk(dingtalk2, JSON.stringify(body)), (data, status, xhr) => {
try {
that.log(resp)
that.log(data)
if (err) {
that.log(JSON.stringify(err));
$.logErr(err);
} else {
if (safeGet(data)) {
$.duckRes = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
}, "json")
2021-10-26 19:20:52 +08:00
}