Merge branch 'devel'

This commit is contained in:
BrokenFire 2018-02-23 19:48:27 +01:00
commit 209e6c50fc
35 changed files with 380 additions and 269 deletions

View File

@ -51,7 +51,7 @@ public class BotListener extends ListenerAdapter {
if(event.getMember().getRoles().size() == 0){ if(event.getMember().getRoles().size() == 0){
logger.info(event.getUser().getName()+ "have no roles, move it!"); logger.info(event.getUser().getName()+ "have no roles, move it!");
new Move().exc(event.getMember(),event.getJDA().getRolesByName("Rat_d'égout",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager()); new Move().exc(event.getMember(),event.getJDA().getRolesByName("Populace",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager());
MainBot.roleFlag = false; MainBot.roleFlag = false;
} }
} }
@ -76,7 +76,7 @@ public class BotListener extends ListenerAdapter {
logger.debug("I'm alone, close audio connection."); logger.debug("I'm alone, close audio connection.");
Music music = (Music) MainBot.commandes.get("music"); Music music = (Music) MainBot.commandes.get("music");
music.audio.stop(event); music.audio.stop();
} }
} }
} }

View File

@ -9,9 +9,9 @@ import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
public interface Commande { public interface Commande {
boolean called(String[] args, MessageReceivedEvent event); boolean called(String[] args, MessageReceivedEvent event);
void action(String[] args, MessageReceivedEvent event); void action(String[] args, MessageReceivedEvent event);
String help(String[] args);
void executed(boolean success, MessageReceivedEvent event); void executed(boolean success, MessageReceivedEvent event);
boolean isPrivateUsable(); boolean isPrivateUsable();
boolean isAdminCmd();
} }

View File

@ -63,11 +63,6 @@ public class Cat implements Commande {
} }
@Override
public String help(String[] args) {
return "";
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -77,4 +72,9 @@ public class Cat implements Commande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -26,33 +26,8 @@ public class DayTrigger implements Commande{
@Override @Override
public void action(String[] args, MessageReceivedEvent event) { public void action(String[] args, MessageReceivedEvent event) {
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
DayListener.getInstance().trigger();
event.getMessage().delete().queue(); event.getMessage().delete().queue();
}
else{
logger.warn("Not admin! DENY!");
if(!event.isFromType(ChannelType.PRIVATE)){
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(message);
add(event.getMessage());
}};
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
}
else{
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getError("Vous n'avez pas l'autorisation de faire ça!"),logger);
}
}
}
@Override
public String help(String[] args) {
return null;
} }
@Override @Override
@ -64,4 +39,9 @@ public class DayTrigger implements Commande{
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return true; return true;
} }
@Override
public boolean isAdminCmd() {
return true;
}
} }

View File

