From 5e5419d2bec2267382c4deab6e2d243fc7efe1b1 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Thu, 15 Feb 2018 00:57:07 +0100 Subject: [PATCH 1/2] Revert "Merge branch 'devel' into origin/master" This reverts commit 34ce297e7c1ff524cb39ee97e415cd53f624a94d. --- .gitignore | 4 - Dockerfile | 2 +- build.gradle | 15 +- src/main/java/net/Broken/BotListener.java | 4 +- src/main/java/net/Broken/Commands/Cat.java | 2 +- src/main/java/net/Broken/Commands/Flush.java | 2 +- src/main/java/net/Broken/Commands/Help.java | 6 +- src/main/java/net/Broken/Commands/Move.java | 4 +- src/main/java/net/Broken/Commands/Music.java | 5 +- .../java/net/Broken/Commands/Over18/Ass.java | 2 +- .../net/Broken/Commands/Over18/Boobs.java | 2 +- .../net/Broken/Commands/Over18/Madame.java | 2 +- .../java/net/Broken/Commands/Over18/Pipe.java | 2 +- .../java/net/Broken/Commands/Over18/SM.java | 2 +- src/main/java/net/Broken/Commands/Ping.java | 2 +- src/main/java/net/Broken/Commands/Spam.java | 8 +- .../java/net/Broken/Commands/SpamInfo.java | 8 +- .../Broken/DB/Entity/PendingUserEntity.java | 72 ------ .../java/net/Broken/DB/Entity/UserEntity.java | 71 ------ .../DB/Repository/PendingUserRepository.java | 12 - .../Broken/DB/Repository/UserRepository.java | 12 - src/main/java/net/Broken/Init.java | 4 +- src/main/java/net/Broken/MainBot.java | 11 +- .../Broken/{Tools => Outils}/AntiSpam.java | 5 +- .../Command/CommandLoader.java | 2 +- .../Command/CommandParser.java | 2 +- .../Command/NumberedCommande.java | 8 +- .../Broken/{Tools => Outils}/DayListener.java | 2 +- .../{Tools => Outils}/EmbedMessageUtils.java | 10 +- .../FindContentOnWebPage.java | 3 +- .../{Tools => Outils}/LimitChecker.java | 2 +- .../{Tools => Outils}/MessageTimeOut.java | 2 +- .../Broken/{Tools => Outils}/Moderateur.java | 2 +- .../{Tools => Outils}/PrivateMessage.java | 4 +- .../Broken/{Tools => Outils}/Redirection.java | 2 +- .../{Tools => Outils}/UserSpamUtils.java | 2 +- .../Broken/RestApi/Data/CommandPostData.java | 2 - .../RestApi/Data/CommandResponseData.java | 7 - .../Data/UserManager/CheckResposeData.java | 15 -- .../RestApi/Data/UserManager/ConfirmData.java | 7 - .../Data/UserManager/UserConnectionData.java | 25 --- .../Data/UserManager/UserInfoData.java | 6 - .../Broken/RestApi/MusicWebAPIController.java | 45 +--- .../RestApi/UserManagerAPIController.java | 95 -------- .../java/net/Broken/Tools/ResourceLoader.java | 40 ---- .../Exceptions/PasswordNotMatchException.java | 4 - .../UserManager/Exceptions/TokenNotMatch.java | 4 - .../Exceptions/UnknownTokenException.java | 4 - .../Exceptions/UserAlreadyRegistered.java | 4 - .../Exceptions/UserNotFoundException.java | 4 - .../Tools/UserManager/PasswordUtils.java | 14 -- .../Tools/UserManager/UserRegister.java | 151 ------------- src/main/java/net/Broken/audio/AudioM.java | 6 +- .../net/Broken/webView/ResisterWebView.java | 16 -- .../MessagesTemplates/RegisterMessage.md | 5 - src/main/resources/application.properties | 5 - src/main/resources/log4j2.xml | 12 +- src/main/resources/static/css/style.css | 10 +- src/main/resources/static/favicon.png | Bin 8358 -> 0 bytes src/main/resources/static/index.html | 104 ++------- src/main/resources/static/js/init.js | 162 +++++--------- src/main/resources/static/js/js.cookie.js | 165 -------------- src/main/resources/static/js/navabar.js | 138 ------------ src/main/resources/static/js/register.js | 176 --------------- src/main/resources/templates/music.html | 103 +-------- src/main/resources/templates/register.html | 210 ------------------ 66 files changed, 160 insertions(+), 1679 deletions(-) delete mode 100644 src/main/java/net/Broken/DB/Entity/PendingUserEntity.java delete mode 100644 src/main/java/net/Broken/DB/Entity/UserEntity.java delete mode 100644 src/main/java/net/Broken/DB/Repository/PendingUserRepository.java delete mode 100644 src/main/java/net/Broken/DB/Repository/UserRepository.java rename src/main/java/net/Broken/{Tools => Outils}/AntiSpam.java (97%) rename src/main/java/net/Broken/{Tools => Outils}/Command/CommandLoader.java (97%) rename src/main/java/net/Broken/{Tools => Outils}/Command/CommandParser.java (98%) rename src/main/java/net/Broken/{Tools => Outils}/Command/NumberedCommande.java (97%) rename src/main/java/net/Broken/{Tools => Outils}/DayListener.java (97%) rename src/main/java/net/Broken/{Tools => Outils}/EmbedMessageUtils.java (92%) rename src/main/java/net/Broken/{Tools => Outils}/FindContentOnWebPage.java (95%) rename src/main/java/net/Broken/{Tools => Outils}/LimitChecker.java (98%) rename src/main/java/net/Broken/{Tools => Outils}/MessageTimeOut.java (97%) rename src/main/java/net/Broken/{Tools => Outils}/Moderateur.java (99%) rename src/main/java/net/Broken/{Tools => Outils}/PrivateMessage.java (80%) rename src/main/java/net/Broken/{Tools => Outils}/Redirection.java (96%) rename src/main/java/net/Broken/{Tools => Outils}/UserSpamUtils.java (97%) delete mode 100644 src/main/java/net/Broken/RestApi/Data/UserManager/CheckResposeData.java delete mode 100644 src/main/java/net/Broken/RestApi/Data/UserManager/ConfirmData.java delete mode 100644 src/main/java/net/Broken/RestApi/Data/UserManager/UserConnectionData.java delete mode 100644 src/main/java/net/Broken/RestApi/Data/UserManager/UserInfoData.java delete mode 100644 src/main/java/net/Broken/RestApi/UserManagerAPIController.java delete mode 100644 src/main/java/net/Broken/Tools/ResourceLoader.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/Exceptions/PasswordNotMatchException.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/Exceptions/TokenNotMatch.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/Exceptions/UnknownTokenException.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/Exceptions/UserAlreadyRegistered.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/Exceptions/UserNotFoundException.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/PasswordUtils.java delete mode 100644 src/main/java/net/Broken/Tools/UserManager/UserRegister.java delete mode 100644 src/main/java/net/Broken/webView/ResisterWebView.java delete mode 100644 src/main/resources/MessagesTemplates/RegisterMessage.md delete mode 100644 src/main/resources/static/favicon.png delete mode 100644 src/main/resources/static/js/js.cookie.js delete mode 100644 src/main/resources/static/js/navabar.js delete mode 100644 src/main/resources/static/js/register.js delete mode 100644 src/main/resources/templates/register.html diff --git a/.gitignore b/.gitignore index b66cef7..4cd1342 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,3 @@ META-INF/ classes/artifacts/Discord_Stroumpf_Beta_jar/ - -src/main/resources/templates/css - -src/main/resources/templates/js diff --git a/Dockerfile b/Dockerfile index 78dedc9..8e99f41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,4 @@ RUN chmod +x gradlew ENV PORT=8080 ENV TOKEN=10 RUN ./gradlew build -CMD java -Xmx500m -jar build/libs/DiscordBot-0.1.0.jar -t ${TOKEN} +CMD java -jar build/libs/DiscordBot-0.1.0.jar -t ${TOKEN} diff --git a/build.gradle b/build.gradle index abd2e38..324379e 100644 --- a/build.gradle +++ b/build.gradle @@ -31,16 +31,15 @@ dependencies { exclude group:"org.springframework.boot", module: "spring-boot-starter-logging" } compile("org.springframework.boot:spring-boot-starter-log4j2") - compile("com.sedmelluq:lavaplayer:1.2.49") + compile("com.sedmelluq:lavaplayer:1.2.45") compile 'net.dv8tion:JDA:3.3.1_303' compile group: 'org.json', name: 'json', version: '20160810' - compile 'org.springframework.security:spring-security-web:5.0.1.RELEASE' -// JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) - compile("org.springframework.boot:spring-boot-starter-data-jpa") { - exclude group:"org.springframework.boot", module: "spring-boot-starter-logging" - } -// Use MySQL Connector-J - compile 'mysql:mysql-connector-java' + // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) + //compile("org.springframework.boot:spring-boot-starter-data-jpa") { + // exclude group:"org.springframework.boot", module: "spring-boot-starter-logging" + //} + // Use MySQL Connector-J + //compile 'mysql:mysql-connector-java' compile 'org.reflections:reflections:0.9.11' diff --git a/src/main/java/net/Broken/BotListener.java b/src/main/java/net/Broken/BotListener.java index b0187e8..48f2afd 100644 --- a/src/main/java/net/Broken/BotListener.java +++ b/src/main/java/net/Broken/BotListener.java @@ -2,8 +2,8 @@ package net.Broken; import net.Broken.Commands.Move; import net.Broken.Commands.Music; -import net.Broken.Tools.AntiSpam; -import net.Broken.Tools.Moderateur; +import net.Broken.Outils.AntiSpam; +import net.Broken.Outils.Moderateur; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; diff --git a/src/main/java/net/Broken/Commands/Cat.java b/src/main/java/net/Broken/Commands/Cat.java index d8c4b57..d8edce5 100644 --- a/src/main/java/net/Broken/Commands/Cat.java +++ b/src/main/java/net/Broken/Commands/Cat.java @@ -2,7 +2,7 @@ package net.Broken.Commands; import net.Broken.Commande; -import net.Broken.Tools.Redirection; +import net.Broken.Outils.Redirection; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; diff --git a/src/main/java/net/Broken/Commands/Flush.java b/src/main/java/net/Broken/Commands/Flush.java index 9336deb..072554a 100644 --- a/src/main/java/net/Broken/Commands/Flush.java +++ b/src/main/java/net/Broken/Commands/Flush.java @@ -1,7 +1,7 @@ package net.Broken.Commands; import net.Broken.Commande; -import net.Broken.Tools.EmbedMessageUtils; +import net.Broken.Outils.EmbedMessageUtils; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.MessageChannel; diff --git a/src/main/java/net/Broken/Commands/Help.java b/src/main/java/net/Broken/Commands/Help.java index 6890891..b29f8ea 100644 --- a/src/main/java/net/Broken/Commands/Help.java +++ b/src/main/java/net/Broken/Commands/Help.java @@ -2,9 +2,9 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; -import net.Broken.Tools.PrivateMessage; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; +import net.Broken.Outils.PrivateMessage; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.Message; diff --git a/src/main/java/net/Broken/Commands/Move.java b/src/main/java/net/Broken/Commands/Move.java index 7852569..befab13 100644 --- a/src/main/java/net/Broken/Commands/Move.java +++ b/src/main/java/net/Broken/Commands/Move.java @@ -2,8 +2,8 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; diff --git a/src/main/java/net/Broken/Commands/Music.java b/src/main/java/net/Broken/Commands/Music.java index 42d640c..6db5a62 100644 --- a/src/main/java/net/Broken/Commands/Music.java +++ b/src/main/java/net/Broken/Commands/Music.java @@ -2,9 +2,10 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; import net.Broken.audio.AudioM; +import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; diff --git a/src/main/java/net/Broken/Commands/Over18/Ass.java b/src/main/java/net/Broken/Commands/Over18/Ass.java index a3ede7a..eabf658 100644 --- a/src/main/java/net/Broken/Commands/Over18/Ass.java +++ b/src/main/java/net/Broken/Commands/Over18/Ass.java @@ -1,6 +1,6 @@ package net.Broken.Commands.Over18; -import net.Broken.Tools.Command.NumberedCommande; +import net.Broken.Outils.Command.NumberedCommande; import org.apache.logging.log4j.LogManager; /** diff --git a/src/main/java/net/Broken/Commands/Over18/Boobs.java b/src/main/java/net/Broken/Commands/Over18/Boobs.java index d2bafd1..c7bf203 100644 --- a/src/main/java/net/Broken/Commands/Over18/Boobs.java +++ b/src/main/java/net/Broken/Commands/Over18/Boobs.java @@ -1,6 +1,6 @@ package net.Broken.Commands.Over18; -import net.Broken.Tools.Command.NumberedCommande; +import net.Broken.Outils.Command.NumberedCommande; import org.apache.logging.log4j.LogManager; /** diff --git a/src/main/java/net/Broken/Commands/Over18/Madame.java b/src/main/java/net/Broken/Commands/Over18/Madame.java index 90cd87c..4e0f5c9 100644 --- a/src/main/java/net/Broken/Commands/Over18/Madame.java +++ b/src/main/java/net/Broken/Commands/Over18/Madame.java @@ -1,7 +1,7 @@ package net.Broken.Commands.Over18; import net.Broken.Commande; -import net.Broken.Tools.Redirection; +import net.Broken.Outils.Redirection; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/Broken/Commands/Over18/Pipe.java b/src/main/java/net/Broken/Commands/Over18/Pipe.java index 009d826..c83b5bd 100644 --- a/src/main/java/net/Broken/Commands/Over18/Pipe.java +++ b/src/main/java/net/Broken/Commands/Over18/Pipe.java @@ -1,6 +1,6 @@ package net.Broken.Commands.Over18; -import net.Broken.Tools.Command.NumberedCommande; +import net.Broken.Outils.Command.NumberedCommande; import org.apache.logging.log4j.LogManager; /** diff --git a/src/main/java/net/Broken/Commands/Over18/SM.java b/src/main/java/net/Broken/Commands/Over18/SM.java index 98982b6..44fac7c 100644 --- a/src/main/java/net/Broken/Commands/Over18/SM.java +++ b/src/main/java/net/Broken/Commands/Over18/SM.java @@ -1,7 +1,7 @@ package net.Broken.Commands.Over18; import net.Broken.Commande; -import net.Broken.Tools.Redirection; +import net.Broken.Outils.Redirection; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/Broken/Commands/Ping.java b/src/main/java/net/Broken/Commands/Ping.java index cab02e5..549ebae 100644 --- a/src/main/java/net/Broken/Commands/Ping.java +++ b/src/main/java/net/Broken/Commands/Ping.java @@ -2,7 +2,7 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.MessageTimeOut; +import net.Broken.Outils.MessageTimeOut; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; diff --git a/src/main/java/net/Broken/Commands/Spam.java b/src/main/java/net/Broken/Commands/Spam.java index 4d4fa6a..e0f1c4a 100644 --- a/src/main/java/net/Broken/Commands/Spam.java +++ b/src/main/java/net/Broken/Commands/Spam.java @@ -2,10 +2,10 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.AntiSpam; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; -import net.Broken.Tools.UserSpamUtils; +import net.Broken.Outils.AntiSpam; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; +import net.Broken.Outils.UserSpamUtils; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; diff --git a/src/main/java/net/Broken/Commands/SpamInfo.java b/src/main/java/net/Broken/Commands/SpamInfo.java index 9755702..1f64797 100644 --- a/src/main/java/net/Broken/Commands/SpamInfo.java +++ b/src/main/java/net/Broken/Commands/SpamInfo.java @@ -2,10 +2,10 @@ package net.Broken.Commands; import net.Broken.Commande; import net.Broken.MainBot; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; -import net.Broken.Tools.PrivateMessage; -import net.Broken.Tools.UserSpamUtils; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; +import net.Broken.Outils.PrivateMessage; +import net.Broken.Outils.UserSpamUtils; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.Message; diff --git a/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java b/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java deleted file mode 100644 index eb06cd7..0000000 --- a/src/main/java/net/Broken/DB/Entity/PendingUserEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.Broken.DB.Entity; - - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class PendingUserEntity { - @Id - @GeneratedValue(strategy= GenerationType.AUTO) - private Integer id; - - private String name; - - private String jdaId; - - private String checkToken; - - private String password; - - public PendingUserEntity() { - } - - public PendingUserEntity(String name, String jdaId, String checkToken, String password) { - this.name = name; - this.jdaId = jdaId; - this.checkToken = checkToken; - this.password = password; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getJdaId() { - return jdaId; - } - - public void setJdaId(String jdaId) { - this.jdaId = jdaId; - } - - public String getCheckToken() { - return checkToken; - } - - public void setCheckToken(String checkToken) { - this.checkToken = checkToken; - } -} diff --git a/src/main/java/net/Broken/DB/Entity/UserEntity.java b/src/main/java/net/Broken/DB/Entity/UserEntity.java deleted file mode 100644 index b0fafd7..0000000 --- a/src/main/java/net/Broken/DB/Entity/UserEntity.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.Broken.DB.Entity; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class UserEntity { - @Id - @GeneratedValue(strategy= GenerationType.AUTO) - private Integer id; - - private String name; - - private String jdaId; - - private String apiToken; - - private String password; - - public UserEntity() { - } - - public UserEntity(PendingUserEntity pendingUserEntity, String apiToken) { - this.name = pendingUserEntity.getName(); - this.jdaId = pendingUserEntity.getJdaId(); - this.password = pendingUserEntity.getPassword(); - this.apiToken = apiToken; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getJdaId() { - return jdaId; - } - - public void setJdaId(String jdaId) { - this.jdaId = jdaId; - } - - public String getApiToken() { - return apiToken; - } - - public void setApiToken(String apiToken) { - this.apiToken = apiToken; - } -} diff --git a/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java b/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java deleted file mode 100644 index c72adbc..0000000 --- a/src/main/java/net/Broken/DB/Repository/PendingUserRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.Broken.DB.Repository; - -import net.Broken.DB.Entity.PendingUserEntity; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface PendingUserRepository extends CrudRepository { - List findByJdaId(String jdaId); - - -} diff --git a/src/main/java/net/Broken/DB/Repository/UserRepository.java b/src/main/java/net/Broken/DB/Repository/UserRepository.java deleted file mode 100644 index 86d05d5..0000000 --- a/src/main/java/net/Broken/DB/Repository/UserRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.Broken.DB.Repository; - -import net.Broken.DB.Entity.UserEntity; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface UserRepository extends CrudRepository{ - List findByName(String name); - List findByJdaId(String jdaId); - List findByApiToken(String apiToken); -} diff --git a/src/main/java/net/Broken/Init.java b/src/main/java/net/Broken/Init.java index 6e1f14f..58eaa2b 100644 --- a/src/main/java/net/Broken/Init.java +++ b/src/main/java/net/Broken/Init.java @@ -1,7 +1,7 @@ package net.Broken; -import net.Broken.Tools.Command.CommandLoader; -import net.Broken.Tools.DayListener; +import net.Broken.Outils.Command.CommandLoader; +import net.Broken.Outils.DayListener; import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.JDABuilder; diff --git a/src/main/java/net/Broken/MainBot.java b/src/main/java/net/Broken/MainBot.java index 41b8891..b047837 100644 --- a/src/main/java/net/Broken/MainBot.java +++ b/src/main/java/net/Broken/MainBot.java @@ -1,9 +1,8 @@ package net.Broken; -import net.Broken.Tools.Command.CommandParser; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.UserManager.UserRegister; -import net.Broken.Tools.UserSpamUtils; +import net.Broken.Outils.Command.CommandParser; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.UserSpamUtils; import net.Broken.RestApi.ApiCommandLoader; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.entities.ChannelType; @@ -18,7 +17,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.stereotype.Controller; -import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; @@ -35,12 +33,10 @@ public class MainBot { public static HashMap message_compteur =new HashMap<>(); public static boolean roleFlag = false; public static HashMap spamUtils = new HashMap<>(); - public static UserRegister userRegister = new UserRegister(); public static JDA jda; - public static int messageTimeOut = 10; @@ -78,7 +74,6 @@ public class MainBot { })); } - ApiCommandLoader.load(); diff --git a/src/main/java/net/Broken/Tools/AntiSpam.java b/src/main/java/net/Broken/Outils/AntiSpam.java similarity index 97% rename from src/main/java/net/Broken/Tools/AntiSpam.java rename to src/main/java/net/Broken/Outils/AntiSpam.java index 00d3355..a8d89d4 100644 --- a/src/main/java/net/Broken/Tools/AntiSpam.java +++ b/src/main/java/net/Broken/Outils/AntiSpam.java @@ -1,7 +1,10 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.Broken.MainBot; import net.Broken.Commands.Move; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; +import net.Broken.Outils.UserSpamUtils; import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.exceptions.HierarchyException; diff --git a/src/main/java/net/Broken/Tools/Command/CommandLoader.java b/src/main/java/net/Broken/Outils/Command/CommandLoader.java similarity index 97% rename from src/main/java/net/Broken/Tools/Command/CommandLoader.java rename to src/main/java/net/Broken/Outils/Command/CommandLoader.java index 9bc7131..cd6ece5 100644 --- a/src/main/java/net/Broken/Tools/Command/CommandLoader.java +++ b/src/main/java/net/Broken/Outils/Command/CommandLoader.java @@ -1,4 +1,4 @@ -package net.Broken.Tools.Command; +package net.Broken.Outils.Command; import net.Broken.Commande; import net.Broken.MainBot; diff --git a/src/main/java/net/Broken/Tools/Command/CommandParser.java b/src/main/java/net/Broken/Outils/Command/CommandParser.java similarity index 98% rename from src/main/java/net/Broken/Tools/Command/CommandParser.java rename to src/main/java/net/Broken/Outils/Command/CommandParser.java index 3160f12..632070a 100644 --- a/src/main/java/net/Broken/Tools/Command/CommandParser.java +++ b/src/main/java/net/Broken/Outils/Command/CommandParser.java @@ -1,4 +1,4 @@ -package net.Broken.Tools.Command; +package net.Broken.Outils.Command; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/net/Broken/Tools/Command/NumberedCommande.java b/src/main/java/net/Broken/Outils/Command/NumberedCommande.java similarity index 97% rename from src/main/java/net/Broken/Tools/Command/NumberedCommande.java rename to src/main/java/net/Broken/Outils/Command/NumberedCommande.java index cd65172..e3900da 100644 --- a/src/main/java/net/Broken/Tools/Command/NumberedCommande.java +++ b/src/main/java/net/Broken/Outils/Command/NumberedCommande.java @@ -1,8 +1,8 @@ -package net.Broken.Tools.Command; +package net.Broken.Outils.Command; import net.Broken.Commande; -import net.Broken.Tools.FindContentOnWebPage; -import net.Broken.Tools.LimitChecker; -import net.Broken.Tools.Redirection; +import net.Broken.Outils.FindContentOnWebPage; +import net.Broken.Outils.LimitChecker; +import net.Broken.Outils.Redirection; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/Broken/Tools/DayListener.java b/src/main/java/net/Broken/Outils/DayListener.java similarity index 97% rename from src/main/java/net/Broken/Tools/DayListener.java rename to src/main/java/net/Broken/Outils/DayListener.java index b4c77b2..7f4edf1 100644 --- a/src/main/java/net/Broken/Tools/DayListener.java +++ b/src/main/java/net/Broken/Outils/DayListener.java @@ -1,4 +1,4 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.Broken.Commands.Spam; import net.dv8tion.jda.core.exceptions.RateLimitedException; import org.apache.logging.log4j.LogManager; diff --git a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java b/src/main/java/net/Broken/Outils/EmbedMessageUtils.java similarity index 92% rename from src/main/java/net/Broken/Tools/EmbedMessageUtils.java rename to src/main/java/net/Broken/Outils/EmbedMessageUtils.java index 15ceaf7..4dd380c 100644 --- a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java +++ b/src/main/java/net/Broken/Outils/EmbedMessageUtils.java @@ -1,9 +1,10 @@ -package net.Broken.Tools; +package net.Broken.Outils; -import net.Broken.MainBot; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.entities.Member; +import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.MessageEmbed; +import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import java.awt.*; @@ -68,10 +69,5 @@ public class EmbedMessageUtils { } - public static MessageEmbed getRegister(String message) { - return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build(); - } - - } \ No newline at end of file diff --git a/src/main/java/net/Broken/Tools/FindContentOnWebPage.java b/src/main/java/net/Broken/Outils/FindContentOnWebPage.java similarity index 95% rename from src/main/java/net/Broken/Tools/FindContentOnWebPage.java rename to src/main/java/net/Broken/Outils/FindContentOnWebPage.java index e9a0edc..6d13a34 100644 --- a/src/main/java/net/Broken/Tools/FindContentOnWebPage.java +++ b/src/main/java/net/Broken/Outils/FindContentOnWebPage.java @@ -1,8 +1,9 @@ -package net.Broken.Tools; +package net.Broken.Outils; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; diff --git a/src/main/java/net/Broken/Tools/LimitChecker.java b/src/main/java/net/Broken/Outils/LimitChecker.java similarity index 98% rename from src/main/java/net/Broken/Tools/LimitChecker.java rename to src/main/java/net/Broken/Outils/LimitChecker.java index fff834c..89e17ef 100644 --- a/src/main/java/net/Broken/Tools/LimitChecker.java +++ b/src/main/java/net/Broken/Outils/LimitChecker.java @@ -1,4 +1,4 @@ -package net.Broken.Tools; +package net.Broken.Outils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/Broken/Tools/MessageTimeOut.java b/src/main/java/net/Broken/Outils/MessageTimeOut.java similarity index 97% rename from src/main/java/net/Broken/Tools/MessageTimeOut.java rename to src/main/java/net/Broken/Outils/MessageTimeOut.java index aa100eb..01984a3 100644 --- a/src/main/java/net/Broken/Tools/MessageTimeOut.java +++ b/src/main/java/net/Broken/Outils/MessageTimeOut.java @@ -1,4 +1,4 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.exceptions.ErrorResponseException; diff --git a/src/main/java/net/Broken/Tools/Moderateur.java b/src/main/java/net/Broken/Outils/Moderateur.java similarity index 99% rename from src/main/java/net/Broken/Tools/Moderateur.java rename to src/main/java/net/Broken/Outils/Moderateur.java index c8fc8de..2bb33dc 100644 --- a/src/main/java/net/Broken/Tools/Moderateur.java +++ b/src/main/java/net/Broken/Outils/Moderateur.java @@ -1,5 +1,5 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.Broken.MainBot; diff --git a/src/main/java/net/Broken/Tools/PrivateMessage.java b/src/main/java/net/Broken/Outils/PrivateMessage.java similarity index 80% rename from src/main/java/net/Broken/Tools/PrivateMessage.java rename to src/main/java/net/Broken/Outils/PrivateMessage.java index 9b05c35..9ac7c56 100644 --- a/src/main/java/net/Broken/Tools/PrivateMessage.java +++ b/src/main/java/net/Broken/Outils/PrivateMessage.java @@ -1,8 +1,10 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.MessageEmbed; +import net.dv8tion.jda.core.entities.PrivateChannel; import net.dv8tion.jda.core.entities.User; +import net.dv8tion.jda.core.exceptions.RateLimitedException; import org.apache.logging.log4j.Logger; /** diff --git a/src/main/java/net/Broken/Tools/Redirection.java b/src/main/java/net/Broken/Outils/Redirection.java similarity index 96% rename from src/main/java/net/Broken/Tools/Redirection.java rename to src/main/java/net/Broken/Outils/Redirection.java index 50b8243..011971b 100644 --- a/src/main/java/net/Broken/Tools/Redirection.java +++ b/src/main/java/net/Broken/Outils/Redirection.java @@ -1,4 +1,4 @@ -package net.Broken.Tools; +package net.Broken.Outils; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/net/Broken/Tools/UserSpamUtils.java b/src/main/java/net/Broken/Outils/UserSpamUtils.java similarity index 97% rename from src/main/java/net/Broken/Tools/UserSpamUtils.java rename to src/main/java/net/Broken/Outils/UserSpamUtils.java index e7e63d1..f99fb1c 100644 --- a/src/main/java/net/Broken/Tools/UserSpamUtils.java +++ b/src/main/java/net/Broken/Outils/UserSpamUtils.java @@ -1,4 +1,4 @@ -package net.Broken.Tools; +package net.Broken.Outils; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Message; diff --git a/src/main/java/net/Broken/RestApi/Data/CommandPostData.java b/src/main/java/net/Broken/RestApi/Data/CommandPostData.java index 1d73cc5..f08c26d 100644 --- a/src/main/java/net/Broken/RestApi/Data/CommandPostData.java +++ b/src/main/java/net/Broken/RestApi/Data/CommandPostData.java @@ -7,6 +7,4 @@ public class CommandPostData { public String url; public int playlistLimit; public String chanelId; - public String name; - public String token; } diff --git a/src/main/java/net/Broken/RestApi/Data/CommandResponseData.java b/src/main/java/net/Broken/RestApi/Data/CommandResponseData.java index ffea0d8..e78e8c2 100644 --- a/src/main/java/net/Broken/RestApi/Data/CommandResponseData.java +++ b/src/main/java/net/Broken/RestApi/Data/CommandResponseData.java @@ -6,16 +6,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; public class CommandResponseData { public String Commande; public String Message; - public String error; public CommandResponseData(String commande, String message) { Commande = commande; Message = message; } - - public CommandResponseData(String commande, String message, String error) { - Commande = commande; - Message = message; - this.error = error; - } } diff --git a/src/main/java/net/Broken/RestApi/Data/UserManager/CheckResposeData.java b/src/main/java/net/Broken/RestApi/Data/UserManager/CheckResposeData.java deleted file mode 100644 index b169111..0000000 --- a/src/main/java/net/Broken/RestApi/Data/UserManager/CheckResposeData.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.Broken.RestApi.Data.UserManager; - -public class CheckResposeData { - public boolean accepted; - public String name; - public String message; - public String id; - - public CheckResposeData(boolean accepted, String name, String message, String id) { - this.accepted = accepted; - this.name = name; - this.message = message; - this.id = id; - } -} diff --git a/src/main/java/net/Broken/RestApi/Data/UserManager/ConfirmData.java b/src/main/java/net/Broken/RestApi/Data/UserManager/ConfirmData.java deleted file mode 100644 index 9aad50b..0000000 --- a/src/main/java/net/Broken/RestApi/Data/UserManager/ConfirmData.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.Broken.RestApi.Data.UserManager; - -public class ConfirmData { - public String id; - public String checkToken; - -} diff --git a/src/main/java/net/Broken/RestApi/Data/UserManager/UserConnectionData.java b/src/main/java/net/Broken/RestApi/Data/UserManager/UserConnectionData.java deleted file mode 100644 index 77563a0..0000000 --- a/src/main/java/net/Broken/RestApi/Data/UserManager/UserConnectionData.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.Broken.RestApi.Data.UserManager; - -public class UserConnectionData { - public boolean accepted; - public String token; - public String message; - public String error; - public String name; - - public UserConnectionData(boolean accepted, String name, String token, String message) { - this.accepted = accepted; - this.token = token; - this.message = message; - this.name = name; - this.error = null; - } - - public UserConnectionData(boolean accepted, String message, String error) { - this.accepted = accepted; - this.token = null; - this.message = message; - this.error = error; - this.name = null; - } -} diff --git a/src/main/java/net/Broken/RestApi/Data/UserManager/UserInfoData.java b/src/main/java/net/Broken/RestApi/Data/UserManager/UserInfoData.java deleted file mode 100644 index c5edf0e..0000000 --- a/src/main/java/net/Broken/RestApi/Data/UserManager/UserInfoData.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.Broken.RestApi.Data.UserManager; - -public class UserInfoData { - public String name; - public String password; -} diff --git a/src/main/java/net/Broken/RestApi/MusicWebAPIController.java b/src/main/java/net/Broken/RestApi/MusicWebAPIController.java index a0a6e5a..309b837 100644 --- a/src/main/java/net/Broken/RestApi/MusicWebAPIController.java +++ b/src/main/java/net/Broken/RestApi/MusicWebAPIController.java @@ -4,33 +4,24 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import net.Broken.Commands.Music; -import net.Broken.DB.Entity.UserEntity; -import net.Broken.DB.Repository.UserRepository; import net.Broken.MainBot; import net.Broken.RestApi.Data.*; -import net.Broken.RestApi.Data.UserManager.CheckResposeData; -import net.Broken.RestApi.Data.UserManager.UserInfoData; -import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException; -import net.Broken.Tools.UserManager.Exceptions.UserNotFoundException; import net.Broken.audio.NotConectedException; import net.Broken.audio.NullMusicManager; import net.dv8tion.jda.core.entities.VoiceChannel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; -// import net.Broken.DB.Repository.SavedPlaylistRepository; +// import net.Broken.DB.SavedPlaylistRepository; @RestController @RequestMapping("/api/music/") @@ -38,9 +29,6 @@ public class MusicWebAPIController { Logger logger = LogManager.getLogger(); // @Autowired // public SavedPlaylistRepository savedPlaylist; - @Autowired - UserRepository userRepository; - @RequestMapping("/currentMusicInfo") public CurrentMusicData getCurrentM(){ @@ -77,32 +65,17 @@ public class MusicWebAPIController { } @RequestMapping(value = "/command", method = RequestMethod.POST) - public ResponseEntity command(@RequestBody CommandPostData data, HttpServletRequest request){ + public ResponseEntity command(@RequestBody CommandPostData data){ if(data.command != null) { - if(data.token != null) { - try { - UserEntity user = MainBot.userRegister.getUserWithApiToken(userRepository, data.token); - logger.info("receive command " + data.command + " from " + request.getRemoteAddr() + " USER: " + user.getName()); - Music musicCommande = (Music) MainBot.commandes.get("music"); + logger.info("receive command: " + data.command); + Music musicCommande = (Music) MainBot.commandes.get("music"); - if (ApiCommandLoader.apiCommands.containsKey(data.command)) - return ApiCommandLoader.apiCommands.get(data.command).action(musicCommande, data); - else - return new ResponseEntity<>(new CommandResponseData(data.command, "Unknown Command", "command"), HttpStatus.BAD_REQUEST); + if(ApiCommandLoader.apiCommands.containsKey(data.command)) + return ApiCommandLoader.apiCommands.get(data.command).action(musicCommande,data); + else + return new ResponseEntity<>(new CommandResponseData(data.command,"Unknown Command"), HttpStatus.BAD_REQUEST); - } catch (UnknownTokenException e) { - logger.warn("Command with unknown token from: "+request.getRemoteAddr()); - return new ResponseEntity<>(new CommandResponseData(data.command,"Unknown Token!\nPlease Re-connect.", "token"), HttpStatus.UNAUTHORIZED); - - } - - } - else{ - logger.warn("Command without token! ip: "+ request.getRemoteAddr()); - return new ResponseEntity<>(new CommandResponseData(data.command,"Missing token!\nPlease Re-connect.","token"), HttpStatus.UNAUTHORIZED); - - } } else logger.info("Null"); @@ -112,6 +85,7 @@ public class MusicWebAPIController { @RequestMapping(value = "/getChanel", method = RequestMethod.GET) public List getChanel(){ List temp = new ArrayList<>(); + logger.info(MainBot.jda.getVoiceChannels().size()); for(VoiceChannel aChanel : MainBot.jda.getVoiceChannels()){ temp.add(new Chanel(aChanel.getName(),aChanel.getId(),aChanel.getPosition())); } @@ -121,7 +95,6 @@ public class MusicWebAPIController { - // DB Test Ignore it // @RequestMapping(value = "/test", method = RequestMethod.GET) diff --git a/src/main/java/net/Broken/RestApi/UserManagerAPIController.java b/src/main/java/net/Broken/RestApi/UserManagerAPIController.java deleted file mode 100644 index 2cb9abb..0000000 --- a/src/main/java/net/Broken/RestApi/UserManagerAPIController.java +++ /dev/null @@ -1,95 +0,0 @@ -package net.Broken.RestApi; - -import net.Broken.DB.Entity.PendingUserEntity; -import net.Broken.DB.Entity.UserEntity; -import net.Broken.DB.Repository.PendingUserRepository; -import net.Broken.DB.Repository.UserRepository; -import net.Broken.MainBot; -import net.Broken.RestApi.Data.UserManager.CheckResposeData; -import net.Broken.RestApi.Data.UserManager.ConfirmData; -import net.Broken.RestApi.Data.UserManager.UserConnectionData; -import net.Broken.RestApi.Data.UserManager.UserInfoData; -import net.Broken.Tools.UserManager.Exceptions.PasswordNotMatchException; -import net.Broken.Tools.UserManager.Exceptions.TokenNotMatch; -import net.Broken.Tools.UserManager.Exceptions.UserAlreadyRegistered; -import net.Broken.Tools.UserManager.Exceptions.UserNotFoundException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/userManagement") -public class UserManagerAPIController { - Logger logger = LogManager.getLogger(); - @Autowired - PendingUserRepository pendingUserRepository; - - @Autowired - UserRepository userRepository; - - @Autowired - private PasswordEncoder passwordEncoder; - - - @RequestMapping(value = "/preRegister", method = RequestMethod.POST) - public ResponseEntity command(@RequestBody UserInfoData data){ - if(data != null && data.name != null) { - try { - String id = MainBot.userRegister.sendCheckToken(pendingUserRepository, userRepository, passwordEncoder, data); - return new ResponseEntity<>(new CheckResposeData(true, data.name, "Message sent", id), HttpStatus.OK); - } catch (UserNotFoundException e) { - logger.warn("User \"" + data.name + "\" not found!"); - return new ResponseEntity<>(new CheckResposeData(false, data.name, "User not found on server!",""), HttpStatus.NOT_FOUND); - } catch (PasswordNotMatchException userAlreadyRegistered) { - return new ResponseEntity<>(new CheckResposeData(false, data.name, "User already registered in pending database and password not match!",""), HttpStatus.NOT_ACCEPTABLE); - - } catch (UserAlreadyRegistered userAlreadyRegistered) { - return new ResponseEntity<>(new CheckResposeData(false, data.name, "User already registered in database!",""), HttpStatus.NOT_ACCEPTABLE); - } - } - else{ - return new ResponseEntity<>(new CheckResposeData(false, "", "Missing parameter(s)",""), HttpStatus.BAD_REQUEST); - } - } - - @RequestMapping(value = "/confirmAccount", method = RequestMethod.POST) - public ResponseEntity confirAccount(@RequestBody ConfirmData data){ - //TODO move pending user to accepted and return right things - try { - PendingUserEntity pUser = MainBot.userRegister.confirmCheckToken(pendingUserRepository, Integer.parseInt(data.id), data.checkToken); - UserEntity user = new UserEntity(pUser, MainBot.userRegister.generateApiToken()); - userRepository.save(user); - pendingUserRepository.delete(pUser); - - return new ResponseEntity<>(new UserConnectionData(true, user.getName(), user.getApiToken(),""),HttpStatus.OK); - } catch (TokenNotMatch tokenNotMatch) { - logger.warn("Pre token not match for "+data.id+"!"); - return new ResponseEntity<>(new UserConnectionData(false,"Token not match!","token"),HttpStatus.NOT_ACCEPTABLE); - } catch (UserNotFoundException e) { - logger.warn("Id not found in DB ("+data.id+")"); - return new ResponseEntity<>(new UserConnectionData(false,"User not found on DB!", "user"),HttpStatus.NOT_ACCEPTABLE); - } - } - - @RequestMapping(value = "/requestToken", method = RequestMethod.POST) - public ResponseEntity requestToken(@RequestBody UserInfoData data){ - try { - UserEntity user = MainBot.userRegister.getUser(userRepository, passwordEncoder, data); - return new ResponseEntity<>(new UserConnectionData(true, user.getName(), user.getApiToken(), ""), HttpStatus.OK); - - } catch (UserNotFoundException e) { - return new ResponseEntity<>(new UserConnectionData(false,"User not registered!", "user"),HttpStatus.NOT_ACCEPTABLE); - } catch (PasswordNotMatchException e) { - return new ResponseEntity<>(new UserConnectionData(false,"Wrong user name or password!", "password"),HttpStatus.NOT_ACCEPTABLE); - } - } - - -} diff --git a/src/main/java/net/Broken/Tools/ResourceLoader.java b/src/main/java/net/Broken/Tools/ResourceLoader.java deleted file mode 100644 index 02eea97..0000000 --- a/src/main/java/net/Broken/Tools/ResourceLoader.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.Broken.Tools; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Scanner; - - - -public class ResourceLoader { - - private Logger logger = LogManager.getLogger(); - - public String getFile(String fileName) { - - StringBuilder result = new StringBuilder(""); - - //Get file from resources folder - ClassLoader classLoader = getClass().getClassLoader(); - InputStream file = classLoader.getResourceAsStream(fileName); - - try (Scanner scanner = new Scanner(file, "UTF-8")) { - - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - result.append(line).append("\n"); - } - - scanner.close(); - - } - - return result.toString(); - - } - -} diff --git a/src/main/java/net/Broken/Tools/UserManager/Exceptions/PasswordNotMatchException.java b/src/main/java/net/Broken/Tools/UserManager/Exceptions/PasswordNotMatchException.java deleted file mode 100644 index 0eeac2e..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/Exceptions/PasswordNotMatchException.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.Broken.Tools.UserManager.Exceptions; - -public class PasswordNotMatchException extends Exception{ -} diff --git a/src/main/java/net/Broken/Tools/UserManager/Exceptions/TokenNotMatch.java b/src/main/java/net/Broken/Tools/UserManager/Exceptions/TokenNotMatch.java deleted file mode 100644 index fc5d6e9..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/Exceptions/TokenNotMatch.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.Broken.Tools.UserManager.Exceptions; - -public class TokenNotMatch extends Exception { -} diff --git a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UnknownTokenException.java b/src/main/java/net/Broken/Tools/UserManager/Exceptions/UnknownTokenException.java deleted file mode 100644 index e72b52e..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UnknownTokenException.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.Broken.Tools.UserManager.Exceptions; - -public class UnknownTokenException extends Exception{ -} diff --git a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserAlreadyRegistered.java b/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserAlreadyRegistered.java deleted file mode 100644 index f945a30..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserAlreadyRegistered.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.Broken.Tools.UserManager.Exceptions; - -public class UserAlreadyRegistered extends Exception { -} diff --git a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserNotFoundException.java b/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserNotFoundException.java deleted file mode 100644 index 232c53c..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/Exceptions/UserNotFoundException.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.Broken.Tools.UserManager.Exceptions; - -public class UserNotFoundException extends Exception{ -} diff --git a/src/main/java/net/Broken/Tools/UserManager/PasswordUtils.java b/src/main/java/net/Broken/Tools/UserManager/PasswordUtils.java deleted file mode 100644 index a965602..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/PasswordUtils.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.Broken.Tools.UserManager; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; - -@Configuration -public class PasswordUtils { - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } -} diff --git a/src/main/java/net/Broken/Tools/UserManager/UserRegister.java b/src/main/java/net/Broken/Tools/UserManager/UserRegister.java deleted file mode 100644 index 715a218..0000000 --- a/src/main/java/net/Broken/Tools/UserManager/UserRegister.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.Broken.Tools.UserManager; - -import net.Broken.DB.Entity.PendingUserEntity; -import net.Broken.DB.Entity.UserEntity; -import net.Broken.DB.Repository.PendingUserRepository; -import net.Broken.DB.Repository.UserRepository; -import net.Broken.MainBot; -import net.Broken.RestApi.Data.UserManager.UserInfoData; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.PrivateMessage; -import net.Broken.Tools.ResourceLoader; -import net.Broken.Tools.UserManager.Exceptions.*; -import net.dv8tion.jda.core.entities.MessageEmbed; -import net.dv8tion.jda.core.entities.User; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.security.crypto.password.PasswordEncoder; - -import java.security.SecureRandom; -import java.util.List; -import java.util.UUID; - -public class UserRegister { - - private Logger logger = LogManager.getLogger(); - - - public String sendCheckToken(PendingUserRepository pendingUserRepository, UserRepository userRepository, PasswordEncoder passwordEncoder, UserInfoData userInfo) throws UserNotFoundException, PasswordNotMatchException, UserAlreadyRegistered { - - logger.info("New registration for " + userInfo.name); - - List users = MainBot.jda.getUsersByName(userInfo.name,true); - if(users.size() < 1) - throw new UserNotFoundException(); - - User user = users.get(0); - logger.info("User found!"); - - PendingUserEntity pendingUserEntity = null; - String token = ""; - - //Test if exist on register user - if(userRepository.findByJdaId(user.getId()).size() > 0){ - logger.warn("User already registered!"); - throw new UserAlreadyRegistered(); - } - - - - //Check if exist in pading user Table - List pendingUsers = pendingUserRepository.findByJdaId(user.getId()); - if(pendingUsers.size() != 0){ - PendingUserEntity thisUser = pendingUsers.get(0); - if(passwordEncoder.matches(userInfo.password, thisUser.getPassword())){ - logger.info("Password matches"); - pendingUserEntity = thisUser; - token = thisUser.getCheckToken(); - }else{ - logger.warn("Password Not Match!"); - throw new PasswordNotMatchException(); - } - } - - - - logger.info("Generating check Token..."); - if(token.equals("")){ - token = generateCheckToken(); - } - - logger.info("Token generated: " + token); - if(pendingUserEntity == null) { - pendingUserEntity = new PendingUserEntity(user.getName(), user.getId(), token, passwordEncoder.encode(userInfo.password)); - pendingUserEntity = pendingUserRepository.save(pendingUserEntity); - } - - String message = new ResourceLoader().getFile("MessagesTemplates/RegisterMessage.md"); - - message = message.replace("%code",token); - - MessageEmbed ebM = EmbedMessageUtils.getRegister(message); - PrivateMessage.send(user,ebM,logger); - return pendingUserEntity.getId().toString(); - - } - - public PendingUserEntity confirmCheckToken(PendingUserRepository pendingUserRepository, int id, String checkToken ) throws TokenNotMatch, UserNotFoundException { - PendingUserEntity pendingUser = pendingUserRepository.findOne(id); - if(pendingUser != null) { - if(pendingUser.getCheckToken().equals(checkToken)){ - logger.info("Check Token match!"); - } - else{ - logger.warn("Check token not match!"); - throw new TokenNotMatch(); - } - } - else{ - logger.warn("Id not Found!"); - throw new UserNotFoundException(); - } - return pendingUser; - } - - public UserEntity getUser(UserRepository userRepository, PasswordEncoder passwordEncoder, UserInfoData userInfoData) throws UserNotFoundException, PasswordNotMatchException { - List users = userRepository.findByName(userInfoData.name); - if(users.size()<1){ - logger.warn("Login with unknown username: " + userInfoData.name); - throw new UserNotFoundException(); - } - else{ - UserEntity user = users.get(0); - if(passwordEncoder.matches(userInfoData.password,user.getPassword())){ - logger.info("Login successful for " + user.getName()); - return user; - } - else - { - logger.warn("Login fail for " + user.getName() + ", wrong password!"); - throw new PasswordNotMatchException(); - } - } - } - - public UserEntity getUserWithApiToken(UserRepository userRepository, String token) throws UnknownTokenException { - List users = userRepository.findByApiToken(token); - if(users.size() > 0){ - return users.get(0); - } - else - throw new UnknownTokenException(); - - } - - public String generateApiToken(){ - return UUID.randomUUID().toString(); - } - - private String generateCheckToken(){ - SecureRandom random = new SecureRandom(); - long longToken = Math.abs( random.nextLong() ); - String randomStr = Long.toString( longToken, 16 ); - randomStr = randomStr.substring(0,4); - randomStr = randomStr.toUpperCase(); - return randomStr; - } - - -} diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/audio/AudioM.java index d608d67..c51d971 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/audio/AudioM.java @@ -9,13 +9,15 @@ import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import net.Broken.MainBot; -import net.Broken.Tools.EmbedMessageUtils; -import net.Broken.Tools.MessageTimeOut; +import net.Broken.Outils.EmbedMessageUtils; +import net.Broken.Outils.MessageTimeOut; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Message; +import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; +import net.dv8tion.jda.core.managers.AudioManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/Broken/webView/ResisterWebView.java b/src/main/java/net/Broken/webView/ResisterWebView.java deleted file mode 100644 index 3c0c246..0000000 --- a/src/main/java/net/Broken/webView/ResisterWebView.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.Broken.webView; - - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -public class ResisterWebView { - @RequestMapping("/register") - public String music(@RequestParam(value="id", required = true, defaultValue = "") String id, Model model){ - model.addAttribute("id", id); - return "register"; - } -} diff --git a/src/main/resources/MessagesTemplates/RegisterMessage.md b/src/main/resources/MessagesTemplates/RegisterMessage.md deleted file mode 100644 index 630fbf3..0000000 --- a/src/main/resources/MessagesTemplates/RegisterMessage.md +++ /dev/null @@ -1,5 +0,0 @@ - -Une tentative d'association à etait demandé. - -Voici le code de vérification: -**%code** diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e1fd2b4..4c6606e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1 @@ server.port=${PORT} -spring.jpa.hibernate.ddl-auto=update -spring.datasource.url=${DB_URL} -spring.datasource.username=${DB_USER} -spring.datasource.password=${DB_PWD} -spring.thymeleaf.cache=true \ No newline at end of file diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 467272d..45bcb8a 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -7,29 +7,23 @@ [%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan} - + [%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan} - + - - - [%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan} - - - diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index f6d371e..397fb88 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -1,8 +1,8 @@ -/*.nav-wrapper{*/ - /*!*margin-right: 1%;*!*/ - /*margin-left: 1%;*/ - /*width: 100%;*/ -/*}*/ +.nav-wrapper{ + margin-right: 1%; + margin-left: 1%; + width: 100%; +} .collapsible-body{ diff --git a/src/main/resources/static/favicon.png b/src/main/resources/static/favicon.png deleted file mode 100644 index d690bb47560e0838ee7604e0bb29a172fd2e3d26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8358 zcmbtZ2{_bU+du!YXN@8h(?%&Q6nDl9whac>odI!z8;lBXxGnXOFTlnMos*Ug@>jmQi8e7?cz;oyJ!=o6I?#i(*e2-zTHJcA-!1y2r25Y10euN zs4ox&{6GNU1^@@YL3jUp>)+WgCo|+}tnScmnUfFQo%FgxU-3kC>I{}Q7aDZV8sr~P z%lKhZ;ANljc-`w=*#zr2tGC0e64r48tY`S*L7q-w^UaK1)QM2{?egJ@8cBCHiiPF% z-eEmE{k{#~>FDhHxaL8;*h0h}0KSUPs|s_<#7McdSg3(_UtD@E0=)+&4Tmo}=yoSfq&nvXhGIoXss=>B;-KPaMZO>ZDId3IW_uIBSYWF(~1Y z%`wEizTY+tYvE2MV6$gq{?%Ho|Ypskq66qjyQst;T>M5U*vPZJRA^UNz0}h z4A74dz$UNlTXx03xNUM0zyLm$JT2i)rg~>7MH7R4;ljMC=-EG#>NdIu;2w}!t9fV^ zW%P`6pnpNtuiT>Os`q3r7Y^Xol3DRDf+}=hBF4-+xEXOPscbR0{2-i29$L#V;U-<| zX1=QkYy^|b)|$Jc?fLk)bty)S*U6~-Y$h8 zpjCsxQnn+Qg%e{ii6eTC$mT&0txnFH`g5>@Gxc;+38o1z$!$zXm+;w)Y?S;sUHAh`vtXmJ({1|);EOxB%rr@(AwaI2Yn=3e&jc7Gm-;RG|r7_9Fh+v<^ci*{3J%oJn0r-4kAVJ}v9WLum0 z92%10V;$aMH|q%fo_d(u>+R3W4)*Q_YAZ-D8|_N&3y#VQ0io|y;>9FBmca_rQyow5 zrkpY;XvUUE2Kv`sRr0FxmucI0p#QZ72xbI!OR*sUddgB1v0kif0Q&EQTb}zgznGTb z2A5BOj{65ob?Y%b!-s#%GskbHHX$C!1d|*^ROYg>koR19eZ(lQg;u(zn4DVKDgB zcYHo@dM!-HAuuTfX_rrT=1`h0gR8<6OTxa1J%rGogtA1z3$Mz{VdY$a_3vr(>?jkZ}J`2@kBmHxPh16q;- zvYQ#PAi0Fh>K}RA(uG05Jt2exlUTu=qLe*ENnxOSc=jkT`$%CDPT3wokIhxmPfX9k z;0~`+*I(y_VO2uL^nA#X$em63Kw;Ko#o_?T6R}?fx)!*g5-H>w2k!f&`<54LyI=>n zCk4v2FkP#`YR};xn{9SYNW)Win0==RSY7YgpXV{n2TxoQ_gw|>t~Z`lK5Ua^0nz7i z6zgtE6$WK*M`^}rZ*JWNJ(b+pBQ0`>qxhz)BxNYO<6B)q+eWw?x3T9rPsR#TMy_~1 zLou*_22e@ZVN*D#~xbYYYYR1xE2w*XJZ&?JMCt16}8+d&=FWnfPu=U?u?|!UA zvQ-qMm2F>es(Cz$PgO>H_ey$isCcU|h?mXiZicEA(UzWQzuw)jB-ntT)O7le46Bhy z$z?}?nGQz6;R2YHYtyNf_zeJ~?Lgv;JLo%(7ecRMc34mVf!8qX{up=%W0zKNOA91O zLly*!a$s;M13L*7;YMk=3F##PRGNE<8C3uf?2uFg76RgqRzY+>%vzg;cT z{IsfevtnP3KQ&qf8~26yGdcmb2QC~X6g(&}V|pRqY^%p2&6nc@O`vX|8qu)**W`cV zU6%d}yfAyDU%^HF|J$UZ`;yQvw7&yj(*w2rGcbRU8Dx1MW)YPG$loN<*x-I&V#_J~ z^AbZrpd|?7iiY=ZlcXh-e_;5}Yx{2}aVg`t+nl&>y0*qLCzut_odSX#)1O-}C~fat z+>Tp53FBfCUMoBLtl1fO(8s=Pn~ozQ#Ixw=#&3ABEHpda*_;~8Iu+zUm`iPQ6%2iF zez>H?kQ`8rfq^CcX!oFBQ}S)Bc0W~PcT8JY>nJ3Ub1NI{V_@XOE1o zjct`?9MGb8#6_tr9)#=cByjmgAKgXw%+WS37WG1BoBE`LmTb)1OP}v^lVaB7eY;(o zSx<7WyQf;O!w|G6Jl>qe{YnM`HBOUB3(#yx`+yI8(L}%DU)tMllc$DBJk+V`ba>Y5 z%l<~qS-~0Ufd>9lpX77YP>J1?DZ!vK=g)Ams6#oU(o)uMzG(80oZlJu?zNU{}9!7ei3pcIa`I@hb;R&)$f`d`*&``}bd@OQ&0>blLSq zbEV#cN8oAGo7irC!}*8^2A!3_#r{0p#VycblpXghqIK3N+4FGZXF=9QNA+_n!_zt( zN1@|b)x39e=g-}XO;9eSoTM@Ahh>4>_o3>L9S*axh4eS=!qoA+DG`7ny^Ia0(5Vk6 zzV1^lZ88RCd&dj93?!M~Z@F!?#3NXcd~~Cfe0d8s!K~1WVw~d!-jIZ*>hwh6}q`!yFU$@&F#Z`wyH5IPc{COT4u=3oXpMQ z_0CcSw`x?K1E%nZ(1apwrBnBog(7V$HmtA5*WHn$JCZp_An}_f%g(P!fOT=^%gOb? zp836#G4}Jg7F6f$21?%g@8vOjYyq1uFI(OT1WYiDGC{AO@WiCE$qc1p3N&rci(u?8(P?LAp!)+ zCe-g#r7LXK}W%dv5Ic-SG>T2gBKvh9=Xyxwt6EX~JFaTyk0`N1pi#Jom(2=>=Ei7+QHZ@57#)M}9c9zuel18)-XsSviFPaa;;lQv ziFMa^m2%*!9(bM2hKi1k_v7)XFmr$TVY0nA;MWus1{YhUQPQ@_pIjhNEbv@E5#bN}j(GJt9Pc0c%Fma@mxUIbWlHFYmnhnnyA zdYJFCHAP#2{RR4OosdwNyT<1PLCm_wO%qosxOiGjCx8}zpOI$GF`F*cA@wiwRANPI zZ1~OLt{tgpA=_*2R+1lPv(=~WSSt4P94G_oB&Z|kx%h9yBFBfA;0;M=59BAJE8KQuLfYHO~;Tl=H> zkzHk6!im#}vBP9Ii;q$?*_O%}Wxe~T2-jfHlnF;pM0p`fc7x_l+rW+5^9{Yn#X$2+ zKyBL!SZi0TD73{?%{4#zJ521#-Ycf20gaM^FSIaEiLP76xLDc+4wPK9XV3<2-qLmW z$QB$+D3IOmJMD$`qsByEA|FMYbrrT9+4$osmlQ4S3{mGV@Wo|o_SP^I1ICX#Z3Q<{ z2A&=}%eFI`t>+FBo%#&s-)CE~DGP%&a^vtBvVqlibi-Uftu00*-|m&83KFUJs~hgYy<{>O`iK&AHv~dbyN-!ocTy zc2iyXX;m&s0Gbiv{v=_WOi8`eEtM&EO@WYdzp7n_6GQ(A& zutl!xZSy@Q1}jY9hQoxV_s?qDaHsKEJZtiBx`2f&lQO96adu7i&vgm85C8`2$&#bD z%xr$EIK_D5A6E>;LY0a5tVUkoYA_@JEt{EHO@Y!aA0mu zJk~v?yQ%2CEgqW7+V`9*NqiQQs8^lZUG-~e#$+GoJCGdZDVeL*f?m|lH?^21Y&O8` zbC~+2oxhgU&prxP1aeQ!vt2nQACzPG&=dL7sR|cJ0 zkSOItu;8;d972`RrSu`~7NwOzR8zDBKGOsss;0zvk|2&31bHc?S+~Qcf zw);mBArW~_Beenu0DKG7&OA-r0}IsN4gMPNkx@HraEIeBIi%IPHHqR;^*wI*toQov_p^}YzTMAXK+vI&63ku;V^GnCh;j zF;O$ep7cG#Q`^P_xk;B7KF(Q$22T(q4VHEs=N{(kg;a-d;P%E}H0rF)KNtNd6voYX zs$X|;!2S4wHX@`f+nl^^>_KJ~4s}C69!^>%&s@fY!Ohow&mGQbIp^7-B2j+P7Nb>H zxj%5?v;;2mG< z#SmsgB@*Yi`;UEbH_Tt)z`e1a(xQz=SrvSxqiIPFassN-qn$b zszY#-@_zlf?tvLx9K|z}mGGJV(6njIPPl^w^l02kOmPAOPM)yKd`(K*%72}m_b+Dm^M^ef2tbo)zZ2N@!S zHBvbrNFysxsE6P2ofDS?lyon{a~-3>N|(y5Lof(Bmzy=gUt5H&534*nUTZ5SHI&l) z=Ex7LoO1W&+whq0uwkLCerEAQ=6`{{CKMC!v=rj3o>S{EqJb`Cb3lyD(y?p1(T@ zJXHZfw~X23zTK=7oH1&jv+L1+ot@_%^R~=8aPGr|w0hXpyE7%Sl$Aip?#fZ(CyF`K z{2G;4qrycnZN7@7@*!9dL9h_{uM2yY$hmY`|9>Wo|5}!`6fM*?f__B Discord Bot - @@ -15,109 +12,32 @@ - - - - - + - - - - - - - - - - - - - - - - - - -
@@ -125,8 +45,14 @@ - - + diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/init.js index 99fde47..f0e86c8 100644 --- a/src/main/resources/static/js/init.js +++ b/src/main/resources/static/js/init.js @@ -25,14 +25,12 @@ $(document).ready(function() { $('#btn_play').click(function () { switch (state){ case "PLAYING": - sendCommand({ command: "PAUSE"}) + sendCommand(JSON.stringify({ command: "PAUSE"})) break; case "PAUSE": - sendCommand({ command: "PLAY"}) + sendCommand(JSON.stringify({ command: "PLAY"})) break; - default: - sendCommand({command: "PLAY"}) } }); @@ -40,10 +38,10 @@ $(document).ready(function() { $('#btn_next').click(function () { - sendCommand({ command: "NEXT"}); + sendCommand(JSON.stringify({ command: "NEXT"})); }); $('#btn_stop').click(function () { - sendCommand({ command: "STOP"}); + sendCommand(JSON.stringify({ command: "STOP"})); }); $('.dropdown-button').dropdown({ @@ -87,7 +85,7 @@ $(document).ready(function() { var command = { command: "FLUSH" }; - sendCommand(command); + sendCommand(JSON.stringify(command)); }); $('#btn_add_top').click(function () { @@ -98,7 +96,7 @@ $(document).ready(function() { onHead: true }; $('#input_link').val(''); - sendCommand(command); + sendCommand(JSON.stringify(command)); }); $('#btn_add_bottom').click(function () { @@ -110,7 +108,7 @@ $(document).ready(function() { onHead: false }; $('#input_link').val(''); - sendCommand(command); + sendCommand(JSON.stringify(command)); }); $('#btn_ok_channel').click(function () { @@ -119,7 +117,7 @@ $(document).ready(function() { command: "CONNECT", chanelId: $('input[name=vocalRadio]:checked').val() }; - sendCommand(command); + sendCommand(JSON.stringify(command)); }); }) @@ -146,50 +144,27 @@ function getCurentMusic() { $('#btn_info').addClass("determinate").removeClass("indeterminate"); } $('#music_progress').width("0%"); - if(Cookies.get('token') != undefined){ - if (!$('#btn_stop').hasClass("disabled")) { - $('#btn_stop').addClass("disabled"); - } - if (!$('#btn_info').hasClass("disabled")) { - $('#btn_info').addClass("disabled"); - } - if ($('#add_btn').hasClass("disabled")) { - $('#add_btn').removeClass("disabled"); - } - if ($('#flush_btn').hasClass("disabled")) { - $('#flush_btn').removeClass("disabled"); - } - if ($('#btn_play').hasClass("disabled")) { - $('#btn_play').removeClass("disabled"); - } - if ($('#btn_next').hasClass("disabled")) { - $('#btn_next').removeClass("disabled"); - } - } - else{ - if (!$('#btn_stop').hasClass("disabled")) { - $('#btn_stop').addClass("disabled"); - } - if (!$('#btn_info').hasClass("disabled")) { - $('#btn_info').addClass("disabled"); - } - if (!$('#add_btn').hasClass("disabled")) { - $('#add_btn').addClass("disabled"); - } - if (!$('#flush_btn').hasClass("disabled")) { - $('#flush_btn').addClass("disabled"); - } - - if (!$('#btn_play').hasClass("disabled")) { - $('#btn_play').addClass("disabled"); - } - if (!$('#btn_next').hasClass("disabled")) { - $('#btn_next').addClass("disabled"); - } - } $('#btn_play').children().text("play_arrow"); + if (!$('#btn_stop').hasClass("disabled")) { + $('#btn_stop').addClass("disabled"); + } + if (!$('#btn_info').hasClass("disabled")) { + $('#btn_info').addClass("disabled"); + } + if ($('#add_btn').hasClass("disabled")) { + $('#add_btn').removeClass("disabled"); + } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); + } + if ($('#btn_play').hasClass("disabled")) { + $('#btn_play').removeClass("disabled"); + } + if ($('#btn_next').hasClass("disabled")) { + $('#btn_next').removeClass("disabled"); + } $('#music_img').attr("src","/img/no_music.jpg"); $('#total_time').text("00:00"); @@ -231,7 +206,6 @@ function getCurentMusic() { $('#music_progress').width("0%"); $('#btn_play').children().text("play_arrow"); - if (!$('#btn_play').hasClass("disabled")) { $('#btn_play').addClass("disabled"); } @@ -253,13 +227,11 @@ function getCurentMusic() { $('#music_img').attr("src","/img/disconnected.png"); - if(Cookies.get('token') != undefined){ - if(!disconected){ - getChannels(); - disconected = true; - } - } + if(!disconected){ + getChannels(); + disconected = true; + } @@ -306,7 +278,7 @@ function getPlayList() { command: "DELL", url: $(this).attr("data_url") }; - sendCommand(command); + sendCommand(JSON.stringify(command)); }); @@ -362,55 +334,30 @@ function updateControl(data){ $('#music_text').text(data.info.title); var percent = (data.currentPos / data.info.length) * 100; // console.log(percent) - if (!$('#music_progress').hasClass("indeterminate")) { - $('#music_progress').addClass("determinate").removeClass("indeterminate"); + if (!$('#btn_info').hasClass("indeterminate")) { + $('#btn_info').addClass("determinate").removeClass("indeterminate"); } $('#music_progress').width(percent + "%"); - if(Cookies.get('token') != undefined){ - if ($('#btn_play').hasClass("disabled")) { - $('#btn_play').removeClass("disabled"); - } - if ($('#btn_stop').hasClass("disabled")) { - $('#btn_stop').removeClass("disabled"); - } - if ($('#btn_info').hasClass("disabled")) { - $('#btn_info').removeClass("disabled"); - } - if ($('#add_btn').hasClass("disabled")) { - $('#add_btn').removeClass("disabled"); - } - if ($('#flush_btn').hasClass("disabled")) { - $('#flush_btn').removeClass("disabled"); - } - - if ($('#btn_next').hasClass("disabled")) { - $('#btn_next').removeClass("disabled"); - } + if ($('#btn_play').hasClass("disabled")) { + $('#btn_play').removeClass("disabled"); } - else - { - if (!$('#btn_play').hasClass("disabled")) { - $('#btn_play').addClass("disabled"); - } - if (!$('#btn_stop').hasClass("disabled")) { - $('#btn_stop').addClass("disabled"); - } - if (!$('#btn_info').hasClass("disabled")) { - $('#btn_info').addClass("disabled"); - } - if (!$('#add_btn').hasClass("disabled")) { - $('#add_btn').addClass("disabled"); - } - if (!$('#flush_btn').hasClass("disabled")) { - $('#flush_btn').addClass("disabled"); - } - - if (!$('#btn_next').hasClass("disabled")) { - $('#btn_next').addClass("disabled"); - } + if ($('#btn_stop').hasClass("disabled")) { + $('#btn_stop').removeClass("disabled"); + } + if ($('#btn_info').hasClass("disabled")) { + $('#btn_info').removeClass("disabled"); + } + if ($('#add_btn').hasClass("disabled")) { + $('#add_btn').removeClass("disabled"); + } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); } + if ($('#btn_next').hasClass("disabled")) { + $('#btn_next').removeClass("disabled"); + } $('#music_img').attr("src","https://img.youtube.com/vi/"+data.info.identifier+"/hqdefault.jpg"); // console.log(data); @@ -419,15 +366,13 @@ function updateControl(data){ updateModal(data); } -function sendCommand(command){ - command["token"] = Cookies.get('token'); - console.log(command) +function sendCommand(commandStr){ $.ajax({ type: "POST", dataType: 'json', contentType: 'application/json', url: "/api/music/command", - data: JSON.stringify(command), + data: commandStr, success: function (data) { console.log(data); } @@ -435,11 +380,6 @@ function sendCommand(command){ }).fail(function (data) { console.log(data); alert(data.responseJSON.Message); - if(data.responseJSON.error === "token"){ - Cookies.remove('token'); - Cookies.remove('name'); - location.reload(); - } }); } diff --git a/src/main/resources/static/js/js.cookie.js b/src/main/resources/static/js/js.cookie.js deleted file mode 100644 index 9a0945e..0000000 --- a/src/main/resources/static/js/js.cookie.js +++ /dev/null @@ -1,165 +0,0 @@ -/*! - * JavaScript Cookie v2.2.0 - * https://github.com/js-cookie/js-cookie - * - * Copyright 2006, 2015 Klaus Hartl & Fagner Brack - * Released under the MIT license - */ -;(function (factory) { - var registeredInModuleLoader = false; - if (typeof define === 'function' && define.amd) { - define(factory); - registeredInModuleLoader = true; - } - if (typeof exports === 'object') { - module.exports = factory(); - registeredInModuleLoader = true; - } - if (!registeredInModuleLoader) { - var OldCookies = window.Cookies; - var api = window.Cookies = factory(); - api.noConflict = function () { - window.Cookies = OldCookies; - return api; - }; - } -}(function () { - function extend () { - var i = 0; - var result = {}; - for (; i < arguments.length; i++) { - var attributes = arguments[ i ]; - for (var key in attributes) { - result[key] = attributes[key]; - } - } - return result; - } - - function init (converter) { - function api (key, value, attributes) { - var result; - if (typeof document === 'undefined') { - return; - } - - // Write - - if (arguments.length > 1) { - attributes = extend({ - path: '/' - }, api.defaults, attributes); - - if (typeof attributes.expires === 'number') { - var expires = new Date(); - expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); - attributes.expires = expires; - } - - // We're using "expires" because "max-age" is not supported by IE - attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; - - try { - result = JSON.stringify(value); - if (/^[\{\[]/.test(result)) { - value = result; - } - } catch (e) {} - - if (!converter.write) { - value = encodeURIComponent(String(value)) - .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); - } else { - value = converter.write(value, key); - } - - key = encodeURIComponent(String(key)); - key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); - key = key.replace(/[\(\)]/g, escape); - - var stringifiedAttributes = ''; - - for (var attributeName in attributes) { - if (!attributes[attributeName]) { - continue; - } - stringifiedAttributes += '; ' + attributeName; - if (attributes[attributeName] === true) { - continue; - } - stringifiedAttributes += '=' + attributes[attributeName]; - } - return (document.cookie = key + '=' + value + stringifiedAttributes); - } - - // Read - - if (!key) { - result = {}; - } - - // To prevent the for loop in the first place assign an empty array - // in case there are no cookies at all. Also prevents odd result when - // calling "get()" - var cookies = document.cookie ? document.cookie.split('; ') : []; - var rdecode = /(%[0-9A-Z]{2})+/g; - var i = 0; - - for (; i < cookies.length; i++) { - var parts = cookies[i].split('='); - var cookie = parts.slice(1).join('='); - - if (!this.json && cookie.charAt(0) === '"') { - cookie = cookie.slice(1, -1); - } - - try { - var name = parts[0].replace(rdecode, decodeURIComponent); - cookie = converter.read ? - converter.read(cookie, name) : converter(cookie, name) || - cookie.replace(rdecode, decodeURIComponent); - - if (this.json) { - try { - cookie = JSON.parse(cookie); - } catch (e) {} - } - - if (key === name) { - result = cookie; - break; - } - - if (!key) { - result[name] = cookie; - } - } catch (e) {} - } - - return result; - } - - api.set = api; - api.get = function (key) { - return api.call(api, key); - }; - api.getJSON = function () { - return api.apply({ - json: true - }, [].slice.call(arguments)); - }; - api.defaults = {}; - - api.remove = function (key, attributes) { - api(key, '', extend(attributes, { - expires: -1 - })); - }; - - api.withConverter = init; - - return api; - } - - return init(function () {}); -})); diff --git a/src/main/resources/static/js/navabar.js b/src/main/resources/static/js/navabar.js deleted file mode 100644 index 8ae0ba7..0000000 --- a/src/main/resources/static/js/navabar.js +++ /dev/null @@ -1,138 +0,0 @@ -var nav_bar_account_link; -var connected_link = "account_box"; -var disconnected_link = "account_box"; -var input_name; -var input_psw; -var btn_submit; -var btn_disconnect; -var nav_name; - -$(document).ready(function() { - $('.button-navbar-mobile').sideNav({ - menuWidth: 400, // Default is 300 - edge: 'right', // Choose the horizontal origin - closeOnClick: false, // Closes side-nav on clicks, useful for Angular/Meteor - draggable: true // Choose whether you can drag to open on touch screens, - }); - - - nav_bar_account_link = $("#nav-bar-account"); - input_name = $("#user_input"); - input_psw = $("#password_input"); - btn_submit = $("#btn-submit-connect"); - btn_disconnect = $("#nav-disconnect"); - nav_name = $("#nav-name"); - - if(Cookies.get('token') === undefined){ - disconnected() - } - else{ - connected(); - } - - listeners(); -}); - - -function popOutSubmit(){ - if (btn_submit.hasClass("scale-in")) { - btn_submit.removeClass("scale-in"); - btn_submit.addClass("scale-out"); - } -} - -function popInSubmit(){ - if (btn_submit.hasClass("scale-out")) { - btn_submit.removeClass("scale-out"); - btn_submit.addClass("scale-in"); - } -} - - - -function connected(){ - console.log("Connected!"); - nav_bar_account_link.html(connected_link); - $('.dropdown-account').dropdown({ - constrainWidth: false, // Does not change width of dropdown to that of the activator - belowOrigin: true, // Displays dropdown below the button - alignment: 'left', // Displays dropdown with edge aligned to the left of button - stopPropagation: false // Stops event propagation - } - ); - nav_name.text(Cookies.get('name')); -} - -function disconnected() { - console.log("Disconnected"); - nav_bar_account_link.html(disconnected_link); - var modalConnection = $('#modal_connection'); - modalConnection.modal(); - if (typeof needLogin !== 'undefined'){ - modalConnection.modal('open'); - } - -} - - -function tryConnection() { - var request = { name: input_name.val(), password: input_psw.val()}; - $.ajax({ - type: "POST", - dataType: 'json', - contentType: 'application/json', - url: "/api/userManagement/requestToken", - data: JSON.stringify(request), - success: function (data) { - console.log(data); - Cookies.set('token',data.token); - Cookies.set('name', data.name); - debugger; - location.reload(); - } - - }).fail(function (data) { - console.log(data); - switch(data.responseJSON.error){ - case "user": - input_name.addClass("invalid"); - break; - - case "password": - input_psw.addClass("invalid"); - break; - } - - }); - - - return true; -} - - -function listeners() { - input_name.on("input", function () { - if(input_name.val() !== "" && input_psw.val() !== "") { - popInSubmit(); - }else - { - popOutSubmit(); - } - }); - - input_psw.on("input", function () { - if(input_name.val() !== "" && input_psw.val() !== "") { - popInSubmit(); - }else - { - popOutSubmit(); - } - }); - - btn_disconnect.click(function () { - Cookies.remove('token'); - Cookies.remove('name'); - location.reload(); - }); - -} \ No newline at end of file diff --git a/src/main/resources/static/js/register.js b/src/main/resources/static/js/register.js deleted file mode 100644 index f64baee..0000000 --- a/src/main/resources/static/js/register.js +++ /dev/null @@ -1,176 +0,0 @@ - -var ok_passwrd = false; -$(document).ready(function() { - var baseUrl = window.location.protocol + "//" +window.location.host + window.location.pathname; - console.log(baseUrl); - $('.button-collapse-1').sideNav({ - menuWidth: 400, // Default is 300 - edge: 'right', // Choose the horizontal origin - closeOnClick: false, // Closes side-nav on clicks, useful for Angular/Meteor - draggable: true // Choose whether you can drag to open on touch screens, - }); - - var sendBtn = $('#sendBtn'); - - - $('#name').on("input", function () { - if($('#name').val() === ""){ - if (sendBtn.hasClass("scale-in")) { - sendBtn.removeClass("scale-in"); - sendBtn.addClass("scale-out"); - } - } - else{ - if (sendBtn.hasClass("scale-out") && ok_passwrd) { - sendBtn.removeClass("scale-out"); - sendBtn.addClass("scale-in"); - } - } - }); - - - var passwrd = $('#passwrd'); - var confirm = $('#passwrd2'); - passwrd.on("input", function () { - if((passwrd.val() === confirm.val())&& passwrd.val() !== ''){ - if (passwrd.hasClass("invalid")) { - passwrd.addClass("valid"); - passwrd.removeClass("invalid"); - confirm.addClass("valid"); - confirm.removeClass("invalid"); - - - } - if($('#name').val() !== ""){ - if (sendBtn.hasClass("scale-out")) { - sendBtn.removeClass("scale-out"); - sendBtn.addClass("scale-in"); - } - } - ok_passwrd = true; - } - else{ - if (!passwrd.hasClass("invalid")) { - passwrd.addClass("invalid"); - passwrd.removeClass("valid"); - confirm.addClass("invalid"); - confirm.removeClass("valid"); - - } - if (sendBtn.hasClass("scale-in")) { - sendBtn.removeClass("scale-in"); - sendBtn.addClass("scale-out"); - } - ok_passwrd = false; - } - }); - - confirm.on("input", function () { - if((passwrd.val() === confirm.val())&& passwrd.val() !== ''){ - if (passwrd.hasClass("invalid")) { - passwrd.addClass("valid"); - passwrd.removeClass("invalid"); - confirm.addClass("valid"); - confirm.removeClass("invalid"); - - } - if($('#name').val() !== ""){ - if (sendBtn.hasClass("scale-out")) { - sendBtn.removeClass("scale-out"); - sendBtn.addClass("scale-in"); - } - } - ok_passwrd = true; - } - else{ - if (!passwrd.hasClass("invalid")) { - passwrd.addClass("invalid"); - passwrd.removeClass("valid"); - confirm.addClass("invalid"); - confirm.removeClass("valid"); - } - - if (sendBtn.hasClass("scale-in")) { - sendBtn.removeClass("scale-in"); - sendBtn.addClass("scale-out"); - } - ok_passwrd = false; - } - }); - - - $('#sendBtn').click(function () { - var name = $('#name').val(); - var password = $('#passwrd').val(); - - $.ajax({ - type: "POST", - dataType: 'json', - contentType: 'application/json', - url: "/api/userManagement/preRegister", - data: JSON.stringify({ name: name, password: password}), - success: function (data) { - console.log(data); - window.location.href = baseUrl + "?id="+data.id - } - - }).fail(function (data) { - console.log(data); - if(data.status === 404){ - alert("User Not Found!"); - $('#name').addClass("invalid"); - $('#name').removeClass("valid"); - - } - else{ - alert(data.responseJSON.message); - } - - }); - }); - - $('#modalToken').modal({dismissible: false}); - if(id !== ''){ - $('#modalToken').modal('open'); - } - - - $('#input_preToken').on("input", function () { - var sendBtn = $('#preTokenSend'); - if($('#input_preToken').val().length < 4){ - if (sendBtn.hasClass("scale-in")) { - sendBtn.removeClass("scale-in"); - sendBtn.addClass("scale-out"); - } - } - else{ - if (sendBtn.hasClass("scale-out")) { - sendBtn.removeClass("scale-out"); - sendBtn.addClass("scale-in"); - } - } - }); - $('#preTokenSend').click(function () { - $.ajax({ - type: "POST", - dataType: 'json', - contentType: 'application/json', - url: "/api/userManagement/confirmAccount", - data: JSON.stringify({ id: id.toString(), checkToken: $('#input_preToken').val()}), - success: function (data) { - console.log(data); - Cookies.set('token',data.token); - Cookies.set('name', data.name); - debugger; - window.location.href = "/" - } - - }).fail(function (data) { - console.log(data); - alert(data.responseJSON.message); - - }); - }); - - -}); diff --git a/src/main/resources/templates/music.html b/src/main/resources/templates/music.html index cd1d19c..7ac65a4 100644 --- a/src/main/resources/templates/music.html +++ b/src/main/resources/templates/music.html @@ -3,10 +3,7 @@ - Music Control - Discord Bot - + Discord Bot - Music Control @@ -16,106 +13,31 @@ - - - - - - - - - - - - - - - - - - - - -
@@ -292,11 +214,6 @@ - - - diff --git a/src/main/resources/templates/register.html b/src/main/resources/templates/register.html deleted file mode 100644 index b8bf740..0000000 --- a/src/main/resources/templates/register.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - User Registration - Discord Bot - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-

Account Registration

-
-
-
-
- assignment_ind - - -
-
-
-
-
-
- security - - -
-
-
-
-
-
- security - - -
-
-
-
- Sendsend -
-
-
- - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From b662935be985dcc8cf5f1cbaf60b23c12f967a8d Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 15 Feb 2018 00:59:02 +0100 Subject: [PATCH 2/2] update readMe --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3cb6697..7998a30 100644 --- a/README.md +++ b/README.md @@ -9,25 +9,67 @@ > version: '2' > > services: -> botdiscord: -> image: brokenfire/brokendiscordbot:latest +> botdiscorddevel: +> image: brokenfire/brokendiscordbot:latest > networks: > - proxy +> - internal > environment: -> - PORT=8081 +> - PORT=8080 > - TOKEN=1111111111111 #CHANGE ME! +> - DB_URL=jdbc:mysql://database/botdiscord +> - DB_USER=root +> - DB_PWD=ogahxu1eigohN2Eok0xoawae #CHANGE ME! > labels: > - "traefik.frontend.rule=Host:exemple.com" #CHANGE ME! +> - "traefik.docker.network=proxy" > - "traefik.port=8080" > - "traefik.backend=botdiscord" > - "traefik.frontend.entryPoints=http,https" -> volumes: -> - "./logs:/bot_src/logs" +> volumes: +> - "./logs:/bot_src/logs" +> depends_on: +> - "database" > restart: always > +> phpmyadmin: +> image: phpmyadmin/phpmyadmin:latest +> labels: +> - "traefik.frontend.rule=Host:phpmyadmin.exemple.com" #CHANGE ME! +> - "traefik.port=80" +> - "traefik.docker.network=proxy" +> - "traefik.backend=phpmyadmin" +> - "traefik.frontend.entryPoints=http,https" +> environment: +> - PMA_HOST=database +> depends_on: +> - "database" +> networks: +> - proxy +> - internal +> +> database: +> image: mariadb:latest +> volumes: +> - ./db:/var/lib/mysql +> labels: +> - "traefik.enable=false" +> environment: +> - MYSQL_ROOT_PASSWORD=ogahxu1eigohN2Eok0xoawae #CHANGE ME! +> - MYSQL_DATABASE=botdiscord +> - MYSQL_USER= #CHANGE ME! +> - MYSQL_PASSWORD= #CHANGE ME! +> networks: +> - internal +> +> +> > networks: > proxy: -> external: true +> external: true +> internal: +> external: false +> > ``` > Docker hub [repo](https://hub.docker.com/r/brokenfire/brokendiscordbot/)