Skip to content

Commit

Permalink
Updating tag detection and bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jan 7, 2024
1 parent 31f257f commit 0c96a5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/de/presti/ree6/commands/impl/nsfw/Rule34.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/de/presti/ree6/utils/external/RequestUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 0c96a5b

Please sign in to comment.