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){
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;
}
}
@ -76,7 +76,7 @@ public class BotListener extends ListenerAdapter {
logger.debug("I'm alone, close audio connection.");
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 {
boolean called(String[] args, MessageReceivedEvent event);
void action(String[] args, MessageReceivedEvent event);
String help(String[] args);
void executed(boolean success, MessageReceivedEvent event);
boolean isPrivateUsable();
boolean isAdminCmd();
}

View File

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

View File

@ -26,33 +26,8 @@ public class DayTrigger implements Commande{
@Override
public void action(String[] args, MessageReceivedEvent event) {
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
DayListener.getInstance().trigger();
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
@ -64,4 +39,9 @@ public class DayTrigger implements Commande{
public boolean isPrivateUsable() {
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
public void executed(boolean success, MessageReceivedEvent event) {
@ -68,4 +63,9 @@ public class Flush implements Commande{
public boolean isPrivateUsable() {
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.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.awt.*;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -36,26 +38,39 @@ public class Help implements Commande {
if (MainBot.commandes.containsKey(argsString))
{
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)) {
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)
{
Message finalRest = rest;
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(finalRest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
else if(!args[1].toLowerCase().equals("true")){
Message finalRest1 = rest;
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(finalRest1);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
} 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
public void executed(boolean success, MessageReceivedEvent event) {
@ -116,4 +126,9 @@ public class Help implements Commande {
public boolean isPrivateUsable() {
return true;
}
@Override
public boolean isAdminCmd() {
return false;
}
}

View File

@ -113,70 +113,57 @@ public class Move implements Commande {
user = serveur.getMember(userL.get(0));
serveur=event.getGuild();
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.debug("Utilisateur trouvée");
try {
boolean erreur=this.exc(user,roleL,true,serveur,serveur.getManager());
if(erreur)
{
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Verifier le rôle cible. ")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
else
{
StringBuilder roleStr = new StringBuilder("");
boolean first = true;
for( Role role : roleL)
{
if (!first) {
roleStr.append(", ");
}
else
first = false;
roleStr.append("__");
roleStr.append(role.getName());
roleStr.append("__");
}
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveOk("Déplacement de "+user.getEffectiveName()+" vers "+roleStr.toString()+" reussi.")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
}catch (HierarchyException e){
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
logger.info("Autorisation suffisante, deplacement autorisé");
logger.debug("Utilisateur trouvée");
try {
boolean erreur=this.exc(user,roleL,true,serveur,serveur.getManager());
if(erreur)
{
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Verifier le rôle cible. ")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
logger.error("Hierarchy error, please move bot's role on top!");
}
else
{
StringBuilder roleStr = new StringBuilder("");
boolean first = true;
for( Role role : roleL)
{
if (!first) {
roleStr.append(", ");
}
else
first = false;
roleStr.append("__");
roleStr.append(role.getName());
roleStr.append("__");
}
}
else
{
logger.warn("Autorisation insuffisante, deplacement refusé");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Vous n'avez pas l'autorisation de faicre ça!")).complete();
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveOk("Déplacement de "+user.getEffectiveName()+" vers "+roleStr.toString()+" reussi.")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
}catch (HierarchyException e){
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
logger.error("Hierarchy error, please move bot's role on top!");
}
}
}
@ -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() {
return false;
}
@Override
public boolean isAdminCmd() {
return true;
}
}

View File

@ -128,13 +128,21 @@ public class Music implements Commande {
}
break;
case "disconnect":
audio.stop();
List<Message> messages = new ArrayList<Message>(){{
add(event.getMessage());
}};
new MessageTimeOut(messages, 0).start();
break;
default:
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(event.getMessage());
}};
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
new MessageTimeOut(messagess, MainBot.messageTimeOut).start();
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
public void executed(boolean success, MessageReceivedEvent event) {
@ -165,6 +167,11 @@ public class Music implements Commande {
return false;
}
@Override
public boolean isAdminCmd() {
return false;
}
public AudioM getAudioManager(){
return audio;
}

View File

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

View File

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

View File

@ -31,8 +31,16 @@ public class Madame implements Commande{
while(!success && !error)
{
try {
event.getTextChannel().sendMessage(redirect.get("http://dites.bonjourmadame.fr/random")).queue();
success=true;
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();
success=true;
}
} catch (IOException e) {
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
public void executed(boolean success, MessageReceivedEvent event) {
@ -70,4 +73,9 @@ public class Madame implements Commande{
public boolean isPrivateUsable() {
return false;
}
@Override
public boolean isAdminCmd() {
return false;
}
}

View File

@ -54,4 +54,9 @@ public class Pipe extends NumberedCommande {
public boolean isPrivateUsable() {
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
public void executed(boolean success, MessageReceivedEvent event) {
@ -54,4 +49,9 @@ public class SM implements Commande {
public boolean isPrivateUsable() {
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.
*/
public class Ping implements Commande {
private String HELP = "`//ping` \n :arrow_right:\t*Renvoi le ping du bot*";
@Override
public boolean called(String[] args, MessageReceivedEvent event) {
return true;
@ -41,12 +38,6 @@ public class Ping implements Commande {
LogManager.getLogger().debug("pong");
}
@Override
public String help(String[] args) {
return HELP;
}
@Override
public void executed(boolean success, MessageReceivedEvent event)
{
@ -58,4 +49,9 @@ public class Ping implements Commande {
public boolean isPrivateUsable() {
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
public void executed(boolean success, MessageReceivedEvent event)
{
@ -95,6 +87,11 @@ public class Spam implements Commande {
return false;
}
@Override
public boolean isAdminCmd() {
return true;
}
public void pardon(MessageReceivedEvent event, String[] args){
Guild serveur = event.getGuild();
@ -125,30 +122,12 @@ public class Spam implements Commande {
else {
Member user = serveur.getMember(userL.get(0));
logger.info("Tentative de pardon de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/****************************
* c'est un big dady *
/****************************
* virif si en spammer *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
logger.info("Autorisation suffisante, pardon autorisé");
/****************************
* virif si en spammer *
****************************/
if (MainBot.spamUtils.containsKey(user.getUser())) {
if (MainBot.spamUtils.get(user.getUser()).isOnSpam()) {
MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
} else {
logger.warn("Utilisateur pas en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
if (MainBot.spamUtils.containsKey(user.getUser())) {
if (MainBot.spamUtils.get(user.getUser()).isOnSpam()) {
MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
} else {
logger.warn("Utilisateur pas en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
@ -159,9 +138,10 @@ public class Spam implements Commande {
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();
logger.warn("Utilisateur pas en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
@ -210,48 +190,36 @@ public class Spam implements Commande {
Guild serveur = event.getGuild();
Member user = serveur.getMember(userL.get(0));
logger.info("Tentative d'extermination de "+user.getEffectiveName()+" par l'utilisateur "+event.getAuthor().getName());
String multiStr =args[2];
/****************************
* c'est un big dady *
* virif pas deja en spammer *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
if(MainBot.spamUtils.containsKey(user.getUser()))
{
logger.info("Autorisation suffisante, extermination autorisé");
String multiStr =args[2];
/****************************
* virif pas deja en spammer *
****************************/
if(MainBot.spamUtils.containsKey(user.getUser()))
{
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
{
this.goSpam(user,multiStr,serveur,event);
}
else
{
logger.warn("Utilisateur deja en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).complete();
}
}
else
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
{
this.goSpam(user,multiStr,serveur,event);
}
else
{
logger.warn("Utilisateur deja en spam.");
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();
}
}
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();
this.goSpam(user,multiStr,serveur,event);
}
}
@ -300,36 +268,23 @@ public class Spam implements Commande {
else {
Member user = serveur.getMember(userL.get(0));
logger.info("Tentative de reset de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/****************************
* c'est un big dady *
* verif utilisteur trouver *
****************************/
if(event.getMember().hasPermission(Permission.ADMINISTRATOR)){
logger.info("Autorisation suffisante, pardon autorisé");
/****************************
* verif utilisteur trouver *
****************************/
if (MainBot.spamUtils.containsKey(user.getUser())) {
logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi");
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n *Le multiplcicateur de " + user.getEffectiveName() + " a été remit a zéro.*").complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
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();
if (MainBot.spamUtils.containsKey(user.getUser())) {
logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi");
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n *Le multiplcicateur de " + user.getEffectiveName() + " a été remit a zéro.*").complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
MainBot.spamUtils.remove(user.getUser());
}
}
}
else

View File

@ -27,7 +27,6 @@ public class SpamInfo implements Commande{
private HashMap<User,MessageUpdater> threadHashMap = new HashMap<>();
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
public boolean called(String[] args, MessageReceivedEvent event) {
return false;
@ -93,11 +92,6 @@ public class SpamInfo implements Commande{
}
@Override
public String help(String[] args) {
return HELP;
}
@Override
@ -110,6 +104,11 @@ public class SpamInfo implements Commande{
return true;
}
@Override
public boolean isAdminCmd() {
return false;
}
public String formatSecond(int second){
long days = TimeUnit.SECONDS.toDays(second);
second -= TimeUnit.DAYS.toSeconds(days);

View File

@ -3,9 +3,12 @@ package net.Broken;
import net.Broken.RestApi.ApiCommandLoader;
import net.Broken.Tools.Command.CommandParser;
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.UserSpamUtils;
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.Message;
import net.dv8tion.jda.core.entities.User;
@ -20,6 +23,7 @@ import org.springframework.stereotype.Controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by seb65 on 19/10/2016.
@ -95,19 +99,37 @@ public class MainBot {
if (commandes.containsKey(cmd.commande))
{
if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable())
{
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())
{
commandes.get(cmd.commande).action(cmd.args, cmd.event);
commandes.get(cmd.commande).executed(true, cmd.event);
commandes.get(cmd.commande).action(cmd.args, cmd.event);
commandes.get(cmd.commande).executed(true, cmd.event);
}
else if (!cmd.event.isFromType(ChannelType.PRIVATE))
{
commandes.get(cmd.commande).action(cmd.args, cmd.event);
commandes.get(cmd.commande).executed(true, cmd.event);
}
else
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
}
else if (!cmd.event.isFromType(ChannelType.PRIVATE))
{
commandes.get(cmd.commande).action(cmd.args, cmd.event);
commandes.get(cmd.commande).executed(true, cmd.event);
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();
}
}
else
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
}

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
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.dv8tion.jda.core.exceptions.RateLimitedException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* Created by seb65 on 09/11/2016.
*/
public class DayListener extends Thread {
private GregorianCalendar calendar;
private Calendar calendar;
private int previousDay;
private ArrayList<NewDayListener> listeners = new ArrayList<>();
private Logger logger = LogManager.getLogger();
private DayListener() {
calendar = new GregorianCalendar();
calendar = Calendar.getInstance();
previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH);
}
@ -40,7 +43,8 @@ public class DayListener extends Thread {
@Override
public void run() {
while(true)
{
{ calendar = Calendar.getInstance();
logger.debug(calendar.get(GregorianCalendar.DAY_OF_MONTH)+"/"+previousDay);
if(calendar.get(GregorianCalendar.DAY_OF_MONTH) != previousDay)
{
LogManager.getLogger().info("New day triggered!");
@ -48,7 +52,7 @@ public class DayListener extends Thread {
previousDay = calendar.get(GregorianCalendar.DAY_OF_MONTH);
}
try {
sleep(1800000);
sleep(600000);
} catch (InterruptedException 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 java.awt.*;
import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class EmbedMessageUtils {
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) {
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(){
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){
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) {
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) {
@ -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();
}
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) {
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) {
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) {
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) {
@ -60,11 +71,12 @@ public class EmbedMessageUtils {
}
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) {
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();
}
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();
}
}
logger.debug("Timiout! Deleting message!");
for(Message aMessage: messages)
{
try {
logger.debug(aMessage.getContent());
aMessage.delete().queue();
}catch (ErrorResponseException e){
logger.warn("Unknown Message");

View File

@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
@ -14,13 +15,15 @@ public class ResourceLoader {
private Logger logger = LogManager.getLogger();
public String getFile(String fileName) {
public String getFile(String fileName) throws FileNotFoundException {
StringBuilder result = new StringBuilder("");
//Get file from resources folder
ClassLoader classLoader = getClass().getClassLoader();
InputStream file = classLoader.getResourceAsStream(fileName);
if(file == null)
throw new FileNotFoundException();
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.security.crypto.password.PasswordEncoder;
import java.io.FileNotFoundException;
import java.security.SecureRandom;
import java.util.List;
import java.util.UUID;
@ -86,7 +87,12 @@ public class UserRegister {
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);

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.flush();
playedChanel = null;
event.getGuild().getAudioManager().closeAudioConnection();
guild.getAudioManager().closeAudioConnection();
}
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,7 +123,11 @@ $(document).ready(function() {
sendCommand(command);
});
})
$('#btn_disconnect').click(function () {
sendCommand({command : "DISCONNECT"})
})
});
@ -167,6 +171,9 @@ function getCurentMusic() {
if ($('#btn_next').hasClass("disabled")) {
$('#btn_next').removeClass("disabled");
}
if ($('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').removeClass("disabled");
}
}
else{
if (!$('#btn_stop').hasClass("disabled")) {
@ -188,6 +195,10 @@ function getCurentMusic() {
if (!$('#btn_next').hasClass("disabled")) {
$('#btn_next').addClass("disabled");
}
if (!$('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').addClass("disabled");
}
}
$('#btn_play').children().text("play_arrow");
@ -215,8 +226,6 @@ function getCurentMusic() {
$('#btn_play').removeClass("amber");
$('#btn_play').addClass("green");
updateControl(data);
break;
case "LOADING":
@ -255,6 +264,9 @@ function getCurentMusic() {
if (!$('#flush_btn').hasClass("disabled")) {
$('#flush_btn').addClass("disabled");
}
if (!$('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').addClass("disabled");
}
$('#music_img').attr("src","/img/disconnected.png");
@ -394,6 +406,9 @@ function updateControl(data){
if ($('#btn_next').hasClass("disabled")) {
$('#btn_next').removeClass("disabled");
}
if ($('#btn_disconnect').hasClass("disabled")) {
$('#btn_disconnect').removeClass("disabled");
}
}
else
{
@ -416,6 +431,9 @@ function updateControl(data){
if (!$('#btn_next').hasClass("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>
</a>
</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 class="col s4" >
<table>