|
21 | 21 | import java.net.URL; |
22 | 22 | import java.time.Duration; |
23 | 23 | import java.time.temporal.ChronoUnit; |
24 | | -import java.util.Arrays; |
25 | 24 | import java.util.List; |
| 25 | +import java.util.Objects; |
26 | 26 | import java.util.Scanner; |
27 | 27 | import java.util.regex.Matcher; |
28 | 28 | import java.util.regex.Pattern; |
@@ -164,7 +164,7 @@ private void checkContentAutomod(@Nonnull Message message) { |
164 | 164 | */ |
165 | 165 | private void handleSpam(@Nonnull Message msg, Member member) { |
166 | 166 | // java files -> not spam |
167 | | - if (!msg.getAttachments().isEmpty() && msg.getAttachments().stream().allMatch(a -> a.getFileExtension().equals("java"))) { |
| 167 | + if (!msg.getAttachments().isEmpty() && msg.getAttachments().stream().allMatch(a -> Objects.equals(a.getFileExtension(), "java"))) { |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | new ModerationService(Bot.config.get(member.getGuild())) |
@@ -196,21 +196,19 @@ private void handleSpam(@Nonnull Message msg, Member member) { |
196 | 196 | * @param message The message to check. |
197 | 197 | * @return True if a link is found and False if not. |
198 | 198 | */ |
199 | | - public boolean hasSuspiciousLink(Message message) { |
| 199 | + public boolean hasSuspiciousLink(@NotNull Message message) { |
200 | 200 | final String messageRaw = message.getContentRaw(); |
201 | 201 | Matcher urlMatcher = URL_PATTERN.matcher(messageRaw); |
202 | 202 | if (messageRaw.contains("http://") || messageRaw.contains("https://")) { |
203 | 203 | // only do it for a links, so it won't iterate for each message |
204 | 204 | while (urlMatcher.find()) { |
205 | 205 | String url = urlMatcher.group(0).trim(); |
206 | 206 | try { |
207 | | - // TODO: Fix URISyntaxException |
208 | 207 | URI uri = new URI(url); |
209 | 208 | if (uri.getHost() != null && spamUrls.contains(uri.getHost())) { |
210 | 209 | return true; |
211 | 210 | } |
212 | 211 | } catch (URISyntaxException e) { |
213 | | - ExceptionLogger.capture(e, getClass().getSimpleName()); |
214 | 212 | log.error("Error while parsing URL: " + url, e); |
215 | 213 | } |
216 | 214 | } |
|
0 commit comments