diff --git a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java index 8621373..dad3011 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotAdminCommandProcess.java @@ -64,9 +64,10 @@ public class BotAdminCommandProcess { @Command public static String saveProperties() { - log.info("正在保存全局配置文件..."); + log.info("正在保存配置文件..."); SettingProperties.saveProperties(); - return "保存全局配置文件 - 操作已完成."; + log.info("配置文件保存操作已完成."); + return "保存配置 - 操作已完成."; } @Command diff --git a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java index 03bbe94..7d5f315 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java @@ -218,7 +218,7 @@ public class BotCommandProcess { try { int index = 0; int itemLimit = 10; - String itemLimitPropertyKey = "ranking.ItemCountLimit"; + String itemLimitPropertyKey = "ranking.itemCountLimit"; try { itemLimit = Integer.parseInt(SettingProperties .getProperty(SettingProperties.GLOBAL, itemLimitPropertyKey, "10")); @@ -379,7 +379,7 @@ public class BotCommandProcess { int limit = 8; try { limit = Integer.parseInt(SettingProperties. - getProperty(SettingProperties.GLOBAL, "search.ItemCountLimit", "8")); + getProperty(SettingProperties.GLOBAL, "search.itemCountLimit", "8")); } catch (Exception e) { log.warn("参数转换异常!将使用默认值(" + limit + ")", e); } @@ -424,7 +424,7 @@ public class BotCommandProcess { //pageCount String imageMsg = getImageById(fromGroup, illustId, PixivDownload.PageQuality.REGULAR, 1); - if (isNoSafe(illustId, SettingProperties.getProperties(SettingProperties.GLOBAL), true)) { + if (isNoSafe(illustId, SettingProperties.getProperties(fromGroup), true)) { log.warn("作品Id {} 为R-18作品, 跳过.", illustId); continue; } else if(isReported(illustId)) { diff --git a/src/main/java/net/lamgc/cgj/bot/SettingProperties.java b/src/main/java/net/lamgc/cgj/bot/SettingProperties.java index eb4b3e4..835b021 100644 --- a/src/main/java/net/lamgc/cgj/bot/SettingProperties.java +++ b/src/main/java/net/lamgc/cgj/bot/SettingProperties.java @@ -186,7 +186,13 @@ public final class SettingProperties { */ public static String setProperty(long groupId, String key, String value) { Objects.requireNonNull(key); - Properties targetProperties = groupId <= 0 ? globalProp : getGroupProperties(groupId); + Properties targetProperties; + if(groupId <= 0) { + changeList.add(groupId); + targetProperties = getGroupProperties(groupId); + } else { + targetProperties = globalProp; + } String lastValue = targetProperties.getProperty(key); if(value != null) { targetProperties.setProperty(key, value); @@ -214,6 +220,9 @@ public final class SettingProperties { if (groupId <= 0) { throw new IllegalArgumentException("Group number cannot be 0 or negative: " + groupId); } + if(!groupPropMap.containsKey(groupId)) { + groupPropMap.put(groupId, new Properties(globalProp)); + } return groupPropMap.get(groupId); }