From 87f2535b4836818fced7a5d583888a55e6a0b7ec Mon Sep 17 00:00:00 2001 From: LamGC Date: Thu, 11 Jun 2020 09:08:58 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20BotCommandProcess=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96Tag=E8=BF=87=E6=BB=A4=E8=A1=A8=E8=BE=BE=E5=BC=8F;=20[C?= =?UTF-8?q?hange]=20ImageCacheHandler=20=E8=B0=83=E6=95=B4=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA=E7=BA=A7=E5=88=AB;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java | 7 ++++++- .../java/net/lamgc/cgj/bot/cache/ImageCacheHandler.java | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java index 5c6b711..8795525 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Pattern; @SuppressWarnings({"SameParameterValue"}) public class BotCommandProcess { @@ -522,6 +523,10 @@ public class BotCommandProcess { return reportStore.exists(String.valueOf(illustId)); } + /** + * Tag过滤表达式 + */ + private final static Pattern tagPattern = Pattern.compile(".*R-*18.*"); /** * 检查指定作品是否为r18 * @param illustId 作品Id @@ -538,7 +543,7 @@ public class BotCommandProcess { boolean rawValue = illustInfo.get("xRestrict").getAsInt() != 0; if(!rawValue) { for(JsonElement tag : tags) { - boolean current = tag.getAsString().matches("R-*18") || tag.getAsString().contains("R18"); + boolean current = tagPattern.matcher(tag.getAsString()).matches(); if (current) { rawValue = true; break; diff --git a/src/main/java/net/lamgc/cgj/bot/cache/ImageCacheHandler.java b/src/main/java/net/lamgc/cgj/bot/cache/ImageCacheHandler.java index 9cd4c26..9020ec0 100644 --- a/src/main/java/net/lamgc/cgj/bot/cache/ImageCacheHandler.java +++ b/src/main/java/net/lamgc/cgj/bot/cache/ImageCacheHandler.java @@ -38,7 +38,7 @@ public class ImageCacheHandler implements EventHandler { } try { - log.info("图片 {} Event正在进行...({})", event.getStoreFile().getName(), Integer.toHexString(event.hashCode())); + log.debug("图片 {} Event正在进行...({})", event.getStoreFile().getName(), Integer.toHexString(event.hashCode())); File storeFile = event.getStoreFile(); log.debug("正在缓存图片 {} (Path: {})", storeFile.getName(), storeFile.getAbsolutePath()); try { @@ -87,7 +87,7 @@ public class ImageCacheHandler implements EventHandler { } event.getImageCache().put(URLs.getResourceName(event.getDownloadLink()), storeFile); } finally { - log.info("图片 {} Event结束({})", event.getStoreFile().getName(), Integer.toHexString(event.hashCode())); + log.debug("图片 {} Event结束({})", event.getStoreFile().getName(), Integer.toHexString(event.hashCode())); cacheQueue.remove(event); } }