Change all message to Embled message, adding spaminfo auto refresh
This commit is contained in:
parent
ad26b1dbdf
commit
947fb39523
@ -2,13 +2,16 @@ package net.Broken.Commandes;
|
|||||||
|
|
||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
|
import net.Broken.Outils.EmbedMessageUtils;
|
||||||
import net.Broken.Outils.PrivateMessage;
|
import net.Broken.Outils.PrivateMessage;
|
||||||
|
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.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
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 org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +34,7 @@ public class Help implements Commande {
|
|||||||
{
|
{
|
||||||
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
|
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n\n"+MainBot.commandes.get(argsString).help(args)).queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getHelp(argsString,MainBot.commandes.get(argsString).help(args))).queue();
|
||||||
else{
|
else{
|
||||||
PrivateMessage.send(event.getAuthor(), MainBot.commandes.get(argsString).help(args),logger);
|
PrivateMessage.send(event.getAuthor(), MainBot.commandes.get(argsString).help(args),logger);
|
||||||
}
|
}
|
||||||
@ -41,23 +44,23 @@ public class Help implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Commande Inconue!__** :warning:").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getUnknowCommand()).queue();
|
||||||
else{
|
else{
|
||||||
PrivateMessage.send(event.getAuthor(),":warning: **__Commande Inconue!__** :warning:",logger);
|
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getUnknowCommand(),logger);
|
||||||
}
|
}
|
||||||
logger.info("Commande Inconnue!");
|
logger.info("Commande Inconnue!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String txt="";
|
StringBuilder txt= new StringBuilder();
|
||||||
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
|
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
|
||||||
txt=txt+"\n//"+e.getKey();
|
txt.append("\n- ").append(e.getKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right:\t**__commandes envoyées par message privé__**").queue();
|
|
||||||
PrivateMessage.send(event.getAuthor(),"Commandes du bot:\n\n```"+txt+"```\n\nUtilise `//help <commande>` pour plus de détails.",logger);
|
event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Commandes envoyées par message privé").setColor(Color.green).build()).queue();
|
||||||
|
PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Commandes du bot").setDescription(txt.toString()).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.Broken.Commandes;
|
package net.Broken.Commandes;
|
||||||
|
|
||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
|
import net.Broken.Outils.EmbedMessageUtils;
|
||||||
import net.dv8tion.jda.core.entities.*;
|
import net.dv8tion.jda.core.entities.*;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.core.managers.GuildController;
|
import net.dv8tion.jda.core.managers.GuildController;
|
||||||
@ -97,7 +98,7 @@ public class Move implements Commande {
|
|||||||
if(userL.size()<1 ||roleL.size()<1)
|
if(userL.size()<1 ||roleL.size()<1)
|
||||||
{
|
{
|
||||||
logger.info("Mentionnement Incorect.");
|
logger.info("Mentionnement Incorect.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur de déplacement__** :warning:\n:arrow_right: Erreur, Utilisateur ou Role mal mentioner. `//help move` pour plus d'info ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError(":arrow_right: Utilisateur ou Role mal mentioner.")).queue();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -113,17 +114,17 @@ public class Move implements Commande {
|
|||||||
boolean erreur=this.exc(user,roleCible,true,serveur,serveur.getManager());
|
boolean erreur=this.exc(user,roleCible,true,serveur,serveur.getManager());
|
||||||
if(erreur)
|
if(erreur)
|
||||||
{
|
{
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur de déplacement.__** :warning:\n:arrow_right: Verifier le rôle cible. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError(":arrow_right: Verifier le rôle cible. ")).queue();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:ok: **Déplacement de "+user.getEffectiveName()+" vers "+roleCible.getName()+" reussi.** :ok:").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveOk("Déplacement de "+user.getEffectiveName()+" vers "+roleCible.getName()+" reussi.")).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.info("Autorisation insuffisante, deplacement refusé");
|
logger.info("Autorisation insuffisante, deplacement refusé");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Vous n'avez pas l'autorisation de faire ca!__**:warning: ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Vous n'avez pas l'autorisation de faire ca!")).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ public class Move implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Arguments maquant.");
|
logger.warn("Arguments maquant.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur de déplacement__** :warning:\n:arrow_right: Arguments manquant. `//help move` pour plus d'info ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError(":arrow_right: Arguments manquant.")).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.Broken.Commandes;
|
|||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
import net.Broken.Outils.AntiSpam;
|
import net.Broken.Outils.AntiSpam;
|
||||||
|
import net.Broken.Outils.EmbedMessageUtils;
|
||||||
import net.Broken.Outils.UserSpamUtils;
|
import net.Broken.Outils.UserSpamUtils;
|
||||||
import net.dv8tion.jda.core.entities.Guild;
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
import net.dv8tion.jda.core.entities.Member;
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
@ -76,7 +77,7 @@ public class Spam implements Commande {
|
|||||||
@Override
|
@Override
|
||||||
public String help(String[] args)
|
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*Anuller la punition d'un utilisateur.*\n\n`//spam reset <@utilisateur>`\n:arrow_right:\t*RAZ du multiplicateur d'un utilisateur.*";
|
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
|
||||||
@ -110,7 +111,7 @@ public class Spam implements Commande {
|
|||||||
if(userL.size()<1)
|
if(userL.size()<1)
|
||||||
{
|
{
|
||||||
logger.error("Utilisateur introuvable.");
|
logger.error("Utilisateur introuvable.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur introuvable. ");
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur introuvable. ","pardon")).queue();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Member user = serveur.getMember(userL.get(0));
|
Member user = serveur.getMember(userL.get(0));
|
||||||
@ -130,25 +131,25 @@ public class Spam implements Commande {
|
|||||||
MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
|
MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Utilisateur pas en spam.");
|
logger.warn("Utilisateur pas en spam.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Utilisateur pas en spam.");
|
logger.warn("Utilisateur pas en spam.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Autorisation insuffisante, pardon refusé");
|
logger.warn("Autorisation insuffisante, pardon refusé");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:no_entry_sign: **__Vous n'avez pas l'autorisation de faire sa!__** :no_entry_sign: ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Argument manquant.");
|
logger.warn("Argument manquant.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Argument manquant__**:warning: \n:arrow_right: Utilisation: `//spam pardon <@utilisateur>`.").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","pardon")).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ public class Spam implements Commande {
|
|||||||
if(userL.size()<1)
|
if(userL.size()<1)
|
||||||
{
|
{
|
||||||
logger.warn("Mentionnement Incorect (Spam).");
|
logger.warn("Mentionnement Incorect (Spam).");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur, Utilisateur mal mentioner. `//help spam extermine` pour plus d'info ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur mal mentioner. ","extermine")).queue();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ public class Spam implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Utilisateur deja en spam.");
|
logger.warn("Utilisateur deja en spam.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur déjà spammeur. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ public class Spam implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Autorisation insuffisante, extermination refusé");
|
logger.warn("Autorisation insuffisante, extermination refusé");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:no_entry_sign: **__Vous n'avez pas l'autorisation de faire ça!__** :no_entry_sign: ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -226,7 +227,7 @@ public class Spam implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Argument manquant.");
|
logger.warn("Argument manquant.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Argument manquant__**:warning: \n:arrow_right: Utilisation: `//spam extermine <utilisateur> <multiplicateur>`.").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","extermine")).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +250,7 @@ public class Spam implements Commande {
|
|||||||
if(userL.size()<1)
|
if(userL.size()<1)
|
||||||
{
|
{
|
||||||
logger.warn("Utilisateur introuvable.");
|
logger.warn("Utilisateur introuvable.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur introuvable. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur introuvable.","reset")).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -272,7 +273,7 @@ public class Spam implements Commande {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Autorisation insuffisante, reset refusé");
|
logger.warn("Autorisation insuffisante, reset refusé");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:no_entry_sign: **__Vous n'avez pas l'autorisation de faire ca!__** :no_entry_sign: ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ca!")).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,7 +281,7 @@ public class Spam implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn("Argument manquant.");
|
logger.warn("Argument manquant.");
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Argument manquant__**:warning: \n:arrow_right: Utilisation: `//spam reset <utilisateur>`.").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","reset")).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2,23 +2,30 @@ package net.Broken.Commandes;
|
|||||||
|
|
||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
|
import net.Broken.Outils.EmbedMessageUtils;
|
||||||
import net.Broken.Outils.PrivateMessage;
|
import net.Broken.Outils.PrivateMessage;
|
||||||
import net.Broken.Outils.UserSpamUtils;
|
import net.Broken.Outils.UserSpamUtils;
|
||||||
|
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.Member;
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
|
import net.dv8tion.jda.core.entities.Message;
|
||||||
import net.dv8tion.jda.core.entities.User;
|
import net.dv8tion.jda.core.entities.User;
|
||||||
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.util.HashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by sebastien on 13/03/17.
|
* Created by sebastien on 13/03/17.
|
||||||
*/
|
*/
|
||||||
public class SpamInfo implements Commande{
|
public class SpamInfo implements Commande{
|
||||||
|
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 relative aux punitions contre le spam de l'utilisateur mentionnée (de l'auteur si pas de mention)*";
|
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;
|
||||||
@ -35,28 +42,52 @@ public class SpamInfo implements Commande{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Message message = null;
|
||||||
if(!MainBot.spamUtils.containsKey(user)){
|
if(!MainBot.spamUtils.containsKey(user)){
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n\n__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `1`\n\t- En spam: `Non`").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `1`\n\t- En spam: `Non`")).queue();
|
||||||
else
|
else
|
||||||
PrivateMessage.send(event.getAuthor(),"__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `1`\n\t- En spam: `Non`",logger);
|
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `1`\n\t- En spam: `Non`"),logger);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
UserSpamUtils util = MainBot.spamUtils.get(user);
|
UserSpamUtils util = MainBot.spamUtils.get(user);
|
||||||
if(!util.isOnSpam()){
|
if(!util.isOnSpam()){
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n\n__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).queue();
|
||||||
else
|
else
|
||||||
PrivateMessage.send(event.getAuthor(),"__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`",logger);
|
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`"),logger);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(!event.isFromType(ChannelType.PRIVATE))
|
if(!event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n\n__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`").queue();
|
message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`")).complete();
|
||||||
else
|
else
|
||||||
PrivateMessage.send(event.getAuthor(),"__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`",logger);
|
message = PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`"),logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(message != null){
|
||||||
|
if(threadHashMap.containsKey(user)){
|
||||||
|
MessageUpdater startedThread = threadHashMap.get(user);
|
||||||
|
if(!message.getChannelType().equals(startedThread.message.getChannelType())){
|
||||||
|
MessageUpdater newThread = new MessageUpdater(message,MainBot.spamUtils.get(user),user);
|
||||||
|
threadHashMap.put(user,newThread);
|
||||||
|
newThread.start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
threadHashMap.get(user).stop = true;
|
||||||
|
MessageUpdater newThread = new MessageUpdater(message,MainBot.spamUtils.get(user),user);
|
||||||
|
threadHashMap.replace(user, newThread);
|
||||||
|
newThread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageUpdater newThread = new MessageUpdater(message,MainBot.spamUtils.get(user),user);
|
||||||
|
threadHashMap.put(user, newThread);
|
||||||
|
newThread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -103,4 +134,43 @@ public class SpamInfo implements Commande{
|
|||||||
return finalText;
|
return finalText;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class MessageUpdater extends Thread{
|
||||||
|
public Message message;
|
||||||
|
public UserSpamUtils util;
|
||||||
|
public boolean stop;
|
||||||
|
private int oldValue;
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public MessageUpdater(Message message, UserSpamUtils util,User user) {
|
||||||
|
this.message = message;
|
||||||
|
this.util = util;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
logger.debug("Start "+user.getName()+" theard!");
|
||||||
|
oldValue = util.getTimeLeft();
|
||||||
|
while (util.getTimeLeft()!=0 && !stop){
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
if(util.getTimeLeft()%5 == 0 && oldValue - util.getTimeLeft() >= 5){
|
||||||
|
message.editMessage(EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`")).complete();
|
||||||
|
oldValue = util.getTimeLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.debug("Kill "+user.getName()+" theard!");
|
||||||
|
if(stop)
|
||||||
|
message.editMessage(new EmbedBuilder().setColor(Color.RED).setTitle("Aborted").build()).complete();
|
||||||
|
else
|
||||||
|
message.editMessage(EmbedMessageUtils.getSpamInfo(user.getName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).complete();
|
||||||
|
threadHashMap.remove(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@ import net.Broken.Commandes.*;
|
|||||||
import net.Broken.Commandes.Over18.*;
|
import net.Broken.Commandes.Over18.*;
|
||||||
import net.Broken.Outils.CommandParser;
|
import net.Broken.Outils.CommandParser;
|
||||||
import net.Broken.Outils.DayListener;
|
import net.Broken.Outils.DayListener;
|
||||||
|
import net.Broken.Outils.EmbedMessageUtils;
|
||||||
import net.Broken.Outils.UserSpamUtils;
|
import net.Broken.Outils.UserSpamUtils;
|
||||||
import net.dv8tion.jda.core.AccountType;
|
import net.dv8tion.jda.core.*;
|
||||||
import net.dv8tion.jda.core.JDA;
|
|
||||||
import net.dv8tion.jda.core.JDABuilder;
|
|
||||||
import net.dv8tion.jda.core.OnlineStatus;
|
|
||||||
import net.dv8tion.jda.core.entities.*;
|
import net.dv8tion.jda.core.entities.*;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
||||||
@ -20,7 +18,6 @@ import javax.security.auth.login.LoginException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,18 +25,19 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class MainBot {
|
public class MainBot {
|
||||||
|
|
||||||
|
private static boolean dev = false;
|
||||||
|
private static String token = null;
|
||||||
private static JDA jda;
|
private static JDA jda;
|
||||||
public static final CommandParser parser =new CommandParser();
|
public static final CommandParser parser =new CommandParser();
|
||||||
public static HashMap<String, Commande> commandes = new HashMap<>();
|
public static HashMap<String, Commande> commandes = new HashMap<>();
|
||||||
public static boolean okInit=false;
|
public static boolean okInit=false;
|
||||||
public static HashMap<User, String[]> historique =new HashMap<>();
|
public static HashMap<User, ArrayList<Message>> historique =new HashMap<>();
|
||||||
public static HashMap<User, Integer> message_compteur =new HashMap<>();
|
public static HashMap<User, Integer> message_compteur =new HashMap<>();
|
||||||
|
|
||||||
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>();
|
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>();
|
||||||
|
|
||||||
public static ArrayList<Class<?>> privateUsableCommand = new ArrayList<>();
|
|
||||||
|
|
||||||
static Logger logger = LogManager.getLogger();
|
private static Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
logger.trace("trace");
|
logger.trace("trace");
|
||||||
@ -47,12 +45,28 @@ public class MainBot {
|
|||||||
logger.info("info");
|
logger.info("info");
|
||||||
logger.warn("warn");
|
logger.warn("warn");
|
||||||
logger.error("error");
|
logger.error("error");
|
||||||
|
int i = 0;
|
||||||
|
for(String aArg: args){
|
||||||
|
logger.debug(aArg);
|
||||||
|
if(aArg.startsWith("--") || aArg.startsWith("-")){
|
||||||
|
aArg = aArg.replaceAll("-","");
|
||||||
|
if(aArg.equals("token") || aArg.equals("t")){
|
||||||
|
token = args[i+1];
|
||||||
|
}
|
||||||
|
else if(aArg.equals("dev") || aArg.equals("d")){
|
||||||
|
dev = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* Initialisation *
|
* Initialisation *
|
||||||
****************************/
|
****************************/
|
||||||
logger.info("-------------------INITIALISATION-------------------");
|
logger.info("-------------------INITIALISATION-------------------");
|
||||||
//Bot démarrer sans token
|
//Bot démarrer sans token
|
||||||
if (args.length < 1) {
|
if (token == null) {
|
||||||
logger.fatal("Veuilliez indiquer le token du bot en argument...");
|
logger.fatal("Veuilliez indiquer le token du bot en argument...");
|
||||||
okInit=false;
|
okInit=false;
|
||||||
}
|
}
|
||||||
@ -64,7 +78,7 @@ public class MainBot {
|
|||||||
|
|
||||||
logger.info("Connection au serveur...");
|
logger.info("Connection au serveur...");
|
||||||
//connection au bot
|
//connection au bot
|
||||||
jda = new JDABuilder(AccountType.BOT).addEventListener(new BotListener()).setToken(args[0]).setBulkDeleteSplittingEnabled(false).buildBlocking();
|
jda = new JDABuilder(AccountType.BOT).addEventListener(new BotListener()).setToken(token).setBulkDeleteSplittingEnabled(false).buildBlocking();
|
||||||
jda.setAutoReconnect(true);
|
jda.setAutoReconnect(true);
|
||||||
jda.addEventListener();
|
jda.addEventListener();
|
||||||
okInit=true;
|
okInit=true;
|
||||||
@ -84,25 +98,25 @@ public class MainBot {
|
|||||||
* Definition des commande *
|
* Definition des commande *
|
||||||
*************************************/
|
*************************************/
|
||||||
jda.getPresence().setGame(Game.of("Statut: Loading..."));
|
jda.getPresence().setGame(Game.of("Statut: Loading..."));
|
||||||
jda.getTextChannels().forEach(MessageChannel::sendTyping);
|
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||||
commandes.put("ping", new PingCommande());
|
commandes.put("ping", new PingCommande());
|
||||||
commandes.put("help",new Help());
|
commandes.put("help",new Help());
|
||||||
commandes.put("move", new Move());
|
commandes.put("move", new Move());
|
||||||
commandes.put("spam", new Spam());
|
commandes.put("spam", new Spam());
|
||||||
jda.getTextChannels().forEach(MessageChannel::sendTyping);
|
|
||||||
|
if(!dev){
|
||||||
commandes.put("ass",new Ass());
|
commandes.put("ass",new Ass());
|
||||||
jda.getTextChannels().forEach(MessageChannel::sendTyping);
|
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||||
commandes.put("boobs",new Boobs());
|
commandes.put("boobs",new Boobs());
|
||||||
jda.getTextChannels().forEach(MessageChannel::sendTyping);
|
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||||
commandes.put("pipe",new Pipe());
|
commandes.put("pipe",new Pipe());
|
||||||
jda.getTextChannels().forEach(MessageChannel::sendTyping);
|
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||||
commandes.put("sm",new SM());
|
commandes.put("sm",new SM());
|
||||||
commandes.put("madame",new Madame());
|
commandes.put("madame",new Madame());
|
||||||
commandes.put("cat",new Cat());
|
commandes.put("cat",new Cat());
|
||||||
|
}
|
||||||
commandes.put("spaminfo",new SpamInfo());
|
commandes.put("spaminfo",new SpamInfo());
|
||||||
|
|
||||||
privateUsableCommand.add(Help.class);
|
|
||||||
privateUsableCommand.add(PingCommande.class);
|
|
||||||
|
|
||||||
//On recupere le l'id serveur
|
//On recupere le l'id serveur
|
||||||
Guild serveur = jda.getGuilds().get(0);
|
Guild serveur = jda.getGuilds().get(0);
|
||||||
@ -138,6 +152,8 @@ public class MainBot {
|
|||||||
logger.info("-----------------FIN INITIALISATION-----------------");
|
logger.info("-----------------FIN INITIALISATION-----------------");
|
||||||
|
|
||||||
jda.getPresence().setGame(Game.of("Statut: Ok!"));
|
jda.getPresence().setGame(Game.of("Statut: Ok!"));
|
||||||
|
// MessageEmbed test = EmbedMessageUtils.getHelp("test",command)
|
||||||
|
// jda.getTextChannels().get(0).sendMessage(test).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,9 +188,9 @@ public class MainBot {
|
|||||||
{
|
{
|
||||||
MessageReceivedEvent event = cmd.event;
|
MessageReceivedEvent event = cmd.event;
|
||||||
if(event.isFromType(ChannelType.PRIVATE))
|
if(event.isFromType(ChannelType.PRIVATE))
|
||||||
event.getPrivateChannel().sendMessage("\n:warning: **__Commande inconnue!__** :warning:\n:arrow_right: Utilisez `//help` pour voirs les commandes disponible. ").queue();
|
event.getPrivateChannel().sendMessage(EmbedMessageUtils.getUnknowCommand()).queue();
|
||||||
else
|
else
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Commande inconnue!__** :warning:\n:arrow_right: Utilisez `//help` pour voirs les commandes disponible. ").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getUnknowCommand()).queue();
|
||||||
logger.warn("Commande inconnue");
|
logger.warn("Commande inconnue");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,7 @@ public class AntiSpam {
|
|||||||
|
|
||||||
logger.info("Punition de "+user.getEffectiveName()+" avec un multiplicateur de "+MainBot.spamUtils.get(user.getUser()));
|
logger.info("Punition de "+user.getEffectiveName()+" avec un multiplicateur de "+MainBot.spamUtils.get(user.getUser()));
|
||||||
|
|
||||||
event.getTextChannel().sendMessage(user.getAsMention()+"\n```markdown\n#-----------------SPAM DETECTEUR----------------#\n# #\n# La prochaine fois tu fermeras ta gueule! #\n# #\n# On te revoit dans "+MainBot.spamUtils.get(user.getUser()).getMultip()+"min #\n# #\n#-----------------------------------------------#```").queue();
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamExtermine(user,MainBot.spamUtils.get(user.getUser()).getMultip())).queue();
|
||||||
|
|
||||||
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
||||||
{
|
{
|
||||||
MainBot.spamUtils.get(user.getUser()).setOnSpam(true);
|
MainBot.spamUtils.get(user.getUser()).setOnSpam(true);
|
||||||
@ -121,8 +120,7 @@ public class AntiSpam {
|
|||||||
logger.info("["+user.getEffectiveName()+"] Fin de spam pour "+user.getEffectiveName()+" apres "+multip+"min.");
|
logger.info("["+user.getEffectiveName()+"] Fin de spam pour "+user.getEffectiveName()+" apres "+multip+"min.");
|
||||||
move.exc(user, saveRoleUser.get(0), true, serveur, serveurManager); //aSaveroleUser=saveRoleUser.get(i)
|
move.exc(user, saveRoleUser.get(0), true, serveur, serveurManager); //aSaveroleUser=saveRoleUser.get(i)
|
||||||
logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min");
|
logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min");
|
||||||
chanel.sendMessage(user.getAsMention()+"\n```markdown\n#-----------------SPAM DETECTEUR----------------#\n# #\n# Un spammeur est de retour, fais gaffe! #\n# Je te surveille! #\n# #\n#-----------------------------------------------#```").queue();
|
chanel.sendMessage(EmbedMessageUtils.getSpamPardon(user)).queue();
|
||||||
|
|
||||||
|
|
||||||
// #-----------------------------------------------#
|
// #-----------------------------------------------#
|
||||||
|
|
||||||
|
47
src/net/Broken/Outils/EmbedMessageUtils.java
Normal file
47
src/net/Broken/Outils/EmbedMessageUtils.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package net.Broken.Outils;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.core.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
|
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||||
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageEmbed getSpamExtermine(Member autor, int multi) {
|
||||||
|
return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " détecté comme spammer !\n\nOn te revoit dans __**" + multi + "**__ min!").setImage("https://media.giphy.com/media/WVudyGEaizNeg/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageEmbed getSpamPardon(Member autor) {
|
||||||
|
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 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageEmbed getMoveOk(String message) {
|
||||||
|
return new EmbedBuilder().setTitle(":ok: Move :ok: ").setDescription(message).setColor(Color.green).setFooter("'//help move' pour plus d'info ", null).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageEmbed getSpamError(String message, String sub) {
|
||||||
|
return new EmbedBuilder().setTitle(":warning: Spam Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help spam "+sub+"' pour plus d'info ", null).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -5,18 +5,20 @@ import net.Broken.MainBot;
|
|||||||
|
|
||||||
import net.dv8tion.jda.core.entities.Guild;
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
import net.dv8tion.jda.core.entities.Member;
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
|
import net.dv8tion.jda.core.entities.Message;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.core.managers.GuildManager;
|
import net.dv8tion.jda.core.managers.GuildManager;
|
||||||
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.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Parayre on 24/10/2016.
|
* Created by Parayre on 24/10/2016.
|
||||||
*/
|
*/
|
||||||
public class Moderateur {
|
public class Moderateur {
|
||||||
|
|
||||||
Logger logger = LogManager.getLogger();
|
Logger logger = LogManager.getLogger();
|
||||||
private String[] tabMessages;
|
|
||||||
|
|
||||||
public Moderateur() {}
|
public Moderateur() {}
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ public class Moderateur {
|
|||||||
// SINON retourne 0
|
// SINON retourne 0
|
||||||
public int analyse(Member user, Guild serveur, GuildManager serveurManager, MessageReceivedEvent event){
|
public int analyse(Member user, Guild serveur, GuildManager serveurManager, MessageReceivedEvent event){
|
||||||
|
|
||||||
String[] toi = new String[5];//Creer tableau pour la copie
|
ArrayList<Message> thisUserHistory = new ArrayList<>();//Creer tableau pour la copie
|
||||||
int i = 0; // variable de parcours de "historique"
|
int i = 0; // variable de parcours de "historique"
|
||||||
int nbMessage = 3;
|
int nbMessage = 3;
|
||||||
int spam = 0;
|
int spam = 0;
|
||||||
@ -33,51 +35,54 @@ public class Moderateur {
|
|||||||
/********************************************
|
/********************************************
|
||||||
* si l'USER a deja envoyé un message *
|
* si l'USER a deja envoyé un message *
|
||||||
********************************************/
|
********************************************/
|
||||||
if(MainBot.historique.containsKey(user))// Si le user a deja posté un message
|
if(MainBot.historique.containsKey(user.getUser()))// Si le user a deja posté un message
|
||||||
{
|
{
|
||||||
|
logger.debug("ok");
|
||||||
/********************************************
|
/********************************************
|
||||||
* COPIE des infos d"historique" vers TOI[] *
|
* COPIE des infos d"historique" vers TOI[] *
|
||||||
********************************************/
|
********************************************/
|
||||||
i = 0;
|
thisUserHistory = (ArrayList<Message>) MainBot.historique.get(user.getUser()).clone();
|
||||||
while( (MainBot.historique.get(user)[i] != null) && (i < nbMessage) ){
|
|
||||||
toi[i+1] = MainBot.historique.get(user)[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Ajout dernier message recu + dans histo' *
|
* Ajout dernier message recu + dans histo' *
|
||||||
********************************************/
|
********************************************/
|
||||||
toi[0] = event.getMessage().getContent();// On stocke en position [0] le nouveau message
|
thisUserHistory.add(0,event.getMessage());
|
||||||
MainBot.historique.put(user.getUser(), toi);// On ajoute dans l'historique TOI
|
if(thisUserHistory.size()>nbMessage+1)
|
||||||
|
thisUserHistory.remove(4);
|
||||||
|
MainBot.historique.put(user.getUser(), thisUserHistory);// On ajoute dans l'historique TOI
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
* ANALYSE des messages *
|
* ANALYSE des messages *
|
||||||
*****************************/
|
*****************************/
|
||||||
if(toi[3].equals(toi[2])&&toi[2].equals(toi[1]) && toi[1].equals(toi[0]) ){
|
int equalCont = 0;
|
||||||
|
String oldMessage = "";
|
||||||
|
for(Message aMessage : thisUserHistory){
|
||||||
|
if(aMessage.getContent().equals(oldMessage))
|
||||||
|
equalCont++;
|
||||||
|
oldMessage = aMessage.getContent();
|
||||||
|
logger.debug( "\t- "+aMessage.getContent());
|
||||||
|
|
||||||
|
}
|
||||||
|
if(equalCont >= nbMessage){
|
||||||
spam = 1;
|
spam = 1;
|
||||||
logger.info("Detection de spam pour "+user.getEffectiveName()+"avec 3 messages identique: ");
|
logger.info("Detection de spam pour "+user.getEffectiveName()+"avec 3 messages identique: ");
|
||||||
for(int j=0;MainBot.historique.get(user).length-1>j;j++)
|
for(Message aMessage : thisUserHistory)
|
||||||
{
|
{
|
||||||
logger.info("\t"+j+". "+MainBot.historique.get(user)[j]);
|
logger.info("\t - "+aMessage.getContent());
|
||||||
}
|
}
|
||||||
toi[0] = "";
|
MainBot.historique.put(user.getUser(), new ArrayList<Message>());
|
||||||
toi[1] = "";
|
|
||||||
toi[2] = "";
|
|
||||||
toi[3] = "";
|
|
||||||
MainBot.historique.put(user.getUser(), toi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
logger.debug("ok else ");
|
||||||
/********************************************
|
/********************************************
|
||||||
* SI c'est le 1er message de l'USER *
|
* SI c'est le 1er message de l'USER *
|
||||||
********************************************/
|
********************************************/
|
||||||
// si le user n'a pas encore posté de message
|
// si le user n'a pas encore posté de message
|
||||||
// on ajoute le dernier message dans "historique"
|
// on ajoute le dernier message dans "historique"
|
||||||
toi[0] = event.getMessage().getContent();
|
thisUserHistory.add(0,event.getMessage());
|
||||||
toi[1] = "";
|
|
||||||
toi[2] = "";
|
MainBot.historique.put(user.getUser(), thisUserHistory);
|
||||||
toi[3] = "";
|
|
||||||
MainBot.historique.put(user.getUser(), toi);
|
|
||||||
}
|
}
|
||||||
/**********************************
|
/**********************************
|
||||||
* AFFICHAGE DE HISTORIQUE *
|
* AFFICHAGE DE HISTORIQUE *
|
||||||
@ -99,10 +104,10 @@ public class Moderateur {
|
|||||||
MainBot.message_compteur.put(user.getUser(),0);
|
MainBot.message_compteur.put(user.getUser(),0);
|
||||||
spam = 1;
|
spam = 1;
|
||||||
logger.info("Detection de spam pour "+user.getEffectiveName()+"avec 5 message en 5seg: ");
|
logger.info("Detection de spam pour "+user.getEffectiveName()+"avec 5 message en 5seg: ");
|
||||||
String[] histo = MainBot.historique.get(user.getUser());
|
ArrayList<Message> histo = MainBot.historique.get(user.getUser());
|
||||||
for (String unMessage:histo ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
for (Message aMessage:histo ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||||
{
|
{
|
||||||
logger.debug("\t*"+unMessage);
|
logger.debug("\t*"+aMessage.getContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.Broken.Outils;
|
package net.Broken.Outils;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.core.entities.Message;
|
||||||
|
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.core.entities.PrivateChannel;
|
import net.dv8tion.jda.core.entities.PrivateChannel;
|
||||||
import net.dv8tion.jda.core.entities.User;
|
import net.dv8tion.jda.core.entities.User;
|
||||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
||||||
@ -10,13 +12,12 @@ import org.apache.logging.log4j.Logger;
|
|||||||
*/
|
*/
|
||||||
public class PrivateMessage {
|
public class PrivateMessage {
|
||||||
public static void send(User user, String message, Logger logger){
|
public static void send(User user, String message, Logger logger){
|
||||||
if(!user.hasPrivateChannel()){
|
|
||||||
logger.debug("Create Private Chanel");
|
|
||||||
|
|
||||||
user.openPrivateChannel().complete();
|
user.openPrivateChannel().complete().sendMessage(message).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
user.getJDA().getPrivateChannels().get(0).sendMessage(message).queue();
|
public static Message send(User user, MessageEmbed message, Logger logger){
|
||||||
|
return user.openPrivateChannel().complete().sendMessage(message).complete();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class UserSpamUtils {
|
|||||||
this.onSpam = onSpam;
|
this.onSpam = onSpam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Member getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user