From 0eadefa74f7b019f4980d6df4ced7ef9645ca609 Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 24 Apr 2020 01:24:03 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20BotAdminCommandProcess=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=BD=9C=E5=93=81=E6=8A=A5=E5=91=8A=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD;=20[Add]=20BotCommandProcess=20=E5=AF=B9Repo?= =?UTF-8?q?rt=E5=A2=9E=E5=8A=A0=E6=8A=A5=E5=91=8A=E6=97=B6=E9=97=B4;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lamgc/cgj/bot/BotAdminCommandProcess.java | 28 +++++++++++++++++++ .../net/lamgc/cgj/bot/BotCommandProcess.java | 1 + 2 files changed, 29 insertions(+) diff --git a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java index 752780e..568b44f 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java @@ -14,6 +14,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; +import java.text.SimpleDateFormat; import java.util.*; 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 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 ? "作品已解封!" : "解封失败!可能该作品并未被封禁。"; + } + } diff --git a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java index 641ec84..0d3a158 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java @@ -578,6 +578,7 @@ public class BotCommandProcess { log.warn("收到作品反馈(IllustId: {}, 原因: {})", illustId, reason); JsonObject reportJson = new JsonObject(); reportJson.addProperty("illustId", illustId); + reportJson.addProperty("reportTime", new Date().getTime()); reportJson.addProperty("reason", reason); reportStore.update(String.valueOf(illustId), reportJson, 0); return "色图姬收到了你的报告,将屏蔽该作品并对作品违规情况进行核实,感谢你的反馈!";