修复FastJSON大版本更新后API变动

This commit is contained in:
Yutousama 2022-04-28 09:50:33 +08:00
parent f1ed4be143
commit 7943606dc0
22 changed files with 103 additions and 88 deletions

View File

@ -58,8 +58,8 @@
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.1</version>
</dependency>

View File

@ -1,6 +1,6 @@
package com.yutou.qqbot.Controllers;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.utlis.AppTools;
import com.yutou.qqbot.utlis.HttpTools;

View File

@ -1,7 +1,8 @@
package com.yutou.qqbot.Controllers;
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.models.XiaoMi.MiRouter;
import com.yutou.qqbot.utlis.HttpTools;
import com.yutou.qqbot.utlis.RedisTools;
@ -23,7 +24,7 @@ public class MiRouterDevices {
if (data == null) {
array = new JSONArray();
} else {
array = JSONArray.parseArray(data);
array = JSON.parseArray(data);
}
for (Object o : array) {
JSONObject item = (JSONObject) o;
@ -47,9 +48,9 @@ public class MiRouterDevices {
if (data == null) {
array = new JSONArray();
} else {
array = JSONArray.parseArray(data);
array = JSON.parseArray(data);
}
JSONArray _array= (JSONArray) array.clone();
JSONArray _array= JSON.parseArray(array.toString());
for (Object o : array) {
JSONObject item = (JSONObject) o;
if (item.getString("mac").equals(getRemoteAddress(request.getRemoteAddr()))) {
@ -62,7 +63,7 @@ public class MiRouterDevices {
}
private String getRemoteAddress(String ip) {
JSONObject data = JSONObject.parseObject(HttpTools.get(XiaoMiRouter.getDeviceListUrl()));
JSONObject data = JSON.parseObject(HttpTools.get(XiaoMiRouter.getDeviceListUrl()));
if (data.getInteger("code") == 0) {
JSONArray array=data.getJSONArray("list");
for (Object o : array) {

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class QQBotApplication {
public static final String version="QQBot v.1.2.23";
public static final String version="QQBot v.1.2.24";
public static void main(String[] args) {
System.out.println("version = " + version);
SpringApplication.run(QQBotApplication.class, args);

View File

@ -1,7 +1,8 @@
package com.yutou.qqbot;
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.utlis.Log;
import com.yutou.qqbot.utlis.RedisTools;
import redis.clients.jedis.Jedis;
@ -49,7 +50,7 @@ public class QQNumberManager {
}
public boolean addPower(Long qq, String power){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("power");
array.add(power);
json.put("power",array);
@ -60,7 +61,7 @@ public class QQNumberManager {
public List<String> getPower(Long qq){
List<String> list=new ArrayList<>();
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("power");
for (Object power : array) {
list.add((String) power);
@ -72,7 +73,7 @@ public class QQNumberManager {
public List<String> getUseModel(long qq) {
List<String> list=new ArrayList<>();
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("model");
for (Object power : array) {
list.add((String) power);
@ -83,7 +84,7 @@ public class QQNumberManager {
}
public boolean delPower(Long qq, String power){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("power");
array.remove(power);
json.put("power",array);
@ -93,7 +94,7 @@ public class QQNumberManager {
}
public boolean addUseModel(Long qq,Class<?> modelClass){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("model");
array.add(modelClass.getName());
json.put("model",array);
@ -103,7 +104,7 @@ public class QQNumberManager {
}
public boolean delUseModel(Long qq,Class<?> modelClass){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("model");
array.remove(modelClass.getName());
json.put("model",array);
@ -113,7 +114,7 @@ public class QQNumberManager {
}
public boolean isExistsPower(Long qq, String... power){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("power");
for (String key : power) {
if(!array.contains(key)){
@ -126,14 +127,14 @@ public class QQNumberManager {
}
public boolean isGroup(Long qq){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
return json.getBoolean("group");
JSONObject json= JSON.parseObject(RedisTools.get(qq));
return json.getBooleanValue("group");
}
return false;
}
public boolean isUseModel(Long qq,Class<?> modelClass){
if(RedisTools.exists(qq,null)){
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
JSONObject json=JSON.parseObject(RedisTools.get(qq));
JSONArray array=json.getJSONArray("model");
return array.contains(modelClass.getName());
}

View File

@ -1,7 +1,7 @@
package com.yutou.qqbot.bilibili;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.interfaces.ObjectInterface;
import com.yutou.qqbot.utlis.HttpTools;
import lombok.Data;

View File

@ -1,9 +1,9 @@
package com.yutou.qqbot.bilibili;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.utlis.ConfigTools;
import org.springframework.util.StringUtils;
import com.yutou.qqbot.utlis.StringUtils;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
@ -109,7 +109,7 @@ public class BiliBiliUtils {
return "";
}
JSONObject json = JSONObject.parseObject(ConfigTools.readFile(new File("bilibili.cookie")));
JSONObject json = JSON.parseObject(ConfigTools.readFile(new File("bilibili.cookie")));
StringBuilder builder = new StringBuilder();
for (String s : json.keySet()) {
builder.append(s).append("=").append(json.getString(s)).append(";");

View File

@ -1,7 +1,8 @@
package com.yutou.qqbot.bilibili;
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.utlis.ConfigTools;
import com.yutou.qqbot.utlis.HttpTools;
@ -15,7 +16,7 @@ public class BiliLogin {
public JSONObject login(){
JSONObject login= JSONObject.parseObject(HttpTools.get("https://passport.bilibili.com/qrcode/getLoginUrl"));
JSONObject login= JSON.parseObject(HttpTools.get("https://passport.bilibili.com/qrcode/getLoginUrl"));
JSONObject json=new JSONObject();
json.put("code",login.getInteger("code"));
json.put("url",login.getJSONObject("data").getString("url"));
@ -33,7 +34,7 @@ public class BiliLogin {
cancel();
return;
}
JSONObject json=JSONObject.parseObject(HttpTools.post("https://passport.bilibili.com/qrcode/getLoginInfo",bd.getBytes(StandardCharsets.UTF_8)));
JSONObject json=JSON.parseObject(HttpTools.post("https://passport.bilibili.com/qrcode/getLoginInfo",bd.getBytes(StandardCharsets.UTF_8)));
if(json.containsKey("code")&&json.getInteger("code")==0){
System.out.println("json = " + json);
String _url=json.getJSONObject("data").getString("url");

View File

@ -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]);

View File

@ -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) {

View 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();

View 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.*;
@ -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;

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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~");

View File

@ -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;

View File

@ -1,7 +1,8 @@
package com.yutou.qqbot.utlis;
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;
@ -25,7 +26,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
JSONArray main = JSONArray.parseArray(str);
JSONArray main = JSON.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
@ -60,7 +61,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
return JSONObject.parseObject(str);
return JSON.parseObject(str);
}
public static JSONArray getPeople(int id) {
@ -117,7 +118,7 @@ public class BangumiTools {
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, URLEncoder.encode(key, StandardCharsets.UTF_8)));
return JSONObject.parseObject(str);
return JSON.parseObject(str);
}
/**

View File

@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import java.io.*;
@ -44,7 +45,7 @@ public class ConfigTools {
String src = readFile(file);
if (src != null) {
try {
JSONObject json = JSONObject.parseObject(src);
JSONObject json = JSON.parseObject(src);
return json.getObject(key, t);
} catch (Exception e) {
}
@ -80,7 +81,7 @@ public class ConfigTools {
if (src == null) {
src = "{}";
}
JSONObject json = JSONObject.parseObject(src);
JSONObject json = JSON.parseObject(src);
json.put(key, data);
saveFile(file, json.toJSONString());
return false;

View File

@ -1,6 +1,6 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.interfaces.DownloadInterface;
import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
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.ObjectInterface;
import redis.clients.jedis.Jedis;
@ -292,7 +293,7 @@ public class RedisTools {
public static void bot(String value) {
switch (value) {
case "getip":
JSONObject json = JSONObject.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
JSONObject json = JSON.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
String ip = json.getString("ip");
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
break;

View File

@ -1,7 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@ -49,8 +49,8 @@ public class WebClient {
json.getString("domain"),
json.getString("path"),
containsDate ? new Date(t) : new Date(),
json.containsKey("secure")?json.getBoolean("secure"):false,
json.containsKey("httpOnly")?json.getBoolean("httpOnly"):false
json.getBooleanValue("secure"),
json.getBooleanValue("httpOnly")
);
list.add(cookie);

View File

@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
import java.nio.charset.StandardCharsets;
@ -24,7 +25,7 @@ public class XiaoMiRouter {
json.put("password", oldPwd);
json.put("logtype", 2);
json.put("nonce", nonce);
json = JSONObject.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
json = JSON.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
if (json.getInteger("code") == 0) {
token = json.getString("token");
return token;
@ -42,7 +43,7 @@ public class XiaoMiRouter {
public static void main(String[] args) {
String url = XiaoMiRouter.getDeviceListUrl();
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
JSONObject json = JSON.parseObject(HttpTools.get(url));
System.out.println("json = " + json);
}
}