fix setu bugs

This commit is contained in:
Yutousama 2021-01-24 19:34:37 +08:00
parent 20d797adb9
commit c2023fbc1e
2 changed files with 11 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ToolsApplication { public class ToolsApplication {
public static final String version="1.0.16.05"; public static final String version="1.0.16.09";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("当前版本号:"+version); System.out.println("当前版本号:"+version);

View File

@ -20,9 +20,13 @@ import java.util.TimerTask;
public class QQSetu { public class QQSetu {
public static void printTodaySetu() { public static void printTodaySetu() {
String js = RedisTools.get(Tools.getToDayTime() + "_setu", 1); String redisKey=Tools.getToDayTime() + "_setu";
String js = RedisTools.get(redisKey, 1);
if (js != null) { if (js != null) {
JSONObject json = JSONObject.parseObject(js); JSONObject json = JSONObject.parseObject(js);
if(json.containsKey("isPrint")&&json.getBoolean("isPrint")){
return;
}
Map<String,Float> groupAverage=new HashMap<>(); Map<String,Float> groupAverage=new HashMap<>();
Map<String,String> groupImage=new HashMap<>(); Map<String,String> groupImage=new HashMap<>();
JSONObject setu=null; JSONObject setu=null;
@ -39,8 +43,10 @@ public class QQSetu {
} }
} }
for (String id : groupImage.keySet()) { for (String id : groupImage.keySet()) {
setu=json.getJSONObject(id); setu=json.getJSONObject(groupImage.get(id));
if(setu!=null){ if(setu!=null){
json.put("isPrint",true);
RedisTools.set(1,redisKey,json.toJSONString());
JSONObject info=setu.getJSONObject("info"); JSONObject info=setu.getJSONObject("info");
JSONObject score=setu.getJSONObject("score"); JSONObject score=setu.getJSONObject("score");
MessageChainBuilder builder = new MessageChainBuilder(); MessageChainBuilder builder = new MessageChainBuilder();
@ -84,7 +90,7 @@ public class QQSetu {
json.put("sourName", event.getSenderName()); json.put("sourName", event.getSenderName());
json.put("sourQQ", event.getSender().getId()); json.put("sourQQ", event.getSender().getId());
json.put("group", event.getGroup().getId()); json.put("group", event.getGroup().getId());
RedisTools.set(event.getGroup().getId()+"setu", json.toJSONString(),5*60); RedisTools.set(event.getGroup().getId()+"setu", json.toJSONString(),6*60);
if (timer != null) { if (timer != null) {
timer.cancel(); timer.cancel();
timer = null; timer = null;
@ -176,14 +182,13 @@ public class QQSetu {
} }
try { try {
float i = Float.parseFloat(msg.trim()); float i = Float.parseFloat(msg.trim());
if (i > 0 && i < 10) { if (i > 0 && i <= 10) {
String name = event.getSenderName(); String name = event.getSenderName();
if (!setuScore.containsKey(name)) { if (!setuScore.containsKey(name)) {
setuScore.put(name, i); setuScore.put(name, i);
} }
} }
} catch (Exception ignored) { } catch (Exception ignored) {
ignored.printStackTrace();
} }
} }