[Add] BotAdminCommandProcess 完善作品报告管理功能;

[Add] BotCommandProcess 对Report增加报告时间;
This commit is contained in:
LamGC 2020-04-24 01:24:03 +08:00
parent 4afa414725
commit 0eadefa74f
2 changed files with 29 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class BotAdminCommandProcess { public class BotAdminCommandProcess {
@ -222,4 +223,31 @@ public class BotAdminCommandProcess {
}); });
} }
@Command
public static String getReportList() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Set<String> keys = BotCommandProcess.reportStore.keys();
StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append("当前被报告的作品列表:\n");
for(String key : keys) {
String illustIdStr = key.substring(key.indexOf(".") + 1);
JsonObject report = BotCommandProcess.reportStore.getCache(illustIdStr).getAsJsonObject();
log.debug("{} - Report: {}", illustIdStr, report);
String reason = report.get("reason").isJsonNull() ? "" : report.get("reason").getAsString();
msgBuilder.append(illustIdStr)
.append("(").append(dateFormat.format(new Date(report.get("reportTime").getAsLong()))).append(")")
.append(reason).append("\n");
}
return msgBuilder.toString();
}
@Command
public static String unBanArtwork(@Argument(name = "id") int illustId) {
if(illustId <= 0) {
return "无效的作品id!";
}
boolean removeResult = BotCommandProcess.reportStore.remove(String.valueOf(illustId));
return removeResult ? "作品已解封!" : "解封失败!可能该作品并未被封禁。";
}
} }

View File

@ -578,6 +578,7 @@ public class BotCommandProcess {
log.warn("收到作品反馈(IllustId: {}, 原因: {})", illustId, reason); log.warn("收到作品反馈(IllustId: {}, 原因: {})", illustId, reason);
JsonObject reportJson = new JsonObject(); JsonObject reportJson = new JsonObject();
reportJson.addProperty("illustId", illustId); reportJson.addProperty("illustId", illustId);
reportJson.addProperty("reportTime", new Date().getTime());
reportJson.addProperty("reason", reason); reportJson.addProperty("reason", reason);
reportStore.update(String.valueOf(illustId), reportJson, 0); reportStore.update(String.valueOf(illustId), reportJson, 0);
return "色图姬收到了你的报告,将屏蔽该作品并对作品违规情况进行核实,感谢你的反馈!"; return "色图姬收到了你的报告,将屏蔽该作品并对作品违规情况进行核实,感谢你的反馈!";