Emote filter, Chat filter improvements, Disable commands, and custom
commands
This commit is contained in:
parent
a0df294674
commit
f05582baaf
|
@ -0,0 +1,2 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>Biscuit</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>1.2.2</version>
|
<version>1.3</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||||
|
@ -42,6 +44,7 @@
|
||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -74,6 +77,10 @@
|
||||||
<id>soluvas-public-thirdparty</id>
|
<id>soluvas-public-thirdparty</id>
|
||||||
<url>http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/</url>
|
<url>http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -214,5 +221,9 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
18
pom.xml
18
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>Biscuit</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.3</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -53,6 +56,10 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
|
@ -78,8 +85,17 @@
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.CrabMustard</groupId>
|
||||||
|
<artifactId>emoji-java</artifactId>
|
||||||
|
<version>v5.1.1-fixed</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-configuration2</artifactId>
|
<artifactId>commons-configuration2</artifactId>
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
import com.fpghoti.biscuit.commands.CommandListener;
|
import com.fpghoti.biscuit.commands.CommandListener;
|
||||||
import com.fpghoti.biscuit.commands.client.AddCommand;
|
import com.fpghoti.biscuit.commands.client.AddCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ChnameCommand;
|
|
||||||
import com.fpghoti.biscuit.commands.client.DivideCommand;
|
import com.fpghoti.biscuit.commands.client.DivideCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ToggleRoleCommand;
|
import com.fpghoti.biscuit.commands.client.ToggleRoleCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.HelpCommand;
|
import com.fpghoti.biscuit.commands.client.HelpCommand;
|
||||||
|
@ -97,7 +96,6 @@ public class Main {
|
||||||
commands.add(new RecentSpammersCommand());
|
commands.add(new RecentSpammersCommand());
|
||||||
commands.add(new ChanIDCommand());
|
commands.add(new ChanIDCommand());
|
||||||
commands.add(new UIDCommand());
|
commands.add(new UIDCommand());
|
||||||
commands.add(new ChnameCommand());
|
|
||||||
commands.add(new ToggleRoleCommand());
|
commands.add(new ToggleRoleCommand());
|
||||||
commands.add(new SquareRootCommand());
|
commands.add(new SquareRootCommand());
|
||||||
commands.add(new AddCommand());
|
commands.add(new AddCommand());
|
||||||
|
|
|
@ -13,6 +13,12 @@ public abstract class BaseCommand{
|
||||||
protected List<String> identifiers;
|
protected List<String> identifiers;
|
||||||
protected List<String> notes;
|
protected List<String> notes;
|
||||||
|
|
||||||
|
public BaseCommand(String name, String description, String usage) {
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.usage = usage;
|
||||||
|
}
|
||||||
|
|
||||||
public BaseCommand() {
|
public BaseCommand() {
|
||||||
this.identifiers = new ArrayList<String>();
|
this.identifiers = new ArrayList<String>();
|
||||||
this.notes = new ArrayList<String>();
|
this.notes = new ArrayList<String>();
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -33,6 +35,18 @@ public class CommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
public boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
||||||
|
|
||||||
|
if(e != null) {
|
||||||
|
|
||||||
|
if(Util.contains(PropertiesRetrieval.disabledCommands(), label)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!PermUtil.isAdmin(e.getMember()) && Util.contains(PropertiesRetrieval.disabledUserCommands(), label)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String input = label + " ";
|
String input = label + " ";
|
||||||
for (String s : args) {
|
for (String s : args) {
|
||||||
input += s + " ";
|
input += s + " ";
|
||||||
|
@ -68,6 +82,17 @@ public class CommandManager {
|
||||||
((ConsoleCommand)match).execute(trimmedArgs);
|
((ConsoleCommand)match).execute(trimmedArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
if(Util.contains(PropertiesRetrieval.getCustomCmds(), label)) {
|
||||||
|
CustomCommand cc = new CustomCommand(label);
|
||||||
|
if(args.length >= 1) {
|
||||||
|
commandReply(e, "``Command:" + " " + cc.getName() + "``");
|
||||||
|
commandReply(e, "``Description:" + " " + cc.getDescription() + "``");
|
||||||
|
commandReply(e, "``Usage:" + " " + cc.getUsage() + "``");
|
||||||
|
}else {
|
||||||
|
commandReply(e, CustomCommand.fixPlaceholders(e, cc.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.fpghoti.biscuit.commands;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class CustomCommand extends BaseCommand {
|
||||||
|
|
||||||
|
public static String fixPlaceholders(MessageReceivedEvent event, String msg) {
|
||||||
|
msg = msg.replace("<user>", event.getAuthor().getAsMention());
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public CustomCommand(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return PropertiesRetrieval.getCommandSignifier() + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
String desc = ConfigRetrieval.getFromConfig("cc-" + name + "-description");
|
||||||
|
if(desc == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandType getType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
String msg = ConfigRetrieval.getFromConfig("cc-" + name + "-message");
|
||||||
|
if(msg == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,31 +0,0 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
|
||||||
import com.fpghoti.biscuit.Main;
|
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
|
||||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|
||||||
|
|
||||||
public class ChnameCommand extends ClientCommand{
|
|
||||||
|
|
||||||
public ChnameCommand() {
|
|
||||||
name = "Channel Name";
|
|
||||||
description = "Retrieves the channel name.";
|
|
||||||
usage = PropertiesRetrieval.getCommandSignifier() + "chname";
|
|
||||||
minArgs = 0;
|
|
||||||
maxArgs = 0;
|
|
||||||
identifiers.add("chname");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(String[] args, MessageReceivedEvent event) {
|
|
||||||
Biscuit b = Main.getBiscuit();
|
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -chname");
|
|
||||||
if(PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember())) {
|
|
||||||
event.getTextChannel().sendMessage("DEBUG: " + event.getTextChannel().getName()).queue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.CustomCommand;
|
||||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
@ -36,13 +38,27 @@ public class HelpCommand extends ClientCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BaseCommand> commands = biscuit.getCommandManager().getCommands();
|
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||||
|
String[] ccs = PropertiesRetrieval.getCustomCmds();
|
||||||
|
for(String s : ccs) {
|
||||||
|
if(!Util.contains(PropertiesRetrieval.disabledCommands(), s)) {
|
||||||
|
CustomCommand cc = new CustomCommand(s);
|
||||||
|
commands.add(cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(BaseCommand bc : biscuit.getCommandManager().getCommands()) {
|
||||||
|
String bclabel = bc.getUsage().split(" ")[0];
|
||||||
|
if(!Util.contains(PropertiesRetrieval.disabledCommands(), bclabel.replace(PropertiesRetrieval.getCommandSignifier(), ""))) {
|
||||||
|
commands.add(bc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
||||||
if (pg > pageCount) {
|
if (pg > pageCount) {
|
||||||
pg = pageCount;
|
pg = pageCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.getTextChannel().sendMessage("**Use " + PropertiesRetrieval.getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue();
|
||||||
event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue();
|
event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue();
|
||||||
String msg = "";
|
String msg = "";
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
|
@ -90,6 +90,11 @@ public class ConfigRetrieval {
|
||||||
added = addProperty("Captcha-Reward-Role", "cleared", prop, added);
|
added = addProperty("Captcha-Reward-Role", "cleared", prop, added);
|
||||||
added = addProperty("No-Captcha-Kick", "false", prop, added);
|
added = addProperty("No-Captcha-Kick", "false", prop, added);
|
||||||
added = addProperty("No-Captcha-Kick-Time", "10", prop, added);
|
added = addProperty("No-Captcha-Kick-Time", "10", prop, added);
|
||||||
|
added = addProperty("Block-Unicode-Emotes", "baby,snake,squid", prop, added);
|
||||||
|
added = addProperty("Block-Custom-Emotes", "badfish,fix,bigleaf", prop, added);
|
||||||
|
added = addProperty("Custom-Command-Names", "", prop, added);
|
||||||
|
added = addProperty("DisabledCommands", "cmd1,cmd2,cmd3", prop, added);
|
||||||
|
added = addProperty("DisabledUserCommands", "cmd4,cmd5,cmd6", prop, added);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,4 +73,23 @@ public class PropertiesRetrieval {
|
||||||
return ConfigRetrieval.getFromConfig("ToggleRoles").replace(" ", "").split(",");
|
return ConfigRetrieval.getFromConfig("ToggleRoles").replace(" ", "").split(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] blockedUnicodeEmotes(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Block-Unicode-Emotes").replace(" ", "").split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] blockedCustomEmotes(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Block-Custom-Emotes").replace(" ", "").split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getCustomCmds(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Custom-Command-Names").replace(" ", "").split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] disabledCommands(){
|
||||||
|
return ConfigRetrieval.getFromConfig("DisabledCommands").replace(" ", "").split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] disabledUserCommands(){
|
||||||
|
return ConfigRetrieval.getFromConfig("DisabledUserCommands").replace(" ", "").split(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,12 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.getAuthor().isBot() && event.getMessage().getContentRaw().contains("This message contains words not appropriate for this channel.") || (ChatFilter.isNaughty(event.getMessage().getContentDisplay()))){
|
if(event.getAuthor().isBot() && event.getMessage().getContentRaw().contains("This message contains words not appropriate for this channel.") || (ChatFilter.filter(event))){
|
||||||
MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
|
MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
//staff channels do not need filtering, as the filter could actually be a hinderance
|
//staff channels do not need filtering, as the filter could actually be a hinderance
|
||||||
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.isNaughty(event.getMessage().getContentDisplay())){
|
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
||||||
String text = event.getMessage().getContentDisplay();
|
|
||||||
log.info("Removed Msg - REASON NAUGHTY WORD(S) - by " + event.getAuthor().getName() + ": " + text);
|
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").complete();
|
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").complete();
|
||||||
MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
|
MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ public class FastMsgRemoveTimer extends BiscuitTimer{
|
||||||
|
|
||||||
public FastMsgRemoveTimer(){
|
public FastMsgRemoveTimer(){
|
||||||
delay = (long) 0;
|
delay = (long) 0;
|
||||||
period = (long) 1*1000;
|
//period = (long) 1*1000;
|
||||||
|
period = (long) 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -1,47 +1,148 @@
|
||||||
package com.fpghoti.biscuit.util;
|
package com.fpghoti.biscuit.util;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class ChatFilter {
|
public class ChatFilter {
|
||||||
|
|
||||||
//CHAT FILTER
|
public static String[] suffixes = {"ing","s","ed","er","es","y","ers","ier","iest","ies","ys"};
|
||||||
|
|
||||||
public static Boolean isNaughty(String sentence){
|
public static boolean filter(MessageReceivedEvent event) {
|
||||||
|
return filter(event, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean filter(MessageReceivedEvent event, boolean silent) {
|
||||||
|
String msg = event.getMessage().getContentDisplay();
|
||||||
|
|
||||||
|
//Message removal priority occurs in this order
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
//Naughty word check
|
||||||
|
boolean filter = (filter(msg));
|
||||||
|
if(filter) {
|
||||||
|
if(!silent) {
|
||||||
|
Main.log.info("Removed Msg - REASON NAUGHTY WORD(S) - by " + event.getAuthor().getName() + ": " + msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Custom emote check
|
||||||
|
for(Emote e : event.getMessage().getEmotes()) {
|
||||||
|
String name = e.getName();
|
||||||
|
|
||||||
|
for(String s : PropertiesRetrieval.blockedCustomEmotes()) {
|
||||||
|
if(s.equals(name)) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found) {
|
||||||
|
if(!silent) {
|
||||||
|
Main.log.info("Removed Msg - REASON BLOCKED CUSTOM EMOTE(S) - by " + event.getAuthor().getName() + ": " + msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unicode emote check
|
||||||
|
for(String u : EmojiParser.extractEmojis(msg)) {
|
||||||
|
u = EmojiParser.parseToAliases(u).replace(":","");
|
||||||
|
for(String s : PropertiesRetrieval.blockedUnicodeEmotes()) {
|
||||||
|
if(s.equalsIgnoreCase(u)) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found) {
|
||||||
|
if(!silent) {
|
||||||
|
Main.log.info("Removed Msg - REASON BLOCKED UNICODE EMOTE(S) - by " + event.getAuthor().getName() + ": " + msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean filter(String sentence){
|
||||||
for(String s : sentence.split(" ")){
|
for(String s : sentence.split(" ")){
|
||||||
if(isNaughtyWord(s)){
|
if(filterWord(s)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isNaughtyWord(String word){
|
public static boolean filterWord(String word) {
|
||||||
String wordp = "";
|
String[] match = findMatchPair(word);
|
||||||
String word2 = word.toLowerCase();
|
if(match != null) {
|
||||||
if(word2.length() >= 2 && word2.charAt(word2.length() -1) == '!'){
|
|
||||||
for(int i = 0; i < word2.length() -1; i++ ){
|
|
||||||
wordp += word2.charAt(i);
|
|
||||||
}
|
|
||||||
word2 = wordp;
|
|
||||||
}
|
|
||||||
wordp = "";
|
|
||||||
for(int i = 0; i < word2.length(); i++ ){
|
|
||||||
if(word2.charAt(i) != '!'){
|
|
||||||
wordp += word2.charAt(i);
|
|
||||||
}else{
|
|
||||||
wordp += 'i';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
word2 = wordp;
|
|
||||||
word2 = word2.replaceAll("\\p{Punct}+", "").replaceAll("1", "i").replaceAll("5", "s").replaceAll("6", "g").replaceAll("3", "e");
|
|
||||||
String[] list = PropertiesRetrieval.getNaughtyWords();
|
|
||||||
for(String item : list){
|
|
||||||
if(word.equalsIgnoreCase(item) || word.equalsIgnoreCase(item + "s")){
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
word2 = null;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String findMatch(String word) {
|
||||||
|
String[] match = findMatchPair(word);
|
||||||
|
if(match == null || match[0] == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return match[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] findMatchPair(String word) {
|
||||||
|
String cleaned = "";
|
||||||
|
word = word.toLowerCase();
|
||||||
|
if(word.length() >= 2 && word.charAt(word.length() -1) == '!'){
|
||||||
|
for(int i = 0; i < word.length() -1; i++ ){
|
||||||
|
cleaned += word.charAt(i);
|
||||||
|
}
|
||||||
|
word = cleaned;
|
||||||
|
}
|
||||||
|
cleaned = "";
|
||||||
|
for(int i = 0; i < word.length(); i++ ){
|
||||||
|
if(word.charAt(i) != '!'){
|
||||||
|
cleaned += word.charAt(i);
|
||||||
|
}else{
|
||||||
|
cleaned += 'i';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cleaned = cleaned.replace(" ", "");
|
||||||
|
cleaned = cleaned.replaceAll("\\p{Punct}+", "").replaceAll("1", "i").replaceAll("5", "s").replaceAll("6", "g").replaceAll("3", "e").replaceAll("0", "o").replaceAll("9", "g").replaceAll("8", "b");
|
||||||
|
if(cleaned.equals("")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String[] wordSuf = {null,null};
|
||||||
|
for(String item : PropertiesRetrieval.getNaughtyWords()) {
|
||||||
|
if(cleaned.equalsIgnoreCase(item)){
|
||||||
|
wordSuf[0] = item;
|
||||||
|
return wordSuf;
|
||||||
|
}
|
||||||
|
for(String suffix : suffixes) {
|
||||||
|
if(cleaned.equalsIgnoreCase(item + suffix)){
|
||||||
|
wordSuf[0] = item;
|
||||||
|
wordSuf[1] = suffix;
|
||||||
|
return wordSuf;
|
||||||
|
}
|
||||||
|
String last = item.substring(item.length() - 1);
|
||||||
|
if(cleaned.equalsIgnoreCase(item + last + suffix)){
|
||||||
|
wordSuf[0] = item;
|
||||||
|
wordSuf[1] = last + suffix;
|
||||||
|
return wordSuf;
|
||||||
|
}
|
||||||
|
if(cleaned.equalsIgnoreCase(item + last + last + suffix)){
|
||||||
|
wordSuf[0] = item;
|
||||||
|
wordSuf[1] = last + last + suffix;
|
||||||
|
return wordSuf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,15 @@ public class Util {
|
||||||
return s.matches("[0-9]+");
|
return s.matches("[0-9]+");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean contains(String[] list, String s) {
|
||||||
|
for(String l : list) {
|
||||||
|
if(s.equals(l)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isDeciDigit(String s){
|
public static boolean isDeciDigit(String s){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
String s2 = "";
|
String s2 = "";
|
||||||
|
|
|
@ -49,3 +49,26 @@ No-Captcha-Kick = false
|
||||||
#Kick user after this number of minutes has passed without captcha clear
|
#Kick user after this number of minutes has passed without captcha clear
|
||||||
#Due to the way the countdown works, the kick may not happen until at most one minute after
|
#Due to the way the countdown works, the kick may not happen until at most one minute after
|
||||||
No-Captcha-Kick-Time = 10
|
No-Captcha-Kick-Time = 10
|
||||||
|
|
||||||
|
#Messages with these unicode emotes will be removed
|
||||||
|
Block-Unicode-Emotes = baby,snake,squid
|
||||||
|
|
||||||
|
#Messages with these custom emotes will be removed
|
||||||
|
Block-Custom-Emotes = badfish,fix,bigleaf
|
||||||
|
|
||||||
|
#Disable these commands for ALL users
|
||||||
|
DisabledCommands = cmd1,cmd2,cmd3
|
||||||
|
|
||||||
|
#Disabled these commands for normal users
|
||||||
|
DisabledUserCommands = cmd4,cmd5,cmd6
|
||||||
|
|
||||||
|
#List your custom commands here. This line will always generate blank.
|
||||||
|
#Example - Custom-Command-Names = hello,botcheck,apple
|
||||||
|
Custom-Command-Names =
|
||||||
|
|
||||||
|
#Placeholder(s):
|
||||||
|
#<user> - Mentions the sender
|
||||||
|
#Setting up custom commands works like this:
|
||||||
|
#
|
||||||
|
#cc-hello-message = Hello, <user>!
|
||||||
|
#cc-hello-description = Greets the sender.
|
Loading…
Reference in New Issue