[Fix] CacheStoreCentral 修复Search命令中'option'参数区分大小写的问题;

[Fix] BotCommandProcess 修复Search命令中遇到不存在作品时会中断处理的问题;
[Change] BotCommandProcess 调整Ranking命令的'type'参数默认值(ILLUST -> ALL);
This commit is contained in:
LamGC 2020-06-12 10:12:29 +08:00
parent 951824cbe2
commit 3b3f97e638
2 changed files with 14 additions and 4 deletions

View File

@ -141,7 +141,7 @@ public class BotCommandProcess {
@Argument(force = false, name = "date") Date queryTime, @Argument(force = false, name = "date") Date queryTime,
@Argument(force = false, name = "force") boolean force, @Argument(force = false, name = "force") boolean force,
@Argument(force = false, name = "mode", defaultValue = "DAILY") String contentMode, @Argument(force = false, name = "mode", defaultValue = "DAILY") String contentMode,
@Argument(force = false, name = "type", defaultValue = "ILLUST") String contentType @Argument(force = false, name = "type", defaultValue = "ALL") String contentType
) { ) {
Date queryDate = queryTime; Date queryDate = queryTime;
if (queryDate == null) { if (queryDate == null) {
@ -366,8 +366,17 @@ public class BotCommandProcess {
PixivURL.getPixivRefererLink(illustId) PixivURL.getPixivRefererLink(illustId)
); );
String imageMsg = CacheStoreCentral.getCentral() String imageMsg;
.getImageById(fromGroup, illustId, PixivDownload.PageQuality.REGULAR, 1); try {
imageMsg = CacheStoreCentral.getCentral()
.getImageById(fromGroup, illustId, PixivDownload.PageQuality.REGULAR, 1);
} catch (NoSuchElementException e) {
if(e.getMessage().startsWith("No work found: ")) {
log.warn("作品 {} 不存在, 跳过该作品...", illustId);
continue;
}
throw e;
}
if (isNoSafe(illustId, SettingProperties.getProperties(fromGroup), false)) { if (isNoSafe(illustId, SettingProperties.getProperties(fromGroup), false)) {
log.warn("作品Id {} 为R-18作品, 跳过.", illustId); log.warn("作品Id {} 为R-18作品, 跳过.", illustId);
continue; continue;

View File

@ -403,7 +403,8 @@ public final class CacheStoreCentral {
} }
if (contentOption != null) { if (contentOption != null) {
try { try {
searchBuilder.setSearchContentOption(PixivSearchBuilder.SearchContentOption.valueOf(contentOption)); searchBuilder.setSearchContentOption(
PixivSearchBuilder.SearchContentOption.valueOf(contentOption.trim().toUpperCase()));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.warn("不支持的SearchContentOption: {}", contentOption); log.warn("不支持的SearchContentOption: {}", contentOption);
} }