mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Fix] BotGlobal 修复BotGlobal初始化失败的问题;
[Fix] BotCommandProcess 修复Search命令未找到相关作品时提示语无法触发的问题; [Change] BotCommandProcess 调整'isNoSafe(int, Properties, boolean)'方法中对于作品限制的判断方式;
This commit is contained in:
parent
4bbed5fd55
commit
9a8aac1960
@ -305,6 +305,7 @@ public class BotCommandProcess {
|
||||
} catch (Exception e) {
|
||||
log.warn("参数转换异常!将使用默认值(" + limit + ")", e);
|
||||
}
|
||||
int totalCount = 0;
|
||||
for (PixivSearchBuilder.SearchArea searchArea : PixivSearchBuilder.SearchArea.values()) {
|
||||
if (!resultBody.has(searchArea.jsonKey) ||
|
||||
resultBody.getAsJsonObject(searchArea.jsonKey).getAsJsonArray("data").size() == 0) {
|
||||
@ -371,12 +372,13 @@ public class BotCommandProcess {
|
||||
.append(illustPreLoadData.get(PreLoadDataComparator.Attribute.COMMENT.attrName).getAsInt())
|
||||
.append("\n").append(imageMsg).append("\n");
|
||||
count++;
|
||||
totalCount++;
|
||||
}
|
||||
if (count > limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Strings.isNullOrEmpty(result.toString()) ?
|
||||
return totalCount <= 0 ?
|
||||
"搜索完成,未找到相关作品。" :
|
||||
Strings.nullToEmpty(result.toString()) + "预览图片并非原图,使用“.cgj image -id 作品id”获取原图\n" +
|
||||
"如有不当作品,可使用\".cgj report -id 作品id\"向色图姬反馈。";
|
||||
@ -501,15 +503,17 @@ public class BotCommandProcess {
|
||||
*/
|
||||
public static boolean isNoSafe(int illustId, Properties settingProp, boolean returnRaw)
|
||||
throws IOException, NoSuchElementException {
|
||||
// TODO(LamGC, 20200604): 看看能不能通过官方获得作品R18信息, 进而加强过滤;
|
||||
JsonArray tags = CacheStoreCentral.getIllustInfo(illustId, false).getAsJsonArray("tags");
|
||||
boolean rawValue = false;
|
||||
for(JsonElement tag : tags) {
|
||||
boolean current = tag.getAsString().matches("R-*18") || tag.getAsString().contains("R18");
|
||||
// log.warn("Match: {}, Tag: {}", current, tag.getAsString());
|
||||
if (current) {
|
||||
rawValue = true;
|
||||
break;
|
||||
JsonObject illustInfo = CacheStoreCentral.getIllustInfo(illustId, false);
|
||||
JsonArray tags = illustInfo.getAsJsonArray("tags");
|
||||
boolean rawValue = illustInfo.get("xRestrict").getAsInt() != 0;
|
||||
if(!rawValue) {
|
||||
for(JsonElement tag : tags) {
|
||||
boolean current = tag.getAsString().matches("R-*18") || tag.getAsString().contains("R18");
|
||||
// log.warn("Match: {}, Tag: {}", current, tag.getAsString());
|
||||
if (current) {
|
||||
rawValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnRaw || settingProp == null ? rawValue :
|
||||
|
@ -60,7 +60,7 @@ public final class BotGlobal {
|
||||
this.dataStoreDir = new File((!dataStoreDirPath.endsWith("/") || !dataStoreDirPath.endsWith("\\")) ?
|
||||
dataStoreDirPath + System.getProperty("file.separator") : dataStoreDirPath);
|
||||
|
||||
this.imageStoreDir = new File(BotGlobal.getGlobal().getDataStoreDir(), "data/image/cgj/");
|
||||
this.imageStoreDir = new File(getDataStoreDir(), "data/image/cgj/");
|
||||
|
||||
String proxyAddress = System.getProperty("cgj.proxy");
|
||||
HttpHost temp = null;
|
||||
|
Loading…
Reference in New Issue
Block a user