Skip to content

Commit 0e49bdc

Browse files
committed
Fixed Issue
1 parent 8e8b868 commit 0e49bdc

File tree

2 files changed

+2
-68
lines changed

2 files changed

+2
-68
lines changed

src/main/java/org/mangorage/mangobot/modules/logs/LogAnalyser.java

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55

66
package org.mangorage.mangobot.modules.logs;
77

8-
import java.io.IOException;
9-
import java.io.InputStream;
10-
import java.util.ArrayList;
118
import java.util.HashSet;
129
import java.util.List;
1310
import java.util.Set;
1411
import java.util.function.BiPredicate;
1512

16-
import org.mangorage.mangobot.core.Util;
17-
18-
import net.dv8tion.jda.api.entities.Message;
19-
2013
public final class LogAnalyser {
2114
public static LogAnalyser of(LogAnalyserModule... modules) {
2215
return new LogAnalyser(List.of(modules));
@@ -59,67 +52,8 @@ public void addAll(LogAnalyserModule... modules) {
5952
this.mods.addAll(List.of(modules));
6053
}
6154

62-
63-
// Be sure to include slashes, Paste.ee and other sites without separate or
64-
// only raw URLs will not work, ones with fancy raw URLs like OpenSUSE paste
65-
// will also not be included at this time.
66-
public String[] supported_paste_sites = new String[] {
67-
"paste.mikumikudance.jp/",
68-
"paste.centos.org/",
69-
"pastebin.com/", "mclo.gs/"
70-
};
71-
72-
public void scanMessage(Message message, StringBuilder stringBuilder) {
73-
String content = message.getContentStripped();
74-
for (String uri : getLogURLs(content)) {
75-
InputStream log = Util.getFileInputStream(uri);
76-
if (log != null) {
77-
try {
78-
String str = Util.getStringFromInputStream(log);
79-
readLog(stringBuilder, str);
80-
} catch (IOException e) {
81-
// TODO Auto-generated catch block
82-
e.printStackTrace();
83-
}
84-
}
85-
86-
}
87-
}
88-
89-
public ArrayList<String> getLogURLs(String message) {
90-
ArrayList<String> list = new ArrayList<>();
91-
for (String word : message.split(" ")) {
92-
93-
for (String paste : supported_paste_sites) {
94-
if (word.contains(paste)) {
95-
96-
if (paste.equals("mclo.gs/")) {
97-
String[] url_arr = word.split("/");
98-
String slug = url_arr[url_arr.length - 1];
99-
list.add("https://api.mclo.gs/1/raw/" + slug);
100-
} else if (paste.equals("pastebin.com/")) {
101-
String[] url_arr = word.split("/");
102-
String slug = url_arr[url_arr.length - 1];
103-
list.add("https://pastebin.com/raw/" + slug);
104-
} else { // Add more else ifs for other sites
105-
if (word.contains("/view/raw/")) {
106-
list.add(word);
107-
} else if (word.contains("/view/")) {
108-
list.add(word.replace("/view/", "/view/raw/"));
109-
}
110-
111-
}
112-
113-
}
114-
115-
}
116-
117-
}
118-
119-
return list;
120-
}
121-
12255
public void readLog(StringBuilder message, String log) {
56+
log = log.replace("\\r?\\n", "\\n");
12357
for(LogAnalyserModule mod : mods) {
12458
mod.analyse(log, message);
12559
}

src/main/java/org/mangorage/mangobot/modules/logs/LogAnalyserModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public interface LogAnalyserModule {
1111

1212
static String[] split(String str) {
13-
return str.replace("\r\n", "\n").replace("\r", "\n").split("\n");
13+
return str.split("\n");
1414
}
1515

1616
LogAnalyser MAIN = LogAnalyser.of(

0 commit comments

Comments
 (0)