涩图模块:修复每日统计没效果

This commit is contained in:
Yutousama 2022-04-22 00:35:48 +08:00
parent 61feb23f16
commit e96bdefb67
2 changed files with 44 additions and 51 deletions

View File

@ -43,7 +43,7 @@ public class GetSeTu extends Model {
if ("00:00:00".equals(time)) { if ("00:00:00".equals(time)) {
del(); del();
} else if (RedisTools.get("Setu_time", "23:59:00").equals(time)) { } else if (RedisTools.get("Setu_time", "23:59:00").equals(time)) {
send(); send(qq);
} }
} }
@ -57,62 +57,56 @@ public class GetSeTu extends Model {
redis.close(); redis.close();
} }
private void send() { private void send(Long group) {
Jedis redis = RedisTools.getRedis(); Jedis redis = RedisTools.getRedis();
redis.select(RedisTools.QQBOT_USER); redis.select(RedisTools.QQBOT_USER);
Set<String> keys = redis.keys("Setu_*"); String key = redis.get("Setu_"+group);
Log.i("进入涩图打印:" + keys.size());
redis.close(); redis.close();
for (String key : keys) { String ret = RedisTools.get(key);
if ("Setu_time".equals(key)) { MessageChainBuilder builder = null;
continue; Log.i(key, ret);
if (!StringUtils.isEmpty(ret)) {
JSONArray array = JSONArray.parseArray(ret);
builder = new MessageChainBuilder();
builder.append("各位老色胚们晚上好,现在公布本群涩图数据!");
builder.append("\n");
builder.append("本群今日共查询:");
builder.append(String.valueOf(array.size()));
builder.append("次!\n");
builder.append("接下来公布大伙的XP系统");
builder.append("\n");
Map<Long, List<String>> map = new HashMap<>();
for (Object o : array) {
JSONObject item = (JSONObject) o;
List<String> tags = map.getOrDefault(item.getLong("user"), new ArrayList<>());
tags.add(item.getString("key"));
map.put(item.getLong("user"), tags);
} }
String ret = RedisTools.get(key); Long maxQQ = -1L;
MessageChainBuilder builder = null; int max = -1;
Log.i(key, ret); for (Long qq : map.keySet()) {
if (!StringUtils.isEmpty(ret)) { builder.append("------------------\n");
JSONArray array = JSONArray.parseArray(ret); List<String> list = map.get(qq);
builder = new MessageChainBuilder(); if (list.size() > max) {
builder.append("各位老色胚们晚上好,现在公布本群涩图数据!"); max = list.size();
builder.append("\n"); maxQQ = qq;
builder.append("本群今日共查询:");
builder.append(String.valueOf(array.size()));
builder.append("次!\n");
builder.append("接下来公布大伙的XP系统");
builder.append("\n");
Map<Long, List<String>> map = new HashMap<>();
for (Object o : array) {
JSONObject item = (JSONObject) o;
List<String> tags = map.getOrDefault(item.getLong("user"), new ArrayList<>());
tags.add(item.getString("key"));
map.put(item.getLong("user"), tags);
} }
Long maxQQ = -1L; builder.append(new At(qq))
int max = -1; .append(":\n");
for (Long qq : map.keySet()) { for (String tag : list) {
builder.append("------------------\n"); builder.append(tag).append("\n");
List<String> list = map.get(qq);
if (list.size() > max) {
max = list.size();
maxQQ = qq;
}
builder.append(new At(qq))
.append(":\n");
for (String tag : list) {
builder.append(tag).append("\n");
}
builder.append("------------------\n");
} }
builder.append("那么今日最色批的就是:"); builder.append("------------------\n");
builder.append(new At(maxQQ));
builder.append("\n");
builder.append("如果炸群了请找他(\n");
builder.append("明天见~");
}
Log.i("打印色图统计:" + builder);
if (builder != null) {
QQBotManager.getInstance().sendMessage(Long.parseLong(key.replace("Setu_", "")), builder);
} }
builder.append("那么今日最色批的就是:");
builder.append(new At(maxQQ));
builder.append("\n");
builder.append("如果炸群了请找他(\n");
builder.append("明天见~");
}
Log.i("打印色图统计:" + builder);
if (builder != null) {
QQBotManager.getInstance().sendMessage(Long.parseLong(key.replace("Setu_", "")), builder);
} }
} }

View File

@ -29,7 +29,6 @@ public class ApplicationInit implements ApplicationRunner {
return; return;
} }
oldTime = time; oldTime = time;
Log.i("ApplicationInit run > "+oldTime );
for (Class<?> model : Model.classList) { for (Class<?> model : Model.classList) {
new Thread(() -> { new Thread(() -> {
try { try {