@ -54,11 +54,6 @@ public class Flush implements Commande{
} }
} }
@Override
public String help(String[] args) {
return "`//flush <nbr>`\n:arrow_right:\t*Efface les n derniers messages (Max = 100)*";
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -68,4 +63,9 @@ public class Flush implements Commande{
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -8,11 +8,13 @@ import net.Broken.Tools.PrivateMessage;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.awt.*; import java.awt.*;
import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -36,26 +38,39 @@ public class Help implements Commande {
if (MainBot.commandes.containsKey(argsString)) if (MainBot.commandes.containsKey(argsString))
{ {
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName()); logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
MessageEmbed messageEmbed;
try {
messageEmbed = EmbedMessageUtils.getHelp(argsString);
} catch (FileNotFoundException e) {
try {
messageEmbed = EmbedMessageUtils.getHelp("Default");
} catch (FileNotFoundException e1) {
messageEmbed = EmbedMessageUtils.getInternalError();
logger.catching(e1);
}
}
if(!event.isFromType(ChannelType.PRIVATE)) { if(!event.isFromType(ChannelType.PRIVATE)) {
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getHelp(argsString, MainBot.commandes.get(argsString).help(args))).complete(); Message rest = event.getTextChannel().sendMessage(messageEmbed).complete();
if(args.length<=1) if(args.length<=1)
{ {
Message finalRest = rest;
List<Message> messages = new ArrayList<Message>(){{ List<Message> messages = new ArrayList<Message>(){{
add(rest); add(finalRest);
add(event.getMessage()); add(event.getMessage());
}}; }};
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else if(!args[1].toLowerCase().equals("true")){ else if(!args[1].toLowerCase().equals("true")){
Message finalRest1 = rest;
List<Message> messages = new ArrayList<Message>(){{ List<Message> messages = new ArrayList<Message>(){{
add(rest); add(finalRest1);
add(event.getMessage()); add(event.getMessage());
}}; }};
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} else{ } else{
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getHelp(argsString, MainBot.commandes.get(argsString).help(args)),logger); PrivateMessage.send(event.getAuthor(), messageEmbed,logger);
} }
@ -102,11 +117,6 @@ public class Help implements Commande {
} }
@Override
public String help(String[] args) {
return null;
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -116,4 +126,9 @@ public class Help implements Commande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return true; return true;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -113,8 +113,6 @@ public class Move implements Commande {
user = serveur.getMember(userL.get(0)); user = serveur.getMember(userL.get(0));
serveur=event.getGuild(); serveur=event.getGuild();
logger.info("Tentative de déplacement de "+user.getEffectiveName()+" vers "+roleL+" par l'utilisateur "+event.getAuthor().getName()); logger.info("Tentative de déplacement de "+user.getEffectiveName()+" vers "+roleL+" par l'utilisateur "+event.getAuthor().getName());
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
{
logger.info("Autorisation suffisante, deplacement autorisé"); logger.info("Autorisation suffisante, deplacement autorisé");
logger.debug("Utilisateur trouvée"); logger.debug("Utilisateur trouvée");
@ -165,19 +163,8 @@ public class Move implements Commande {
} }
}
else
{
logger.warn("Autorisation insuffisante, deplacement refusé");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Vous n'avez pas l'autorisation de faicre ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
}
} }
else else
@ -201,16 +188,6 @@ public class Move implements Commande {
}
/**
*
* @param args
* @return
*/
@Override
public String help(String[] args) {
return HELP;
} }
/** /**
@ -227,4 +204,9 @@ public class Move implements Commande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return true;
}
} }

View File

@ -128,13 +128,21 @@ public class Music implements Commande {
} }
break; break;
case "disconnect":
audio.stop();
List<Message> messages = new ArrayList<Message>(){{
add(event.getMessage());
}};
new MessageTimeOut(messages, 0).start();
break;
default: default:
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Arguments inconu!")).complete(); Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Arguments inconu!")).complete();
List<Message> messages = new ArrayList<Message>(){{ List<Message> messagess = new ArrayList<Message>(){{
add(message); add(message);
add(event.getMessage()); add(event.getMessage());
}}; }};
new MessageTimeOut(messages, MainBot.messageTimeOut).start(); new MessageTimeOut(messagess, MainBot.messageTimeOut).start();
break; break;
} }
@ -149,12 +157,6 @@ public class Music implements Commande {
} }
} }
@Override
public String help(String[] args) {
return "`//music play <url>`\n:arrow_right:\t*Let's dance! Deffinit le chat vocal à utiliser.*\n\n`//music pause`\n:arrow_right:\t*Mise en pause de la piste en cours.*\n\n`//music resume`\n:arrow_right:\t*Reprise de la lecture de la piste en cours.*\n\n`//music next`\n:arrow_right:\t*Change le piste en cours.*\n\n`//music stop`\n:arrow_right:\t*Arrête la piste en cours.*\n\n`//music info`\n:arrow_right:\t*Affiche les infos de la piste en cours.*\n\n`//music flush`\n:arrow_right:\t*Supprime la playlist en cours.*\n\n`//music list`\n:arrow_right:\t*Affiche la playlist en cours.*\n\n`//music add(Next) <url>`\n:arrow_right:\t*Ajoute l'url à la playlist en cour.*";
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -165,6 +167,11 @@ public class Music implements Commande {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
public AudioM getAudioManager(){ public AudioM getAudioManager(){
return audio; return audio;
} }

View File

@ -21,4 +21,9 @@ public class Ass extends NumberedCommande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -20,4 +20,9 @@ public class Boobs extends NumberedCommande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -31,8 +31,16 @@ public class Madame implements Commande{
while(!success && !error) while(!success && !error)
{ {
try { try {
String url = redirect.get("http://dites.bonjourmadame.fr/random");
if((url.contains("club") && (url.contains("rejoindre") || url.contains("rejoignez"))) || (url.contains("samedi") && url.contains("dimanche"))){
logger.debug("Advertisement detected! Retry! ("+url+")");
}
else{
event.getTextChannel().sendMessage(redirect.get("http://dites.bonjourmadame.fr/random")).queue(); event.getTextChannel().sendMessage(redirect.get("http://dites.bonjourmadame.fr/random")).queue();
success=true; success=true;
}
} catch (IOException e) { } catch (IOException e) {
errorCp++; errorCp++;
logger.warn("Erreur de redirection. (Essais n°"+errorCp+")"); logger.warn("Erreur de redirection. (Essais n°"+errorCp+")");
@ -56,11 +64,6 @@ public class Madame implements Commande{
} }
} }
@Override
public String help(String[] args) {
return HELP;
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -70,4 +73,9 @@ public class Madame implements Commande{
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -54,4 +54,9 @@ public class Pipe extends NumberedCommande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -40,11 +40,6 @@ public class SM implements Commande {
} }
@Override
public String help(String[] args) {
return HELP;
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {
@ -54,4 +49,9 @@ public class SM implements Commande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -16,9 +16,6 @@ import java.util.List;
* Created by seb65 on 19/10/2016. * Created by seb65 on 19/10/2016.
*/ */
public class Ping implements Commande { public class Ping implements Commande {
private String HELP = "`//ping` \n :arrow_right:\t*Renvoi le ping du bot*";
@Override @Override
public boolean called(String[] args, MessageReceivedEvent event) { public boolean called(String[] args, MessageReceivedEvent event) {
return true; return true;
@ -41,12 +38,6 @@ public class Ping implements Commande {
LogManager.getLogger().debug("pong"); LogManager.getLogger().debug("pong");
} }
@Override
public String help(String[] args) {
return HELP;
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) public void executed(boolean success, MessageReceivedEvent event)
{ {
@ -58,4 +49,9 @@ public class Ping implements Commande {
public boolean isPrivateUsable() { public boolean isPrivateUsable() {
return true; return true;
} }
@Override
public boolean isAdminCmd() {
return false;
}
} }

View File

@ -76,14 +76,6 @@ public class Spam implements Commande {
} }
@Override
public String help(String[] args)
{
return "`//spam extermine <@utilisateur> <multiplicateur>`\n:arrow_right:\t*Punir un spammeur.*\n\n`//spam pardon <@utilisateur>`\n:arrow_right:\t*Annuler la punition d'un utilisateur.*\n\n`//spam reset <@utilisateur>`\n:arrow_right:\t*RAZ du multiplicateur d'un utilisateur.*";
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) public void executed(boolean success, MessageReceivedEvent event)
{ {
@ -95,6 +87,11 @@ public class Spam implements Commande {
return false; return false;
} }
@Override
public boolean isAdminCmd() {
return true;
}
public void pardon(MessageReceivedEvent event, String[] args){ public void pardon(MessageReceivedEvent event, String[] args){
Guild serveur = event.getGuild(); Guild serveur = event.getGuild();
@ -125,13 +122,6 @@ public class Spam implements Commande {
else { else {
Member user = serveur.getMember(userL.get(0)); Member user = serveur.getMember(userL.get(0));
logger.info("Tentative de pardon de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName()); logger.info("Tentative de pardon de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/****************************
* c'est un big dady *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
logger.info("Autorisation suffisante, pardon autorisé");
/**************************** /****************************
* virif si en spammer * * virif si en spammer *
****************************/ ****************************/
@ -158,16 +148,6 @@ public class Spam implements Commande {
}}; }};
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} else {
logger.warn("Autorisation insuffisante, pardon refusé");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
} }
} }
else else
@ -210,13 +190,8 @@ public class Spam implements Commande {
Guild serveur = event.getGuild(); Guild serveur = event.getGuild();
Member user = serveur.getMember(userL.get(0)); Member user = serveur.getMember(userL.get(0));
logger.info("Tentative d'extermination de "+user.getEffectiveName()+" par l'utilisateur "+event.getAuthor().getName()); logger.info("Tentative d'extermination de "+user.getEffectiveName()+" par l'utilisateur "+event.getAuthor().getName());
/****************************
* c'est un big dady *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
{
logger.info("Autorisation suffisante, extermination autorisé");
String multiStr =args[2]; String multiStr =args[2];
@ -233,6 +208,11 @@ public class Spam implements Commande {
{ {
logger.warn("Utilisateur deja en spam."); logger.warn("Utilisateur deja en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).complete(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
@ -243,18 +223,6 @@ public class Spam implements Commande {
} }
} }
else
{
logger.warn("Autorisation insuffisante, extermination refusé");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
}
} }
@ -300,12 +268,8 @@ public class Spam implements Commande {
else { else {
Member user = serveur.getMember(userL.get(0)); Member user = serveur.getMember(userL.get(0));
logger.info("Tentative de reset de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName()); logger.info("Tentative de reset de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/****************************
* c'est un big dady *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
logger.info("Autorisation suffisante, pardon autorisé");
/**************************** /****************************
* verif utilisteur trouver * * verif utilisteur trouver *
****************************/ ****************************/
@ -320,18 +284,9 @@ public class Spam implements Commande {
MainBot.spamUtils.remove(user.getUser()); MainBot.spamUtils.remove(user.getUser());
} }
} else {
logger.warn("Autorisation insuffisante, reset refusé");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
}
else else
{ {
logger.warn("Argument manquant."); logger.warn("Argument manquant.");

View File

@ -27,7 +27,6 @@ public class SpamInfo implements Commande{
private HashMap<User,MessageUpdater> threadHashMap = new HashMap<>(); private HashMap<User,MessageUpdater> threadHashMap = new HashMap<>();
Logger logger = LogManager.getLogger(); Logger logger = LogManager.getLogger();
private String HELP="`//spaminfo <@utilisateur> `\n:arrow_right:\t*Affiche les infos relatives aux punitions contre le spam de l'utilisateur mentionnée (de l'auteur si pas de mention)*";
@Override @Override
public boolean called(String[] args, MessageReceivedEvent event) { public boolean called(String[] args, MessageReceivedEvent event) {
return false; return false;
@ -93,11 +92,6 @@ public class SpamInfo implements Commande{
}
@Override
public String help(String[] args) {
return HELP;
} }
@Override @Override
@ -110,6 +104,11 @@ public class SpamInfo implements Commande{
return true; return true;
} }
@Override
public boolean isAdminCmd() {
return false;
}
public String formatSecond(int second){ public String formatSecond(int second){
long days = TimeUnit.SECONDS.toDays(second); long days = TimeUnit.SECONDS.toDays(second);
second -= TimeUnit.DAYS.toSeconds(days); second -= TimeUnit.DAYS.toSeconds(days);

View File

@ -3,9 +3,12 @@ package net.Broken;
import net.Broken.RestApi.ApiCommandLoader; import net.Broken.RestApi.ApiCommandLoader;
import net.Broken.Tools.Command.CommandParser; import net.Broken.Tools.Command.CommandParser;
import net.Broken.Tools.EmbedMessageUtils; import net.Broken.Tools.EmbedMessageUtils;
import net.Broken.Tools.MessageTimeOut;
import net.Broken.Tools.PrivateMessage;
import net.Broken.Tools.UserManager.UserRegister; import net.Broken.Tools.UserManager.UserRegister;
import net.Broken.Tools.UserSpamUtils; import net.Broken.Tools.UserSpamUtils;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.core.entities.User;
@ -20,6 +23,7 @@ import org.springframework.stereotype.Controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
/** /**
* Created by seb65 on 19/10/2016. * Created by seb65 on 19/10/2016.
@ -95,6 +99,8 @@ public class MainBot {
if (commandes.containsKey(cmd.commande)) if (commandes.containsKey(cmd.commande))
{ {
Commande cmdObj = commandes.get(cmd.commande);
if(!cmdObj.isAdminCmd() || cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR)){
if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable()) if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable())
{ {
@ -108,6 +114,22 @@ public class MainBot {
} }
else else
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue(); cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
}
else{
if(cmd.event.isFromType(ChannelType.PRIVATE)){
PrivateMessage.send(cmd.event.getAuthor(),EmbedMessageUtils.getUnautorized(), logger);
}
else{
Message msg = cmd.event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete();
List<Message> messages = new ArrayList<Message>(){{
add(msg);
add(cmd.event.getMessage());
}};
new MessageTimeOut(messages, messageTimeOut).start();
}
}
} }

View File

@ -0,0 +1,21 @@
package net.Broken.RestApi.Commands;
import net.Broken.Commands.Music;
import net.Broken.MainBot;
import net.Broken.RestApi.CommandInterface;
import net.Broken.RestApi.Data.CommandPostData;
import net.Broken.RestApi.Data.CommandResponseData;
import net.Broken.audio.WebLoadUtils;
import net.dv8tion.jda.core.entities.User;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public class Disconnect implements CommandInterface{
@Override
public ResponseEntity<CommandResponseData> action(Music musicCommande, CommandPostData data, User user) {
Music music = (Music) MainBot.commandes.get("music");
music.audio.stop();
return new ResponseEntity<>(new CommandResponseData(data.command,"Ok"), HttpStatus.OK);
}
}

View File

@ -128,11 +128,6 @@ public abstract class NumberedCommande implements Commande{
} }
@Override
public String help(String[] args) {
return"`//"+this.toString().toLowerCase() +" update`\n:arrow_right: *Rafraichi la liste des images.*\n`//"+this.toString().toLowerCase()+" get <numero>`\n:arrow_right: *Affiche l'image portant le numero donné*";
}
@Override @Override
public void executed(boolean success, MessageReceivedEvent event) { public void executed(boolean success, MessageReceivedEvent event) {

View File

@ -2,20 +2,23 @@ package net.Broken.Tools.DayListener;
import net.Broken.Commands.Spam; import net.Broken.Commands.Spam;
import net.dv8tion.jda.core.exceptions.RateLimitedException; import net.dv8tion.jda.core.exceptions.RateLimitedException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
/** /**
* Created by seb65 on 09/11/2016. * Created by seb65 on 09/11/2016.
*/ */
public class DayListener extends Thread { public class DayListener extends Thread {
private GregorianCalendar calendar; private Calendar calendar;
private int previousDay; private int previousDay;
private ArrayList<NewDayListener> listeners = new ArrayList<>(); private ArrayList<NewDayListener> listeners = new ArrayList<>();
private Logger logger = LogManager.getLogger();
private DayListener() { private DayListener() {
calendar = new GregorianCalendar(); calendar = Calendar.getInstance();
previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH); previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH);
} }
@ -40,7 +43,8 @@ public class DayListener extends Thread {
@Override @Override
public void run() { public void run() {
while(true) while(true)
{ { calendar = Calendar.getInstance();
logger.debug(calendar.get(GregorianCalendar.DAY_OF_MONTH)+"/"+previousDay);
if(calendar.get(GregorianCalendar.DAY_OF_MONTH) != previousDay) if(calendar.get(GregorianCalendar.DAY_OF_MONTH) != previousDay)
{ {
LogManager.getLogger().info("New day triggered!"); LogManager.getLogger().info("New day triggered!");
@ -48,7 +52,7 @@ public class DayListener extends Thread {
previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH); previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH);
} }
try { try {
sleep(1800000); sleep(600000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
LogManager.getLogger().catching(e); LogManager.getLogger().catching(e);
} }

View File

@ -6,29 +6,35 @@ import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.MessageEmbed; import net.dv8tion.jda.core.entities.MessageEmbed;
import java.awt.*; import java.awt.*;
import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class EmbedMessageUtils { public class EmbedMessageUtils {
public static MessageEmbed getUnknowCommand() { public static MessageEmbed getUnknowCommand() {
return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).build(); return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getError(String message) { public static MessageEmbed getError(String message) {
return new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message).build(); EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
return buildStandar(temp);
} }
public static MessageEmbed getNoPrivate(){ public static MessageEmbed getNoPrivate(){
return new EmbedBuilder().setTitle(":warning: Commande non disponible en privé! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.red).build(); EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Commande non disponible en privé! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.red);
return buildStandar(temp);
} }
public static MessageEmbed getMusicError(String message){ public static MessageEmbed getMusicError(String message){
return new EmbedBuilder().setTitle(":warning: Musique Error :warning:").setDescription(":arrow_right: "+message).setFooter("'//help music' pour plus d'info",null).setColor(Color.red).build(); return new EmbedBuilder().setTitle(":warning: Musique Error :warning:").setDescription(":arrow_right: "+message).setFooter("'//help music' pour plus d'info",null).setColor(Color.red).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getMusicOk(String message) { public static MessageEmbed getMusicOk(String message) {
return new EmbedBuilder().setTitle(":loud_sound: Music :loud_sound:").setDescription(message).setColor(Color.green).setFooter("'//help music' pour plus d'info ", null).build(); EmbedBuilder temp = new EmbedBuilder().setTitle(":loud_sound: Music :loud_sound:").setDescription(message).setColor(Color.green);
return buildStandar(temp);
} }
public static MessageEmbed getSpamExtermine(Member autor, int multi) { public static MessageEmbed getSpamExtermine(Member autor, int multi) {
@ -39,20 +45,25 @@ public class EmbedMessageUtils {
return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " est de retour, fais gaffe!\nJe te surveille!").setImage("https://media.giphy.com/media/3o7TKwBctlv08kY08M/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build(); return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " est de retour, fais gaffe!\nJe te surveille!").setImage("https://media.giphy.com/media/3o7TKwBctlv08kY08M/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build();
} }
public static MessageEmbed getHelp(String name, String helpMessage) {
return new EmbedBuilder().setTitle(":question: " + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase() + " :question: ").setDescription("\n" + helpMessage).setColor(Color.green).build(); public static MessageEmbed getHelp(String command) throws FileNotFoundException {
String name = command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase();
String message = new ResourceLoader().getFile("Help/"+name+"/fr/main.md");
EmbedBuilder temp = new EmbedBuilder().setTitle(":question: " + command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase() + " :question: ").setDescription(message).setColor(Color.green);
return buildStandar(temp);
} }
public static MessageEmbed getMoveError(String message) { public static MessageEmbed getMoveError(String message) {
return new EmbedBuilder().setTitle(":warning: Move Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help move' pour plus d'info ", null).build(); return new EmbedBuilder().setTitle(":warning: Move Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help move' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getMoveOk(String message) { public static MessageEmbed getMoveOk(String message) {
return new EmbedBuilder().setTitle(":arrow_left: Move :arrow_right: ").setDescription(message).setColor(Color.green).setFooter("'//help move' pour plus d'info ", null).build(); EmbedBuilder temp = new EmbedBuilder().setTitle(":arrow_left: Move :arrow_right: ").setDescription(message).setColor(Color.green);
return buildStandar(temp);
} }
public static MessageEmbed getSpamError(String message) { public static MessageEmbed getSpamError(String message) {
return new EmbedBuilder().setTitle(":warning: Spam Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help spam' pour plus d'info ", null).build(); return new EmbedBuilder().setTitle(":warning: Spam Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help spam' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getSpamError(String message, String sub) { public static MessageEmbed getSpamError(String message, String sub) {
@ -60,11 +71,12 @@ public class EmbedMessageUtils {
} }
public static MessageEmbed getSpamInfo(String message) { public static MessageEmbed getSpamInfo(String message) {
return new EmbedBuilder().setTitle(":hourglass: Spam Info :hourglass:").setDescription(message).setColor(Color.green).setFooter("'//help spaminfo' pour plus d'info ", null).build(); EmbedBuilder temp = new EmbedBuilder().setTitle(":hourglass: Spam Info :hourglass:").setDescription(message).setColor(Color.green);
return buildStandar(temp);
} }
public static MessageEmbed getFlushError(String message) { public static MessageEmbed getFlushError(String message) {
return new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help flush' pour plus d'info ", null).build(); return new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help flush' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
@ -72,6 +84,19 @@ public class EmbedMessageUtils {
return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build(); return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getInternalError(){
return getError("Je... Je... je ne me sent pas bien... :thermometer_face: \nContactez vite mon developeur!");
}
public static MessageEmbed buildStandar(EmbedBuilder embedBuilder){
String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM"));
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
return embedBuilder.setFooter("bot.seb6596.ovh | "+date+" at "+time, MainBot.jda.getSelfUser().getAvatarUrl()).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build();
}
public static MessageEmbed getUnautorized(){
return getError("Vous n'avez pas l'autorisation de faire ça!");
}
} }

View File

@ -26,10 +26,10 @@ public class MessageTimeOut extends Thread{
e.printStackTrace(); e.printStackTrace();
} }
} }
logger.debug("Timiout! Deleting message!");
for(Message aMessage: messages) for(Message aMessage: messages)
{ {
try { try {
logger.debug(aMessage.getContent());
aMessage.delete().queue(); aMessage.delete().queue();
}catch (ErrorResponseException e){ }catch (ErrorResponseException e){
logger.warn("Unknown Message"); logger.warn("Unknown Message");

View File

@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Scanner; import java.util.Scanner;
@ -14,13 +15,15 @@ public class ResourceLoader {
private Logger logger = LogManager.getLogger(); private Logger logger = LogManager.getLogger();
public String getFile(String fileName) { public String getFile(String fileName) throws FileNotFoundException {
StringBuilder result = new StringBuilder(""); StringBuilder result = new StringBuilder("");
//Get file from resources folder //Get file from resources folder
ClassLoader classLoader = getClass().getClassLoader(); ClassLoader classLoader = getClass().getClassLoader();
InputStream file = classLoader.getResourceAsStream(fileName); InputStream file = classLoader.getResourceAsStream(fileName);
if(file == null)
throw new FileNotFoundException();
try (Scanner scanner = new Scanner(file, "UTF-8")) { try (Scanner scanner = new Scanner(file, "UTF-8")) {

View File

@ -18,6 +18,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceS
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import java.io.FileNotFoundException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -86,7 +87,12 @@ public class UserRegister {
pendingUserEntity = pendingUserRepository.save(pendingUserEntity); pendingUserEntity = pendingUserRepository.save(pendingUserEntity);
} }
String message = new ResourceLoader().getFile("MessagesTemplates/RegisterMessage.md"); String message = null;
try {
message = new ResourceLoader().getFile("MessagesTemplates/RegisterMessage.md");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
message = message.replace("%code",token); message = message.replace("%code",token);

View File

@ -258,12 +258,13 @@ public class AudioM {
} }
} }
public void stop (GuildVoiceLeaveEvent event) { public void stop () {
GuildMusicManager musicManager = getGuildAudioPlayer(event.getGuild()); GuildMusicManager musicManager = getGuildAudioPlayer(guild);
musicManager.scheduler.stop(); musicManager.scheduler.stop();
musicManager.scheduler.flush();
playedChanel = null; playedChanel = null;
event.getGuild().getAudioManager().closeAudioConnection(); guild.getAudioManager().closeAudioConnection();
} }
public GuildMusicManager getMusicManager() throws NullMusicManager, NotConectedException { public GuildMusicManager getMusicManager() throws NullMusicManager, NotConectedException {

View File

@ -0,0 +1,4 @@
Ho! Regarde! Un chat!
Mais il est different à chaque fois en plus!
C'est trop cute! :cat:

View File

@ -0,0 +1,2 @@
L'aide pour cette commande n'est pas encore disponible !
Pour contribué: https://github.com/BrokenFire/BrokenDiscordBot

View File

@ -0,0 +1,3 @@
`//flush <nbr>`
:arrow_right: *Efface les n derniers messages (Max = 100)*

View File

@ -0,0 +1,2 @@
`//move <@utilisateur> <@rôleCible>`
:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire des montions.*

View File

@ -0,0 +1,26 @@
`//music play <url>`
:arrow_right: *Let's dance! Deffinit le chat vocal à utiliser.*
`//music pause`
:arrow_right: *Mise en pause de la piste en cours.*
`//music resume`
:arrow_right: *Reprise de la lecture de la piste en cours.*
`//music next`
:arrow_right: *Change le piste en cours.*
`//music stop`
:arrow_right: *Arrête la piste en cours.*
`//music info`
:arrow_right: *Affiche les infos de la piste en cours.*
`//music flush`
:arrow_right: *Supprime la playlist en cours.*
`//music list`
:arrow_right: *Affiche la playlist en cours.*
`//music add(Next) <url>`
:arrow_right: *Ajoute l'url à la playlist en cour.*

View File

@ -0,0 +1,2 @@
`//ping`
:arrow_right: *Renvoi le ping du bot*

View File

@ -0,0 +1,8 @@
`//spam extermine <@utilisateur> <multiplicateur>`
:arrow_right: *Punir un spammeur.*
`//spam pardon <@utilisateur>`
:arrow_right: *Annuler la punition d'un utilisateur.*
`//spam reset <@utilisateur>`
:arrow_right: *RAZ du multiplicateur d'un utilisateur.*

View File

@ -0,0 +1,2 @@
`//spaminfo <@utilisateur> `
:arrow_right: *Affiche les infos relatives aux punitions contre le spam de l'utilisateur mentionnée (de l'auteur si pas de mention)*

View File

@ -123,8 +123,12 @@ $(document).ready(function() {
sendCommand(command); sendCommand(command);
}); });
$('#btn_disconnect').click(function () {
sendCommand({command : "DISCONNECT"})
}) })
});
@ -167,6 +171,9 @@ function getCurentMusic() {
if ($('#btn_next').hasClass("disabled")) { if ($('#btn_next').hasClass("disabled")) {
$('#btn_next').removeClass("disabled"); $('#btn_next').removeClass("disabled");
} }
if ($('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').removeClass("disabled");
}
} }
else{ else{
if (!$('#btn_stop').hasClass("disabled")) { if (!$('#btn_stop').hasClass("disabled")) {
@ -188,6 +195,10 @@ function getCurentMusic() {
if (!$('#btn_next').hasClass("disabled")) { if (!$('#btn_next').hasClass("disabled")) {
$('#btn_next').addClass("disabled"); $('#btn_next').addClass("disabled");
} }
if (!$('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').addClass("disabled");
}
} }
$('#btn_play').children().text("play_arrow"); $('#btn_play').children().text("play_arrow");
@ -215,8 +226,6 @@ function getCurentMusic() {
$('#btn_play').removeClass("amber"); $('#btn_play').removeClass("amber");
$('#btn_play').addClass("green"); $('#btn_play').addClass("green");
updateControl(data); updateControl(data);
break; break;
case "LOADING": case "LOADING":
@ -255,6 +264,9 @@ function getCurentMusic() {
if (!$('#flush_btn').hasClass("disabled")) { if (!$('#flush_btn').hasClass("disabled")) {
$('#flush_btn').addClass("disabled"); $('#flush_btn').addClass("disabled");
} }
if (!$('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').addClass("disabled");
}
$('#music_img').attr("src","/img/disconnected.png"); $('#music_img').attr("src","/img/disconnected.png");
@ -394,6 +406,9 @@ function updateControl(data){
if ($('#btn_next').hasClass("disabled")) { if ($('#btn_next').hasClass("disabled")) {
$('#btn_next').removeClass("disabled"); $('#btn_next').removeClass("disabled");
} }
if ($('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').removeClass("disabled");
}
} }
else else
{ {
@ -416,6 +431,9 @@ function updateControl(data){
if (!$('#btn_next').hasClass("disabled")) { if (!$('#btn_next').hasClass("disabled")) {
$('#btn_next').addClass("disabled"); $('#btn_next').addClass("disabled");
} }
if (!$('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').addClass("disabled");
}
} }

View File

@ -156,7 +156,17 @@
<i class="material-icons">info</i> <i class="material-icons">info</i>
</a> </a>
</div> </div>
</div> </div>
<div class="row center">
<div class="col offset-s5 s2 center">
<a class="btn-large red accent-4 z-depth-3 waves-effect waves-light" id="btn_disconnect">
<i class="material-icons">call_end</i>
</a>
</div>
</div>
</div> </div>
<div class="col s4" > <div class="col s4" >
<table> <table>