Forget to check advertisement on daily madame

This commit is contained in:
Sebastien 2018-03-05 14:18:50 +01:00
parent 16ba70b650
commit 2d17b1c295
2 changed files with 13 additions and 4 deletions

View File

@ -32,7 +32,7 @@ public class Madame implements Commande{
String url = redirect.get("http://dites.bonjourmadame.fr/random"); String url = redirect.get("http://dites.bonjourmadame.fr/random");
logger.debug("URL: "+url); logger.debug("URL: "+url);
if(scanPageForTipeee(url)){ if(scanPageForTipeee(url, logger)){
logger.debug("Advertisement detected! Retry! ("+url+")"); logger.debug("Advertisement detected! Retry! ("+url+")");
} }
else{ else{
@ -82,7 +82,7 @@ public class Madame implements Commande{
* @throws StringIndexOutOfBoundsException * @throws StringIndexOutOfBoundsException
* @throws IOException * @throws IOException
*/ */
private boolean scanPageForTipeee(String url) throws StringIndexOutOfBoundsException, IOException{ public static boolean scanPageForTipeee(String url, Logger logger) throws StringIndexOutOfBoundsException, IOException{
String content = FindContentOnWebPage.getSourceUrl(url); String content = FindContentOnWebPage.getSourceUrl(url);
String imgClickLink = content.substring(content.indexOf("photo post")); String imgClickLink = content.substring(content.indexOf("photo post"));
imgClickLink = imgClickLink.substring(imgClickLink.indexOf("<a")); imgClickLink = imgClickLink.substring(imgClickLink.indexOf("<a"));

View File

@ -1,5 +1,6 @@
package net.Broken.Tools.DayListener.Listeners; package net.Broken.Tools.DayListener.Listeners;
import net.Broken.Commands.Over18.Madame;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.Tools.DayListener.NewDayListener; import net.Broken.Tools.DayListener.NewDayListener;
import net.Broken.Tools.Redirection; import net.Broken.Tools.Redirection;
@ -24,8 +25,16 @@ public class DailyMadame implements NewDayListener{
while(!success && !error) while(!success && !error)
{ {
try { try {
String url = redirect.get("http://dites.bonjourmadame.fr/random");
logger.debug("URL: "+url);
if(Madame.scanPageForTipeee(url, logger)){
logger.debug("Advertisement detected! Retry! ("+url+")");
}
else{
chanel.sendMessage("Le Daily Madame mes petits cochons :kissing_heart:\n" + redirect.get("http://dites.bonjourmadame.fr/random")).queue(); chanel.sendMessage("Le Daily Madame mes petits cochons :kissing_heart:\n" + redirect.get("http://dites.bonjourmadame.fr/random")).queue();
success=true; success=true;
}
} catch (IOException e) { } catch (IOException e) {
errorCp++; errorCp++;
logger.warn("Erreur de redirection. (Essais n°"+errorCp+")"); logger.warn("Erreur de redirection. (Essais n°"+errorCp+")");