diff --git a/src/main/java/de/presti/ree6/commands/impl/nsfw/Rule34.java b/src/main/java/de/presti/ree6/commands/impl/nsfw/Rule34.java index 02da296be..b4f8d0150 100644 --- a/src/main/java/de/presti/ree6/commands/impl/nsfw/Rule34.java +++ b/src/main/java/de/presti/ree6/commands/impl/nsfw/Rule34.java @@ -77,7 +77,8 @@ public void sendMessage(CommandEvent commandEvent) { if (lowerTagTest.contains("loli") || lowerTagTest.contains("child") || lowerTagTest.contains("children") || lowerTagTest.contains("kid") || lowerTagTest.contains("underaged") || lowerTagTest.contains("underage") || - lowerTagTest.contains("young") || lowerTagTest.contains("petite")) { + lowerTagTest.contains("young") || lowerTagTest.contains("petite") || lowerTagTest.contains("toddler") || + lowerTagTest.contains("todler") || lowerTagTest.contains("baby")) { message.editMessage(commandEvent.getResource("message.nsfw.notAllowed")).queue(); return; } diff --git a/src/main/java/de/presti/ree6/utils/external/RequestUtility.java b/src/main/java/de/presti/ree6/utils/external/RequestUtility.java index 2680fe015..36eecfb6c 100644 --- a/src/main/java/de/presti/ree6/utils/external/RequestUtility.java +++ b/src/main/java/de/presti/ree6/utils/external/RequestUtility.java @@ -5,18 +5,18 @@ import com.google.gson.JsonStreamParser; import de.presti.ree6.bot.BotWorker; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Scanner; -import java.util.regex.Pattern; /** * Utility used to work with HTTP Requests. @@ -107,9 +107,16 @@ public static JsonElement requestJson(Request request) { return jsonObject; } + String content = IOUtils.toString(httpResponse, StandardCharsets.UTF_8); + + if (content.isEmpty()) { + jsonObject.getAsJsonObject().addProperty("success", false); + return jsonObject; + } + try { + JsonStreamParser jsonStreamParser = new JsonStreamParser(content); - JsonStreamParser jsonStreamParser = new JsonStreamParser(new InputStreamReader(httpResponse)); if (jsonStreamParser.hasNext()) { jsonObject = jsonStreamParser.next(); } else { @@ -119,6 +126,7 @@ public static JsonElement requestJson(Request request) { return jsonObject; } catch (Exception ex) { log.error("Couldn't send a Request!", ex); + log.error("Content: " + content); } } catch (IOException e) { log.error("Couldn't send a Request!", e);