Merge branch 'master' into devel

This commit is contained in:
BrokenFire 2018-01-18 11:02:49 +01:00
commit 26759154df
10 changed files with 70 additions and 34 deletions

View File

@ -1 +0,0 @@
worker: java -Dlog4j.configurationFile=log4j2.xml -jar Discord_Stroumpf_Beta.jar -t <token>

View File

@ -1 +0,0 @@
heroku deploy:jar Discord_Stroumpf_Beta.jar -i log4j2.xml --app discord-stroumpf-beta

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="error">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%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}" />
<!--{FATAL=red blink, ERROR=red, WARN=orange, INFO=yellow, DEBUG=green bold, TRACE=blue}-->
</Console>
<!--<RollingFile name="RollingFile" fileName="/logs/curent.log"
filePattern="/logs/$${date:yyyy-MM}/discordBot-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<Pattern>[%d{yyy-MM-dd ~ HH:mm:ss.SSS}][%-5level]%logger{36}: %msg%n</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy minSize="1B"/>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>-->
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="RollingFile" level="info"/>
</Root>
</Loggers>
</Configuration>

View File

@ -1 +0,0 @@
web: java -jar /app/build/libs/DiscordBot-0.1.0.jar -t $TOKEN

View File

@ -10,7 +10,7 @@
> >
> services: > services:
> botdiscord: > botdiscord:
> image: brokenfire/brokendiscordbot > image: brokenfire/brokendiscordbot:latest
> networks: > networks:
> - proxy > - proxy
> environment: > environment:
@ -21,8 +21,8 @@
> - "traefik.port=8080" > - "traefik.port=8080"
> - "traefik.backend=botdiscord" > - "traefik.backend=botdiscord"
> - "traefik.frontend.entryPoints=http,https" > - "traefik.frontend.entryPoints=http,https"
> #volumes: > volumes:
> # - "/var/run/docker.sock:/var/run/docker.sock" > - "./logs:/bot_src/logs"
> restart: always > restart: always
> >
> networks: > networks:
@ -30,3 +30,4 @@
> external: true > external: true
> ``` > ```
> Docker hub [repo](https://hub.docker.com/r/brokenfire/brokendiscordbot/) > Docker hub [repo](https://hub.docker.com/r/brokenfire/brokendiscordbot/)

View File

@ -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<CommandResponseData> 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);
}
}

View File

@ -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.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; 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.ArrayList;
import java.util.List; import java.util.List;
@ -19,6 +21,7 @@ import java.util.concurrent.LinkedBlockingQueue;
public class TrackScheduler extends AudioEventAdapter { public class TrackScheduler extends AudioEventAdapter {
private final AudioPlayer player; private final AudioPlayer player;
private final BlockingDeque<AudioTrack> queue; private final BlockingDeque<AudioTrack> queue;
Logger logger = LogManager.getLogger();
/** /**
* @param player The audio player this scheduler uses * @param player The audio player this scheduler uses
@ -85,6 +88,22 @@ public class TrackScheduler extends AudioEventAdapter {
return player.getPlayingTrack().getInfo(); 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. * Start the next track, stopping the current one if it is playing.
*/ */

View File

@ -16,7 +16,7 @@
<TimeBasedTriggeringPolicy interval="1" modulate="true"/> <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/> <SizeBasedTriggeringPolicy size="250 MB"/>
</Policies> </Policies>
<DefaultRolloverStrategy max="60" /> <DefaultRolloverStrategy max="120"/>
</RollingFile> </RollingFile>
<File name="current" fileName="logs/current.log" append="false"> <File name="current" fileName="logs/current.log" append="false">
<PatternLayout> <PatternLayout>

View File

@ -35,6 +35,8 @@ $(document).ready(function() {
}); });
$('#btn_next').click(function () { $('#btn_next').click(function () {
sendCommand(JSON.stringify({ command: "NEXT"})); sendCommand(JSON.stringify({ command: "NEXT"}));
}); });
@ -270,6 +272,15 @@ function getPlayList() {
$('#playlist_list').append(template); $('#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"); $('#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)); $('#total_time').text(msToTime(data.info.length));
$('#current_time').text(msToTime(data.currentPos)); $('#current_time').text(msToTime(data.currentPos));
updateModal(data); updateModal(data);

View File

@ -177,6 +177,11 @@
<li class="collection-item">Author: @author</li> <li class="collection-item">Author: @author</li>
<li class="collection-item">Duration: @lenght</li> <li class="collection-item">Duration: @lenght</li>
<li class="collection-item">URL: <a target="_blank" href="@url">@url</a></li> <li class="collection-item">URL: <a target="_blank" href="@url">@url</a></li>
<li class="collection-item center">
<a class="btn red darken-4 z-depth-3 waves-effect waves-light btn_dell_playlist" data_url="@url">
<i class="material-icons medium">delete</i>
</a>
</li>
</ul> </ul>
</div> </div>
</li> </li>