diff --git a/Heroku/Procfile b/Heroku/Procfile deleted file mode 100644 index 5540597..0000000 --- a/Heroku/Procfile +++ /dev/null @@ -1 +0,0 @@ -worker: java -Dlog4j.configurationFile=log4j2.xml -jar Discord_Stroumpf_Beta.jar -t diff --git a/Heroku/deploy.sh b/Heroku/deploy.sh deleted file mode 100644 index 59587a8..0000000 --- a/Heroku/deploy.sh +++ /dev/null @@ -1 +0,0 @@ -heroku deploy:jar Discord_Stroumpf_Beta.jar -i log4j2.xml --app discord-stroumpf-beta \ No newline at end of file diff --git a/Heroku/log4j2.xml b/Heroku/log4j2.xml deleted file mode 100644 index c776217..0000000 --- a/Heroku/log4j2.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Procfile b/Procfile deleted file mode 100644 index e3b7ecc..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: java -jar /app/build/libs/DiscordBot-0.1.0.jar -t $TOKEN diff --git a/README.md b/README.md index 6e2c3bf..3cb6697 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ > > services: > botdiscord: -> image: brokenfire/brokendiscordbot +> image: brokenfire/brokendiscordbot:latest > networks: > - proxy > environment: @@ -21,8 +21,8 @@ > - "traefik.port=8080" > - "traefik.backend=botdiscord" > - "traefik.frontend.entryPoints=http,https" -> #volumes: -> # - "/var/run/docker.sock:/var/run/docker.sock" +> volumes: +> - "./logs:/bot_src/logs" > restart: always > > networks: @@ -30,3 +30,4 @@ > external: true > ``` > Docker hub [repo](https://hub.docker.com/r/brokenfire/brokendiscordbot/) + diff --git a/src/main/java/net/Broken/RestApi/Commands/Dell.java b/src/main/java/net/Broken/RestApi/Commands/Dell.java new file mode 100644 index 0000000..cb7fbc3 --- /dev/null +++ b/src/main/java/net/Broken/RestApi/Commands/Dell.java @@ -0,0 +1,29 @@ +package net.Broken.RestApi.Commands; + +import net.Broken.Commands.Music; +import net.Broken.RestApi.CommandInterface; +import net.Broken.RestApi.Data.CommandPostData; +import net.Broken.RestApi.Data.CommandResponseData; +import net.Broken.audio.NotConectedException; +import net.Broken.audio.NullMusicManager; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +public class Dell implements CommandInterface { + @Override + public ResponseEntity action(Music musicCommande, CommandPostData data) { + if(data.url != null) { + try { + if(musicCommande.getAudioManager().getMusicManager().scheduler.remove(data.url)){ + return new ResponseEntity<>(new CommandResponseData(data.command, "Accepted"), HttpStatus.OK); + } + else + return new ResponseEntity<>(new CommandResponseData(data.command,"URL not found"), HttpStatus.NOT_FOUND); + } catch (NullMusicManager | NotConectedException nullMusicManager) { + return new ResponseEntity<>(new CommandResponseData(data.command, "Not connected to vocal!"), HttpStatus.NOT_ACCEPTABLE); + } + } + return new ResponseEntity<>(new CommandResponseData(data.command, "Missing URL"), HttpStatus.NOT_ACCEPTABLE); + + } +} diff --git a/src/main/java/net/Broken/audio/TrackScheduler.java b/src/main/java/net/Broken/audio/TrackScheduler.java index bcd231f..6b6e0e5 100644 --- a/src/main/java/net/Broken/audio/TrackScheduler.java +++ b/src/main/java/net/Broken/audio/TrackScheduler.java @@ -5,6 +5,8 @@ import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.List; @@ -19,6 +21,7 @@ import java.util.concurrent.LinkedBlockingQueue; public class TrackScheduler extends AudioEventAdapter { private final AudioPlayer player; private final BlockingDeque queue; + Logger logger = LogManager.getLogger(); /** * @param player The audio player this scheduler uses @@ -85,6 +88,22 @@ public class TrackScheduler extends AudioEventAdapter { return player.getPlayingTrack().getInfo(); } + public boolean remove(String uri){ + for(AudioTrack track : queue){ + if(track.getInfo().uri.equals(uri)){ + if(!queue.remove(track)) { + logger.info("Delete failure!"); + return false; + } else { + logger.info("Delete succeful"); + return true; + } + } + } + logger.info("Delete failure! Not found."); + return false; + } + /** * Start the next track, stopping the current one if it is playing. */ diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 413893a..467272d 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -16,7 +16,7 @@ - + diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/init.js index 5983666..f0e86c8 100644 --- a/src/main/resources/static/js/init.js +++ b/src/main/resources/static/js/init.js @@ -35,6 +35,8 @@ $(document).ready(function() { }); + + $('#btn_next').click(function () { sendCommand(JSON.stringify({ command: "NEXT"})); }); @@ -270,6 +272,15 @@ function getPlayList() { $('#playlist_list').append(template); + }); + $(".btn_dell_playlist").click(function () { + var command = { + command: "DELL", + url: $(this).attr("data_url") + }; + sendCommand(JSON.stringify(command)); + + }); } } @@ -349,7 +360,7 @@ function updateControl(data){ } $('#music_img').attr("src","https://img.youtube.com/vi/"+data.info.identifier+"/hqdefault.jpg"); - console.log(data); + // console.log(data); $('#total_time').text(msToTime(data.info.length)); $('#current_time').text(msToTime(data.currentPos)); updateModal(data); diff --git a/src/main/resources/templates/music.html b/src/main/resources/templates/music.html index c3d7164..7ac65a4 100644 --- a/src/main/resources/templates/music.html +++ b/src/main/resources/templates/music.html @@ -177,6 +177,11 @@
  • Author: @author
  • Duration: @lenght
  • URL: @url
  • +
  • + + delete + +