Merge branch 'devel'

This commit is contained in:
BrokenFire 2018-02-27 15:47:17 +01:00
commit 3cac9bb0e5
34 changed files with 384 additions and 198 deletions

View File

@ -42,7 +42,7 @@ dependencies {
// Use MySQL Connector-J
compile 'mysql:mysql-connector-java'
compile 'org.reflections:reflections:0.9.11'
compile 'org.apache.commons:commons-lang3:3.7'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.jayway.jsonpath:json-path')

View File

@ -12,6 +12,7 @@ public interface Commande {
void executed(boolean success, MessageReceivedEvent event);
boolean isPrivateUsable();
boolean isAdminCmd();
boolean isNSFW();
}

View File

@ -77,4 +77,9 @@ public class Cat implements Commande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -44,4 +44,9 @@ public class DayTrigger implements Commande{
public boolean isAdminCmd() {
return true;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -38,4 +38,9 @@ public class Error implements Commande{
public boolean isAdminCmd() {
return true;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -68,4 +68,9 @@ public class Flush implements Commande{
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -6,6 +6,7 @@ import net.Broken.RestApi.CommandInterface;
import net.Broken.Tools.EmbedMessageUtils;
import net.Broken.Tools.MessageTimeOut;
import net.Broken.Tools.PrivateMessage;
import net.Broken.Tools.TableRenderer;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.ChannelType;
@ -26,6 +27,7 @@ import java.util.Map;
*/
public class Help implements Commande {
Logger logger = LogManager.getLogger();
private int cellLenght = 25;
@Override
public boolean called(String[] args, MessageReceivedEvent event) {
return true;
@ -114,7 +116,12 @@ public class Help implements Commande {
}
else
{
StringBuilder txt= new StringBuilder();
TableRenderer table = new TableRenderer();
table.setHeader("Command","PU");
TableRenderer nsfwTable = new TableRenderer();
nsfwTable.setHeader("NSFW Only\u00A0", "PU");
List<String> noPu = new ArrayList<>();
boolean isAdmin;
if(event.isFromType(ChannelType.PRIVATE))
@ -124,17 +131,28 @@ public class Help implements Commande {
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
if(!e.getValue().isAdminCmd() || isAdmin)
txt.append("\n- ").append(e.getKey());
if(!e.getValue().isAdminCmd() || isAdmin){
if(e.getValue().isPrivateUsable())
table.addRow(e.getKey(), "XX");
else if(e.getValue().isNSFW())
nsfwTable.addRow(e.getKey(),"");
else
noPu.add(e.getKey());
}
}
for(String key : noPu)
table.addRow(key, "");
String txt = table.build();
txt += "\n\n";
txt += nsfwTable.build();
if(!event.isFromType(ChannelType.PRIVATE)){
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>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
new MessageTimeOut(MainBot.messageTimeOut, rest, event.getMessage()).start();
}
@ -144,10 +162,13 @@ public class Help implements Commande {
else
role = "Non Admin";
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt.toString()),logger);
try {
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getHelpList(role, txt),logger);
} catch (FileNotFoundException e) {
logger.catching(e);
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getInternalError(), logger);
}
}
@ -169,4 +190,9 @@ public class Help implements Commande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -209,4 +209,9 @@ public class Move implements Commande {
public boolean isAdminCmd() {
return true;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -172,6 +172,11 @@ public class Music implements Commande {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
public AudioM getAudioManager(){
return audio;
}

View File

@ -26,4 +26,9 @@ public class Ass extends NumberedCommande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return true;
}
}

View File

@ -25,4 +25,9 @@ public class Boobs extends NumberedCommande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return true;
}
}

View File

@ -26,50 +26,41 @@ public class Madame implements Commande{
@Override
public void action(String[] args, MessageReceivedEvent event) {
this.event = event;
if(event.getTextChannel().isNSFW()) {
Redirection redirect = new Redirection();
boolean success=false;
boolean error=false;
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
Redirection redirect = new Redirection();
boolean success=false;
boolean error=false;
int errorCp=0;
while(!success && !error)
{
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
@ -87,23 +78,11 @@ public class Madame implements Commande{
return false;
}
private boolean isAdvertisementUrl(String url){
//Scan url
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;
}
@Override
public boolean isNSFW() {
return true;
}
private boolean scanPageForTipeee(String url) throws StringIndexOutOfBoundsException, IOException{
String content = FindContentOnWebPage.getUrlSource(url);
String imgClickLink = content.substring(content.indexOf("photo post"));

View File

@ -11,40 +11,6 @@ public class Pipe extends NumberedCommande {
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
public String toString() {
return "Pipe";
@ -59,4 +25,9 @@ public class Pipe extends NumberedCommande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return true;
}
}

View File

@ -20,23 +20,13 @@ public class SM implements Commande {
@Override
public void action(String[] args, MessageReceivedEvent event) {
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 {
// event.getTextChannel().sendMessage(redirect.get("https://bonjourfetish.tumblr.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.");
}
}
@ -54,4 +44,9 @@ public class SM implements Commande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return true;
}
}

View File

@ -29,11 +29,7 @@ public class Ping implements Commande {
event.getPrivateChannel().sendMessage(":arrow_right: Pong! `" + ping+ "ms`").queue();
else {
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `" + ping + "ms`").complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
new MessageTimeOut(MainBot.messageTimeOut, event.getMessage(), rest).start();
}
LogManager.getLogger().debug("pong");
}
@ -41,7 +37,6 @@ public class Ping implements Commande {
@Override
public void executed(boolean success, MessageReceivedEvent event)
{
return;
}
@ -54,4 +49,9 @@ public class Ping implements Commande {
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -92,6 +92,11 @@ public class Spam implements Commande {
return true;
}
@Override
public boolean isNSFW() {
return false;
}
public void pardon(MessageReceivedEvent event, String[] args){
Guild serveur = event.getGuild();

View File

@ -109,6 +109,11 @@ public class SpamInfo implements Commande{
return false;
}
@Override
public boolean isNSFW() {
return false;
}
public String formatSecond(int second){
long days = TimeUnit.SECONDS.toDays(second);
second -= TimeUnit.DAYS.toSeconds(days);

View File

@ -101,6 +101,7 @@ public class MainBot {
{
Commande cmdObj = commandes.get(cmd.commande);
if(!cmdObj.isAdminCmd() || cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR)){
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))
{
commandes.get(cmd.commande).action(cmd.args, cmd.event);
commandes.get(cmd.commande).executed(true, cmd.event);
if(!cmdObj.isNSFW() || cmd.event.getTextChannel().isNSFW()){
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
cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue();
@ -121,11 +129,7 @@ public class MainBot {
}
else{
Message msg = cmd.event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete();
List<Message> messages = new ArrayList<Message>(){{
add(msg);
add(cmd.event.getMessage());
}};
new MessageTimeOut(messages, messageTimeOut).start();
new MessageTimeOut(messageTimeOut, msg, cmd.event.getMessage()).start();
}
}

View File

@ -15,7 +15,7 @@ import java.net.URL;
* Created by seb65 on 07/11/2016.
*/
public abstract class NumberedCommande implements Commande{
Logger logger = LogManager.getLogger();
private Logger logger = LogManager.getLogger();
public String HELP="T'es sérieux la?";
int minNumber = 1;
int maxNumber = -1;
@ -49,76 +49,65 @@ public abstract class NumberedCommande implements Commande{
{
if(args.length == 0)
{
if(event.getTextChannel().getName().equals("nsfw-over18")) {
Redirection redirect= new Redirection();
int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber)));
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();
int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber)));
String result = FindContentOnWebPage.doYourJob(baseURL + randomResult + "-2", divClass, htmlType);
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n"+result).queue();
logger.warn("Erreur chanel.");
}
}
else
{
if(args[0].toLowerCase().equals("update"))
{
logger.info("update commande from "+event.getMessage().getAuthor().getName());
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Updating...").queue();
switch (args[0].toLowerCase()) {
case "update":
logger.info("update commande from " + event.getMessage().getAuthor().getName());
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: Updating...").queue();
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;
int newNumber = maxNumber;
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();
newNumber = LimitChecker.doYourJob(baseURL, maxNumber);
} catch (IOException e) {
logger.catching(e);
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur interne...").queue();
e.printStackTrace();
}
}
else{
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;
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();
logger.warn("Bad Argument: "+event.getMessage().getContent()+" From "+event.getAuthor().getName());
}
}
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());
logger.warn("Bad Argument: " + event.getMessage().getContent() + " From " + event.getAuthor().getName());
break;
}
}
} catch (IOException e) {

View File

@ -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();
}
public static EmbedBuilder getError(String message) {
EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
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();
}
public static MessageEmbed getHelp(String command) throws FileNotFoundException {
String name = command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase();
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();
}
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();
}
@ -98,9 +97,12 @@ public class EmbedMessageUtils {
return buildStandar(getError("Vous n'avez pas l'autorisation de faire ça!"));
}
public static MessageEmbed getHelpList(String role, String list){
return new EmbedBuilder().setTitle("Command du bot ("+role+")").setDescription(list).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build();
public static MessageEmbed getHelpList(String role, String list) throws FileNotFoundException {
String message = new ResourceLoader().getFile("Help/main.md");
message = message.replace("@list", list);
return new EmbedBuilder().setTitle("Command du bot ("+role+")").setDescription(message).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build();
}
}

View File

@ -5,6 +5,8 @@ import net.dv8tion.jda.core.exceptions.ErrorResponseException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MessageTimeOut extends Thread{
@ -16,6 +18,11 @@ public class MessageTimeOut extends Thread{
this.second = second;
}
public MessageTimeOut(int second, Message... messages) {
this.messages = Arrays.asList(messages);
this.second = second;
}
@Override
public void run() {
logger.debug("Timer for message deletion stated...");

View File

@ -0,0 +1,108 @@
package net.Broken.Tools;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.commons.lang3.StringUtils;
public class TableRenderer {
private int width;
private List<Object> header;
private List<List<Object>> table = new ArrayList<>();
private String empty = "";
public TableRenderer() {
}
public void setHeader(Object... header) {
this.header = Arrays.asList(header);
if (header.length > this.width)
this.width = header.length;
}
public void addRow(Object... header) {
List<Object> objects = Arrays.asList(header);
table.add(objects);
if (header.length > this.width)
this.width = header.length;
}
public void setEmptyString(String str) {
this.empty = str;
}
private String[][] normalizeTable() {
int height = header == null ? table.size() : (table.size() + 1);
String[][] normalized = new String[height][width];
int vIndex = 0;
if (header != null) {
for (int hIndex = 0; hIndex < width; hIndex++) {
if (header.size() > hIndex)
normalized[vIndex][hIndex] = header.get(hIndex).toString();
else
normalized[vIndex][hIndex] = this.empty;
}
vIndex++;
}
for (List<Object> obj : table) {
for (int hIndex = 0; hIndex < width; hIndex++) {
if (obj.size() > hIndex)
normalized[vIndex][hIndex] = obj.get(hIndex).toString();
else
normalized[vIndex][hIndex] = this.empty+"s";
}
vIndex++;
}
return normalized;
}
private int[] getCollumnWidths(String[][] table, int padding) {
int collums[] = new int[width];
for (int vIndex = 0; vIndex < table.length; vIndex++)
for (int hIndex = 0; hIndex < width; hIndex++)
if (table[vIndex][hIndex].length() + padding > collums[hIndex])
collums[hIndex] = table[vIndex][hIndex].length() + padding;
collums[collums.length-1] -= padding;
return collums;
}
private String buildElement(String element, int width, String emptyChar) {
String result = element;
if (result.length() < width)
result += StringUtils.repeat(emptyChar, width - result.length());
return result;
}
private String buildLine(String[] strings, int[] widths, boolean header) {
String line = IntStream.range(0, strings.length)
.mapToObj((i) -> buildElement(strings[i], widths[i], " "))
.collect(Collectors.joining(""));
line = ""+ line + "";
if (header) {
String seperator = IntStream.range(0, strings.length)
.mapToObj((i) -> buildElement("", widths[i], ""))
.collect(Collectors.joining(""));
line += "\n" + "╪═" + seperator + "══╪";
}
return line;
}
public String build() {
String[][] table = normalizeTable();
int[] widths = getCollumnWidths(table, 1);
return IntStream.range(0, table.length)
.mapToObj(i -> buildLine(table[i], widths, header != null && i==0))
.collect(Collectors.joining("\n"));
}
}

View File

@ -0,0 +1,4 @@
Hey look! A cat!
And he's different everytime !
That is so cute! :cat:

View File

@ -0,0 +1,2 @@
This command doesn't have any help at the moment.
To help us improve: https://github.com/BrokenFire/BrokenDiscordBot

View File

@ -0,0 +1,3 @@
`//flush <number>`
:arrow_right: *Erase the n last posts (Max = 100)*

View File

@ -0,0 +1,2 @@
`//move <@user> <@targeted_role>`
:arrow_right: *Move an user to the targeted role.*

View File

@ -1,2 +1,2 @@
`//move <@utilisateur> <@rôleCible>`
:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire des montions.*
:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire les mentions.*

View File

@ -0,0 +1,26 @@
`//music play <url>`
:arrow_right: *Let's dance! Sets the vocal chat to use.*
`//music pause`
:arrow_right: *Pause the current track.*
`//music resume`
:arrow_right: *Resume the current track.*
`//music next`
:arrow_right: *Skip the current track.*
`//music stop`
:arrow_right: *Stop the current track and empty the playlist.*
`//music info`
:arrow_right: *Show info of the current track.*
`//music flush`
:arrow_right: *Delete the current playlist.*
`//music list`
:arrow_right: *Show information of the current playlist.*
`//music add(Next) <url>`
:arrow_right: *Add the url to the current playlist.*

View File

@ -1,5 +1,5 @@
`//music play <url>`
:arrow_right: *Let's dance! Deffinit le chat vocal à utiliser.*
:arrow_right: *Let's dance! Definit le chat vocal à utiliser.*
`//music pause`
:arrow_right: *Mise en pause de la piste en cours.*
@ -8,10 +8,10 @@
:arrow_right: *Reprise de la lecture de la piste en cours.*
`//music next`
:arrow_right: *Change le piste en cours.*
:arrow_right: *Change la piste en cours.*
`//music stop`
:arrow_right: *Arrête la piste en cours.*
:arrow_right: *Arrête la piste en cours et supprime la playlist.*
`//music info`
:arrow_right: *Affiche les infos de la piste en cours.*
@ -23,4 +23,4 @@
:arrow_right: *Affiche la playlist en cours.*
`//music add(Next) <url>`
:arrow_right: *Ajoute l'url à la playlist en cour.*
:arrow_right: *Ajoute l'url à la playlist en cours.*

View File

@ -0,0 +1,2 @@
`//ping`
:arrow_right: *Send back the bot's ping*

View File

@ -0,0 +1,8 @@
`//spam extermine <@user> <multiplier>`
:arrow_right: *Penalize a spammer.*
`//spam pardon <@user>`
:arrow_right: *Forgive a spammer*
`//spam reset <@user>`
:arrow_right: *Reset the user's multiplier.*

View File

@ -0,0 +1,2 @@
`//spaminfo <@user> `
:arrow_right: *Show punishment's information against the spam of the mentioned user (the author if there is no mention)*

View File

@ -0,0 +1,5 @@
```
@list
```
_PU = Private Usable (Utilisable en Message Privée)_

View File

@ -1,5 +1,5 @@
Une tentative d'association à etait demandé.
Une tentative d'association a été demandée.
Voici le code de vérification:
**%code**