diff --git a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java index 4f38acf..1886d82 100644 --- a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java +++ b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java @@ -40,7 +40,7 @@ public class TurnipProphet extends Model { } - static int nowTime=-1; + static int nowTime = -1; @Override public boolean isUserPublic() { @@ -113,9 +113,12 @@ public class TurnipProphet extends Model { String pattern = null; JSONObject json; JSONArray array; - if (StringUtils.isEmpty(data)||getDay()==0) { + if (StringUtils.isEmpty(data) || getDay() == 0) { array = new JSONArray(); json = new JSONObject(); + if (getDay() == 0 && !StringUtils.isEmpty(data)) { + json = JSONObject.parseObject(data); + } array.add(-1); array.add(-1); array.add(-1); @@ -145,19 +148,21 @@ public class TurnipProphet extends Model { } if (getDay() == 0) { if (json.containsKey("pattern")) { - json.put("old_pattern", json.getString("pattern")); - pattern = json.getString("pattern"); - } - if (money >= 90 && money <= 110) { - array.set(0, money); - } - } else { - if (money >= 9 && money <= 660) { - if (getTime() < 12) { - array.set(getDay() * 2 - 1, money); + if (!json.containsKey("tmp_pattern")) { + json.put("old_pattern", json.getString("pattern")); + pattern = json.getString("pattern"); } else { - array.set(getDay() * 2, money); + pattern = json.getString("old_pattern"); } + json.put("tmp_pattern", json.getString("pattern")); + } + array.set(0, money); + } else { + json.remove("tmp_pattern"); + if (getTime() < 12) { + array.set(getDay() * 2 - 1, money); + } else { + array.set(getDay() * 2, money); } } json.put("turnip", array); @@ -184,8 +189,8 @@ public class TurnipProphet extends Model { QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势..."); Map map = openTurnip(prices, pattern); - if(map==null){ - map=openTurnip(prices,pattern); + if (map == null) { + map = openTurnip(prices, pattern); } String tmp_pattern = sendQQ(map, prices, pattern, qq); if (!StringUtils.isEmpty(tmp_pattern)) { @@ -202,11 +207,11 @@ public class TurnipProphet extends Model { } private String sendQQ(Map map, String prices, String pattern, long qq) { + String url = String.format("https://turnipprophet.io?prices=%s%s", + prices, + pattern == null ? "" : "&pattern=" + pattern + ); if (map == null) { - String url = String.format("https://turnipprophet.io?prices=%s%s", - prices, - pattern == null ? "" : "&pattern=" + pattern - ); QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览:\n" + url); return null; } @@ -243,6 +248,7 @@ public class TurnipProphet extends Model { out.append(tmp.getString(TurnipData.MODEL)).append(":").append(tmp.getString(TurnipData.PR)).append("\n"); } out.append("------------").append("\n"); + out.append("网页版:").append("\n").append(url).append("\n"); out.append("祝好运 :)"); Log.i("TurnipProphet", out.toString()); @@ -255,9 +261,10 @@ public class TurnipProphet extends Model { super.onTime(time); nowTime = Integer.parseInt(time.split(":")[0]); } - public int getTime(){ - if(nowTime==-1){ - nowTime=Integer.parseInt(AppTools.getHours()); + + public int getTime() { + if (nowTime == -1) { + nowTime = Integer.parseInt(AppTools.getHours()); } return nowTime; } @@ -280,7 +287,7 @@ public class TurnipProphet extends Model { ); System.out.println("url = " + url); LinkedHashMap map = new LinkedHashMap<>(); - WebDriver driver =WebClient.getInstance().getWebDriver(); + WebDriver driver = WebClient.getInstance().getWebDriver(); driver.get(url); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); @@ -330,20 +337,20 @@ public class TurnipProphet extends Model { } } } - int maxMoney=0; - String maxDay=null; + int maxMoney = 0; + String maxDay = null; for (String key : map.keySet()) { - if(map.get(key).contains("~")){ + if (map.get(key).contains("~")) { for (String s : map.get(key).split("~")) { - if(Integer.parseInt(s)>maxMoney){ - maxMoney=Integer.parseInt(s); - maxDay=key; + if (Integer.parseInt(s) > maxMoney) { + maxMoney = Integer.parseInt(s); + maxDay = key; } } - }else{ - if(Integer.parseInt(map.get(key))>maxMoney){ - maxMoney=Integer.parseInt(map.get(key)); - maxDay=key; + } else { + if (Integer.parseInt(map.get(key)) > maxMoney) { + maxMoney = Integer.parseInt(map.get(key)); + maxDay = key; } } } diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java index 606220c..0c4c93e 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java @@ -40,7 +40,7 @@ public class Tsdm extends Model { @Override public void onTime(String time) { super.onTime(time); - if ("08:00:00".equals(time)) { + if ("08:05:00".equals(time)) { Log.i("开始天使动漫签到"); try { tsdmSign();