Adding spam info !
This commit is contained in:
parent
7b0f1429d1
commit
ad26b1dbdf
@ -43,10 +43,6 @@ public class BotListener extends ListenerAdapter {
|
||||
//On a detecter que c'etait une commande
|
||||
//System.out.println(event.getMessage().getContent());
|
||||
MainBot.handleCommand(MainBot.parser.parse(event.getMessage().getContent(), event));
|
||||
logger.debug("ok");
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (!event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId()))
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ public interface Commande {
|
||||
void action(String[] args, MessageReceivedEvent event);
|
||||
String help(String[] args);
|
||||
void executed(boolean success, MessageReceivedEvent event);
|
||||
boolean isPrivateUsable();
|
||||
|
||||
|
||||
}
|
||||
|
@ -72,4 +72,9 @@ public class Cat implements Commande {
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -77,4 +77,9 @@ public class Help implements Commande {
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -168,4 +168,8 @@ public class Move implements Commande {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,9 @@ public class Ass extends NumberedCommande {
|
||||
public String toString() {
|
||||
return "Ass";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,9 @@ public class Boobs extends NumberedCommande {
|
||||
public String toString() {
|
||||
return "Boobs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +64,9 @@ public class Madame implements Commande{
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -49,4 +49,9 @@ public class Pipe extends NumberedCommande {
|
||||
public String toString() {
|
||||
return "Pipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -51,4 +51,9 @@ public class SM implements Commande {
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +43,9 @@ public class PingCommande implements Commande {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.Broken.Commandes;
|
||||
import net.Broken.Commande;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.Outils.AntiSpam;
|
||||
import net.Broken.Outils.UserSpamUtils;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
@ -84,6 +85,11 @@ public class Spam implements Commande {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void pardon(MessageReceivedEvent event, String[] args){
|
||||
|
||||
Guild serveur = event.getGuild();
|
||||
@ -119,30 +125,30 @@ public class Spam implements Commande {
|
||||
/****************************
|
||||
* virif si en spammer *
|
||||
****************************/
|
||||
if (MainBot.minuteurStatut.containsKey(user)) {
|
||||
if (MainBot.minuteurStatut.get(user)) {
|
||||
MainBot.minuteurStatut.put(user, false);
|
||||
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.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ").queue();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
logger.warn("Utilisateur pas en spam.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Utilisateur non spammeur. ").queue();
|
||||
}
|
||||
|
||||
} else {
|
||||
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: ");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:no_entry_sign: **__Vous n'avez pas l'autorisation de faire sa!__** :no_entry_sign: ").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Argument manquant.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Argument manquant__**:warning: \n:arrow_right: Utilisation: `//spam pardon <@utilisateur>`.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Argument manquant__**:warning: \n:arrow_right: Utilisation: `//spam pardon <@utilisateur>`.").queue();
|
||||
}
|
||||
|
||||
|
||||
@ -187,9 +193,9 @@ public class Spam implements Commande {
|
||||
/****************************
|
||||
* virif pas deja en spammer *
|
||||
****************************/
|
||||
if(MainBot.minuteurStatut.containsKey(user))
|
||||
if(MainBot.spamUtils.containsKey(user.getUser()))
|
||||
{
|
||||
if(!MainBot.minuteurStatut.get(user))
|
||||
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
||||
{
|
||||
this.goSpam(user,multiStr,serveur,event);
|
||||
}
|
||||
@ -258,10 +264,10 @@ public class Spam implements Commande {
|
||||
/****************************
|
||||
* verif utilisteur trouver *
|
||||
****************************/
|
||||
if (MainBot.userMulti.containsKey(user)) {
|
||||
if (MainBot.spamUtils.containsKey(user.getUser())) {
|
||||
logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n *Le multiplcicateur de " + user.getEffectiveName() + " a été remit a zéro.*").queue();
|
||||
MainBot.userMulti.remove(user);
|
||||
MainBot.spamUtils.remove(user.getUser());
|
||||
|
||||
}
|
||||
} else {
|
||||
@ -282,7 +288,7 @@ public class Spam implements Commande {
|
||||
if (args[0].equals("all"))
|
||||
{
|
||||
logger.info("Reset automatique des multiplicateur.");
|
||||
for (Member unUser: MainBot.userMulti.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
for (User unUser: MainBot.spamUtils.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
{
|
||||
MainBot.message_compteur.remove(unUser);
|
||||
}
|
||||
@ -306,13 +312,14 @@ public class Spam implements Commande {
|
||||
else
|
||||
{
|
||||
int multi = Integer.parseInt(multiStr);
|
||||
if(MainBot.minuteurStatut.containsKey(user))
|
||||
if(MainBot.spamUtils.containsKey(user))
|
||||
{
|
||||
MainBot.userMulti.replace(user,multi);
|
||||
MainBot.spamUtils.get(user).setMultip(multi);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainBot.userMulti.put(user,multi);
|
||||
MainBot.spamUtils.put(user.getUser(),new UserSpamUtils(user));
|
||||
MainBot.spamUtils.get(user.getUser()).setMultip(multi);
|
||||
}
|
||||
|
||||
new AntiSpam().extermine(user,serveur,serveur.getManager(),false,event);
|
||||
|
@ -1,8 +1,106 @@
|
||||
package net.Broken.Commandes;
|
||||
|
||||
import net.Broken.Commande;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.Outils.PrivateMessage;
|
||||
import net.Broken.Outils.UserSpamUtils;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by sebastien on 13/03/17.
|
||||
*/
|
||||
public class SpamInfo {
|
||||
public class SpamInfo implements Commande{
|
||||
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)*";
|
||||
@Override
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
User user;
|
||||
if(event.getMessage().getMentionedUsers().size() == 0){
|
||||
user = event.getAuthor();
|
||||
}
|
||||
else {
|
||||
user = event.getMessage().getMentionedUsers().get(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!MainBot.spamUtils.containsKey(user)){
|
||||
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();
|
||||
else
|
||||
PrivateMessage.send(event.getAuthor(),"__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `1`\n\t- En spam: `Non`",logger);
|
||||
}
|
||||
else{
|
||||
UserSpamUtils util = MainBot.spamUtils.get(user);
|
||||
if(!util.isOnSpam()){
|
||||
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();
|
||||
else
|
||||
PrivateMessage.send(event.getAuthor(),"__**Spam info de "+user.getName()+":**__\n\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`",logger);
|
||||
}
|
||||
else{
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help(String[] args) {
|
||||
return HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String formatSecond(int second){
|
||||
long days = TimeUnit.SECONDS.toDays(second);
|
||||
second -= TimeUnit.DAYS.toSeconds(days);
|
||||
|
||||
long hours = TimeUnit.SECONDS.toHours(second);
|
||||
second -= TimeUnit.HOURS.toSeconds(hours);
|
||||
|
||||
|
||||
long minutes = TimeUnit.SECONDS.toMinutes(second);
|
||||
second -= TimeUnit.MINUTES.toSeconds(minutes);
|
||||
|
||||
long seconds = TimeUnit.SECONDS.toSeconds(second);
|
||||
|
||||
logger.debug(""+days+":"+hours+":"+minutes+":"+seconds);
|
||||
String finalText = "";
|
||||
if(days!=0)
|
||||
finalText += days+" jour(s) ";
|
||||
if(hours!=0)
|
||||
finalText += hours+"h ";
|
||||
if(minutes!=0)
|
||||
finalText += minutes+"min ";
|
||||
finalText += seconds+"s";
|
||||
|
||||
return finalText;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.Broken;
|
||||
|
||||
import net.Broken.Commandes.*;
|
||||
import net.Broken.Commandes.Over18.*;
|
||||
import net.Broken.Outils.CommandParser;
|
||||
import net.Broken.Outils.DayListener;
|
||||
import net.Broken.Outils.FindContentOnWebPage;
|
||||
import net.Broken.Outils.Redirection;
|
||||
import net.Broken.Commandes.*;
|
||||
import net.Broken.Outils.UserSpamUtils;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDABuilder;
|
||||
@ -19,7 +18,10 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 19/10/2016.
|
||||
@ -30,11 +32,10 @@ public class MainBot {
|
||||
public static final CommandParser parser =new CommandParser();
|
||||
public static HashMap<String, Commande> commandes = new HashMap<>();
|
||||
public static boolean okInit=false;
|
||||
public static HashMap<Member, String[]> historique =new HashMap<>();
|
||||
public static HashMap<Member, Integer> message_compteur =new HashMap<>();
|
||||
public static HashMap<User, String[]> historique =new HashMap<>();
|
||||
public static HashMap<User, Integer> message_compteur =new HashMap<>();
|
||||
|
||||
public static Hashtable<Member,Integer> userMulti = new Hashtable();
|
||||
public static Hashtable<Member,Boolean> minuteurStatut = new Hashtable<>();
|
||||
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>();
|
||||
|
||||
public static ArrayList<Class<?>> privateUsableCommand = new ArrayList<>();
|
||||
|
||||
@ -98,6 +99,7 @@ public class MainBot {
|
||||
commandes.put("sm",new SM());
|
||||
commandes.put("madame",new Madame());
|
||||
commandes.put("cat",new Cat());
|
||||
commandes.put("spaminfo",new SpamInfo());
|
||||
|
||||
privateUsableCommand.add(Help.class);
|
||||
privateUsableCommand.add(PingCommande.class);
|
||||
@ -135,8 +137,6 @@ public class MainBot {
|
||||
dayListener.start();
|
||||
logger.info("-----------------FIN INITIALISATION-----------------");
|
||||
|
||||
/*List<User> userAction = serveur.getUsersByName("Broken_Fire");
|
||||
new Move().exc(userAction.get(0),"Big Daddy",true,serveur,serveur.getManager());*/
|
||||
jda.getPresence().setGame(Game.of("Statut: Ok!"));
|
||||
|
||||
}
|
||||
@ -152,8 +152,7 @@ public class MainBot {
|
||||
|
||||
if (commandes.containsKey(cmd.commande))
|
||||
{
|
||||
logger.debug("ok");
|
||||
if(cmd.event.isFromType(ChannelType.PRIVATE) && privateUsableCommand.contains(commandes.get(cmd.commande).getClass()))
|
||||
if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable())
|
||||
{
|
||||
|
||||
commandes.get(cmd.commande).action(cmd.args, cmd.event);
|
||||
@ -165,7 +164,7 @@ public class MainBot {
|
||||
commandes.get(cmd.commande).executed(true, cmd.event);
|
||||
}
|
||||
else
|
||||
cmd.event.getPrivateChannel().sendMessage("\n:warning: **__Commande non disponible en priver!__** :warning:").queue();
|
||||
cmd.event.getPrivateChannel().sendMessage("\n:warning: **__Commande non disponible en privé!__** :warning:").queue();
|
||||
|
||||
|
||||
}
|
||||
@ -203,7 +202,7 @@ public class MainBot {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//System.out.println("\n5sec Ecoulées !");
|
||||
for (Member unUser: message_compteur.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
for (User unUser: message_compteur.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
{
|
||||
MainBot.message_compteur.put(unUser, 0);
|
||||
}
|
||||
|
@ -41,35 +41,35 @@ public class AntiSpam {
|
||||
}
|
||||
|
||||
// On créer un nouvelle case dans le tableau des statuts si il n'y est pas
|
||||
if(!MainBot.minuteurStatut.containsKey(user))
|
||||
if(!MainBot.spamUtils.containsKey(user.getUser()))
|
||||
{
|
||||
MainBot.minuteurStatut.put(user,false);
|
||||
MainBot.spamUtils.put(user.getUser(),new UserSpamUtils(user));
|
||||
}
|
||||
// On verrifie que l'uttilisateur n'est pas deja en spam
|
||||
if(!MainBot.minuteurStatut.get(user))
|
||||
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
||||
{
|
||||
//l'utilisateur n'est pas deja en spam
|
||||
if(MainBot.userMulti.containsKey(user))
|
||||
if(MainBot.spamUtils.get(user.getUser()).getMultip() != 0)
|
||||
{
|
||||
if(MainBot.userMulti.get(user)<45 && incrMulti)
|
||||
if(MainBot.spamUtils.get(user.getUser()).getMultip()<45 && incrMulti)
|
||||
{
|
||||
MainBot.userMulti.replace(user,MainBot.userMulti.get(user)*2);
|
||||
MainBot.spamUtils.get(user.getUser()).setMultip(MainBot.spamUtils.get(user.getUser()).getMultip()*2);
|
||||
}
|
||||
}
|
||||
else
|
||||
MainBot.userMulti.put(user,1);
|
||||
MainBot.spamUtils.get(user.getUser()).setMultip(1);
|
||||
|
||||
logger.info("Punition de "+user.getEffectiveName()+" avec un multiplicateur de "+MainBot.userMulti.get(user));
|
||||
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.userMulti.get(user)+"min connard ! #\n# #\n#-----------------------------------------------#```\n https://cdn.meme.am/instances/64726692.jpg ").queue();
|
||||
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();
|
||||
|
||||
if(!MainBot.minuteurStatut.get(user))
|
||||
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
||||
{
|
||||
MainBot.minuteurStatut.replace(user,true);
|
||||
MainBot.spamUtils.get(user.getUser()).setOnSpam(true);
|
||||
List<Role> spm = serveur.getRolesByName("Spammer", false);
|
||||
move.exc(user, spm.get(0), true, serveur, serveurManger);
|
||||
Thread minuteur =new Minuteur(MainBot.userMulti.get(user), move.user, move.saveRoleUser, move.serveur, move.serveurManager,event);
|
||||
minuteur.start();
|
||||
MainBot.spamUtils.get(user.getUser()).setMinuteur(new Minuteur(MainBot.spamUtils.get(user.getUser()).getMultip(), move.user, move.saveRoleUser, move.serveur, move.serveurManager,event));
|
||||
MainBot.spamUtils.get(user.getUser()).launchMinuteur();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +86,7 @@ public class AntiSpam {
|
||||
public GuildManager serveurManager;
|
||||
public int multip;
|
||||
public MessageReceivedEvent event;
|
||||
public int timeLeft;
|
||||
|
||||
|
||||
public Minuteur(int multip, Member user, List<Role> saveRoleUser, Guild serveur, GuildManager serveurManager, MessageReceivedEvent event )
|
||||
@ -97,30 +98,30 @@ public class AntiSpam {
|
||||
this.serveurManager=serveurManager;
|
||||
this.event=event;
|
||||
this.chanel=event.getTextChannel();
|
||||
this.timeLeft = 60*multip;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int cSeg=0;
|
||||
logger.info("["+user.getEffectiveName()+"] Démarage pour "+multip+"min");
|
||||
while (MainBot.minuteurStatut.get(user))
|
||||
while (MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
||||
{
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(cSeg>60*multip)
|
||||
if(timeLeft<=0)
|
||||
{
|
||||
MainBot.minuteurStatut.replace(user,false);
|
||||
MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
|
||||
}
|
||||
cSeg++;
|
||||
timeLeft--;
|
||||
}
|
||||
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)
|
||||
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#-----------------------------------------------#```\n http://67.media.tumblr.com/tumblr_lvrf58vBkL1qibz0jo1_r1_500.png").queue();
|
||||
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();
|
||||
|
||||
|
||||
// #-----------------------------------------------#
|
||||
|
@ -47,7 +47,7 @@ public class Moderateur {
|
||||
* Ajout dernier message recu + dans histo' *
|
||||
********************************************/
|
||||
toi[0] = event.getMessage().getContent();// On stocke en position [0] le nouveau message
|
||||
MainBot.historique.put(user, toi);// On ajoute dans l'historique TOI
|
||||
MainBot.historique.put(user.getUser(), toi);// On ajoute dans l'historique TOI
|
||||
|
||||
/*****************************
|
||||
* ANALYSE des messages *
|
||||
@ -64,7 +64,7 @@ public class Moderateur {
|
||||
toi[1] = "";
|
||||
toi[2] = "";
|
||||
toi[3] = "";
|
||||
MainBot.historique.put(user, toi);
|
||||
MainBot.historique.put(user.getUser(), toi);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -77,7 +77,7 @@ public class Moderateur {
|
||||
toi[1] = "";
|
||||
toi[2] = "";
|
||||
toi[3] = "";
|
||||
MainBot.historique.put(user, toi);
|
||||
MainBot.historique.put(user.getUser(), toi);
|
||||
}
|
||||
/**********************************
|
||||
* AFFICHAGE DE HISTORIQUE *
|
||||
@ -89,24 +89,24 @@ public class Moderateur {
|
||||
/********************************************
|
||||
* Comptage du nombre de message *
|
||||
********************************************/
|
||||
if(MainBot.message_compteur.containsKey(user))// Si le user a deja posté un message
|
||||
if(MainBot.message_compteur.containsKey(user.getUser()))// Si le user a deja posté un message
|
||||
{
|
||||
int cpt = MainBot.message_compteur.get(user);
|
||||
int cpt = MainBot.message_compteur.get(user.getUser());
|
||||
cpt++;
|
||||
//System.out.println("compteur : "+cpt);
|
||||
MainBot.message_compteur.put(user, cpt);
|
||||
MainBot.message_compteur.put(user.getUser(), cpt);
|
||||
if(cpt > 5){
|
||||
MainBot.message_compteur.put(user,0);
|
||||
MainBot.message_compteur.put(user.getUser(),0);
|
||||
spam = 1;
|
||||
logger.info("Detection de spam pour "+user.getEffectiveName()+"avec 5 message en 5seg: ");
|
||||
String[] histo = MainBot.historique.get(user);
|
||||
String[] histo = MainBot.historique.get(user.getUser());
|
||||
for (String unMessage:histo ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
{
|
||||
logger.debug("\t*"+unMessage);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
MainBot.message_compteur.put(user, 1);
|
||||
MainBot.message_compteur.put(user.getUser(), 1);
|
||||
}
|
||||
|
||||
return spam;
|
||||
|
48
src/net/Broken/Outils/UserSpamUtils.java
Normal file
48
src/net/Broken/Outils/UserSpamUtils.java
Normal file
@ -0,0 +1,48 @@
|
||||
package net.Broken.Outils;
|
||||
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
|
||||
public class UserSpamUtils {
|
||||
private AntiSpam.Minuteur minuteur;
|
||||
private Member user;
|
||||
private int multip = 0;
|
||||
private boolean onSpam = false;
|
||||
|
||||
public int getTimeLeft(){
|
||||
return minuteur.timeLeft;
|
||||
}
|
||||
|
||||
public int getMultip()
|
||||
{
|
||||
return multip;
|
||||
}
|
||||
|
||||
public UserSpamUtils(Member user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
public void setMinuteur(AntiSpam.Minuteur minuteur) {
|
||||
this.minuteur = minuteur;
|
||||
}
|
||||
|
||||
public void launchMinuteur(){
|
||||
minuteur.start();
|
||||
}
|
||||
|
||||
public void setMultip(int multip) {
|
||||
this.multip = multip;
|
||||
}
|
||||
|
||||
public boolean isOnSpam() {
|
||||
return onSpam;
|
||||
}
|
||||
|
||||
public void setOnSpam(boolean onSpam) {
|
||||
this.onSpam = onSpam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user