Remove unused files and add bot version at runtime
This commit is contained in:
1 parent
d9481f4d85
commit
d61d15f36d
8 files changed
+27
-209
No files matched your search
@@ -1,4 +1,5 @@
|
||||
BOT_ENV=dev
|
||||
BOT_VERSION=1.0.0
|
||||
BOT_TOKEN=
|
||||
BOT_PREFIX=
|
||||
BOT_OWNER=
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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<String, OSellyOrder> getOrders() {
|
||||
WebModule sellyApi = new WebModule("https://selly.gg/api/v2/orders");
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
Map<String, OSellyOrder> 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<String, String> 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<String, String> 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;
|
||||
}
|
||||
}
|
||||
@@ -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, [email protected])";
|
||||
private static final String userAgent = String.format("Net Neutrality/%s (Discord bot, [email protected])", NetNeutrality.VERSION);
|
||||
|
||||
|
||||
public WebModule(String url) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user