Merge branch 'master' into devel
This commit is contained in:
commit
adc50b3db8
@ -1,28 +1,31 @@
|
|||||||
package net.Broken.Commands.Over18;
|
package net.Broken.Commands.Over18;
|
||||||
|
|
||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
|
import net.Broken.Tools.FindContentOnWebPage;
|
||||||
import net.Broken.Tools.Redirection;
|
import net.Broken.Tools.Redirection;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Remove this
|
* TODO Remove this
|
||||||
*/
|
*/
|
||||||
public class SM implements Commande {
|
public class SM implements Commande {
|
||||||
Logger logger = LogManager.getLogger();
|
Logger logger = LogManager.getLogger();
|
||||||
public String HELP="T'es sérieux la?";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void action(String[] args, MessageReceivedEvent event) {
|
public void action(String[] args, MessageReceivedEvent event) {
|
||||||
Redirection redirect= new Redirection();
|
Redirection redirect= new Redirection();
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: SM n'est plus disponible pour le moment. Pour plus d'info: https://lc.cx/cbSw :warning: ").queue();
|
try {
|
||||||
// try {
|
String redirectUrl = redirect.get("https://bonjourfetish.tumblr.com/random");
|
||||||
// event.getTextChannel().sendMessage(redirect.get("https://bonjourfetish.tumblr.com/random")).queue();
|
String img = FindContentOnWebPage.doYourJob(redirectUrl, "article-picture center", "img");
|
||||||
// } catch (IOException e) {
|
event.getTextChannel().sendMessage(img).queue();
|
||||||
// logger.warn("Erreur de redirection.");
|
} catch (IOException e) {
|
||||||
// event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
logger.warn("Erreur de redirection.");
|
||||||
// }
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,26 +2,61 @@ package net.Broken.Commands.Over18;
|
|||||||
|
|
||||||
import net.Broken.Commande;
|
import net.Broken.Commande;
|
||||||
import net.Broken.Tools.EmbedMessageUtils;
|
import net.Broken.Tools.EmbedMessageUtils;
|
||||||
|
import net.Broken.Tools.FindContentOnWebPage;
|
||||||
import net.Broken.Tools.Redirection;
|
import net.Broken.Tools.Redirection;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Suicide implements Commande{
|
public class Suicide implements Commande{
|
||||||
|
|
||||||
private String redirectUrl = "https://suicidegirlsandhopefuls.tumblr.com/random";
|
private Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void action(String[] args, MessageReceivedEvent event) {
|
public void action(String[] args, MessageReceivedEvent event) {
|
||||||
Redirection redirection = new Redirection();
|
Redirection redirection = new Redirection();
|
||||||
|
|
||||||
|
String base = "http://suicidegirls.tumblr.com";
|
||||||
|
String redirectUrl = null;
|
||||||
try {
|
try {
|
||||||
event.getTextChannel().sendMessage(redirection.get(redirectUrl)).queue();
|
|
||||||
|
Boolean success = false;
|
||||||
|
int tryCount = 0;
|
||||||
|
while(!success && tryCount < 10 ){
|
||||||
|
redirectUrl = redirection.get(base + "/random");
|
||||||
|
|
||||||
|
String img;
|
||||||
|
try{
|
||||||
|
img = FindContentOnWebPage.doYourJob(redirectUrl, "post photo_nav_caption", "img");
|
||||||
|
event.getTextChannel().sendMessage(img).queue();
|
||||||
|
success = true;
|
||||||
|
|
||||||
|
}catch (StringIndexOutOfBoundsException | IOException e){
|
||||||
|
logger.debug("Photo_nav not found try photoset");
|
||||||
|
|
||||||
|
try {
|
||||||
|
String mid = FindContentOnWebPage.doYourJob(redirectUrl, "html_photoset", "iframe");
|
||||||
|
img = FindContentOnWebPage.doYourJob(base + mid, "photoset_row", "img");
|
||||||
|
event.getTextChannel().sendMessage(img).queue();
|
||||||
|
success = true;
|
||||||
|
} catch (StringIndexOutOfBoundsException | IOException e1) {
|
||||||
|
logger.debug("Nothing found, assume it's a comment.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
tryCount ++;
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogManager.getLogger().catching(e);
|
logger.catching(e);
|
||||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,11 +32,16 @@ import java.util.List;
|
|||||||
@RequestMapping("/api/music/")
|
@RequestMapping("/api/music/")
|
||||||
public class MusicWebAPIController {
|
public class MusicWebAPIController {
|
||||||
Logger logger = LogManager.getLogger();
|
Logger logger = LogManager.getLogger();
|
||||||
@Autowired
|
private final
|
||||||
UserRepository userRepository;
|
UserRepository userRepository;
|
||||||
|
|
||||||
UserUtils userUtils = UserUtils.getInstance();
|
UserUtils userUtils = UserUtils.getInstance();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public MusicWebAPIController(UserRepository userRepository) {
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/currentMusicInfo")
|
@RequestMapping("/currentMusicInfo")
|
||||||
public ResponseEntity<CurrentMusicData> getCurrentM(@RequestParam(value = "guild") String guildId){
|
public ResponseEntity<CurrentMusicData> getCurrentM(@RequestParam(value = "guild") String guildId){
|
||||||
|
@ -16,6 +16,7 @@ public class FindContentOnWebPage {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static String doYourJob(String url, String divClass, String htmlType) throws IOException {
|
public static String doYourJob(String url, String divClass, String htmlType) throws IOException {
|
||||||
|
// System.out.println(url);
|
||||||
String source = getSourceUrl(url);
|
String source = getSourceUrl(url);
|
||||||
int divIndex = source.indexOf(divClass);
|
int divIndex = source.indexOf(divClass);
|
||||||
String sub = source.substring(divIndex);
|
String sub = source.substring(divIndex);
|
||||||
@ -38,6 +39,7 @@ public class FindContentOnWebPage {
|
|||||||
public static String getSourceUrl(String url) throws IOException {
|
public static String getSourceUrl(String url) throws IOException {
|
||||||
URL urlC = new URL(url);
|
URL urlC = new URL(url);
|
||||||
URLConnection yc = urlC.openConnection();
|
URLConnection yc = urlC.openConnection();
|
||||||
|
yc.setRequestProperty("User-Agent","Googlebot");
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||||
yc.getInputStream(), "UTF-8"));
|
yc.getInputStream(), "UTF-8"));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
|
@ -22,7 +22,9 @@ public class Redirection {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public String get(String urlString) throws IOException {
|
public String get(String urlString) throws IOException {
|
||||||
|
System.setProperty("http.agent","Googlebot");
|
||||||
URLConnection con = new URL(urlString).openConnection();
|
URLConnection con = new URL(urlString).openConnection();
|
||||||
|
con.setRequestProperty("User-Agent","Googlebot");
|
||||||
//System.out.println( "orignal url: " + con.getURL() );
|
//System.out.println( "orignal url: " + con.getURL() );
|
||||||
con.connect();
|
con.connect();
|
||||||
//System.out.println( "connected url: " + con.getURL() );
|
//System.out.println( "connected url: " + con.getURL() );
|
||||||
|
@ -4,11 +4,15 @@ import net.Broken.DB.Entity.PlaylistEntity;
|
|||||||
import net.Broken.DB.Entity.TrackEntity;
|
import net.Broken.DB.Entity.TrackEntity;
|
||||||
import net.Broken.DB.Entity.UserEntity;
|
import net.Broken.DB.Entity.UserEntity;
|
||||||
import net.Broken.DB.Repository.UserRepository;
|
import net.Broken.DB.Repository.UserRepository;
|
||||||
|
import net.Broken.MainBot;
|
||||||
import net.Broken.RestApi.Commands.Play;
|
import net.Broken.RestApi.Commands.Play;
|
||||||
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,7 +25,12 @@ public class GeneralWebView {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/")
|
@RequestMapping("/")
|
||||||
public String music(Model model){
|
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId){
|
||||||
|
Guild guild = MainBot.jda.getGuildById(guildId);
|
||||||
|
if(guild != null)
|
||||||
|
model.addAttribute("guild_name", guild.getName());
|
||||||
|
else
|
||||||
|
model.addAttribute("guild_name", "");
|
||||||
|
|
||||||
return CheckPage.getPageIfReady("index");
|
return CheckPage.getPageIfReady("index");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package net.Broken.webView;
|
package net.Broken.webView;
|
||||||
|
|
||||||
|
import net.Broken.MainBot;
|
||||||
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +13,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
@Controller
|
@Controller
|
||||||
public class MusicWebView {
|
public class MusicWebView {
|
||||||
@RequestMapping("/music")
|
@RequestMapping("/music")
|
||||||
public String music(Model model){
|
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId){
|
||||||
|
Guild guild = MainBot.jda.getGuildById(guildId);
|
||||||
|
if(guild != null)
|
||||||
|
model.addAttribute("guild_name", guild.getName());
|
||||||
|
else
|
||||||
|
model.addAttribute("guild_name", "");
|
||||||
|
|
||||||
return CheckPage.getPageIfReady("music");
|
return CheckPage.getPageIfReady("music");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<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="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||||
<title>Music Control - Discord Bot</title>
|
<title>Claptrap Bot</title>
|
||||||
<link rel="icon"
|
<link rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="favicon.png"/>
|
href="favicon.png"/>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 55 KiB |
@ -79,7 +79,9 @@ function disconnected() {
|
|||||||
console.log("Disconnected");
|
console.log("Disconnected");
|
||||||
nav_bar_account_link.html(disconnected_link);
|
nav_bar_account_link.html(disconnected_link);
|
||||||
var modalConnection = $('#modal_connection');
|
var modalConnection = $('#modal_connection');
|
||||||
modalConnection.modal();
|
modalConnection.modal({
|
||||||
|
dismissible: false // Modal can be dismissed by clicking outside of the modal
|
||||||
|
});
|
||||||
if (typeof needLogin !== 'undefined'){
|
if (typeof needLogin !== 'undefined'){
|
||||||
modalConnection.modal('open');
|
modalConnection.modal('open');
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,30 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<!--__________________________________________________________-->
|
<!--__________________________________________________________-->
|
||||||
<!-- NAV BAR -->
|
<!-- NAV BAR -->
|
||||||
<!-- AND -->
|
<!-- AND -->
|
||||||
<!-- LOGIN -->
|
<!-- LOGIN -->
|
||||||
<!--__________________________________________________________-->
|
<!--__________________________________________________________-->
|
||||||
<div th:fragment="header (page)">
|
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
|
<div th:fragment="header (page, guild_name)">
|
||||||
<nav class="blue-grey darken-4 z-depth-3" role="navigation" >
|
<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">Claptrap Bot</a>
|
<a id="logo-container" href="/" class="brand-logo">Claptrap Bot</a>
|
||||||
<ul class="right hide-on-med-and-down">
|
<ul class="right hide-on-med-and-down">
|
||||||
|
<li>
|
||||||
|
<a class="nav-change-guild truncate waves-effect waves-light btn-flat grey-text text-darken-1" th:text="${guild_name}" style="margin-top: 2px;margin-right: 0px;"></a>
|
||||||
|
</li>
|
||||||
<li class="" th:classappend="(${page} == 'home')? 'active' : ''">
|
<li class="" th:classappend="(${page} == 'home')? 'active' : ''">
|
||||||
<a class="waves-effect waves-light" href="/">Home</a>
|
<a class="waves-effect waves-light" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="" th:classappend="(${page} == 'music')? 'active' : ''">
|
<li class="disable" th:classappend="(${page} == 'music')? 'active' : ''">
|
||||||
<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 dropdown-trigger" data-target="dropdown_connected"><i class="material-icons">account_box</i></a>
|
<a class="dropdown-account dropdown-trigger" data-target="dropdown_connected"><i class="material-icons">account_box</i></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<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="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||||
<title>Discord Bot</title>
|
<title>Claptrap Bot</title>
|
||||||
<link rel="icon"
|
<link rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="/favicon.png"/>
|
href="/favicon.png"/>
|
||||||
@ -16,12 +16,13 @@
|
|||||||
|
|
||||||
<body class="blue-grey lighten-5" >
|
<body class="blue-grey lighten-5" >
|
||||||
|
|
||||||
<div th:replace="header :: header ('home')">...</div>
|
<div th:replace="header :: header ('home',${guild_name})">...</div>
|
||||||
|
|
||||||
<div class="section no-pad-bot main" id="index-banner">
|
<div class="section no-pad-bot main" id="index-banner">
|
||||||
<div class="center center-align">
|
<div class="center center-align">
|
||||||
<h2>Home Page</h2>
|
<h2>Home Page</h2>
|
||||||
<h1>Coming Soon</h1>
|
<h1>Coming Soon</h1>
|
||||||
|
<img src="/favicon.png" class="responsive-img"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<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="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||||
<title>Music Control - Discord Bot</title>
|
<title>Claptrap Bot</title>
|
||||||
<link rel="icon"
|
<link rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="/favicon.png"/>
|
href="/favicon.png"/>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<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="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||||
<title>Music Control - Discord Bot</title>
|
<title>Music Control - Claptrap Bot</title>
|
||||||
<link rel="icon"
|
<link rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="favicon.png"/>
|
href="favicon.png"/>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<body class="blue-grey lighten-5" >
|
<body class="blue-grey lighten-5" >
|
||||||
|
|
||||||
<div th:replace="header :: header ('music')">...</div>
|
<div th:replace="header :: header ('music',${guild_name})">...</div>
|
||||||
|
|
||||||
<div class="section no-pad-bot main" id="index-banner">
|
<div class="section no-pad-bot main" id="index-banner">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<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="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||||
<title>User Registration - Discord Bot</title>
|
<title>Sign up - Claptrap Bot</title>
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.png"/>
|
<link rel="icon" type="image/x-icon" href="favicon.png"/>
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<body class="blue-grey lighten-5" >
|
<body class="blue-grey lighten-5" >
|
||||||
|
|
||||||
<div th:replace="header :: header ('')">...</div>
|
<div th:replace="header :: header ('','')">...</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user