[FEATURE] Added bugsnag

This commit is contained in:
JKetelaar
2015-12-27 01:21:09 +01:00
parent 5254fdf8b6
commit 9ee3efae4c
4 changed files with 26 additions and 0 deletions
+3
View File
@@ -1,5 +1,6 @@
package org.parabot;
import com.bugsnag.Client;
import org.parabot.core.Configuration;
import org.parabot.core.Core;
import org.parabot.core.Directories;
@@ -28,6 +29,8 @@ public final class Landing {
private static String username;
private static String password;
public static void main(String... args) throws IOException {
Core.initiateBugsnagInstance();
parseArgs(args);
Core.verbose("Debug mode: " + Core.inDebugMode());
@@ -22,6 +22,7 @@ public class Configuration {
public static final String GET_RANDOMS = "http://bdn.parabot.org/api/get.php?action=randoms";
public static final String DATA_API = "http://bdn.parabot.org/api/v2/data/";
public static final String ITEM_API = DATA_API + "items/";
public static final String BUGSNAG_API = "d79752cf94dd4beb24c3d312a8609f53";
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
}
+18
View File
@@ -1,5 +1,6 @@
package org.parabot.core;
import com.bugsnag.Client;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
import org.parabot.Landing;
@@ -36,6 +37,8 @@ public class Core {
private static Version currentVersion = Configuration.BOT_VERSION;
private static Version latestVersion;
private static Client bugsnagInstance;
public static void disableValidation() {
Core.validate = false;
}
@@ -281,6 +284,8 @@ public class Core {
Core.verbose("Checking for updates...");
validateCache();
setBugsnagVersion();
if ((validVersion() && checksumValid()) || (!checksumValid() && currentVersion.compareTo(latestVersion) >= 0)){
Core.verbose("No updates available.");
return true;
@@ -290,6 +295,19 @@ public class Core {
}
}
public static void initiateBugsnagInstance() {
bugsnagInstance = new Client(Configuration.BUGSNAG_API);
bugsnagInstance.setSendThreads(true);
}
public static void setBugsnagVersion(){
Core.bugsnagInstance.setReleaseStage(currentVersion.compareTo(latestVersion) >= 0 ? "development" : "production");
}
public static void setBugsnagUser(String id, String email, String username){
Core.bugsnagInstance.setUser(id, email, username);
}
public static void debug(int i) {
if(mDebug) {
System.out.println("DEBUG: " + i);
@@ -1,5 +1,7 @@
package org.parabot.core.forum;
import org.parabot.core.Core;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -31,6 +33,8 @@ public class Account {
this.username = username;
this.password = password;
this.api = api;
Core.setBugsnagUser("Null", this.username, "Null");
}
/**