调整天使动漫签到时间

修复大头菜不记录上周趋势的BUG
调整汇报大头菜结果时加入网页地址
This commit is contained in:
Yutousama 2021-12-26 09:08:54 +08:00
parent e0751972a3
commit 66ae1c4e8b
2 changed files with 41 additions and 34 deletions

View File

@ -40,7 +40,7 @@ public class TurnipProphet extends Model {
} }
static int nowTime=-1; static int nowTime = -1;
@Override @Override
public boolean isUserPublic() { public boolean isUserPublic() {
@ -113,9 +113,12 @@ public class TurnipProphet extends Model {
String pattern = null; String pattern = null;
JSONObject json; JSONObject json;
JSONArray array; JSONArray array;
if (StringUtils.isEmpty(data)||getDay()==0) { if (StringUtils.isEmpty(data) || getDay() == 0) {
array = new JSONArray(); array = new JSONArray();
json = new JSONObject(); json = new JSONObject();
if (getDay() == 0 && !StringUtils.isEmpty(data)) {
json = JSONObject.parseObject(data);
}
array.add(-1); array.add(-1);
array.add(-1); array.add(-1);
array.add(-1); array.add(-1);
@ -145,19 +148,21 @@ public class TurnipProphet extends Model {
} }
if (getDay() == 0) { if (getDay() == 0) {
if (json.containsKey("pattern")) { if (json.containsKey("pattern")) {
json.put("old_pattern", json.getString("pattern")); if (!json.containsKey("tmp_pattern")) {
pattern = json.getString("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);
} else { } 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); json.put("turnip", array);
@ -184,8 +189,8 @@ public class TurnipProphet extends Model {
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势..."); QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
Map<String, String> map = openTurnip(prices, pattern); Map<String, String> map = openTurnip(prices, pattern);
if(map==null){ if (map == null) {
map=openTurnip(prices,pattern); map = openTurnip(prices, pattern);
} }
String tmp_pattern = sendQQ(map, prices, pattern, qq); String tmp_pattern = sendQQ(map, prices, pattern, qq);
if (!StringUtils.isEmpty(tmp_pattern)) { if (!StringUtils.isEmpty(tmp_pattern)) {
@ -202,11 +207,11 @@ public class TurnipProphet extends Model {
} }
private String sendQQ(Map<String, String> map, String prices, String pattern, long qq) { private String sendQQ(Map<String, String> 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) { 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); QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览\n" + url);
return null; 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(tmp.getString(TurnipData.MODEL)).append(":").append(tmp.getString(TurnipData.PR)).append("\n");
} }
out.append("------------").append("\n"); out.append("------------").append("\n");
out.append("网页版:").append("\n").append(url).append("\n");
out.append("祝好运 :)"); out.append("祝好运 :)");
Log.i("TurnipProphet", out.toString()); Log.i("TurnipProphet", out.toString());
@ -255,9 +261,10 @@ public class TurnipProphet extends Model {
super.onTime(time); super.onTime(time);
nowTime = Integer.parseInt(time.split(":")[0]); nowTime = Integer.parseInt(time.split(":")[0]);
} }
public int getTime(){
if(nowTime==-1){ public int getTime() {
nowTime=Integer.parseInt(AppTools.getHours()); if (nowTime == -1) {
nowTime = Integer.parseInt(AppTools.getHours());
} }
return nowTime; return nowTime;
} }
@ -280,7 +287,7 @@ public class TurnipProphet extends Model {
); );
System.out.println("url = " + url); System.out.println("url = " + url);
LinkedHashMap<String, String> map = new LinkedHashMap<>(); LinkedHashMap<String, String> map = new LinkedHashMap<>();
WebDriver driver =WebClient.getInstance().getWebDriver(); WebDriver driver = WebClient.getInstance().getWebDriver();
driver.get(url); driver.get(url);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
@ -330,20 +337,20 @@ public class TurnipProphet extends Model {
} }
} }
} }
int maxMoney=0; int maxMoney = 0;
String maxDay=null; String maxDay = null;
for (String key : map.keySet()) { for (String key : map.keySet()) {
if(map.get(key).contains("~")){ if (map.get(key).contains("~")) {
for (String s : map.get(key).split("~")) { for (String s : map.get(key).split("~")) {
if(Integer.parseInt(s)>maxMoney){ if (Integer.parseInt(s) > maxMoney) {
maxMoney=Integer.parseInt(s); maxMoney = Integer.parseInt(s);
maxDay=key; maxDay = key;
} }
} }
}else{ } else {
if(Integer.parseInt(map.get(key))>maxMoney){ if (Integer.parseInt(map.get(key)) > maxMoney) {
maxMoney=Integer.parseInt(map.get(key)); maxMoney = Integer.parseInt(map.get(key));
maxDay=key; maxDay = key;
} }
} }
} }

View File

@ -40,7 +40,7 @@ public class Tsdm extends Model {
@Override @Override
public void onTime(String time) { public void onTime(String time) {
super.onTime(time); super.onTime(time);
if ("08:00:00".equals(time)) { if ("08:05:00".equals(time)) {
Log.i("开始天使动漫签到"); Log.i("开始天使动漫签到");
try { try {
tsdmSign(); tsdmSign();