diff --git a/pom.xml b/pom.xml
index 4603f79..45f491a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,7 +116,7 @@
flyway-maven-plugin
${flyway.version}
- jdbc:mariadb://devops.locusworks.net:3306/
+ jdbc:mariadb://localhost:3306/
false
eighttrack
@@ -126,8 +126,6 @@
filesystem:${basedir}/src/main/resources/database/migration
-
org.mariadb.jdbc
diff --git a/src/main/java/net/locusworks/discord/eighttrack/enums/UserCommands.java b/src/main/java/net/locusworks/discord/eighttrack/enums/UserCommands.java
new file mode 100644
index 0000000..c5d6ebe
--- /dev/null
+++ b/src/main/java/net/locusworks/discord/eighttrack/enums/UserCommands.java
@@ -0,0 +1,5 @@
+package net.locusworks.discord.eighttrack.enums;
+
+public enum UserCommands {
+
+}
diff --git a/src/main/java/net/locusworks/discord/eighttrack/handlers/DiscordEventHandler.java b/src/main/java/net/locusworks/discord/eighttrack/handlers/DiscordEventHandler.java
index 9c2e5b1..cb966c3 100644
--- a/src/main/java/net/locusworks/discord/eighttrack/handlers/DiscordEventHandler.java
+++ b/src/main/java/net/locusworks/discord/eighttrack/handlers/DiscordEventHandler.java
@@ -175,6 +175,9 @@ public class DiscordEventHandler extends ListenerAdapter {
case "-playlist":
gmh.playlist(event, commands);
return;
+ case "+playlist":
+ gmh.adminPlaylist(event, commands);
+ return;
case "+delete":
gmh.delete(event, commands);
return;
diff --git a/src/main/java/net/locusworks/discord/eighttrack/handlers/GuildMusicHandler.java b/src/main/java/net/locusworks/discord/eighttrack/handlers/GuildMusicHandler.java
index aff80e5..29ea718 100644
--- a/src/main/java/net/locusworks/discord/eighttrack/handlers/GuildMusicHandler.java
+++ b/src/main/java/net/locusworks/discord/eighttrack/handlers/GuildMusicHandler.java
@@ -295,10 +295,7 @@ public class GuildMusicHandler {
}
public void upload(GuildMessageReceivedEvent event) {
- if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
- event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
- return;
- }
+ isAdmin(event);
for(Attachment attachment : event.getMessage().getAttachments()) {
attachment.retrieveInputStream().thenAccept((in) -> {
@@ -361,20 +358,17 @@ public class GuildMusicHandler {
sb.append("```");
event.getChannel().sendMessage(sb.toString()).queue();
}
+
+ public void adminPlaylist(GuildMessageReceivedEvent event, List commands) {
+ if(!isAdmin(event)) return;
+
+ }
public void delete(GuildMessageReceivedEvent event, List commands) {
- if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
- event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
- return;
- }
+ if(!isAdmin(event)) return;
if (commands == null || commands.isEmpty()) {
- event.getChannel().sendMessage(event.getAuthor().getAsMention() + " please provide the name of the playlist to play").queue();
- return;
- }
-
- if (commands == null || commands.isEmpty()) {
- event.getChannel().sendMessage("Missing command for +delete. Valid commands are: song, playlist").queue();
+ event.getChannel().sendMessage(event.getMember().getAsMention() + ", Missing command for +delete. Valid commandis : +delete song uuids...").queue();
return;
}
@@ -384,9 +378,6 @@ public class GuildMusicHandler {
case "song":
deleteSong(event, commands);
return;
- case "playlist":
- deleteUserPlayList(event, commands);
- return;
}
}
@@ -591,10 +582,8 @@ public class GuildMusicHandler {
}
private void deleteSong(GuildMessageReceivedEvent event, List commands) {
- if (commands == null || commands.isEmpty()) {
- event.getChannel().sendMessage(event.getAuthor().getAsMention() + ", you have to provide the list of uuids for songs to remove").queue();
- return;
- }
+ if(!checkCommands(event, commands,
+ event.getAuthor().getAsMention() + ", you have to provide the list of uuids for songs to remove")) return;
List songs = guildSongRepoService.getGuildSongRepo().findByGuildAndUuidIn(event.getGuild().getIdLong(), commands.stream().collect(Collectors.toSet()));
if (songs.isEmpty()) {
@@ -629,7 +618,7 @@ public class GuildMusicHandler {
private void deleteUserPlayList(GuildMessageReceivedEvent event, List commands) {
// TODO Auto-generated method stub
-
+ System.out.println(commands.stream().collect(Collectors.joining(", ")));
}
private void deleteGuildSongsConfirm(List songs, String user, Message msg) {
@@ -646,10 +635,8 @@ public class GuildMusicHandler {
}
private void deletePlayList(GuildMessageReceivedEvent event, List commands) {
- if (commands == null || commands.isEmpty()) {
- event.getChannel().sendMessage(event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add").queue();
- return;
- }
+ if(!checkCommands(event, commands,
+ event.getAuthor().getAsMention() + " you have to provide the playlist name and optionally a list of uuids for songs to remove")) return;
Long guildId = event.getGuild().getIdLong();
@@ -743,10 +730,8 @@ public class GuildMusicHandler {
}
private void addPlayList(GuildMessageReceivedEvent event, List commands) {
- if (commands == null || commands.isEmpty()) {
- event.getChannel().sendMessage(event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add").queue();
- return;
- }
+ if(!checkCommands(event, commands,
+ event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add")) return;
Long guildId = event.getGuild().getIdLong();
@@ -850,6 +835,22 @@ public class GuildMusicHandler {
return true;
}
+
+ private boolean isAdmin(GuildMessageReceivedEvent event) {
+ if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
+ event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
+ return false;
+ }
+ return true;
+ }
+
+ private boolean checkCommands(GuildMessageReceivedEvent event, List commands, String msg) {
+ if (commands == null || commands.isEmpty()) {
+ event.getChannel().sendMessage(msg).queue();
+ return false;
+ }
+ return true;
+ }
private void deleteMessage(Message msg) {
try {
@@ -859,4 +860,5 @@ public class GuildMusicHandler {
if (ex.getErrorResponse() != ErrorResponse.UNKNOWN_MESSAGE) throw ex;
}
}
+
}
diff --git a/src/main/java/net/locusworks/discord/eighttrack/services/ConfigurationService.java b/src/main/java/net/locusworks/discord/eighttrack/services/ConfigurationService.java
index b349739..627ec2a 100644
--- a/src/main/java/net/locusworks/discord/eighttrack/services/ConfigurationService.java
+++ b/src/main/java/net/locusworks/discord/eighttrack/services/ConfigurationService.java
@@ -36,6 +36,7 @@ import java.util.Properties;
import javax.annotation.PostConstruct;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -214,7 +215,10 @@ public class ConfigurationService {
}
public Path getMusicDirectory() {
- String dir = configuration.getProperty(Configuration.MUSIC_DIR.getValue(), "");
+ String dir = System.getProperty("MUSIC_DIR") == null ? System.getenv("MUSIC_DIR") : System.getProperty("MUSIC_DIR");
+ if (StringUtils.isBlank(dir)) {
+ dir = configuration.getProperty(Configuration.MUSIC_DIR.getValue(), "");
+ }
return Paths.get(dir);
}
diff --git a/src/main/resources/database/migration/mariadb/afterMigrate.sql b/src/main/resources/database/migration/mariadb/afterMigrate.sql
index 57a53a8..ab92cc8 100644
--- a/src/main/resources/database/migration/mariadb/afterMigrate.sql
+++ b/src/main/resources/database/migration/mariadb/afterMigrate.sql
@@ -1,4 +1,4 @@
-USE pseudobot;
+USE eighttrack;
DELIMITER $$
CREATE PROCEDURE set_optimizer_switch_on()
@@ -15,10 +15,6 @@ BEGIN
IF foo = 0 THEN
CREATE USER 'eighttrackAdmin'@'localhost' IDENTIFIED BY 'zeGAPgbH9HFbqmjRjmwzUDKv';
END IF;
- SELECT COUNT(*) INTO foo FROM mysql.user WHERE User = 'eighttrackAdmin' and Host = '%';
- IF foo = 0 THEN
- CREATE USER 'eighttrackAdmin'@'%' IDENTIFIED BY 'zeGAPgbH9HFbqmjRjmwzUDKv';
- END IF;
END ;$$
DELIMITER ;
@@ -30,5 +26,4 @@ CALL create_user();
DROP PROCEDURE create_user;
GRANT SELECT,INSERT,UPDATE,DELETE ON eighttrack.* TO 'eighttrackAdmin'@'localhost';
-GRANT SELECT,INSERT,UPDATE,DELETE ON eighttrack.* TO 'eighttrackAdmin'@'%';
FLUSH PRIVILEGES;
\ No newline at end of file
diff --git a/src/main/resources/database/migration/mariadb/beforeMigrate.sql b/src/main/resources/database/migration/mariadb/beforeMigrate.sql
new file mode 100644
index 0000000..0346302
--- /dev/null
+++ b/src/main/resources/database/migration/mariadb/beforeMigrate.sql
@@ -0,0 +1 @@
+CREATE DATABASE IF NOT EXISTS eighttrack;
\ No newline at end of file
diff --git a/src/main/resources/eighttrack.properties b/src/main/resources/eighttrack.properties
index 9d405df..8d03e8a 100644
--- a/src/main/resources/eighttrack.properties
+++ b/src/main/resources/eighttrack.properties
@@ -2,7 +2,7 @@ dbAdmin=root
dbAdminPassword=gSkjsvZbQTQtogOrPYqorCuuzp4WUpGFVtPYtMVj47U=
dbUser=eighttrackAdmin
dbUserPassword=RaamWDMgA2p09R3kAiKHqauu6mmKU2HLQ4nAfEGMNOs=
-dbHost=devops.locusworks.net
+dbHost=localhost
dbPort=3306
logLevel=INFO
musicDir=E:/Music