新增手动签到
新增百合会签到 优化天使动漫签到 优化大头菜统计最高价日 修复大头菜第二周数据未清空 新增大头菜显示购入价功能
This commit is contained in:
@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.Log;
|
||||
import com.yutou.qqbot.utlis.RedisTools;
|
||||
import com.yutou.qqbot.utlis.StringUtils;
|
||||
import com.yutou.qqbot.utlis.WebClient;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
import net.mamoe.mirai.event.events.MessageEvent;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
@@ -43,7 +40,7 @@ public class TurnipProphet extends Model {
|
||||
|
||||
}
|
||||
|
||||
static int nowTime;
|
||||
static int nowTime=-1;
|
||||
|
||||
@Override
|
||||
public boolean isUserPublic() {
|
||||
@@ -156,9 +153,7 @@ public class TurnipProphet extends Model {
|
||||
}
|
||||
} else {
|
||||
if (money >= 9 && money <= 660) {
|
||||
System.out.println("array = " + array);
|
||||
System.out.println("array.size() = " + array.size());
|
||||
if (nowTime < 12) {
|
||||
if (getTime() < 12) {
|
||||
array.set(getDay() * 2 - 1, money);
|
||||
} else {
|
||||
array.set(getDay() * 2, money);
|
||||
@@ -189,7 +184,9 @@ public class TurnipProphet extends Model {
|
||||
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
|
||||
|
||||
Map<String, String> map = openTurnip(prices, pattern);
|
||||
|
||||
if(map==null){
|
||||
map=openTurnip(prices,pattern);
|
||||
}
|
||||
String tmp_pattern = sendQQ(map, prices, pattern, qq);
|
||||
if (!StringUtils.isEmpty(tmp_pattern)) {
|
||||
json.put("pattern", tmp_pattern);
|
||||
@@ -197,21 +194,20 @@ public class TurnipProphet extends Model {
|
||||
RedisTools.set(redisKey, json.toJSONString());
|
||||
|
||||
} catch (Exception e) {
|
||||
setData(money, qq);
|
||||
e.printStackTrace();
|
||||
setData(money, qq);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String sendQQ(Map<String, String> map, String prices, String pattern, long qq) {
|
||||
|
||||
if (map == null) {
|
||||
String url = String.format("https://turnipprophet.io?prices=%s%s",
|
||||
prices,
|
||||
pattern == null ? "" : "&pattern=" + pattern
|
||||
);
|
||||
QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览:" + url);
|
||||
QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览:\n" + url);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -221,7 +217,7 @@ public class TurnipProphet extends Model {
|
||||
out.append("预测结果如下:\n");
|
||||
out.append(TurnipData.MODEL).append(prArray.getJSONObject(0).getString(TurnipData.MODEL)).append("\n");
|
||||
out.append(TurnipData.PR).append(prArray.getJSONObject(0).getString(TurnipData.PR)).append("\n");
|
||||
|
||||
out.append("购入价:").append(prices.split("\\.")[0]).append("\n");
|
||||
out.append(TurnipData.MIX).append(map.get(TurnipData.MIX)).append("\n")
|
||||
.append(TurnipData.MAX).append(map.get(TurnipData.MAX)).append("\n")
|
||||
.append(TurnipData.DAY).append(map.get(TurnipData.DAY)).append("\n")
|
||||
@@ -259,6 +255,12 @@ 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());
|
||||
}
|
||||
return nowTime;
|
||||
}
|
||||
|
||||
private int getDay() {
|
||||
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;
|
||||
@@ -266,7 +268,7 @@ public class TurnipProphet extends Model {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TurnipProphet prophet = new TurnipProphet();
|
||||
prophet.setData(88, 583819556);
|
||||
prophet.setData(68, 583819556);
|
||||
|
||||
}
|
||||
|
||||
@@ -284,10 +286,14 @@ public class TurnipProphet extends Model {
|
||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||
Thread.sleep(500);
|
||||
WebElement element = driver.findElement(By.id("output"));
|
||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||
List<WebElement> list = element.findElements(By.tagName("tr"));
|
||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||
JSONObject pr = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
if (list.size() == 0) {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -324,14 +330,24 @@ public class TurnipProphet extends Model {
|
||||
}
|
||||
}
|
||||
}
|
||||
int maxMoney=0;
|
||||
String maxDay=null;
|
||||
for (String key : map.keySet()) {
|
||||
System.err.println("记录最高日:" + map.get(key) + " > " + key);
|
||||
if (!key.equals(TurnipProphet.TurnipData.MAX) &&
|
||||
map.get(key).contains(map.get(TurnipProphet.TurnipData.MAX))) {
|
||||
map.put(TurnipProphet.TurnipData.DAY, key);
|
||||
break;
|
||||
if(map.get(key).contains("~")){
|
||||
for (String s : map.get(key).split("~")) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put(TurnipProphet.TurnipData.DAY, maxDay);
|
||||
pr.put(TurnipProphet.TurnipData.MODEL, array);
|
||||
map.put(TurnipProphet.TurnipData.MODEL, pr.toJSONString());
|
||||
driver.close();
|
||||
|
||||
Reference in New Issue
Block a user