|
8 | 8 |
|
9 | 9 | import java.util.HashSet; |
10 | 10 | import java.util.Set; |
| 11 | +import java.util.Iterator; |
| 12 | +import java.util.ArrayList; |
| 13 | +import java.util.List; |
11 | 14 |
|
12 | 15 | public class AntFarm { |
13 | 16 | private static final String TAG = AntFarm.class.getCanonicalName(); |
@@ -95,9 +98,24 @@ private static class FarmTool { |
95 | 98 |
|
96 | 99 | private static FarmTool[] farmTools; |
97 | 100 |
|
| 101 | + private static final List<String> bizKeyList; |
| 102 | + |
| 103 | + static { |
| 104 | + bizKeyList = new ArrayList<>(); |
| 105 | + bizKeyList.add("ADD_GONGGE_NEW"); |
| 106 | + bizKeyList.add("USER_STARVE_PUSH"); |
| 107 | + bizKeyList.add("HIRE_LOW_ACTIVITY"); |
| 108 | + bizKeyList.add("HEART_DONATION_ADVANCED_FOOD_V2"); |
| 109 | + bizKeyList.add("YEB_PURCHASE"); |
| 110 | + bizKeyList.add("ONLINE_PAY"); |
| 111 | + bizKeyList.add("DIANTAOHUANDUAN"); |
| 112 | + } |
| 113 | + |
98 | 114 | public static void start() { |
99 | 115 | if (!Config.enableFarm()) |
100 | 116 | return; |
| 117 | + |
| 118 | + PluginUtils.invoke(AntFarm.class, PluginUtils.PluginAction.START); |
101 | 119 | new Thread() { |
102 | 120 |
|
103 | 121 | @Override |
@@ -220,6 +238,10 @@ public void run() { |
220 | 238 | cook(userId); |
221 | 239 | } |
222 | 240 |
|
| 241 | + if (Config.chickenDiary()) { |
| 242 | + queryChickenDiaryList(); |
| 243 | + } |
| 244 | + |
223 | 245 | if (Config.useNewEggTool()) { |
224 | 246 | useFarmTool(ownerFarmId, ToolType.NEWEGGTOOL); |
225 | 247 | syncAnimalStatus(ownerFarmId); |
@@ -282,6 +304,8 @@ public void run() { |
282 | 304 | } |
283 | 305 | } |
284 | 306 |
|
| 307 | + PluginUtils.invoke(AntFarm.class, PluginUtils.PluginAction.STOP); |
| 308 | + |
285 | 309 | } catch (Throwable t) { |
286 | 310 | Log.i(TAG, "AntFarm.start.run err:"); |
287 | 311 | Log.printStackTrace(TAG, t); |
@@ -687,42 +711,39 @@ private static void doFarmDailyTask() { |
687 | 711 | for (int i = 0; i < jaFarmTaskList.length(); i++) { |
688 | 712 | jo = jaFarmTaskList.getJSONObject(i); |
689 | 713 | String title = null; |
690 | | - String taskId = null; |
691 | | - int awardCount = 0; |
692 | | - if (!jo.has("taskMode")) |
693 | | - continue; |
694 | 714 | if (jo.has("title")) |
695 | 715 | title = jo.getString("title"); |
696 | | - if ("VIEW".equals(jo.getString("taskMode")) && "TODO".equals(jo.getString("taskStatus"))) { |
697 | | - taskId = jo.getString("taskId"); |
698 | | - awardCount = jo.getInt("awardCount"); |
699 | | - jo = new JSONObject(AntFarmRpcCall.doFarmTask(taskId)); |
700 | | - if ("SUCCESS".equals(jo.getString("memo"))) { |
701 | | - Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g"); |
702 | | - } else { |
703 | | - Log.recordLog(jo.getString("memo"), jo.toString()); |
704 | | - } |
705 | | - } else if ("庄园小视频".equals(title) && "TODO".equals(jo.getString("taskStatus"))) { |
706 | | - awardCount = jo.getInt("awardCount"); |
707 | | - jo = new JSONObject(AntFarmRpcCall.queryTabVideoUrl()); |
708 | | - if ("SUCCESS".equals(jo.getString("memo"))) { |
709 | | - String videoUrl = jo.getString("videoUrl"); |
710 | | - String contentId = videoUrl.substring(videoUrl.indexOf("&contentId=") + 1, |
711 | | - videoUrl.indexOf("&refer")); |
712 | | - jo = new JSONObject(AntFarmRpcCall.videoDeliverModule(contentId)); |
713 | | - if (jo.getBoolean("success")) { |
714 | | - Thread.sleep(15100); |
715 | | - jo = new JSONObject(AntFarmRpcCall.videoTrigger(contentId)); |
| 716 | + if ("TODO".equals(jo.getString("taskStatus"))) { |
| 717 | + int awardCount = jo.optInt("awardCount"); |
| 718 | + String bizKey = jo.getString("bizKey"); |
| 719 | + if ("VIEW".equals(jo.optString("taskMode")) || bizKeyList.contains(bizKey)) { |
| 720 | + jo = new JSONObject(AntFarmRpcCall.doFarmTask(bizKey)); |
| 721 | + if ("SUCCESS".equals(jo.getString("memo"))) { |
| 722 | + Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g"); |
| 723 | + } else { |
| 724 | + Log.recordLog(jo.getString("memo"), jo.toString()); |
| 725 | + } |
| 726 | + } else if ("庄园小视频".equals(title)) { |
| 727 | + jo = new JSONObject(AntFarmRpcCall.queryTabVideoUrl()); |
| 728 | + if ("SUCCESS".equals(jo.getString("memo"))) { |
| 729 | + String videoUrl = jo.getString("videoUrl"); |
| 730 | + String contentId = videoUrl.substring(videoUrl.indexOf("&contentId=") + 1, |
| 731 | + videoUrl.indexOf("&refer")); |
| 732 | + jo = new JSONObject(AntFarmRpcCall.videoDeliverModule(contentId)); |
716 | 733 | if (jo.getBoolean("success")) { |
717 | | - Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g"); |
| 734 | + Thread.sleep(15100); |
| 735 | + jo = new JSONObject(AntFarmRpcCall.videoTrigger(contentId)); |
| 736 | + if (jo.getBoolean("success")) { |
| 737 | + Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g"); |
| 738 | + } else { |
| 739 | + Log.recordLog(jo.getString("resultMsg"), jo.toString()); |
| 740 | + } |
718 | 741 | } else { |
719 | 742 | Log.recordLog(jo.getString("resultMsg"), jo.toString()); |
720 | 743 | } |
721 | 744 | } else { |
722 | | - Log.recordLog(jo.getString("resultMsg"), jo.toString()); |
| 745 | + Log.recordLog(jo.getString("memo"), jo.toString()); |
723 | 746 | } |
724 | | - } else { |
725 | | - Log.recordLog(jo.getString("memo"), jo.toString()); |
726 | 747 | } |
727 | 748 | } |
728 | 749 | } |
@@ -1366,4 +1387,60 @@ private static void acceptGift() { |
1366 | 1387 | } |
1367 | 1388 | } |
1368 | 1389 |
|
| 1390 | + private static void queryChickenDiary(String queryDayStr) { |
| 1391 | + try { |
| 1392 | + JSONObject jo = new JSONObject(AntFarmRpcCall.queryChickenDiary(queryDayStr)); |
| 1393 | + if ("SUCCESS".equals(jo.getString("resultCode"))) { |
| 1394 | + JSONObject chickenDiary = jo.getJSONObject("data").getJSONObject("chickenDiary"); |
| 1395 | + String diaryDateStr = chickenDiary.getString("diaryDateStr"); |
| 1396 | + if (!chickenDiary.has("tietieStatus")) |
| 1397 | + return; |
| 1398 | + JSONObject tietieStatus = chickenDiary.getJSONObject("tietieStatus"); |
| 1399 | + Iterator it = tietieStatus.keys(); |
| 1400 | + while (it.hasNext()) { |
| 1401 | + String key = (String) it.next(); |
| 1402 | + if (tietieStatus.optBoolean(key, false)) { |
| 1403 | + jo = new JSONObject(AntFarmRpcCall.diaryTietie(diaryDateStr, key)); |
| 1404 | + if ("SUCCESS".equals(jo.getString("memo"))) { |
| 1405 | + String prizeType = jo.getString("prizeType"); |
| 1406 | + int prizeNum = jo.optInt("prizeNum", 0); |
| 1407 | + Log.farm("贴贴小鸡💞[" + prizeType + "*" + prizeNum + "]"); |
| 1408 | + } else { |
| 1409 | + Log.i(jo.getString("memo"), jo.toString()); |
| 1410 | + } |
| 1411 | + } |
| 1412 | + } |
| 1413 | + } else { |
| 1414 | + Log.i(jo.getString("resultDesc"), jo.toString()); |
| 1415 | + } |
| 1416 | + } catch (Throwable t) { |
| 1417 | + Log.i(TAG, "queryChickenDiary err:"); |
| 1418 | + Log.printStackTrace(TAG, t); |
| 1419 | + } |
| 1420 | + } |
| 1421 | + |
| 1422 | + private static void queryChickenDiaryList() { |
| 1423 | + try { |
| 1424 | + JSONObject jo = new JSONObject(AntFarmRpcCall.queryChickenDiaryList()); |
| 1425 | + if ("SUCCESS".equals(jo.getString("resultCode"))) { |
| 1426 | + JSONArray chickenDiaryBriefList = jo.getJSONObject("data").optJSONArray("chickenDiaryBriefList"); |
| 1427 | + if (chickenDiaryBriefList != null && chickenDiaryBriefList.length() > 0) { |
| 1428 | + for (int i = 0; i < chickenDiaryBriefList.length(); i++) { |
| 1429 | + jo = chickenDiaryBriefList.getJSONObject(i); |
| 1430 | + if (!jo.optBoolean("read", true)) { |
| 1431 | + String dateStr = jo.getString("dateStr"); |
| 1432 | + queryChickenDiary(dateStr); |
| 1433 | + Thread.sleep(300); |
| 1434 | + } |
| 1435 | + } |
| 1436 | + } |
| 1437 | + } else { |
| 1438 | + Log.i(jo.getString("resultDesc"), jo.toString()); |
| 1439 | + } |
| 1440 | + } catch (Throwable t) { |
| 1441 | + Log.i(TAG, "queryChickenDiaryList err:"); |
| 1442 | + Log.printStackTrace(TAG, t); |
| 1443 | + } |
| 1444 | + } |
| 1445 | + |
1369 | 1446 | } |
0 commit comments