Adding Daily Madame #5

This commit is contained in:
BrokenFire 2018-02-16 15:37:10 +01:00
parent a95aaa536f
commit 70bc064cf7
3 changed files with 44 additions and 2 deletions

View File

@ -22,12 +22,13 @@ public class Madame implements Commande{
@Override @Override
public void action(String[] args, MessageReceivedEvent event) { public void action(String[] args, MessageReceivedEvent event) {
if(event.getTextChannel().getName().equals("nsfw-over18")) {
if(event.getTextChannel().isNSFW()) {
Redirection redirect = new Redirection(); Redirection redirect = new Redirection();
boolean success=false; boolean success=false;
boolean error=false; boolean error=false;
int errorCp=0; int errorCp=0;
while(!success&&!error) while(!success && !error)
{ {
try { try {
event.getTextChannel().sendMessage(redirect.get("http://dites.bonjourmadame.fr/random")).queue(); event.getTextChannel().sendMessage(redirect.get("http://dites.bonjourmadame.fr/random")).queue();

View File

@ -2,6 +2,7 @@ package net.Broken;
import net.Broken.Tools.Command.CommandLoader; import net.Broken.Tools.Command.CommandLoader;
import net.Broken.Tools.DayListener.DayListener; import net.Broken.Tools.DayListener.DayListener;
import net.Broken.Tools.DayListener.Listeners.DailyMadame;
import net.Broken.Tools.DayListener.Listeners.ResetSpam; import net.Broken.Tools.DayListener.Listeners.ResetSpam;
import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.JDA;
@ -83,6 +84,7 @@ public class Init {
DayListener dayListener = DayListener.getInstance(); DayListener dayListener = DayListener.getInstance();
dayListener.addListener(new ResetSpam()); dayListener.addListener(new ResetSpam());
dayListener.addListener(new DailyMadame());
dayListener.start(); dayListener.start();
logger.debug("-----------------FIN INITIALISATION-----------------"); logger.debug("-----------------FIN INITIALISATION-----------------");

View File

@ -0,0 +1,39 @@
package net.Broken.Tools.DayListener.Listeners;
import net.Broken.MainBot;
import net.Broken.Tools.DayListener.NewDayListener;
import net.Broken.Tools.Redirection;
import net.dv8tion.jda.core.entities.TextChannel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
public class DailyMadame implements NewDayListener{
Logger logger = LogManager.getLogger();
@Override
public void onNewDay() {
Redirection redirect = new Redirection();
boolean success=false;
boolean error=false;
int errorCp=0;
TextChannel chanel = MainBot.jda.getTextChannelsByName("nsfw-over18", true).get(0);
while(!success && !error)
{
try {
chanel.sendMessage("Le Daily Madame mes petits cochons :kissing_heart:\n" + redirect.get("http://dites.bonjourmadame.fr/random")).queue();
success=true;
} catch (IOException e) {
errorCp++;
logger.warn("Erreur de redirection. (Essais n°"+errorCp+")");
if(errorCp>5)
{
logger.error("5 Erreur de redirection.");
error=true;
}
}
}
}
}