Skip to content

Commit

Permalink
quick fixes and standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
WholesomeGodList committed May 3, 2020
1 parent d69ceba commit 980ca02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/main/java/bot/ehentai/EHSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void run() {
queryBuilder.append(" ");
}
}
String query = queryBuilder.toString().substring(0, queryBuilder.toString().length() - 1);
String query = queryBuilder.toString().trim();
ArrayList<String> results;

if (deepSearch) {
Expand All @@ -74,8 +74,10 @@ public void run() {
results = EHFetcher.getTopSearchResults(query, 4, nonrestrict);
}

MessageEmbed noResultsAlert = BotAlert.createAlertEmbed("Search Results", "No results found!");
privatechannel.sendMessage(noResultsAlert).queue();
if(results.isEmpty()) {
MessageEmbed noResultsAlert = BotAlert.createAlertEmbed("Search Results", "No results found!");
privatechannel.sendMessage(noResultsAlert).queue();
}

channel.sendTyping().complete();
channel.sendMessage(BotAlert.createAlertEmbed("Search", "Sending the results to your DMs!")).complete();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/bot/nhentai/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public void run() {
queryBuilder.append(" ");
}
}
queryBuilder.append("english");
String query = queryBuilder.toString();
String query = queryBuilder.toString().trim();
ArrayList<String> results;

if (deepSearch) {
Expand All @@ -75,8 +74,10 @@ public void run() {
results = SoupPitcher.getTopSearchResults(query, 4, nonrestrict);
}

MessageEmbed noResultsAlert = BotAlert.createAlertEmbed("Search Results", "No results found!");
privatechannel.sendMessage(noResultsAlert).queue();
if(results.isEmpty()) {
MessageEmbed noResultsAlert = BotAlert.createAlertEmbed("Search Results", "No results found!");
privatechannel.sendMessage(noResultsAlert).queue();
}

channel.sendTyping().complete();
channel.sendMessage(BotAlert.createAlertEmbed("Search", "Sending the results to your DMs!")).complete();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/bot/nhentai/SoupPitcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static int getLatestNumber() {
}

public static ArrayList<String> getTopSearchResults(String query, int pages, boolean nonrestrict) {
query += " english";
String urlQuery = "https://nhentai.net/search/?q=" + URLEncoder.encode(query, StandardCharsets.UTF_8) + "&sort=popular&page=";
ArrayList<String> results = new ArrayList<>();
String newUrlQuery;
Expand All @@ -83,12 +84,12 @@ public static ArrayList<String> getTopSearchResults(String query, int pages, boo
logger.info("Checking " + cur);
SoupPitcher curChecker = new SoupPitcher(cur);
if (!nonrestrict) {
if (curChecker.getLanguage().equals("English") && TagChecker.wholesomeCheck(curChecker.getTags(), query)) {
if (TagChecker.wholesomeCheck(curChecker.getTags(), query)) {
results.add(cur);
logger.info("Wholesome!");
}
} else {
if (curChecker.getLanguage().equals("English") && TagChecker.tagCheck(curChecker.getTags()).isEmpty()) {
if (TagChecker.tagCheck(curChecker.getTags()).isEmpty()) {
results.add(cur);
logger.info("Wholesome!");
}
Expand Down

0 comments on commit 980ca02

Please sign in to comment.