Changed properties name and update build process
This commit is contained in:
1 parent
f51ae465bd
commit
f3d11a5f98
12 files changed
+52
-38
No files matched your search
@@ -0,0 +1,13 @@
|
||||
NETNEUTRALITY_BOT_ENV=dev
|
||||
NETNEUTRALITY_BOT_TOKEN=
|
||||
NETNEUTRALITY_BOT_PREFIX=$
|
||||
NETNEUTRALITY_BOT_OWNER=
|
||||
NETNEUTRALITY_API_PORT=9000
|
||||
|
||||
NETNEUTRALITY_MYSQL_HOST=127.0.0.1
|
||||
NETNEUTRALITY_MYSQL_USER=root
|
||||
NETNEUTRALITY_MYSQL_PASSWORD=
|
||||
NETNEUTRALITY_MYSQL_DATABASE=
|
||||
NETNEUTRALITY_MYSQL_PORT=3306
|
||||
|
||||
NETNEUTRALITY_SENTRY_DSN=
|
||||
+3
-1
@@ -42,4 +42,6 @@ log/
|
||||
target/
|
||||
|
||||
#log4j
|
||||
logs/
|
||||
logs/
|
||||
|
||||
.env
|
||||
@@ -3,7 +3,6 @@ FROM eclipse-temurin:17-jdk-alpine as build
|
||||
COPY .mvn/ .mvn
|
||||
COPY mvnw pom.xml ./
|
||||
COPY src ./src
|
||||
COPY bot.properties.example bot.properties ./
|
||||
|
||||
RUN ["chmod", "+x", "./mvnw"]
|
||||
RUN ./mvnw install
|
||||
@@ -19,7 +18,6 @@ WORKDIR /app
|
||||
ARG API_PORT=9000
|
||||
EXPOSE ${API_PORT}
|
||||
|
||||
COPY bot.properties.example bot.properties ./
|
||||
COPY startup.sh ./
|
||||
COPY --from=build /target/netneutrality-jar-with-dependencies.jar ./
|
||||
|
||||
|
||||
+11
-14
@@ -1,16 +1,13 @@
|
||||
BOT_ENV=dev
|
||||
BOT_VERSION=1.0.0
|
||||
BOT_TOKEN=
|
||||
BOT_PREFIX=
|
||||
BOT_OWNER=
|
||||
GG_EMAIL=
|
||||
GG_PASS=
|
||||
API_PORT=9000
|
||||
NETNEUTRALITY_BOT_ENV=dev
|
||||
NETNEUTRALITY_BOT_TOKEN=
|
||||
NETNEUTRALITY_BOT_PREFIX=
|
||||
NETNEUTRALITY_BOT_OWNER=
|
||||
NETNEUTRALITY_API_PORT=9000
|
||||
|
||||
MYSQL_HOST=127.0.0.1
|
||||
MYSQL_USER=root
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_PORT=3306
|
||||
NETNEUTRALITY_MYSQL_HOST=127.0.0.1
|
||||
NETNEUTRALITY_MYSQL_USER=root
|
||||
NETNEUTRALITY_MYSQL_PASSWORD=
|
||||
NETNEUTRALITY_MYSQL_DATABASE=
|
||||
NETNEUTRALITY_MYSQL_PORT=3306
|
||||
|
||||
SENTRY_DSN=
|
||||
NETNEUTRALITY_SENTRY_DSN=
|
||||
@@ -1,7 +1,8 @@
|
||||
services:
|
||||
db:
|
||||
image: mariadb:10.7
|
||||
restart: always
|
||||
image: mariadb:lts
|
||||
container_name: db
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- netneutrality-db:/var/lib/mysql
|
||||
- ./sql:/docker-entrypoint-initdb.d
|
||||
@@ -10,17 +11,20 @@ services:
|
||||
MYSQL_PASSWORD: 'password'
|
||||
MYSQL_DATABASE: 'netneutrality'
|
||||
MYSQL_ROOT_PASSWORD: 'password'
|
||||
MARIADB_AUTO_UPGRADE: '1'
|
||||
ports:
|
||||
- "3306"
|
||||
networks:
|
||||
- internal
|
||||
|
||||
bot:
|
||||
image: netneutrality:dev
|
||||
container_name: bot
|
||||
build: ./
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
environment:
|
||||
MYSQL_HOST: 'db'
|
||||
MYSQL_USER: 'java'
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
<version>3.7.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Multi-Release>true</Multi-Release>
|
||||
</manifestEntries>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>${main.class}</mainClass>
|
||||
|
||||
@@ -39,9 +39,9 @@ public class NetNeutrality {
|
||||
public static final String VERSION = "2.0.0";
|
||||
|
||||
public static void main(String[] args) {
|
||||
String env = Settings.getInstance().get("BOT_ENV", "dev");
|
||||
String env = Settings.getInstance().get("NETNEUTRALITY_BOT_ENV", "dev");
|
||||
|
||||
String sentryDsn = Settings.getInstance().get("SENTRY_DSN");
|
||||
String sentryDsn = Settings.getInstance().get("NETNEUTRALITY_SENTRY_DSN");
|
||||
if (sentryDsn != null) {
|
||||
logger.info("Found Sentry DSN in config, setting up the SDK..");
|
||||
|
||||
@@ -50,7 +50,6 @@ public class NetNeutrality {
|
||||
options.setEnvironment(env);
|
||||
options.setTracesSampleRate(1.0);
|
||||
options.setDebug(false);
|
||||
options.setRelease(String.format("netneutrality@%s", VERSION));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ public class NetNeutrality {
|
||||
MusicManager.initPlayerManager();
|
||||
jda.addEventListener(new MessageReceivedHandler(), new EditHandler(), new ServerJoinHandler());
|
||||
jda.addEventListener(new SlashCommandHooks());
|
||||
new WebApi(Integer.parseInt(Settings.getInstance().get("API_PORT", "9000")));
|
||||
new WebApi(Integer.parseInt(Settings.getInstance().get("NETNEUTRALITY_API_PORT", "9000")));
|
||||
jda.getPresence().setActivity(Activity.watching("you"));
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new BaseThreadFactory("shutdown").newThread(new ShutdownThread()));
|
||||
@@ -72,7 +71,7 @@ public class NetNeutrality {
|
||||
}
|
||||
|
||||
public static void initJDA() {
|
||||
String token = Settings.getInstance().get("BOT_TOKEN");
|
||||
String token = Settings.getInstance().get("NETNEUTRALITY_BOT_TOKEN");
|
||||
if (token == null) {
|
||||
DBController.shutdown();
|
||||
throw new RuntimeException("No bot token provided, exiting.");
|
||||
|
||||
@@ -29,10 +29,10 @@ public class SessionManager {
|
||||
try {
|
||||
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder().configure();
|
||||
Map<String, Object> settings = new HashMap<>();
|
||||
String dbName = Settings.getInstance().get("MYSQL_DATABASE", "netneutrality");
|
||||
String dbUser = Settings.getInstance().get("MYSQL_USER", "root");
|
||||
String dbPass = Settings.getInstance().get("MYSQL_PASSWORD", "");
|
||||
String dbHost = Settings.getInstance().get("MYSQL_HOST", "localhost");
|
||||
String dbName = Settings.getInstance().get("NETNEUTRALITY_MYSQL_DATABASE", "netneutrality");
|
||||
String dbUser = Settings.getInstance().get("NETNEUTRALITY_MYSQL_USER", "root");
|
||||
String dbPass = Settings.getInstance().get("NETNEUTRALITY_MYSQL_PASSWORD", "");
|
||||
String dbHost = Settings.getInstance().get("NETNEUTRALITY_MYSQL_HOST", "localhost");
|
||||
logger.info(String.format("Connecting to database '%s' at %s:3306 with user '%s'", dbName, dbHost, dbUser));
|
||||
|
||||
settings.put(Environment.URL, String.format("jdbc:mysql://%s:3306/%s", dbHost, dbName));
|
||||
@@ -46,7 +46,7 @@ public class SessionManager {
|
||||
sessionFactory = metadata.getSessionFactoryBuilder().build();
|
||||
|
||||
} catch (Exception e) {
|
||||
String env = Settings.getInstance().get("BOT_ENV", "dev");
|
||||
String env = Settings.getInstance().get("NETNEUTRALITY_BOT_ENV", "dev");
|
||||
if (!"dev".equals(env)) {
|
||||
Sentry.captureException(e);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MessageCommandContext implements CommandContext {
|
||||
|
||||
public String[] getArgs() {
|
||||
String msg = message.getContentDisplay().trim();
|
||||
msg = msg.substring(Settings.getInstance().get("BOT_PREFIX", "$").length()).trim();
|
||||
msg = msg.substring(Settings.getInstance().get("NETNEUTRALITY_BOT_PREFIX", "$").length()).trim();
|
||||
String cmd = msg.split(" ", 2)[0];
|
||||
String[] args = msg.replaceFirst("(" + cmd + ")(\\s+)?", "").split("\s");
|
||||
|
||||
@@ -84,7 +84,7 @@ public class MessageCommandContext implements CommandContext {
|
||||
|
||||
public String getMessageText() {
|
||||
String msg = message.getContentDisplay().trim();
|
||||
msg = msg.substring(Settings.getInstance().get("BOT_PREFIX", "$").length()).trim();
|
||||
msg = msg.substring(Settings.getInstance().get("NETNEUTRALITY_BOT_PREFIX", "$").length()).trim();
|
||||
String cmd = msg.split(" ", 2)[0];
|
||||
|
||||
return msg.replaceFirst("(" + cmd + ")(\s)?", "");
|
||||
@@ -184,7 +184,7 @@ public class MessageCommandContext implements CommandContext {
|
||||
}
|
||||
|
||||
public boolean isMessageFromCreator() {
|
||||
String creatorId = Settings.getInstance().get("BOT_OWNER");
|
||||
String creatorId = Settings.getInstance().get("NETNEUTRALITY_BOT_OWNER");
|
||||
|
||||
return creatorId.equals(member.getId());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MessageReceivedHandler extends ListenerAdapter {
|
||||
GuildManager.getManager(context.getGuild()).checkAndLogMessage(message, context.getGuildUser(), context.getChannel());
|
||||
|
||||
String rawMessage = message.getContentDisplay().trim();
|
||||
String prefix = Settings.getInstance().get("BOT_PREFIX", "$");
|
||||
String prefix = Settings.getInstance().get("NETNEUTRALITY_BOT_PREFIX", "$");
|
||||
|
||||
if (rawMessage.startsWith(prefix)) {
|
||||
rawMessage = rawMessage.replaceFirst(String.format("^[%s\\s]{1,}", prefix), "").trim();
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.Properties;
|
||||
public class Settings {
|
||||
|
||||
private static Settings INSTANCE;
|
||||
private final File propFile = new File("bot.properties");
|
||||
private final Properties prop = new Properties();
|
||||
public final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
@@ -26,8 +27,6 @@ public class Settings {
|
||||
}
|
||||
|
||||
private void checkAndLoadPropertiesFile() {
|
||||
File propFile = new File("bot.properties");
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(propFile)) {
|
||||
prop.load(fis);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: netneutrality.NetNeutrality
|
||||
|
||||
Reference in new issue
Block a user