From d9edaa681fd8c1218b59f41bf96c3a78cf4b40d2 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 9 May 2020 10:10:48 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20BotAdminCommandProcess=20=E4=B8=BA=20ad?= =?UTF-8?q?dPushGroup=20=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=E6=A3=80?= =?UTF-8?q?=E6=9F=A5;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lamgc/cgj/bot/BotAdminCommandProcess.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java index dad3011..478207a 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java @@ -111,6 +111,30 @@ public class BotAdminCommandProcess { @Argument(name = "type", force = false, defaultValue = "ILLUST") String rankingContentType, @Argument(name = "original", force = false, defaultValue = "false") boolean original ) { + if(minTime <= 0 || floatTime <= 0) { + return "时间不能为0或负数!"; + } else if(rankingStart <= 0 || rankingStop - rankingStart <= 0) { + return "排行榜范围选取错误!"; + } + + PixivURL.RankingContentType type; + PixivURL.RankingMode mode; + try { + type = PixivURL.RankingContentType.valueOf("TYPE_" + rankingContentType.toUpperCase()); + } catch(IllegalArgumentException e) { + return "无效的排行榜类型参数!"; + } + + try { + mode = PixivURL.RankingMode.valueOf("MODE_" + rankingMode.toUpperCase()); + } catch(IllegalArgumentException e) { + return "无效的排行榜模式参数!"; + } + + if(!type.isSupportedMode(mode)) { + return "不兼容的排行榜模式与类型!"; + } + long group = groupId <= 0 ? fromGroup : groupId; JsonObject setting = new JsonObject(); setting.addProperty(RANKING_SETTING_TIME_MIN, minTime); @@ -127,7 +151,8 @@ public class BotAdminCommandProcess { removePushGroup(fromGroup, groupId); } - log.info("正在增加Timer...(Setting: {})", setting); + log.info("群组 {} 新推送配置: {}", group, setting); + log.info("正在增加Timer..."); pushInfoMap.put(group, setting); addPushTimer(group, setting); return "已在 " + group + " 开启定时推送功能。";