minor updates for the eventnotifier to run on ze again and minor adjustment for racetimer to detect teleport abuse
This commit is contained in:
@@ -62,7 +62,7 @@ public class DataMapper {
|
||||
int i = 1;
|
||||
for (String str : EventContentMap.values()) {
|
||||
if (i < 6) {
|
||||
System.out.println("str: " + str + "\n");
|
||||
//System.out.println("str: " + str + "\n");
|
||||
s.setString(i, str);
|
||||
i++;
|
||||
} else {
|
||||
|
||||
+56
-24
@@ -30,6 +30,8 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import static jdk.nashorn.internal.objects.NativeRegExp.source;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
@@ -57,52 +59,82 @@ public class EventNotifier {
|
||||
int firstEventForZEFinder = 0;
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine).append("\n");
|
||||
if (inputLine.contains(">Event #") && firstEventForZEFinder == 0) {
|
||||
if (!inputLine.contains("Nomination") && !inputLine.contains("Poll")) {
|
||||
int diff = content.length() - inputLine.length();
|
||||
firstEventForZEFinder = diff > 0 ? diff : 0;
|
||||
if (inputLine.contains(">Event #") && inputLine.contains("data-previewUrl=\"") && firstEventForZEFinder == 0) {
|
||||
//System.out.println("inputLine: " + inputLine);
|
||||
boolean find = Pattern.compile(Pattern.quote("nomination"), Pattern.CASE_INSENSITIVE).matcher(inputLine).find();
|
||||
if (!find) {
|
||||
find = Pattern.compile(Pattern.quote("poll"), Pattern.CASE_INSENSITIVE).matcher(inputLine).find();
|
||||
if (!find) {
|
||||
int diff = content.length() - inputLine.length();
|
||||
firstEventForZEFinder = diff > 0 ? diff : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String str = content.toString();
|
||||
String hRef = "<a href=\"";
|
||||
String hRef = "data-previewUrl=\"";
|
||||
str = str.substring(firstEventForZEFinder);
|
||||
//System.out.println("str post firstEventForZEFinder: " + str);
|
||||
str = str.substring(0, str.indexOf(">Event #"));
|
||||
str = str.substring(str.lastIndexOf(hRef), str.lastIndexOf("\" title="));
|
||||
str = str.trim();
|
||||
str = str.substring(str.indexOf(hRef), str.lastIndexOf("/preview\""));
|
||||
str = str.replace(hRef, "");
|
||||
String urlFirstEvent = "https://unloze.com/" + str;
|
||||
System.out.println(urlFirstEvent);
|
||||
System.out.println("urlFirstEvent: " + urlFirstEvent);
|
||||
url = new URL(urlFirstEvent);
|
||||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
content = new StringBuffer();
|
||||
String title = "";
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine).append("\n");
|
||||
if (inputLine.contains("Server :")) {
|
||||
int diff = content.length() - inputLine.length();
|
||||
firstEventForZEFinder = diff > 0 ? diff : 0;
|
||||
}
|
||||
if (inputLine.contains("<title>Event #")) {
|
||||
title = inputLine;
|
||||
}
|
||||
if (inputLine.contains("Prize :")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
str = content.toString();
|
||||
if (str.contains("Server :") && str.contains("Maps :") && str.contains("Prize :")) {
|
||||
ConcurrentMap<Integer, String> eventContentMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
String html2text = html2text(str);
|
||||
System.out.println(html2text);
|
||||
String title = html2text.substring(0, html2text.indexOf("| UNLOZE"));
|
||||
eventContentMap.put(eventContentMap.size(), title);
|
||||
String rewards = html2text.substring(html2text.indexOf("Prize :") + 7, html2text.lastIndexOf("won"));
|
||||
rewards = rewards + "won";
|
||||
eventContentMap.put(eventContentMap.size(), rewards);
|
||||
String leaders = html2text.substring(html2text.indexOf("Leader :") + 7, html2text.indexOf("Prize :"));
|
||||
eventContentMap.put(eventContentMap.size(), leaders);
|
||||
String date = html2text.substring(html2text.indexOf("Date :") + 6, html2text.indexOf("Time :"));
|
||||
eventContentMap.put(eventContentMap.size(), date);
|
||||
String Time = html2text.substring(html2text.indexOf("Time :") + 6, html2text.indexOf("Leader :"));
|
||||
eventContentMap.put(eventContentMap.size(), Time);
|
||||
String maps = html2text.substring(html2text.indexOf("Maps : -") + 6, html2text.indexOf("Date :"));
|
||||
str = str.substring(firstEventForZEFinder);
|
||||
//System.out.println("str pre thread check: " + str);
|
||||
ConcurrentMap<Integer, String> eventContentMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
String html2text = html2text(str);
|
||||
//System.out.println("html2text: " + html2text);
|
||||
title = html2text(title);
|
||||
title = title.substring(0, title.length() - 8);
|
||||
// System.out.println("title: " + title);
|
||||
eventContentMap.put(eventContentMap.size(), title);
|
||||
String rewards = html2text.substring(html2text.indexOf("Prize :") + 7);
|
||||
// System.out.println("rewards: " + rewards);
|
||||
eventContentMap.put(eventContentMap.size(), rewards);
|
||||
String leaders = html2text.substring(html2text.indexOf("Leader :") + 7, html2text.indexOf("Prize :"));
|
||||
eventContentMap.put(eventContentMap.size(), leaders);
|
||||
String date = html2text.substring(html2text.indexOf("Date :") + 6, html2text.indexOf("Time :"));
|
||||
eventContentMap.put(eventContentMap.size(), date);
|
||||
String Time = html2text.substring(html2text.indexOf("Time :") + 6, html2text.indexOf("Leader :"));
|
||||
eventContentMap.put(eventContentMap.size(), Time);
|
||||
String maps = html2text.substring(html2text.indexOf("Maps : -") + 6, html2text.indexOf("Date :"));
|
||||
if (maps.contains("CS:S Zombie Escape Server IP")){
|
||||
maps = maps.substring(maps.indexOf("Map :") + 5);
|
||||
}
|
||||
maps = maps.trim();
|
||||
System.out.println("maps: " + maps);
|
||||
if (!maps.contains("-")) {
|
||||
eventContentMap.put(eventContentMap.size(), maps);
|
||||
} else {
|
||||
String[] split = maps.split("-");
|
||||
for (String strsplit : split) {
|
||||
eventContentMap.put(eventContentMap.size(), strsplit);
|
||||
}
|
||||
DataMapper.instance.insertIntoDBEventContent(eventContentMap);
|
||||
}
|
||||
//System.out.println("pre insertIntoDBEventContent");
|
||||
DataMapper.instance.insertIntoDBEventContent(eventContentMap);
|
||||
con.disconnect();
|
||||
in.close();
|
||||
} catch (MalformedURLException | ProtocolException ex) {
|
||||
|
||||
Reference in New Issue
Block a user