新增QQ启动前检查签名服务器是否运行

This commit is contained in:
yutou 2023-07-26 09:42:40 +08:00
parent e65eb62417
commit 8da7c2f572
2 changed files with 23 additions and 1 deletions

View File

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

View File

@ -42,8 +42,30 @@ public class QQBotManager {
private void init() {
new Thread(new Runnable() {
private void reset() {
try {
Log.i("QQBot","签名加密服务未启动,1分钟后重试");
Thread.sleep(60 * 1000);
init();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void run() {
String test = HttpTools.get("http://192.168.31.88:7400/");
try {
JSONObject json = JSONObject.parseObject(test);
if (json.getInteger("code") != 0) {
reset();
return;
}
} catch (Exception e) {
reset();
return;
}
long qq = ConfigTools.load(ConfigTools.CONFIG, "qq_number", Long.class);
String password = ConfigTools.load(ConfigTools.CONFIG, "qq_password", String.class);
System.out.println("qq = " + qq);