Change NSFW command detection
This commit is contained in:
parent
5d50c66842
commit
3183794599
@ -12,6 +12,7 @@ public interface Commande {
|
|||||||
void executed(boolean success, MessageReceivedEvent event);
|
void executed(boolean success, MessageReceivedEvent event);
|
||||||
boolean isPrivateUsable();
|
boolean isPrivateUsable();
|
||||||
boolean isAdminCmd();
|
boolean isAdminCmd();
|
||||||
|
boolean isNSFW();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,4 +77,9 @@ public class Cat implements Commande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,9 @@ public class DayTrigger implements Commande{
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,9 @@ public class Error implements Commande{
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,4 +68,9 @@ public class Flush implements Commande{
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,11 +145,7 @@ public class Help implements Commande {
|
|||||||
|
|
||||||
if(!event.isFromType(ChannelType.PRIVATE)){
|
if(!event.isFromType(ChannelType.PRIVATE)){
|
||||||
Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Command envoyées par message privé").setColor(Color.green).build()).complete();
|
Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Command envoyées par message privé").setColor(Color.green).build()).complete();
|
||||||
List<Message> messages = new ArrayList<Message>(){{
|
new MessageTimeOut(MainBot.messageTimeOut, rest, event.getMessage()).start();
|
||||||
add(rest);
|
|
||||||
add(event.getMessage());
|
|
||||||
}};
|
|
||||||
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,10 +156,10 @@ public class Help implements Commande {
|
|||||||
role = "Non Admin";
|
role = "Non Admin";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt),logger);
|
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getHelpList(role, txt),logger);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
logger.catching(e);
|
logger.catching(e);
|
||||||
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getInternalError(), logger);
|
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getInternalError(), logger);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,4 +183,9 @@ public class Help implements Commande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,4 +209,9 @@ public class Move implements Commande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,11 @@ public class Music implements Commande {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public AudioM getAudioManager(){
|
public AudioM getAudioManager(){
|
||||||
return audio;
|
return audio;
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,9 @@ public class Ass extends NumberedCommande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,9 @@ public class Boobs extends NumberedCommande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,50 +26,41 @@ public class Madame implements Commande{
|
|||||||
@Override
|
@Override
|
||||||
public void action(String[] args, MessageReceivedEvent event) {
|
public void action(String[] args, MessageReceivedEvent event) {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
|
Redirection redirect = new Redirection();
|
||||||
if(event.getTextChannel().isNSFW()) {
|
boolean success=false;
|
||||||
Redirection redirect = new Redirection();
|
boolean error=false;
|
||||||
boolean success=false;
|
int errorCp=0;
|
||||||
boolean error=false;
|
while(!success && !error)
|
||||||
int errorCp=0;
|
|
||||||
while(!success && !error)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
String url = redirect.get("http://dites.bonjourmadame.fr/random");
|
|
||||||
logger.debug("URL: "+url);
|
|
||||||
if(scanPageForTipeee(url)){
|
|
||||||
logger.debug("Advertisement detected! Retry! ("+url+")");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
event.getTextChannel().sendMessage(url).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;
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (StringIndexOutOfBoundsException e){
|
|
||||||
logger.catching(e);
|
|
||||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
try {
|
||||||
|
|
||||||
logger.warn("Erreur chanel.");
|
String url = redirect.get("http://dites.bonjourmadame.fr/random");
|
||||||
|
logger.debug("URL: "+url);
|
||||||
|
if(scanPageForTipeee(url)){
|
||||||
|
logger.debug("Advertisement detected! Retry! ("+url+")");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
event.getTextChannel().sendMessage(url).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;
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (StringIndexOutOfBoundsException e){
|
||||||
|
logger.catching(e);
|
||||||
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,23 +78,11 @@ public class Madame implements Commande{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
private boolean isAdvertisementUrl(String url){
|
public boolean isNSFW() {
|
||||||
//Scan url
|
return true;
|
||||||
if(url.toLowerCase().contains("club") && (url.toLowerCase().contains("rejoindre") || url.toLowerCase().contains("rejoignez"))){
|
|
||||||
logger.debug("Advertisement detected with \"club\" and \"rejoidre\" or \"rejoignez\"");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(url.contains("samedi") && url.contains("dimanche")){
|
|
||||||
logger.debug("Advertisement detected with \"samedi\" and \"dimanche\"");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean scanPageForTipeee(String url) throws StringIndexOutOfBoundsException, IOException{
|
private boolean scanPageForTipeee(String url) throws StringIndexOutOfBoundsException, IOException{
|
||||||
String content = FindContentOnWebPage.getUrlSource(url);
|
String content = FindContentOnWebPage.getUrlSource(url);
|
||||||
String imgClickLink = content.substring(content.indexOf("photo post"));
|
String imgClickLink = content.substring(content.indexOf("photo post"));
|
||||||
|
@ -11,40 +11,6 @@ public class Pipe extends NumberedCommande {
|
|||||||
super(LogManager.getLogger(), "http://feelation.com/","featured-img","img");
|
super(LogManager.getLogger(), "http://feelation.com/","featured-img","img");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
System.out.println("ok");
|
|
||||||
String pipeLine=null;
|
|
||||||
URL pipeURL = new URL(redirect.get("http://feelation.com/random"));
|
|
||||||
URLConnection cc = pipeURL.openConnection();
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(cc.getInputStream(), "UTF-8"));
|
|
||||||
String inputLine;
|
|
||||||
|
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null)
|
|
||||||
{
|
|
||||||
System.out.println(inputLine);
|
|
||||||
if(inputLine.contains("class=\"post photo\""))
|
|
||||||
{
|
|
||||||
String[] splited = inputLine.split("<");
|
|
||||||
for(String aString:splited)
|
|
||||||
{
|
|
||||||
if(aString.startsWith("<img src"))
|
|
||||||
{
|
|
||||||
pipeLine=aString;
|
|
||||||
pipeLine=inputLine.replaceAll("<img src=\"","");
|
|
||||||
pipeLine=pipeLine.substring(0,pipeLine.indexOf("\""));
|
|
||||||
System.out.println(pipeLine);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
event.getTextChannel().sendMessage(redirect.get("http://feelation.com/random")).queue();
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Pipe";
|
return "Pipe";
|
||||||
@ -59,4 +25,9 @@ public class Pipe extends NumberedCommande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,23 +20,13 @@ public class SM implements Commande {
|
|||||||
@Override
|
@Override
|
||||||
public void action(String[] args, MessageReceivedEvent event) {
|
public void action(String[] args, MessageReceivedEvent event) {
|
||||||
Redirection redirect= new Redirection();
|
Redirection redirect= new Redirection();
|
||||||
if(event.getTextChannel().getName().equals("nsfw-over18"))
|
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();
|
||||||
{
|
|
||||||
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 {
|
||||||
// event.getTextChannel().sendMessage(redirect.get("https://bonjourfetish.tumblr.com/random")).queue();
|
// event.getTextChannel().sendMessage(redirect.get("https://bonjourfetish.tumblr.com/random")).queue();
|
||||||
// } catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
// logger.warn("Erreur de redirection.");
|
// logger.warn("Erreur de redirection.");
|
||||||
// event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue();
|
// 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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,4 +44,9 @@ public class SM implements Commande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,7 @@ public class Ping implements Commande {
|
|||||||
event.getPrivateChannel().sendMessage(":arrow_right: Pong! `" + ping+ "ms`").queue();
|
event.getPrivateChannel().sendMessage(":arrow_right: Pong! `" + ping+ "ms`").queue();
|
||||||
else {
|
else {
|
||||||
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `" + ping + "ms`").complete();
|
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `" + ping + "ms`").complete();
|
||||||
List<Message> messages = new ArrayList<Message>(){{
|
new MessageTimeOut(MainBot.messageTimeOut, event.getMessage(), rest).start();
|
||||||
add(rest);
|
|
||||||
add(event.getMessage());
|
|
||||||
}};
|
|
||||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
|
||||||
}
|
}
|
||||||
LogManager.getLogger().debug("pong");
|
LogManager.getLogger().debug("pong");
|
||||||
}
|
}
|
||||||
@ -41,7 +37,6 @@ public class Ping implements Commande {
|
|||||||
@Override
|
@Override
|
||||||
public void executed(boolean success, MessageReceivedEvent event)
|
public void executed(boolean success, MessageReceivedEvent event)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,4 +49,9 @@ public class Ping implements Commande {
|
|||||||
public boolean isAdminCmd() {
|
public boolean isAdminCmd() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,11 @@ public class Spam implements Commande {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void pardon(MessageReceivedEvent event, String[] args){
|
public void pardon(MessageReceivedEvent event, String[] args){
|
||||||
|
|
||||||
Guild serveur = event.getGuild();
|
Guild serveur = event.getGuild();
|
||||||
|
@ -109,6 +109,11 @@ public class SpamInfo implements Commande{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String formatSecond(int second){
|
public String formatSecond(int second){
|
||||||
long days = TimeUnit.SECONDS.toDays(second);
|
long days = TimeUnit.SECONDS.toDays(second);
|
||||||
second -= TimeUnit.DAYS.toSeconds(days);
|
second -= TimeUnit.DAYS.toSeconds(days);
|
||||||
|
@ -101,6 +101,7 @@ public class MainBot {
|
|||||||
{
|
{
|
||||||
Commande cmdObj = commandes.get(cmd.commande);
|
Commande cmdObj = commandes.get(cmd.commande);
|
||||||
if(!cmdObj.isAdminCmd() || cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR)){
|
if(!cmdObj.isAdminCmd() || cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR)){
|
||||||
|
|
||||||
if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable())
|
if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable())
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -109,8 +110,15 @@ public class MainBot {
|
|||||||
}
|
}
|
||||||
else if (!cmd.event.isFromType(ChannelType.PRIVATE))
|
else if (!cmd.event.isFromType(ChannelType.PRIVATE))
|
||||||
{
|
{
|
||||||
commandes.get(cmd.commande).action(cmd.args, cmd.event);
|
if(!cmdObj.isNSFW() || cmd.event.getTextChannel().isNSFW()){
|
||||||
commandes.get(cmd.commande).executed(true, cmd.event);
|
commandes.get(cmd.commande).action(cmd.args, cmd.event);
|
||||||
|
commandes.get(cmd.commande).executed(true, cmd.event);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Message msg = cmd.event.getTextChannel().sendMessage(cmd.event.getAuthor().getAsMention() + "\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").complete();
|
||||||
|
new MessageTimeOut(messageTimeOut, msg, cmd.event.getMessage()).start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
|
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
|
||||||
@ -121,11 +129,7 @@ public class MainBot {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Message msg = cmd.event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete();
|
Message msg = cmd.event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete();
|
||||||
List<Message> messages = new ArrayList<Message>(){{
|
new MessageTimeOut(messageTimeOut, msg, cmd.event.getMessage()).start();
|
||||||
add(msg);
|
|
||||||
add(cmd.event.getMessage());
|
|
||||||
}};
|
|
||||||
new MessageTimeOut(messages, messageTimeOut).start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import java.net.URL;
|
|||||||
* Created by seb65 on 07/11/2016.
|
* Created by seb65 on 07/11/2016.
|
||||||
*/
|
*/
|
||||||
public abstract class NumberedCommande implements Commande{
|
public abstract class NumberedCommande implements Commande{
|
||||||
Logger logger = LogManager.getLogger();
|
private Logger logger = LogManager.getLogger();
|
||||||
public String HELP="T'es sérieux la?";
|
public String HELP="T'es sérieux la?";
|
||||||
int minNumber = 1;
|
int minNumber = 1;
|
||||||
int maxNumber = -1;
|
int maxNumber = -1;
|
||||||
@ -49,76 +49,65 @@ public abstract class NumberedCommande implements Commande{
|
|||||||
{
|
{
|
||||||
if(args.length == 0)
|
if(args.length == 0)
|
||||||
{
|
{
|
||||||
if(event.getTextChannel().getName().equals("nsfw-over18")) {
|
int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber)));
|
||||||
Redirection redirect= new Redirection();
|
String result = FindContentOnWebPage.doYourJob(baseURL + randomResult + "-2", divClass, htmlType);
|
||||||
int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber)));
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n"+result).queue();
|
||||||
String result = FindContentOnWebPage.doYourJob(baseURL + randomResult + "-2", divClass, htmlType);
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n"+result).queue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue();
|
|
||||||
|
|
||||||
logger.warn("Erreur chanel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(args[0].toLowerCase().equals("update"))
|
switch (args[0].toLowerCase()) {
|
||||||
{
|
case "update":
|
||||||
logger.info("update commande from "+event.getMessage().getAuthor().getName());
|
logger.info("update commande from " + event.getMessage().getAuthor().getName());
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Updating...").queue();
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: Updating...").queue();
|
||||||
|
|
||||||
int newNumber = maxNumber;
|
int newNumber = maxNumber;
|
||||||
try {
|
|
||||||
newNumber = LimitChecker.doYourJob(baseURL,maxNumber);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(newNumber == maxNumber)
|
|
||||||
{
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Aucune nouvelle image n'a était trouver :cry:").queue();
|
|
||||||
}
|
|
||||||
else if(newNumber-maxNumber == 1) event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: "+(newNumber-maxNumber)+" nouvelle image a été trouvé :kissing_heart:").queue();
|
|
||||||
else
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: "+(newNumber-maxNumber)+" nouvelles images on été trouvé :kissing_heart:").queue();
|
|
||||||
logger.info((newNumber-maxNumber)+" new image(s) found.");
|
|
||||||
maxNumber = newNumber;
|
|
||||||
}
|
|
||||||
else if(args[0].toLowerCase().equals("get")) {
|
|
||||||
if (args.length >= 2)
|
|
||||||
{
|
|
||||||
|
|
||||||
int number = -1;
|
|
||||||
try {
|
try {
|
||||||
number = Integer.parseInt(args[1]);
|
newNumber = LimitChecker.doYourJob(baseURL, maxNumber);
|
||||||
URL url = new URL(baseURL + number + "-2/");
|
|
||||||
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
|
|
||||||
huc.setRequestMethod("GET");
|
|
||||||
huc.connect();
|
|
||||||
int result = huc.getResponseCode();
|
|
||||||
if (result == 200) {
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n" + baseURL + number + "-2/").queue();
|
|
||||||
} else {
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Page introuvable (404)").queue();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.catching(e);
|
e.printStackTrace();
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur interne...").queue();
|
|
||||||
}
|
}
|
||||||
}
|
if (newNumber == maxNumber) {
|
||||||
else{
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: Aucune nouvelle image n'a était trouver :cry:").queue();
|
||||||
|
} else if (newNumber - maxNumber == 1)
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: " + (newNumber - maxNumber) + " nouvelle image a été trouvé :kissing_heart:").queue();
|
||||||
|
else
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: " + (newNumber - maxNumber) + " nouvelles images on été trouvé :kissing_heart:").queue();
|
||||||
|
logger.info((newNumber - maxNumber) + " new image(s) found.");
|
||||||
|
maxNumber = newNumber;
|
||||||
|
break;
|
||||||
|
case "get":
|
||||||
|
if (args.length >= 2) {
|
||||||
|
|
||||||
|
int number = -1;
|
||||||
|
try {
|
||||||
|
number = Integer.parseInt(args[1]);
|
||||||
|
URL url = new URL(baseURL + number + "-2/");
|
||||||
|
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
|
||||||
|
huc.setRequestMethod("GET");
|
||||||
|
huc.connect();
|
||||||
|
int result = huc.getResponseCode();
|
||||||
|
if (result == 200) {
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n" + baseURL + number + "-2/").queue();
|
||||||
|
} else {
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Page introuvable (404)").queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.catching(e);
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur interne...").queue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue();
|
||||||
|
logger.warn("Bad Argument: " + event.getMessage().getContent() + " From " + event.getAuthor().getName());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue();
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue();
|
||||||
logger.warn("Bad Argument: "+event.getMessage().getContent()+" From "+event.getAuthor().getName());
|
logger.warn("Bad Argument: " + event.getMessage().getContent() + " From " + event.getAuthor().getName());
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help "+this.toString().toLowerCase()+"` pour plus d'info ").queue();
|
|
||||||
logger.warn("Bad Argument: "+event.getMessage().getContent()+" From "+event.getAuthor().getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -15,6 +15,7 @@ public class EmbedMessageUtils {
|
|||||||
return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EmbedBuilder getError(String message) {
|
public static EmbedBuilder getError(String message) {
|
||||||
EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
|
EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
|
||||||
return temp;
|
return temp;
|
||||||
@ -45,7 +46,6 @@ public class EmbedMessageUtils {
|
|||||||
return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " est de retour, fais gaffe!\nJe te surveille!").setImage("https://media.giphy.com/media/3o7TKwBctlv08kY08M/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build();
|
return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " est de retour, fais gaffe!\nJe te surveille!").setImage("https://media.giphy.com/media/3o7TKwBctlv08kY08M/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static MessageEmbed getHelp(String command) throws FileNotFoundException {
|
public static MessageEmbed getHelp(String command) throws FileNotFoundException {
|
||||||
String name = command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase();
|
String name = command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase();
|
||||||
String message = new ResourceLoader().getFile("Help/"+name+"/fr/main.md");
|
String message = new ResourceLoader().getFile("Help/"+name+"/fr/main.md");
|
||||||
@ -79,7 +79,6 @@ public class EmbedMessageUtils {
|
|||||||
return new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help flush' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
return new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help flush' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static MessageEmbed getRegister(String message) {
|
public static MessageEmbed getRegister(String message) {
|
||||||
return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
||||||
}
|
}
|
||||||
@ -105,4 +104,5 @@ public class EmbedMessageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -5,6 +5,8 @@ import net.dv8tion.jda.core.exceptions.ErrorResponseException;
|
|||||||
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.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MessageTimeOut extends Thread{
|
public class MessageTimeOut extends Thread{
|
||||||
@ -16,6 +18,11 @@ public class MessageTimeOut extends Thread{
|
|||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageTimeOut(int second, Message... messages) {
|
||||||
|
this.messages = Arrays.asList(messages);
|
||||||
|
this.second = second;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.debug("Timer for message deletion stated...");
|
logger.debug("Timer for message deletion stated...");
|
||||||
|
Loading…
Reference in New Issue
Block a user