From 4570de69d2a4ed082eb2ec85d3e3b9c98cd7de84 Mon Sep 17 00:00:00 2001 From: Aidan Veney Date: Wed, 31 Jul 2024 19:20:21 -0400 Subject: [PATCH] Fix FLR-22 --- .gradle/8.5/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 17 bytes .../flames/events/MessageEvent.java | 1 + .../flames/external/analysis/Analysis.java | 10 +++++----- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gradle/8.5/fileHashes/fileHashes.lock b/.gradle/8.5/fileHashes/fileHashes.lock index 32be7de19d3fd848f8dacd6e3ae9b6e3b2f66071..f476cbca77a77761b3fba17ea85e07346ecd1887 100644 GIT binary patch literal 17 VcmZP;f7<$1n(5GQ1~3qi1^_f_1a|-c literal 17 VcmZP;f7<$1n(5GQ1~3p{1pqWu1YrOG diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index c8c1769d0341d9de62de02ec3f9d98daed078024..4cfb409ad361934ed44d3bde569c1ce710524ebb 100644 GIT binary patch literal 17 VcmZR!TzxQ6SpN141~8D>1^_WJ1knHh literal 17 VcmZR!TzxQ6SpN141~8D>001#71j_&b diff --git a/src/main/java/com/severalcircles/flames/events/MessageEvent.java b/src/main/java/com/severalcircles/flames/events/MessageEvent.java index 44472feb..599b8145 100644 --- a/src/main/java/com/severalcircles/flames/events/MessageEvent.java +++ b/src/main/java/com/severalcircles/flames/events/MessageEvent.java @@ -35,6 +35,7 @@ public class MessageEvent extends ListenerAdapter implements FlamesDiscordEvent @Override public void onMessageReceived(@NotNull MessageReceivedEvent event) { Logger.getGlobal().log(Level.FINE,event.getAuthor().getId() + " Triggered Message Event"); + if (event.getMessage().getContentRaw().matches("[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)")) return; // Don't process URLs super.onMessageReceived(event); User user = event.getAuthor(); Logger logger = Logger.getGlobal(); diff --git a/src/main/java/com/severalcircles/flames/external/analysis/Analysis.java b/src/main/java/com/severalcircles/flames/external/analysis/Analysis.java index 886c1c7e..cdde431e 100644 --- a/src/main/java/com/severalcircles/flames/external/analysis/Analysis.java +++ b/src/main/java/com/severalcircles/flames/external/analysis/Analysis.java @@ -51,13 +51,13 @@ public static List analyzeEntities(String message) throws IOException { AnalyzeEntitiesResponse response = language.analyzeEntities(request); // Print the response - response.getEntitiesList().forEach((element) -> { + List finalList = response.getEntitiesList(); + finalList.removeIf(entity -> entity.getName().matches("\\d+")); + finalList.forEach((element) -> { if (!entityCache.containsKey(element.getName())) entityCache.put(element.getName(), 1); else entityCache.put(element.getName(), entityCache.get(element.getName()) + 1); - }); + }); language.shutdownNow(); - //noinspection StatementWithEmptyBody - while (!language.isShutdown()) {} - return response.getEntitiesList(); + return finalList; } } \ No newline at end of file