修复FastJSON大版本更新后API变动
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.yutou.qqbot.models.Animal;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
@@ -94,7 +95,7 @@ public class TurnipProphet extends Model {
|
||||
QQBotManager.getInstance().sendMessage(sendQQ, getMessage("没有本周数据,无法预测"));
|
||||
return;
|
||||
}
|
||||
JSONObject json = JSONObject.parseObject(data);
|
||||
JSONObject json = JSON.parseObject(data);
|
||||
String prices = json.getString("prices");
|
||||
String pattern = null;
|
||||
if (json.containsKey("old_pattern")) {
|
||||
@@ -132,7 +133,7 @@ public class TurnipProphet extends Model {
|
||||
array = new JSONArray();
|
||||
json = new JSONObject();
|
||||
if (getDay() == 0 && !StringUtils.isEmpty(data)) {
|
||||
json = JSONObject.parseObject(data);
|
||||
json = JSON.parseObject(data);
|
||||
}
|
||||
array.add(-1);
|
||||
array.add(-1);
|
||||
@@ -148,7 +149,7 @@ public class TurnipProphet extends Model {
|
||||
array.add(-1);
|
||||
array.add(-1);
|
||||
} else {
|
||||
json = JSONObject.parseObject(data);
|
||||
json = JSON.parseObject(data);
|
||||
array = json.getJSONArray("turnip");
|
||||
}
|
||||
if (array.getInteger(0) == -1 && getDay() != 0) {
|
||||
@@ -231,7 +232,7 @@ public class TurnipProphet extends Model {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject pr = JSONObject.parseObject(map.get(TurnipData.MODEL));
|
||||
JSONObject pr = JSON.parseObject(map.get(TurnipData.MODEL));
|
||||
JSONArray prArray = pr.getJSONArray(TurnipData.MODEL);
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append("预测结果如下:\n");
|
||||
@@ -350,7 +351,7 @@ public class TurnipProphet extends Model {
|
||||
map.put(TurnipProphet.TurnipData.MIX, tmp[15]);
|
||||
map.put(TurnipProphet.TurnipData.MAX, tmp[16]);
|
||||
} else {
|
||||
if (!array.toJSONString().contains(tmp[0])) {
|
||||
if (!array.toJavaList(String.class).contains(tmp[0])) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put(TurnipProphet.TurnipData.MODEL, tmp[0]);
|
||||
json.put(TurnipProphet.TurnipData.PR, tmp[1]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yutou.qqbot.models.Commands;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.interfaces.DownloadInterface;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
@@ -48,7 +49,7 @@ public class Moyu extends Model {
|
||||
|
||||
private void downloadImage() {
|
||||
String ret = HttpTools.get("https://api.j4u.ink/proxy/remote/moyu.json");
|
||||
JSONObject json = JSONObject.parseObject(ret);
|
||||
JSONObject json = JSON.parseObject(ret);
|
||||
HttpTools.download(json.getJSONObject("data").getString("moyu_url"), AppTools.getToDayTime() + "_moyu.jpg", new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(File file) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yutou.qqbot.models.WebSign;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
@@ -53,7 +54,7 @@ public class BaiHeHui extends Model {
|
||||
}
|
||||
WebDriver driver = WebClient.getInstance().getWebDriver();
|
||||
try {
|
||||
JSONArray array = JSONArray.parseArray(cookie);
|
||||
JSONArray array = JSON.parseArray(cookie);
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
driver.get("https://bbs.yamibo.com/forum.php");
|
||||
driver.manage().deleteAllCookies();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yutou.qqbot.models.WebSign;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
@@ -46,7 +47,7 @@ public class NicePT extends Model {
|
||||
|
||||
public boolean sign() {
|
||||
String url = "https://www.nicept.net/attendance.php";
|
||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("nicept.json")));
|
||||
JSONArray array = JSON.parseArray(ConfigTools.readFile(new File("nicept.json")));
|
||||
if (array == null) {
|
||||
System.err.println("array is null");
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.yutou.qqbot.models.WebSign;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
@@ -61,7 +63,7 @@ public class Tsdm extends Model {
|
||||
}
|
||||
|
||||
public boolean tsdmSign() {
|
||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||
JSONArray array = JSON.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||
if (array == null) {
|
||||
System.err.println("array is null");
|
||||
return false;
|
||||
@@ -126,7 +128,7 @@ public class Tsdm extends Model {
|
||||
}
|
||||
|
||||
public String tsdm(String url) {
|
||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||
JSONArray array = JSON.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||
if (array == null) {
|
||||
System.err.println("array is null");
|
||||
return null;
|
||||
@@ -152,7 +154,6 @@ public class Tsdm extends Model {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean sign = new Tsdm().tsdmSign();
|
||||
System.out.println("sign = " + sign);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.yutou.qqbot.models.XiaoMi;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.HttpTools;
|
||||
@@ -63,14 +64,14 @@ public class MiRouter extends Model {
|
||||
}
|
||||
private void run()throws Exception{
|
||||
String url = XiaoMiRouter.getDeviceListUrl();
|
||||
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
|
||||
JSONObject json = JSON.parseObject(HttpTools.get(url));
|
||||
if (json.getInteger("code") == 0) {
|
||||
String _tmp = RedisTools.get(redis_key);
|
||||
if (_tmp == null) {
|
||||
return;
|
||||
}
|
||||
JSONArray devices = JSONArray.parseArray(_tmp);
|
||||
JSONArray devs = (JSONArray) devices.clone();
|
||||
JSONArray devices = JSON.parseArray(_tmp);
|
||||
JSONArray devs =JSON.parseArray(devices.toString());
|
||||
JSONArray array = json.getJSONArray("list");
|
||||
Set<String> links = new HashSet<>();
|
||||
for (Object o : array) {
|
||||
@@ -78,7 +79,7 @@ public class MiRouter extends Model {
|
||||
for (Object device : devices) {
|
||||
JSONObject _device = (JSONObject) device;
|
||||
devs.remove(_device);
|
||||
if (_device.getString("mac").equals(item.getString("mac")) && !_device.getBoolean("online")) {
|
||||
if (_device.getString("mac").equals(item.getString("mac")) && !_device.getBooleanValue("online")) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(item.getString("oname"));
|
||||
builder.append(" 欢迎回家!").append("\n");
|
||||
@@ -88,14 +89,14 @@ public class MiRouter extends Model {
|
||||
_device.put("online", true);
|
||||
_device.put("name", item.getString("oname"));
|
||||
}
|
||||
if (_device.getString("mac").equals(item.getString("mac")) && _device.getBoolean("online")) {
|
||||
if (_device.getString("mac").equals(item.getString("mac")) && _device.getBooleanValue("online")) {
|
||||
links.add(_device.getString("mac"));
|
||||
_device.put("linkTime", Long.parseLong(item.getJSONObject("statistics").getString("online")));
|
||||
}
|
||||
devs.add(_device);
|
||||
}
|
||||
}
|
||||
devices = (JSONArray) devs.clone();
|
||||
devices = JSON.parseArray(devs.toString());
|
||||
for (Object device : devices) {
|
||||
JSONObject item = (JSONObject) device;
|
||||
if (!links.contains(item.getString("mac")) && item.getLong("linkTime") != 0) {
|
||||
@@ -110,7 +111,7 @@ public class MiRouter extends Model {
|
||||
devs.add(item);
|
||||
}
|
||||
}
|
||||
RedisTools.set(redis_key, devs.toJSONString());
|
||||
RedisTools.set(redis_key, devs.toString());
|
||||
}else {
|
||||
XiaoMiRouter.setNotToken();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.yutou.qqbot.models.setu;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.interfaces.DownloadInterface;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
@@ -64,7 +65,7 @@ public class GetSeTu extends Model {
|
||||
redis.close();
|
||||
MessageChainBuilder builder = null;
|
||||
if (!StringUtils.isEmpty(ret)) {
|
||||
JSONArray array = JSONArray.parseArray(ret);
|
||||
JSONArray array = JSON.parseArray(ret);
|
||||
builder = new MessageChainBuilder();
|
||||
builder.append("各位老色胚们晚上好,现在公布本群涩图数据!");
|
||||
builder.append("\n");
|
||||
@@ -147,7 +148,7 @@ public class GetSeTu extends Model {
|
||||
String redis = RedisTools.get("Setu_" + qq);
|
||||
JSONArray array = new JSONArray();
|
||||
if (!StringUtils.isEmpty(redis)) {
|
||||
array = JSONArray.parseArray(redis);
|
||||
array = JSON.parseArray(redis);
|
||||
}
|
||||
array.add(data);
|
||||
RedisTools.set("Setu_" + qq, array.toString());
|
||||
@@ -182,7 +183,7 @@ public class GetSeTu extends Model {
|
||||
}
|
||||
System.out.println("url = " + url);
|
||||
String ret = HttpTools.get(url);
|
||||
JSONObject json = JSONObject.parseObject(ret);
|
||||
JSONObject json = JSON.parseObject(ret);
|
||||
if (json.getJSONArray("data").size() == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -194,7 +195,7 @@ public class GetSeTu extends Model {
|
||||
builder.append(item.getInteger("pid"));
|
||||
builder.append("\n");
|
||||
builder.append("R18:");
|
||||
if (item.getBoolean("r18")) {
|
||||
if (item.getBooleanValue("r18")) {
|
||||
builder.append("YES!");
|
||||
} else {
|
||||
builder.append("NO~");
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.yutou.qqbot.models.setu;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
import com.yutou.qqbot.Annotations.UseModel;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
@@ -35,8 +36,8 @@ public class QQSetu extends Model {
|
||||
Log.i("今日涩图 redisKey = " + redisKey);
|
||||
String js = RedisTools.get(redisKey, db_print);
|
||||
if (js != null) {
|
||||
JSONObject json = JSONObject.parseObject(js);
|
||||
if(json.containsKey("isPrint")&&json.getBoolean("isPrint")){
|
||||
JSONObject json = JSON.parseObject(js);
|
||||
if(json.containsKey("isPrint")&&json.getBooleanValue("isPrint")){
|
||||
return;
|
||||
}
|
||||
Map<String,Float> groupAverage=new HashMap<>();
|
||||
@@ -128,7 +129,7 @@ public class QQSetu extends Model {
|
||||
}
|
||||
|
||||
private void printSetu(long group) {
|
||||
JSONObject jt = JSONObject.parseObject(RedisTools.get(group+"setu", db_user));
|
||||
JSONObject jt = JSON.parseObject(RedisTools.get(group+"setu", db_user));
|
||||
String id = jt.getString("id");
|
||||
float average = 0;
|
||||
float max = 0;
|
||||
@@ -169,7 +170,7 @@ public class QQSetu extends Model {
|
||||
if (st == null) {
|
||||
json = new JSONObject();
|
||||
} else {
|
||||
json = JSONObject.parseObject(st);
|
||||
json = JSON.parseObject(st);
|
||||
}
|
||||
if (!json.containsKey(id)) {
|
||||
JSONObject item;
|
||||
|
||||
Reference in New Issue
Block a user