From 3b3f97e6385d8172c62cb0f396f3cf0c0c7356d3 Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 12 Jun 2020 10:12:29 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=20CacheStoreCentral=20=E4=BF=AE=E5=A4=8DS?= =?UTF-8?q?earch=E5=91=BD=E4=BB=A4=E4=B8=AD'option'=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E5=A4=A7=E5=B0=8F=E5=86=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98;=20[Fix]=20BotCommandProcess=20=E4=BF=AE=E5=A4=8DSear?= =?UTF-8?q?ch=E5=91=BD=E4=BB=A4=E4=B8=AD=E9=81=87=E5=88=B0=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=BD=9C=E5=93=81=E6=97=B6=E4=BC=9A=E4=B8=AD?= =?UTF-8?q?=E6=96=AD=E5=A4=84=E7=90=86=E7=9A=84=E9=97=AE=E9=A2=98;=20[Chan?= =?UTF-8?q?ge]=20BotCommandProcess=20=E8=B0=83=E6=95=B4Ranking=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84'type'=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC(ILLUST=20->=20ALL);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/lamgc/cgj/bot/BotCommandProcess.java | 15 ++++++++++++--- .../lamgc/cgj/bot/cache/CacheStoreCentral.java | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java index 8795525..bc03f7b 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java @@ -141,7 +141,7 @@ public class BotCommandProcess { @Argument(force = false, name = "date") Date queryTime, @Argument(force = false, name = "force") boolean force, @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; if (queryDate == null) { @@ -366,8 +366,17 @@ public class BotCommandProcess { PixivURL.getPixivRefererLink(illustId) ); - String imageMsg = CacheStoreCentral.getCentral() - .getImageById(fromGroup, illustId, PixivDownload.PageQuality.REGULAR, 1); + String imageMsg; + 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)) { log.warn("作品Id {} 为R-18作品, 跳过.", illustId); continue; diff --git a/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreCentral.java b/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreCentral.java index af965fa..a64ce81 100644 --- a/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreCentral.java +++ b/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreCentral.java @@ -403,7 +403,8 @@ public final class CacheStoreCentral { } if (contentOption != null) { try { - searchBuilder.setSearchContentOption(PixivSearchBuilder.SearchContentOption.valueOf(contentOption)); + searchBuilder.setSearchContentOption( + PixivSearchBuilder.SearchContentOption.valueOf(contentOption.trim().toUpperCase())); } catch (IllegalArgumentException e) { log.warn("不支持的SearchContentOption: {}", contentOption); }