diff --git a/bot.properties.example b/bot.properties.example index 66a5f53..29a40f3 100644 --- a/bot.properties.example +++ b/bot.properties.example @@ -1,4 +1,5 @@ BOT_ENV=dev +BOT_VERSION=1.0.0 BOT_TOKEN= BOT_PREFIX= BOT_OWNER= diff --git a/src/main/java/netneutrality/NetNeutrality.java b/src/main/java/netneutrality/NetNeutrality.java index 330f31d..37caa25 100644 --- a/src/main/java/netneutrality/NetNeutrality.java +++ b/src/main/java/netneutrality/NetNeutrality.java @@ -1,5 +1,11 @@ package netneutrality; +/* + * Copyright (c) anthorob + * + * https://discord.gg/qUa6zNFZsd + */ + import io.sentry.Sentry; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; @@ -30,6 +36,8 @@ public class NetNeutrality { private static JDA jda; public final static Logger logger = LoggerFactory.getLogger(NetNeutrality.class); + public static final String VERSION = "2.0.0"; + public static void main(String[] args) { String sentryDsn = Settings.getInstance().get("SENTRY_DSN"); String env = Settings.getInstance().get("BOT_ENV", "dev"); @@ -37,9 +45,8 @@ public class NetNeutrality { options.setDsn(sentryDsn); options.setEnvironment(env); options.setTracesSampleRate(1.0); - //options.setDebug(env.equals("dev")); options.setDebug(false); - options.setRelease("netneutrality@2.0.0"); + options.setRelease(String.format("netneutrality@%s", VERSION)); }); if ("dev".equals(env)) { @@ -68,8 +75,6 @@ public class NetNeutrality { .build(); jda.awaitReady(); } catch (InvalidTokenException | IllegalArgumentException | InterruptedException e) { - Sentry.captureException(e); - LogHandler.log(e); System.exit(1); } diff --git a/src/main/java/netneutrality/db/entities/OSellyOrder.java b/src/main/java/netneutrality/db/entities/OSellyOrder.java deleted file mode 100644 index 9c15182..0000000 --- a/src/main/java/netneutrality/db/entities/OSellyOrder.java +++ /dev/null @@ -1,114 +0,0 @@ -package netneutrality.db.entities; - -/* - * Copyright (c) anthorob - * - * https://xtremcommunity.com/ - * https://discord.gg/CdFcyQ - */ - -public class OSellyOrder { - - private final String id; - private final String productId; - private final String email; - private final String ip; - private final float value; - private final String currency; - private final String gateway; - private final int risk; - private final int status; - private final int cryptoValue; - private final String cryptoAddress; - private final float usdValue; - private final String createdAt; - - public OSellyOrder(String id, String productId, String email, String ip, float value, String currency, String gateway, int risk, int status, int cryptoValue, String cryptoAddress, float usdValue, String createdAt) { - this.id = id; - this.productId = productId; - this.email = email; - this.ip = ip; - this.value = value; - this.currency = currency; - this.gateway = gateway; - this.risk = risk; - this.status = status; - this.cryptoValue = cryptoValue; - this.cryptoAddress = cryptoAddress; - this.usdValue = usdValue; - this.createdAt = createdAt; - } - - //TODO: Construct from JSONObject - - public String getId() { - return id; - } - - public String getProductId() { - return productId; - } - - public String getEmail() { - return email; - } - - public String getIp() { - return ip; - } - - public float getValue() { - return value; - } - - public String getCurrency() { - return currency; - } - - public String getGateway() { - return gateway; - } - - public int getRisk() { - return risk; - } - - public int getStatus() { - return status; - } - - public int getCryptoValue() { - return cryptoValue; - } - - public String getCryptoAddress() { - return cryptoAddress; - } - - public float getUsdValue() { - return usdValue; - } - - public String getCreatedAt() { - return createdAt; - } - - @Override - public String toString() { - return "MSellyOrder{" + - "id='" + id + '\'' + - ", product_id='" + productId + '\'' + - ", email='" + email + '\'' + - ", ip='" + ip + '\'' + - ", value='" + value + '\'' + - ", currency='" + currency + '\'' + - ", gateway='" + gateway + '\'' + - ", risk='" + risk + '\'' + - ", status='" + status + '\'' + - ", cryptoValue='" + cryptoValue + '\'' + - ", cryptoAddress='" + cryptoAddress + '\'' + - ", usdValue='" + usdValue + '\'' + - ", createdAt='" + createdAt + '\'' + - '}'; - } -} diff --git a/src/main/java/netneutrality/http/Selly.java b/src/main/java/netneutrality/http/Selly.java deleted file mode 100644 index 5bad45c..0000000 --- a/src/main/java/netneutrality/http/Selly.java +++ /dev/null @@ -1,82 +0,0 @@ -package netneutrality.http; -/* - * Copyright (c) anthorob - * - * https://xtremcommunity.com/ - * https://discord.gg/CdFcyQ - */ - -import netneutrality.db.entities.OSellyOrder; -import org.json.JSONArray; -import org.json.JSONObject; - -import java.io.IOException; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; - -public class Selly { - - private final byte[] encodedAuth; - - public Selly(String email, String apiKey) { - String concat = email + ":" + apiKey; - encodedAuth = Base64.getEncoder().encode(concat.getBytes()); - } - - public Map getOrders() { - WebModule sellyApi = new WebModule("https://selly.gg/api/v2/orders"); - Map headers = new HashMap<>(); - Map orders = new HashMap<>(); - headers.put("Authorization", "Basic " + new String(encodedAuth)); - JSONArray response = null; - try { - sellyApi.request(headers); - response = sellyApi.getAsArray(); - } catch (IOException e) { - e.printStackTrace(); - } - - - for (int i = 0; i < response.length(); i++) { - JSONObject order = response.getJSONObject(i); - orders.put(order.getString("id"), new OSellyOrder(order.getString("id"), order.getString("product_id"), order.getString("email"), order.getString("ip_address"), - Float.parseFloat(order.getString("value")), order.getString("currency"), order.getString("gateway"), order.getInt("risk_level"), order.getInt("status"), - order.getInt("crypto_value"), order.getString("crypto_address"), Float.parseFloat(order.getString("usd_value")), order.getString("created_at"))); - } - - - return orders; - } - - public JSONObject getOrderById(String id) { - WebModule order = new WebModule("https://selly.gg/api/v2/orders/" + id); - Map headers = new HashMap<>(); - headers.put("Authorization", "Basic " + new String(encodedAuth)); - JSONObject response = null; - try { - order.request(headers); - response = order.getAsObject(); - } catch (IOException e) { - e.printStackTrace(); - } - - return response; - } - - public JSONArray getProducts() { - WebModule orders = new WebModule("https://selly.gg/api/v2/products"); - Map headers = new HashMap<>(); - headers.put("Authorization", "Basic " + new String(encodedAuth)); - JSONArray response = null; - - try { - orders.request(headers); - response = orders.getAsArray(); - } catch (IOException e) { - e.printStackTrace(); - } - - return response; - } -} diff --git a/src/main/java/netneutrality/http/WebModule.java b/src/main/java/netneutrality/http/WebModule.java index 376037b..ce17a78 100644 --- a/src/main/java/netneutrality/http/WebModule.java +++ b/src/main/java/netneutrality/http/WebModule.java @@ -1,7 +1,14 @@ package netneutrality.http; +/* + * Copyright (c) anthorob + * + * https://discord.gg/qUa6zNFZsd + */ + import io.sentry.Breadcrumb; import io.sentry.Sentry; +import netneutrality.NetNeutrality; import netneutrality.core.LogHandler; import okhttp3.*; import org.json.JSONArray; @@ -19,7 +26,7 @@ public class WebModule { private final OkHttpClient client = new OkHttpClient(); private Response response; //private final String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.43"; - private static final String userAgent = "NetNeutrality/1.0 (Discord bot, anthorob@xtremmail.com)"; + private static final String userAgent = String.format("Net Neutrality/%s (Discord bot, tony@bobert.me)", NetNeutrality.VERSION); public WebModule(String url) { diff --git a/src/main/java/netneutrality/thread/ThreadManager.java b/src/main/java/netneutrality/thread/ThreadManager.java index 335c44b..7854b0f 100644 --- a/src/main/java/netneutrality/thread/ThreadManager.java +++ b/src/main/java/netneutrality/thread/ThreadManager.java @@ -2,8 +2,7 @@ package netneutrality.thread; /* * Copyright (c) anthorob * - * https://xtremcommunity.com/ - * https://discord.gg/CdFcyQ + * https://discord.gg/qUa6zNFZsd */ import java.util.Map; @@ -53,7 +52,7 @@ public class ThreadManager { try { for (ExecutorService ex : executors.values()) { ex.shutdown(); - ex.awaitTermination(2, TimeUnit.SECONDS); + ex.awaitTermination(1, TimeUnit.SECONDS); } } catch (InterruptedException e) { diff --git a/src/main/java/netneutrality/utils/Settings.java b/src/main/java/netneutrality/utils/Settings.java index f0c515e..10f9bf9 100644 --- a/src/main/java/netneutrality/utils/Settings.java +++ b/src/main/java/netneutrality/utils/Settings.java @@ -1,5 +1,11 @@ package netneutrality.utils; +/* + * Copyright (c) anthorob + * + * https://discord.gg/qUa6zNFZsd + */ + import org.apache.commons.io.FileUtils; import java.io.File; @@ -34,7 +40,7 @@ public class Settings { loadEnvironmentVariables(); } catch (IOException e) { - System.err.println("Can't find config file: bot.properties"); + System.err.println("Can't find config file or config file is empty: bot.properties"); System.exit(1); } finally { try { diff --git a/src/main/resources/spy.properties b/src/main/resources/spy.properties deleted file mode 100644 index fa4d6da..0000000 --- a/src/main/resources/spy.properties +++ /dev/null @@ -1,4 +0,0 @@ -driverlist=com.mysql.cj.jdbc.Driver -dateformat=yyyy-MM-dd hh:mm:ss a -appender=com.p6spy.engine.spy.appender.StdoutLogger -logMessageFormat=com.p6spy.engine.spy.appender.SingleLineFormat \ No newline at end of file