Correct SM and suicide crash

This commit is contained in:
Sebastien 2018-12-04 16:52:42 +02:00
parent a1b8c4761c
commit be84a0a1ad
4 changed files with 6 additions and 5 deletions

View File

@ -20,11 +20,12 @@ public class SM implements Commande {
Redirection redirect= new Redirection();
try {
String redirectUrl = redirect.get("https://bonjourfetish.tumblr.com/random");
logger.debug(redirectUrl);
String img = FindContentOnWebPage.doYourJob(redirectUrl, "article-picture center", "img");
event.getTextChannel().sendMessage(img).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();
logger.warn("Redirection fail.");
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Redirection fail (5 attempt), Try again__**:warning: ").queue();
}
}

View File

@ -39,7 +39,7 @@ public class FindContentOnWebPage {
public static String getSourceUrl(String url) throws IOException {
URL urlC = new URL(url);
URLConnection yc = urlC.openConnection();
yc.setRequestProperty("User-Agent","Googlebot");
yc.setRequestProperty("User-Agent","Googlebot/2.1 (+http://www.googlebot.com/bot.html)");
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream(), "UTF-8"));
String inputLine;

View File

@ -24,7 +24,7 @@ public class Redirection {
public String get(String urlString) throws IOException {
System.setProperty("http.agent","Googlebot");
URLConnection con = new URL(urlString).openConnection();
con.setRequestProperty("User-Agent","Googlebot");
con.setRequestProperty("User-Agent","Googlebot/2.1 (+http://www.googlebot.com/bot.html)");
//System.out.println( "orignal url: " + con.getURL() );
con.connect();
//System.out.println( "connected url: " + con.getURL() );

View File

@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<meta name="description" content="Claptrap discord bot at your service! Me and beautiful web interface are ready to serve you! Music control, config, news, you can do anything whit my web page!"/>
<meta name="description" content="Claptrap discord bot at your service! Add me to your discord server and my beautiful web interface will be there for you ! Music control, config, news, you can do anything with my web page!"/>
<title>Claptrap Bot</title>
<link rel="icon"
type="image/x-icon"