Add multiserver to spam

This commit is contained in:
Sebastien 2018-04-26 17:32:38 +02:00
parent 0b535dd24e
commit 59813fe37b
10 changed files with 96 additions and 85 deletions

View File

@ -25,7 +25,7 @@ import java.util.Objects;
* Spam admin command * Spam admin command
*/ */
public class Spam implements Commande { public class Spam implements Commande {
Logger logger = LogManager.getLogger(); private Logger logger = LogManager.getLogger();
@Override @Override
public void action(String[] args, MessageReceivedEvent event) public void action(String[] args, MessageReceivedEvent event)
@ -97,7 +97,7 @@ public class Spam implements Commande {
/**************************** /****************************
* On recupere l'utilisateur et le role cible * On recupere l'utilisateur et le role cible
****************************/ ****************************/
List<User> userL = event.getMessage().getMentionedUsers(); List<Member> userL = event.getMessage().getMentionedMembers();
/**************************** /****************************
@ -114,14 +114,14 @@ public class Spam implements Commande {
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else { else {
Member user = serveur.getMember(userL.get(0)); Member user = userL.get(0);
logger.info("Tentative de pardon de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName()); logger.info("Tentative de pardon de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/**************************** /****************************
* virif si en spammer * * virif si en spammer *
****************************/ ****************************/
if (MainBot.spamUtils.containsKey(user.getUser())) { if (MainBot.spamUtils.containsKey(user)) {
if (MainBot.spamUtils.get(user.getUser()).isOnSpam()) { if (MainBot.spamUtils.get(user).isOnSpam()) {
MainBot.spamUtils.get(user.getUser()).setOnSpam(false); MainBot.spamUtils.get(user).setOnSpam(false);
} else { } else {
logger.warn("Utilisateur pas en spam."); logger.warn("Utilisateur pas en spam.");
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
@ -192,9 +192,9 @@ public class Spam implements Commande {
/**************************** /****************************
* virif pas deja en spammer * * virif pas deja en spammer *
****************************/ ****************************/
if(MainBot.spamUtils.containsKey(user.getUser())) if(MainBot.spamUtils.containsKey(user))
{ {
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam()) if(!MainBot.spamUtils.get(user).isOnSpam())
{ {
this.goSpam(user,multiStr,serveur,event); this.goSpam(user,multiStr,serveur,event);
} }
@ -242,7 +242,7 @@ public class Spam implements Commande {
/**************************** /****************************
* On recupere l'utilisateur et le role cible * On recupere l'utilisateur et le role cible
****************************/ ****************************/
List<User> userL = event.getMessage().getMentionedUsers(); List<Member> userL = event.getMessage().getMentionedMembers();
/**************************** /****************************
@ -260,14 +260,14 @@ public class Spam implements Commande {
} }
else { else {
Member user = serveur.getMember(userL.get(0)); Member user = userL.get(0);
logger.info("Tentative de reset de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName()); logger.info("Tentative de reset de " + user.getEffectiveName() + " par l'utilisateur " + event.getMember().getEffectiveName());
/**************************** /****************************
* verif utilisteur trouver * * verif utilisteur trouver *
****************************/ ****************************/
if (MainBot.spamUtils.containsKey(user.getUser())) { if (MainBot.spamUtils.containsKey(user)) {
logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi"); 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(); 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>(){{ List<Message> messages = new ArrayList<Message>(){{
@ -275,7 +275,7 @@ public class Spam implements Commande {
add(event.getMessage()); add(event.getMessage());
}}; }};
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
MainBot.spamUtils.remove(user.getUser()); MainBot.spamUtils.remove(user);
} }
@ -297,7 +297,7 @@ public class Spam implements Commande {
if (args[0].equals("all")) if (args[0].equals("all"))
{ {
logger.info("Reset automatique des multiplicateur."); logger.info("Reset automatique des multiplicateur.");
for (User unUser: MainBot.spamUtils.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++) for (Member unUser: MainBot.spamUtils.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
{ {
MainBot.message_compteur.remove(unUser); MainBot.message_compteur.remove(unUser);
} }
@ -327,8 +327,8 @@ public class Spam implements Commande {
} }
else else
{ {
MainBot.spamUtils.put(user.getUser(),new UserSpamUtils(user,new ArrayList<>())); MainBot.spamUtils.put(user,new UserSpamUtils(user,new ArrayList<>()));
MainBot.spamUtils.get(user.getUser()).setMultip(multi); MainBot.spamUtils.get(user).setMultip(multi);
} }
new AntiSpam().extermine(user,serveur,serveur.getManager(),false,event); new AntiSpam().extermine(user,serveur,serveur.getManager(),false,event);

View File

@ -8,6 +8,7 @@ import net.Broken.Tools.PrivateMessage;
import net.Broken.Tools.UserSpamUtils; import net.Broken.Tools.UserSpamUtils;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
@ -24,41 +25,41 @@ import java.util.concurrent.TimeUnit;
* Spam Info Command * Spam Info Command
*/ */
public class SpamInfo implements Commande{ public class SpamInfo implements Commande{
private HashMap<User,MessageUpdater> threadHashMap = new HashMap<>(); private HashMap<Member,MessageUpdater> threadHashMap = new HashMap<>();
Logger logger = LogManager.getLogger(); Logger logger = LogManager.getLogger();
@Override @Override
public void action(String[] args, MessageReceivedEvent event) { public void action(String[] args, MessageReceivedEvent event) {
User user; Member user;
if(event.getMessage().getMentionedUsers().size() == 0){ if(event.getMessage().getMentionedUsers().size() == 0){
user = event.getAuthor(); user = event.getMember();
} }
else { else {
user = event.getMessage().getMentionedUsers().get(0); user = event.getMessage().getMentionedMembers().get(0);
} }
Message message = null; Message message = null;
if(!MainBot.spamUtils.containsKey(user)){ if(!MainBot.spamUtils.containsKey(user)){
if(!event.isFromType(ChannelType.PRIVATE)) if(!event.isFromType(ChannelType.PRIVATE))
message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `1`\n\t- En spam: `Non`")).complete(); message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getEffectiveName() + ":\n\t- Multiplicateur: `1`\n\t- En spam: `Non`")).complete();
else else
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `1`\n\t- En spam: `Non`"),logger); PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+":\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))
message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).complete(); message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).complete();
else else
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`"),logger); PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`"),logger);
} }
else{ else{
if(!event.isFromType(ChannelType.PRIVATE)) if(!event.isFromType(ChannelType.PRIVATE))
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(); message = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`")).complete();
else else
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); message = PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`"),logger);
} }
} }
if(message != null){ if(message != null){
@ -139,9 +140,9 @@ public class SpamInfo implements Commande{
public UserSpamUtils util; public UserSpamUtils util;
public boolean stop; public boolean stop;
private int oldValue; private int oldValue;
private User user; private Member user;
public MessageUpdater(Message message,Message command, UserSpamUtils util,User user) { public MessageUpdater(Message message,Message command, UserSpamUtils util, Member user) {
this.message = message; this.message = message;
this.util = util; this.util = util;
this.user = user; this.user = user;
@ -151,14 +152,14 @@ public class SpamInfo implements Commande{
@Override @Override
public void run() { public void run() {
logger.debug("Start "+user.getName()+" theard!"); logger.debug("Start "+user.getEffectiveName()+" theard!");
if(util != null){ if(util != null){
oldValue = util.getTimeLeft(); oldValue = util.getTimeLeft();
while (util.getTimeLeft()!=0 && !stop && util.isOnSpam()){ while (util.getTimeLeft()!=0 && !stop && util.isOnSpam()){
try { try {
Thread.sleep(500); Thread.sleep(500);
if(util.getTimeLeft()%5 == 0 && oldValue - util.getTimeLeft() >= 5){ 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(); message.editMessage(EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+":\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Oui`\n\t- Temps restant: `"+formatSecond(util.getTimeLeft())+"`")).complete();
oldValue = util.getTimeLeft(); oldValue = util.getTimeLeft();
} }
@ -166,14 +167,14 @@ public class SpamInfo implements Commande{
e.printStackTrace(); e.printStackTrace();
} }
} }
logger.debug("Kill "+user.getName()+" theard!"); logger.debug("Kill "+user.getEffectiveName()+" theard!");
if(stop) if(stop)
message.editMessage(new EmbedBuilder().setColor(Color.RED).setTitle("Aborted").build()).complete(); message.editMessage(new EmbedBuilder().setColor(Color.RED).setTitle("Aborted").build()).complete();
else else
message.editMessage(EmbedMessageUtils.getSpamInfo(user.getName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).complete(); message.editMessage(EmbedMessageUtils.getSpamInfo(user.getEffectiveName()+"\n\t- Multiplicateur: `"+util.getMultip()+"`\n\t- En spam: `Non`")).complete();
} }
logger.debug("Timer for message deletion of "+user.getName()+" stated..."); logger.debug("Timer for message deletion of "+user.getEffectiveName()+" stated...");
threadHashMap.remove(user); threadHashMap.remove(user);
List<Message> messages = new ArrayList<>(); List<Message> messages = new ArrayList<>();
messages.add(command); messages.add(command);

View File

@ -10,7 +10,7 @@ import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import java.io.IOException; import java.io.IOException;
public class ytTest implements Commande { public class Test implements Commande {
@Override @Override
public void action(String[] args, MessageReceivedEvent event) { public void action(String[] args, MessageReceivedEvent event) {
event.getJDA().getPresence().setPresence(RichPresence.playing("test").asRichPresence(),false); event.getJDA().getPresence().setPresence(RichPresence.playing("test").asRichPresence(),false);

View File

@ -10,6 +10,7 @@ import net.Broken.audio.Youtube.YoutubeTools;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
@ -33,10 +34,10 @@ import java.util.HashMap;
public class MainBot { public class MainBot {
public static HashMap<String, Commande> commandes = new HashMap<>(); public static HashMap<String, Commande> commandes = new HashMap<>();
public static HashMap<User, ArrayList<Message>> historique =new HashMap<>(); public static HashMap<Member, ArrayList<Message>> historique =new HashMap<>();
public static HashMap<User, Integer> message_compteur =new HashMap<>(); public static HashMap<Member, Integer> message_compteur =new HashMap<>();
public static boolean roleFlag = false; public static boolean roleFlag = false;
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>(); public static HashMap<Member, UserSpamUtils> spamUtils = new HashMap<>();
public static JDA jda; public static JDA jda;
public static boolean ready = false; public static boolean ready = false;

View File

@ -64,7 +64,6 @@ public class UserManagerAPIController {
@RequestMapping(value = "/confirmAccount", method = RequestMethod.POST) @RequestMapping(value = "/confirmAccount", method = RequestMethod.POST)
public ResponseEntity<UserConnectionData> confirAccount(@RequestBody ConfirmData data){ public ResponseEntity<UserConnectionData> confirAccount(@RequestBody ConfirmData data){
//TODO move pending user to accepted and return right things
try { try {
PendingUserEntity pUser = userUtils.confirmCheckToken(pendingUserRepository, Integer.parseInt(data.id), data.checkToken); PendingUserEntity pUser = userUtils.confirmCheckToken(pendingUserRepository, Integer.parseInt(data.id), data.checkToken);
UserEntity user = new UserEntity(pUser, userUtils.generateApiToken()); UserEntity user = new UserEntity(pUser, userUtils.generateApiToken());

View File

@ -43,37 +43,37 @@ public class AntiSpam {
} }
// On créer un nouvelle case dans le tableau des statuts si il n'y est pas // On créer un nouvelle case dans le tableau des statuts si il n'y est pas
if(!MainBot.spamUtils.containsKey(user.getUser())) if(!MainBot.spamUtils.containsKey(user))
{ {
List<Message> messages = new ArrayList<>(); List<Message> messages = new ArrayList<>();
messages.addAll(MainBot.historique.get(user.getUser())); messages.addAll(MainBot.historique.get(user));
MainBot.spamUtils.put(user.getUser(),new UserSpamUtils(user,messages)); MainBot.spamUtils.put(user,new UserSpamUtils(user,messages));
} }
// On verrifie que l'uttilisateur n'est pas deja en spam // On verrifie que l'uttilisateur n'est pas deja en spam
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam()) if(!MainBot.spamUtils.get(user).isOnSpam())
{ {
//l'utilisateur n'est pas deja en spam //l'utilisateur n'est pas deja en spam
if(MainBot.spamUtils.get(user.getUser()).getMultip() != 0) if(MainBot.spamUtils.get(user).getMultip() != 0)
{ {
if(MainBot.spamUtils.get(user.getUser()).getMultip()<45 && incrMulti) if(MainBot.spamUtils.get(user).getMultip()<45 && incrMulti)
{ {
MainBot.spamUtils.get(user.getUser()).setMultip(MainBot.spamUtils.get(user.getUser()).getMultip()*2); MainBot.spamUtils.get(user).setMultip(MainBot.spamUtils.get(user).getMultip()*2);
} }
} }
else else
MainBot.spamUtils.get(user.getUser()).setMultip(1); MainBot.spamUtils.get(user).setMultip(1);
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));
if(!MainBot.spamUtils.get(user.getUser()).isOnSpam()) if(!MainBot.spamUtils.get(user).isOnSpam())
{ {
MainBot.spamUtils.get(user.getUser()).setOnSpam(true); MainBot.spamUtils.get(user).setOnSpam(true);
List<Role> spm = guild.getRolesByName("Spammer", false); List<Role> spm = guild.getRolesByName("Spammer", false);
try{ try{
move.exc(user, spm, true, guild, guildManager); move.exc(user, spm, true, guild, guildManager);
MainBot.spamUtils.get(user.getUser()).addMessage(event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamExtermine(user,MainBot.spamUtils.get(user.getUser()).getMultip())).complete()); MainBot.spamUtils.get(user).addMessage(event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamExtermine(user,MainBot.spamUtils.get(user.getUser()).getMultip())).complete());
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).setMinuteur(new Minuteur(MainBot.spamUtils.get(user).getMultip(), move.user, move.saveRoleUser, move.serveur, move.serveurManager,event));
MainBot.spamUtils.get(user.getUser()).launchMinuteur(); MainBot.spamUtils.get(user).launchMinuteur();
}catch (HierarchyException e){ }catch (HierarchyException e){
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
List<Message> messages = new ArrayList<Message>(){{ List<Message> messages = new ArrayList<Message>(){{
@ -81,7 +81,7 @@ public class AntiSpam {
add(event.getMessage()); add(event.getMessage());
}}; }};
new MessageTimeOut(messages,MainBot.messageTimeOut).start(); new MessageTimeOut(messages,MainBot.messageTimeOut).start();
MainBot.spamUtils.get(user.getUser()).setOnSpam(false); MainBot.spamUtils.get(user).setOnSpam(false);
} }
} }

View File

@ -41,19 +41,19 @@ public class Moderateur {
int nbMessage = 3; int nbMessage = 3;
int spam = 0; int spam = 0;
if(MainBot.spamUtils.containsKey(user.getUser()) && MainBot.spamUtils.get(user.getUser()).isOnSpam()){ if(MainBot.spamUtils.containsKey(user) && MainBot.spamUtils.get(user).isOnSpam()){
MainBot.spamUtils.get(user.getUser()).addMessage(event.getMessage()); MainBot.spamUtils.get(user).addMessage(event.getMessage());
} }
/******************************************** /********************************************
* si l'USER a deja envoyé un message * * si l'USER a deja envoyé un message *
********************************************/ ********************************************/
if(MainBot.historique.containsKey(user.getUser()))// Si le user a deja posté un message if(MainBot.historique.containsKey(user))// Si le user a deja posté un message
{ {
/******************************************** /********************************************
* COPIE des infos d"historique" vers TOI[] * * COPIE des infos d"historique" vers TOI[] *
********************************************/ ********************************************/
thisUserHistory = (ArrayList<Message>) MainBot.historique.get(user.getUser()).clone(); thisUserHistory = (ArrayList<Message>) MainBot.historique.get(user).clone();
/******************************************** /********************************************
* Ajout dernier message recu + dans histo' * * Ajout dernier message recu + dans histo' *
@ -61,7 +61,7 @@ public class Moderateur {
thisUserHistory.add(0,event.getMessage()); thisUserHistory.add(0,event.getMessage());
if(thisUserHistory.size()>nbMessage+1) if(thisUserHistory.size()>nbMessage+1)
thisUserHistory.remove(4); thisUserHistory.remove(4);
MainBot.historique.put(user.getUser(), thisUserHistory);// On ajoute dans l'historique TOI MainBot.historique.put(user, thisUserHistory);// On ajoute dans l'historique TOI
/***************************** /*****************************
* ANALYSE des messages * * ANALYSE des messages *
@ -81,7 +81,7 @@ public class Moderateur {
{ {
logger.info("\t - "+aMessage.getContentRaw()); logger.info("\t - "+aMessage.getContentRaw());
} }
MainBot.historique.put(user.getUser(), new ArrayList<Message>()); MainBot.historique.put(user, new ArrayList<Message>());
} }
} else { } else {
@ -92,7 +92,7 @@ public class Moderateur {
// on ajoute le dernier message dans "historique" // on ajoute le dernier message dans "historique"
thisUserHistory.add(0,event.getMessage()); thisUserHistory.add(0,event.getMessage());
MainBot.historique.put(user.getUser(), thisUserHistory); MainBot.historique.put(user, thisUserHistory);
} }
/********************************** /**********************************
* AFFICHAGE DE HISTORIQUE * * AFFICHAGE DE HISTORIQUE *
@ -104,24 +104,24 @@ public class Moderateur {
/******************************************** /********************************************
* Comptage du nombre de message * * Comptage du nombre de message *
********************************************/ ********************************************/
if(MainBot.message_compteur.containsKey(user.getUser()))// Si le user a deja posté un message if(MainBot.message_compteur.containsKey(user))// Si le user a deja posté un message
{ {
int cpt = MainBot.message_compteur.get(user.getUser()); int cpt = MainBot.message_compteur.get(user);
cpt++; cpt++;
//System.out.println("compteur : "+cpt); //System.out.println("compteur : "+cpt);
MainBot.message_compteur.put(user.getUser(), cpt); MainBot.message_compteur.put(user, cpt);
if(cpt > 5){ if(cpt > 5){
MainBot.message_compteur.put(user.getUser(),0); MainBot.message_compteur.put(user,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: ");
ArrayList<Message> histo = MainBot.historique.get(user.getUser()); ArrayList<Message> histo = MainBot.historique.get(user);
for (Message aMessage:histo ) for (Message aMessage:histo )
{ {
// logger.debug("\t*"+aMessage.getContent()); // logger.debug("\t*"+aMessage.getContent());
} }
} }
}else{ }else{
MainBot.message_compteur.put(user.getUser(), 1); MainBot.message_compteur.put(user, 1);
} }
return spam; return spam;

View File

@ -39,7 +39,7 @@ public class WebLoadUtils {
public void trackLoaded(AudioTrack track) { public void trackLoaded(AudioTrack track) {
logger.info("Single Track detected from web!"); logger.info("Single Track detected from web!");
userAudioTrack = new UserAudioTrack(user, track); //TODO userAudioTrack = new UserAudioTrack(user, track);
if(submit) if(submit)
audioM.play(audioM.getGuild(), audioM.getPlayedChanel(), audioM.getGuildMusicManager(), userAudioTrack, data.onHead); audioM.play(audioM.getGuild(), audioM.getPlayedChanel(), audioM.getGuildMusicManager(), userAudioTrack, data.onHead);
response = new ResponseEntity<>(new CommandResponseData("ADD", "Loaded"), HttpStatus.OK); response = new ResponseEntity<>(new CommandResponseData("ADD", "Loaded"), HttpStatus.OK);

View File

@ -10,27 +10,22 @@
<!-- CSS --> <!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<link href="/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="/css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
</head> </head>
<body class="blue-grey lighten-5" > <body class="blue-grey lighten-5" >
<!--__________________________________________________________--> <nav class="blue-grey darken-4 z-depth-3" role="navigation" >
<!-- NAV BAR -->
<!-- AND -->
<!-- LOGIN -->
<!--__________________________________________________________-->
<nav class="blue-grey darken-4 z-depth-3" role="navigation">
<div class="nav-wrapper container"> <div class="nav-wrapper container">
<a id="logo-container" href="/" class="brand-logo">Discord Bot</a> <a id="logo-container" href="/" class="brand-logo">Discord Bot</a>
<ul class="right hide-on-med-and-down"> <ul class="right hide-on-med-and-down">
<li > <li class="">
<a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a> <a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a>
</li> </li>
<li> <li class="" >
<a class="waves-effect waves-light" href="/music" >Music Control</a> <a class="waves-effect waves-light" href="/music">Music Control</a>
</li> </li>
<li id="nav-bar-account"> <li id="nav-bar-account">
<a class="dropdown-account" data-activates="dropdown1"><i class="material-icons">account_box</i></a> <a class="dropdown-account" data-activates="dropdown1"><i class="material-icons">account_box</i></a>
@ -39,14 +34,25 @@
</ul> </ul>
<ul id="nav-mobile" class="side-nav"> <ul id="nav-mobile" class="side-nav">
<li class="active"> <li class="center">
<a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a> <a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a>
</li> </li>
<li> <li class="center">
<a class="waves-effect waves-light sidenav-trigger" href="/music" data-target="slide-out" >Music Control</a> <a class="waves-effect waves-light" href="/music">Music Control</a>
</li> </li>
<!--TODO Connection mobile--> <li><div class="divider"></div></li>
<li><a class="center nav-change-guild">Change Guild</a></li>
<li>
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Account</a>
</li>
<li>
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Playlists</a>
</li>
<li class="divider"></li>
<li><a class="center red-text nav-disconnect" style="font-weight: bold">Disconnect</a></li>
</ul> </ul>
<a href="#" data-activates="nav-mobile" class="button-navbar-mobile button-collapse"><i class="material-icons">menu</i></a> <a href="#" data-activates="nav-mobile" class="button-navbar-mobile button-collapse"><i class="material-icons">menu</i></a>
</div> </div>
@ -55,9 +61,10 @@
<!-- Dropdown connected --> <!-- Dropdown connected -->
<ul id="dropdown_connected" class="dropdown-content "> <ul id="dropdown_connected" class="dropdown-content ">
<li> <li>
<a class="center blue-grey-text text-darken-4" id="nav-name" style="text-decoration: underline; font-weight: bold"></a> <a class="center blue-grey-text text-darken-4 tooltipped" data-position="left" data-delay="50" data-tooltip="It's you !" id="nav-name" style="font-weight: bold"></a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li><a class="center nav-change-guild" >Change Guild</a></li>
<li> <li>
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Account</a> <a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Account</a>
</li> </li>
@ -65,7 +72,8 @@
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Playlists</a> <a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Playlists</a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li><a class="center red-text" id="nav-disconnect" style="font-weight: bold">Disconnect</a></li>
<li><a class="center red-text nav-disconnect" style="font-weight: bold">Disconnect</a></li>
</ul> </ul>

View File

@ -66,8 +66,10 @@ function connected(){
} }
); );
nav_name.text(Cookies.get('name')); nav_name.text(Cookies.get('name'));
if(Cookies.get('guild') === undefined){ if (typeof needLogin !== 'undefined') {
getGuild() if (Cookies.get('guild') === undefined) {
getGuild()
}
} }
} }