From 66ae1c4e8b9ed27363786ab7fcac2759f1163cf3 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sun, 26 Dec 2021 09:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A4=A9=E4=BD=BF=E5=8A=A8?= =?UTF-8?q?=E6=BC=AB=E7=AD=BE=E5=88=B0=E6=97=B6=E9=97=B4=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=A4=A7=E5=A4=B4=E8=8F=9C=E4=B8=8D=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=B8=8A=E5=91=A8=E8=B6=8B=E5=8A=BF=E7=9A=84BUG=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=B1=87=E6=8A=A5=E5=A4=A7=E5=A4=B4=E8=8F=9C=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=97=B6=E5=8A=A0=E5=85=A5=E7=BD=91=E9=A1=B5=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qqbot/models/Animal/TurnipProphet.java | 73 ++++++++++--------- .../com/yutou/qqbot/models/WebSign/Tsdm.java | 2 +- 2 files changed, 41 insertions(+), 34 deletions(-) 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();