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) {
|
} catch (Exception e) {
|
||||||
log.warn("参数转换异常!将使用默认值(" + limit + ")", e);
|
log.warn("参数转换异常!将使用默认值(" + limit + ")", e);
|
||||||
}
|
}
|
||||||
|
int totalCount = 0;
|
||||||
for (PixivSearchBuilder.SearchArea searchArea : PixivSearchBuilder.SearchArea.values()) {
|
for (PixivSearchBuilder.SearchArea searchArea : PixivSearchBuilder.SearchArea.values()) {
|
||||||
if (!resultBody.has(searchArea.jsonKey) ||
|
if (!resultBody.has(searchArea.jsonKey) ||
|
||||||
resultBody.getAsJsonObject(searchArea.jsonKey).getAsJsonArray("data").size() == 0) {
|
resultBody.getAsJsonObject(searchArea.jsonKey).getAsJsonArray("data").size() == 0) {
|
||||||
@ -371,12 +372,13 @@ public class BotCommandProcess {
|
|||||||
.append(illustPreLoadData.get(PreLoadDataComparator.Attribute.COMMENT.attrName).getAsInt())
|
.append(illustPreLoadData.get(PreLoadDataComparator.Attribute.COMMENT.attrName).getAsInt())
|
||||||
.append("\n").append(imageMsg).append("\n");
|
.append("\n").append(imageMsg).append("\n");
|
||||||
count++;
|
count++;
|
||||||
|
totalCount++;
|
||||||
}
|
}
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Strings.isNullOrEmpty(result.toString()) ?
|
return totalCount <= 0 ?
|
||||||
"搜索完成,未找到相关作品。" :
|
"搜索完成,未找到相关作品。" :
|
||||||
Strings.nullToEmpty(result.toString()) + "预览图片并非原图,使用“.cgj image -id 作品id”获取原图\n" +
|
Strings.nullToEmpty(result.toString()) + "预览图片并非原图,使用“.cgj image -id 作品id”获取原图\n" +
|
||||||
"如有不当作品,可使用\".cgj report -id 作品id\"向色图姬反馈。";
|
"如有不当作品,可使用\".cgj report -id 作品id\"向色图姬反馈。";
|
||||||
@ -501,9 +503,10 @@ public class BotCommandProcess {
|
|||||||
*/
|
*/
|
||||||
public static boolean isNoSafe(int illustId, Properties settingProp, boolean returnRaw)
|
public static boolean isNoSafe(int illustId, Properties settingProp, boolean returnRaw)
|
||||||
throws IOException, NoSuchElementException {
|
throws IOException, NoSuchElementException {
|
||||||
// TODO(LamGC, 20200604): 看看能不能通过官方获得作品R18信息, 进而加强过滤;
|
JsonObject illustInfo = CacheStoreCentral.getIllustInfo(illustId, false);
|
||||||
JsonArray tags = CacheStoreCentral.getIllustInfo(illustId, false).getAsJsonArray("tags");
|
JsonArray tags = illustInfo.getAsJsonArray("tags");
|
||||||
boolean rawValue = false;
|
boolean rawValue = illustInfo.get("xRestrict").getAsInt() != 0;
|
||||||
|
if(!rawValue) {
|
||||||
for(JsonElement tag : tags) {
|
for(JsonElement tag : tags) {
|
||||||
boolean current = tag.getAsString().matches("R-*18") || tag.getAsString().contains("R18");
|
boolean current = tag.getAsString().matches("R-*18") || tag.getAsString().contains("R18");
|
||||||
// log.warn("Match: {}, Tag: {}", current, tag.getAsString());
|
// log.warn("Match: {}, Tag: {}", current, tag.getAsString());
|
||||||
@ -512,6 +515,7 @@ public class BotCommandProcess {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return returnRaw || settingProp == null ? rawValue :
|
return returnRaw || settingProp == null ? rawValue :
|
||||||
rawValue && !settingProp.getProperty("image.allowR18", "false")
|
rawValue && !settingProp.getProperty("image.allowR18", "false")
|
||||||
.equalsIgnoreCase("true");
|
.equalsIgnoreCase("true");
|
||||||
|
@ -60,7 +60,7 @@ public final class BotGlobal {
|
|||||||
this.dataStoreDir = new File((!dataStoreDirPath.endsWith("/") || !dataStoreDirPath.endsWith("\\")) ?
|
this.dataStoreDir = new File((!dataStoreDirPath.endsWith("/") || !dataStoreDirPath.endsWith("\\")) ?
|
||||||
dataStoreDirPath + System.getProperty("file.separator") : dataStoreDirPath);
|
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");
|
String proxyAddress = System.getProperty("cgj.proxy");
|
||||||
HttpHost temp = null;
|
HttpHost temp = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user