Fix Ass, Boobs and Pipe command
This commit is contained in:
parent
f7fcae7260
commit
bc6f559dd3
@ -101,7 +101,6 @@ public class MainBot {
|
||||
commandes.put("sm",new SM());
|
||||
commandes.put("madame",new Madame());
|
||||
commandes.put("cat",new Cat());
|
||||
|
||||
//On recupere le l'id serveur
|
||||
Guild serveur = jda.getGuilds().get(0);
|
||||
|
||||
|
84
src/net/borken/Outils/LimitChecker.java
Normal file
84
src/net/borken/Outils/LimitChecker.java
Normal file
@ -0,0 +1,84 @@
|
||||
package net.borken.Outils;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 20/03/2017.
|
||||
*/
|
||||
public class LimitChecker {
|
||||
static Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
public static int doYourJob(String baseURL, int minNumber) throws IOException {
|
||||
int number = minNumber;
|
||||
URL u = null;
|
||||
int result = -1;
|
||||
|
||||
while(result != 404 )
|
||||
{
|
||||
u = new URL( baseURL+number+"-2/");
|
||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
||||
huc.setRequestMethod ("GET");
|
||||
huc.connect ();
|
||||
result = huc.getResponseCode();
|
||||
logger.debug("URL: "+u.toString()+" Result: "+result);
|
||||
if(result!=404)
|
||||
number += 500;
|
||||
}
|
||||
number-=500;
|
||||
result = -1;
|
||||
logger.debug("First pass: "+number);
|
||||
while(result != 404 )
|
||||
{
|
||||
u = new URL( baseURL+number+"-2/");
|
||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
||||
huc.setRequestMethod ("GET");
|
||||
huc.connect ();
|
||||
result = huc.getResponseCode();
|
||||
logger.debug("URL: "+u.toString()+" Result: "+result);
|
||||
if(result!=404)
|
||||
number += 100;
|
||||
}
|
||||
number-=100;
|
||||
result = -1;
|
||||
logger.debug("Second pass: "+number);
|
||||
while(result != 404 )
|
||||
{
|
||||
u = new URL( baseURL+number+"-2/");
|
||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
||||
huc.setRequestMethod ("GET");
|
||||
huc.connect ();
|
||||
result = huc.getResponseCode();
|
||||
logger.debug("URL: "+u.toString()+" Result: "+result);
|
||||
if(result!=404)
|
||||
number += 10;
|
||||
}
|
||||
number-=10;
|
||||
result = -1;
|
||||
logger.debug("Third pass: "+number);
|
||||
while(result != 404 )
|
||||
{
|
||||
u = new URL( baseURL+number+"-2/");
|
||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
||||
huc.setRequestMethod ("GET");
|
||||
huc.connect ();
|
||||
result = huc.getResponseCode();
|
||||
logger.debug("URL: "+u.toString()+" Result: "+result);
|
||||
if(result!=404)
|
||||
number += 1;
|
||||
}
|
||||
number-=1;
|
||||
logger.debug("Final pass: "+number);
|
||||
return number;
|
||||
|
||||
|
||||
}
|
||||
}
|
66
src/net/borken/commandes/NumberedCommande.java
Normal file
66
src/net/borken/commandes/NumberedCommande.java
Normal file
@ -0,0 +1,66 @@
|
||||
package net.borken.commandes;
|
||||
import net.borken.Commande;
|
||||
import net.borken.Outils.LimitChecker;
|
||||
import net.borken.Outils.Redirection;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 07/11/2016.
|
||||
*/
|
||||
public abstract class NumberedCommande implements Commande{
|
||||
Logger logger = LogManager.getLogger();
|
||||
public String HELP="T'es sérieux la?";
|
||||
int minNumber = 1;
|
||||
int maxNumber = -1;
|
||||
String baseURL;
|
||||
|
||||
|
||||
public NumberedCommande(Logger logger, String baseURL) {
|
||||
this.logger = logger;
|
||||
this.baseURL = baseURL;
|
||||
try {
|
||||
logger.info("Checking max...");
|
||||
maxNumber = LimitChecker.doYourJob(baseURL, minNumber);
|
||||
logger.info("New limit is "+maxNumber);
|
||||
} catch (IOException e) {
|
||||
logger.catching(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
if(event.getTextChannel().getName().equals("over18")) {
|
||||
Redirection redirect= new Redirection();
|
||||
int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber)));
|
||||
event.getTextChannel().sendMessage(baseURL+randomResult+"-2/").queue();
|
||||
}
|
||||
else
|
||||
{
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
||||
|
||||
logger.warn("Erreur chanel.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help(String[] args) {
|
||||
return HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,51 +1,14 @@
|
||||
package net.borken.commandes.Over18;
|
||||
|
||||
import net.borken.Commande;
|
||||
import net.borken.Outils.Redirection;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import net.borken.commandes.NumberedCommande;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 07/11/2016.
|
||||
*/
|
||||
public class Ass implements Commande{
|
||||
Logger logger = LogManager.getLogger();
|
||||
public String HELP="T'es sérieux la?";
|
||||
|
||||
@Override
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
if(event.getTextChannel().getName().equals("over18")) {
|
||||
Redirection redirect= new Redirection();
|
||||
try {
|
||||
event.getTextChannel().sendMessage(redirect.get("http://les400culs.com/random")).queue();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Erreur de redirection.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
||||
|
||||
logger.warn("Erreur chanel.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help(String[] args) {
|
||||
return HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
public class Ass extends NumberedCommande {
|
||||
|
||||
public Ass() {
|
||||
super(LogManager.getLogger(), "http://les400culs.com/");
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,14 @@
|
||||
package net.borken.commandes.Over18;
|
||||
|
||||
import net.borken.Commande;
|
||||
import net.borken.Outils.Redirection;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import net.borken.commandes.NumberedCommande;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 07/11/2016.
|
||||
*/
|
||||
public class Boobs implements Commande {
|
||||
Logger logger = LogManager.getLogger();
|
||||
public String HELP="T'es sérieux la?";
|
||||
|
||||
@Override
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
if(event.getTextChannel().getName().equals("over18")) {
|
||||
Redirection redirect = new Redirection();
|
||||
try {
|
||||
event.getTextChannel().sendMessage(redirect.get("http://beautifulphotosbeautifulboobs.tumblr.com/random")).queue();
|
||||
//event.getTextChannel().sendMessage(redirect.get("http://lesaintdesseins.fr/random")).queue();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Erreur de redirection.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
||||
logger.warn("Erreur chanel.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help(String[] args) {
|
||||
return HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
public class Boobs extends NumberedCommande {
|
||||
|
||||
public Boobs() {
|
||||
super(LogManager.getLogger(), "http://lesaintdesseins.fr/");
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,18 @@
|
||||
package net.borken.commandes.Over18;
|
||||
|
||||
import net.borken.Commande;
|
||||
import net.borken.Outils.Redirection;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import net.borken.commandes.NumberedCommande;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 07/11/2016.
|
||||
*/
|
||||
public class Pipe implements Commande {
|
||||
Logger logger = LogManager.getLogger();
|
||||
public String HELP="T'es sérieux la?";
|
||||
@Override
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return false;
|
||||
public class Pipe extends NumberedCommande {
|
||||
public Pipe() {
|
||||
super(LogManager.getLogger(), "http://feelation.com/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
|
||||
Redirection redirect= new Redirection();
|
||||
if(event.getTextChannel().getName().equals("over18"))
|
||||
{
|
||||
|
||||
try {
|
||||
System.out.println("ok");
|
||||
/*
|
||||
System.out.println("ok");
|
||||
String pipeLine=null;
|
||||
URL pipeURL = new URL(redirect.get("http://feelation.com/random"));
|
||||
URLConnection cc = pipeURL.openConnection();
|
||||
@ -63,28 +44,5 @@ public class Pipe implements Commande {
|
||||
|
||||
in.close();
|
||||
event.getTextChannel().sendMessage(redirect.get("http://feelation.com/random")).queue();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Erreur de redirection.");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
||||
|
||||
logger.warn("Erreur chanel.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help(String[] args) {
|
||||
return HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(boolean success, MessageReceivedEvent event) {
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user