Add captcha, auto generate config, and Spigot support
This commit is contained in:
parent
ffd6e5978b
commit
f7887de08f
|
@ -1,19 +0,0 @@
|
||||||
#Change this to redefine the main command signifier character/String
|
|
||||||
Command-Signifier:-
|
|
||||||
|
|
||||||
#Automatically places spammers in spam mode
|
|
||||||
AllowSpamPunish:true
|
|
||||||
|
|
||||||
Channels-To-Not-Chatlog:ignore_me
|
|
||||||
|
|
||||||
#Bot token provided by Discord
|
|
||||||
Bot-Token:
|
|
||||||
|
|
||||||
#Normal channels will have messages with these words deleted by the bot
|
|
||||||
NaughtyList:piff
|
|
||||||
|
|
||||||
#Bot can automatically assign role upon user join
|
|
||||||
UseCustomDefaultRole:true
|
|
||||||
|
|
||||||
#Does nothing if UseCustomDefaultRole is off
|
|
||||||
DefaultRoleName:Standard
|
|
|
@ -2,8 +2,8 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>MrBouncer</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>3.0</version>
|
<version>1.1</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.fpghoti.mrbouncer.MrBouncer</mainClass>
|
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -50,6 +50,14 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>bungeecord-repo</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>oss.sonatype.org</id>
|
<id>oss.sonatype.org</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
|
@ -57,7 +65,7 @@
|
||||||
<repository>
|
<repository>
|
||||||
<id>jcenter</id>
|
<id>jcenter</id>
|
||||||
<name>jcenter-bintray</name>
|
<name>jcenter-bintray</name>
|
||||||
<url>http://jcenter.bintray.com</url>
|
<url>https://jcenter.bintray.com</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
|
@ -68,6 +76,94 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bungeecord-chat</artifactId>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>bungeecord-api</artifactId>
|
||||||
|
<version>1.15-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bungeecord-config</artifactId>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bungeecord-event</artifactId>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bungeecord-protocol</artifactId>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>netty-transport-native-unix-common</artifactId>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bungeecord-chat</artifactId>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.java.dev.jna</groupId>
|
<groupId>net.java.dev.jna</groupId>
|
||||||
<artifactId>jna</artifactId>
|
<artifactId>jna</artifactId>
|
||||||
|
|
38
pom.xml
38
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>ALPHA-0.1</version>
|
<version>1.1</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.fpghoti.biscuit.Biscuit</mainClass>
|
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -54,6 +54,14 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>bungeecord-repo</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>oss.sonatype.org</id>
|
<id>oss.sonatype.org</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
|
@ -72,6 +80,25 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>bungeecord-api</artifactId>
|
||||||
|
<version>1.15-SNAPSHOT</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okio</groupId>
|
<groupId>com.squareup.okio</groupId>
|
||||||
<artifactId>okio</artifactId>
|
<artifactId>okio</artifactId>
|
||||||
|
@ -100,7 +127,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.0.0_46</version>
|
<version>4.1.1_155</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.cage</groupId>
|
||||||
|
<artifactId>cage</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.java.dev.jna</groupId>
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.fpghoti.biscuit;
|
package com.fpghoti.biscuit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
@ -7,10 +8,18 @@ import java.util.Timer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.commands.CommandManager;
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||||
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
|
import com.github.cage.Cage;
|
||||||
|
import com.github.cage.GCage;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
||||||
public class Biscuit {
|
public class Biscuit {
|
||||||
|
|
||||||
|
@ -19,6 +28,9 @@ public class Biscuit {
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private List<BiscuitTimer> timers;
|
private List<BiscuitTimer> timers;
|
||||||
|
private File captchaDir;
|
||||||
|
private Cage cage;
|
||||||
|
|
||||||
|
|
||||||
public Biscuit(JDA jda, Logger log) {
|
public Biscuit(JDA jda, Logger log) {
|
||||||
this.jda = jda;
|
this.jda = jda;
|
||||||
|
@ -27,6 +39,15 @@ public class Biscuit {
|
||||||
commandManager = new CommandManager();
|
commandManager = new CommandManager();
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timers = new ArrayList<BiscuitTimer>();
|
timers = new ArrayList<BiscuitTimer>();
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
captchaDir = new File("captcha");
|
||||||
|
}else {
|
||||||
|
captchaDir = new File(PluginCore.plugin.getDataFolder(), "captcha");
|
||||||
|
}
|
||||||
|
captchaDir.mkdir();
|
||||||
|
cage = new GCage();
|
||||||
|
wipeCaptchaDir();
|
||||||
|
loadPreUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
|
@ -70,6 +91,44 @@ public class Biscuit {
|
||||||
timers.remove(bt);
|
timers.remove(bt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void wipeCaptchaDir() {
|
||||||
|
Main.log.info("Wiping captcha files...");
|
||||||
|
boolean good = true;
|
||||||
|
File[] files = captchaDir.listFiles();
|
||||||
|
for (File file : files){
|
||||||
|
if (!file.delete()){
|
||||||
|
good = false;
|
||||||
|
Main.log.error("Could not remove captcha file: " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(good) {
|
||||||
|
Main.log.info("All captcha files successfully removed!");
|
||||||
|
}else {
|
||||||
|
Main.log.error("Some captcha file(s) could not be removed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cage getCage() {
|
||||||
|
return this.cage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPreUsers() {
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
for(Member m : g.getMembers()) {
|
||||||
|
User u = m.getUser();
|
||||||
|
if(!PreUser.preUserExists(u)) {
|
||||||
|
if(m.getRoles().size() == 1) {
|
||||||
|
for(Role role : m.getRoles()){
|
||||||
|
if(role.getName().equalsIgnoreCase(PropertiesRetrieval.getDefaultRole())){
|
||||||
|
PreUser.users.add(new PreUser(u));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,27 +8,36 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
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.ChanIDCommand;
|
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ChnameCommand;
|
import com.fpghoti.biscuit.commands.client.ChnameCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.DivideCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.DontNotifyCommand;
|
import com.fpghoti.biscuit.commands.client.DontNotifyCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.HelpCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.MultiplyCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.NotSpammerCommand;
|
import com.fpghoti.biscuit.commands.client.NotSpammerCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.NotifyCommand;
|
import com.fpghoti.biscuit.commands.client.NotifyCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.PingCommand;
|
import com.fpghoti.biscuit.commands.client.PingCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.PowerCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.RecentSpammersCommand;
|
import com.fpghoti.biscuit.commands.client.RecentSpammersCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ShutDownCommand;
|
|
||||||
import com.fpghoti.biscuit.commands.client.SoftMuteCommand;
|
import com.fpghoti.biscuit.commands.client.SoftMuteCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.SquareRootCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.SubtractCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.UIDCommand;
|
import com.fpghoti.biscuit.commands.client.UIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.UnSoftMuteCommand;
|
import com.fpghoti.biscuit.commands.client.UnSoftMuteCommand;
|
||||||
import com.fpghoti.biscuit.commands.console.SayCommand;
|
import com.fpghoti.biscuit.commands.console.SayCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.console.ShutdownConsoleCommand;
|
||||||
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
||||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.Properties;
|
import com.fpghoti.biscuit.global.Properties;
|
||||||
|
import com.fpghoti.biscuit.listener.DMListener;
|
||||||
import com.fpghoti.biscuit.listener.JoinListener;
|
import com.fpghoti.biscuit.listener.JoinListener;
|
||||||
import com.fpghoti.biscuit.listener.MessageDeleteListener;
|
import com.fpghoti.biscuit.listener.MessageDeleteListener;
|
||||||
import com.fpghoti.biscuit.listener.MessageEditListener;
|
import com.fpghoti.biscuit.listener.MessageEditListener;
|
||||||
import com.fpghoti.biscuit.listener.MessageReceiveListener;
|
import com.fpghoti.biscuit.listener.MessageReceiveListener;
|
||||||
import com.fpghoti.biscuit.timer.task.BotMsgRemoveTimer;
|
import com.fpghoti.biscuit.timer.task.BotMsgRemoveTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
||||||
|
import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.FastMsgRemoveTimer;
|
import com.fpghoti.biscuit.timer.task.FastMsgRemoveTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.SlowMsgRemoveTimer;
|
import com.fpghoti.biscuit.timer.task.SlowMsgRemoveTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
||||||
|
@ -49,6 +58,9 @@ public class Main {
|
||||||
public static final Logger log = LoggerFactory.getLogger("ch.qos.logback.core.ConsoleAppender");
|
public static final Logger log = LoggerFactory.getLogger("ch.qos.logback.core.ConsoleAppender");
|
||||||
public static Scanner sc;
|
public static Scanner sc;
|
||||||
public static Biscuit biscuit;
|
public static Biscuit biscuit;
|
||||||
|
public static boolean ready = false;
|
||||||
|
public static boolean isPlugin = false;
|
||||||
|
public static boolean shutdownStarted = false;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
@ -62,6 +74,7 @@ public class Main {
|
||||||
jda.addEventListener(new MessageEditListener());
|
jda.addEventListener(new MessageEditListener());
|
||||||
jda.addEventListener(new MessageDeleteListener());
|
jda.addEventListener(new MessageDeleteListener());
|
||||||
jda.addEventListener(new JoinListener());
|
jda.addEventListener(new JoinListener());
|
||||||
|
jda.addEventListener(new DMListener());
|
||||||
|
|
||||||
String link = "NULL";
|
String link = "NULL";
|
||||||
Properties.naughtyList = ConfigRetrieval.getFromConfig("NaughtyList");
|
Properties.naughtyList = ConfigRetrieval.getFromConfig("NaughtyList");
|
||||||
|
@ -73,6 +86,7 @@ public class Main {
|
||||||
biscuit.addTimer(new FastMsgRemoveTimer());
|
biscuit.addTimer(new FastMsgRemoveTimer());
|
||||||
biscuit.addTimer(new SlowMsgRemoveTimer());
|
biscuit.addTimer(new SlowMsgRemoveTimer());
|
||||||
biscuit.addTimer(new SoftMuteTimer());
|
biscuit.addTimer(new SoftMuteTimer());
|
||||||
|
biscuit.addTimer(new DecrementTimer());
|
||||||
|
|
||||||
biscuit.loadTimers();
|
biscuit.loadTimers();
|
||||||
|
|
||||||
|
@ -80,21 +94,28 @@ public class Main {
|
||||||
|
|
||||||
//Client
|
//Client
|
||||||
|
|
||||||
|
commands.add(new HelpCommand());
|
||||||
commands.add(new PingCommand());
|
commands.add(new PingCommand());
|
||||||
commands.add(new SoftMuteCommand());
|
commands.add(new SoftMuteCommand());
|
||||||
commands.add(new UnSoftMuteCommand());
|
commands.add(new UnSoftMuteCommand());
|
||||||
commands.add(new NotSpammerCommand());
|
commands.add(new NotSpammerCommand());
|
||||||
commands.add(new RecentSpammersCommand());
|
commands.add(new RecentSpammersCommand());
|
||||||
commands.add(new ChanIDCommand());
|
commands.add(new ChanIDCommand());
|
||||||
commands.add(new ShutDownCommand());
|
|
||||||
commands.add(new UIDCommand());
|
commands.add(new UIDCommand());
|
||||||
commands.add(new ChnameCommand());
|
commands.add(new ChnameCommand());
|
||||||
commands.add(new NotifyCommand());
|
commands.add(new NotifyCommand());
|
||||||
commands.add(new DontNotifyCommand());
|
commands.add(new DontNotifyCommand());
|
||||||
|
commands.add(new SquareRootCommand());
|
||||||
|
commands.add(new AddCommand());
|
||||||
|
commands.add(new SubtractCommand());
|
||||||
|
commands.add(new MultiplyCommand());
|
||||||
|
commands.add(new DivideCommand());
|
||||||
|
commands.add(new PowerCommand());
|
||||||
|
|
||||||
//Console
|
//Console
|
||||||
|
|
||||||
commands.add(new SayCommand());
|
commands.add(new SayCommand());
|
||||||
|
commands.add(new ShutdownConsoleCommand());
|
||||||
|
|
||||||
link = "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot";
|
link = "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot";
|
||||||
log.info("Connection successful!");
|
log.info("Connection successful!");
|
||||||
|
@ -103,6 +124,7 @@ public class Main {
|
||||||
log.info(link);
|
log.info(link);
|
||||||
log.info("======================================================================");
|
log.info("======================================================================");
|
||||||
log.info("CHAT LOGS BEGIN HERE:");
|
log.info("CHAT LOGS BEGIN HERE:");
|
||||||
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startJDA() {
|
private static void startJDA() {
|
||||||
|
@ -124,20 +146,39 @@ public class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startCommandListener() {
|
private static void startCommandListener() {
|
||||||
|
if(!isPlugin) {
|
||||||
sc = new Scanner(System.in);
|
sc = new Scanner(System.in);
|
||||||
CommandListener cl = new CommandListener();
|
CommandListener cl = new CommandListener();
|
||||||
cl.sc = sc;
|
cl.sc = sc;
|
||||||
cl.jda = jda;
|
cl.jda = jda;
|
||||||
jda.addEventListener(cl);
|
jda.addEventListener(cl);
|
||||||
new Thread(cl).start();
|
new Thread(cl).start();
|
||||||
|
}else {
|
||||||
|
CommandListener cl = new CommandListener();
|
||||||
|
cl.jda = jda;
|
||||||
|
jda.addEventListener(cl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Biscuit getBiscuit() {
|
||||||
|
return biscuit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
|
if(!shutdownStarted) {
|
||||||
|
shutdownStarted = true;
|
||||||
log.info("Shutting down...");
|
log.info("Shutting down...");
|
||||||
|
biscuit.wipeCaptchaDir();
|
||||||
|
if(jda != null) {
|
||||||
|
jda.shutdown();
|
||||||
|
}
|
||||||
|
if(!isPlugin) {
|
||||||
sc.close();
|
sc.close();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.fpghoti.biscuit;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
|
|
||||||
|
public class PluginCore extends JavaPlugin{
|
||||||
|
|
||||||
|
public static PluginCore plugin;
|
||||||
|
|
||||||
|
public void onEnable(){
|
||||||
|
plugin = this;
|
||||||
|
Main.isPlugin = true;
|
||||||
|
String[] args = {};
|
||||||
|
Main.main(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
Main.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
CommandManager m = Main.getBiscuit().getCommandManager();
|
||||||
|
if(m != null) {
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
Player p = (Player)sender;
|
||||||
|
if(!p.hasPermission("biscuit.admin")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m.dispatch(label,args);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ public class CommandListener extends ListenerAdapter implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(MessageReceivedEvent event){
|
public void onMessageReceived(MessageReceivedEvent event){
|
||||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(PropertiesRetrieval.getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(PropertiesRetrieval.getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||||
log.info("True");
|
//log.info("True");
|
||||||
API.getBiscuit().getCommandManager().parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
API.getBiscuit().getCommandManager().parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,5 @@ public abstract class ConsoleCommand extends BaseCommand{
|
||||||
public CommandType getType() {
|
public CommandType getType() {
|
||||||
return CommandType.CONSOLE;
|
return CommandType.CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class AddCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public AddCommand() {
|
||||||
|
name = "Add";
|
||||||
|
description = "Finds sum of two numbers.";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "add <Num1> <Num2>";
|
||||||
|
minArgs = 2;
|
||||||
|
maxArgs = 2;
|
||||||
|
identifiers.add("add");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -add");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
double num2 = Double.parseDouble(args[1]);
|
||||||
|
String sum = Double.toString(num + num2);
|
||||||
|
String end = sum.substring(Math.max(sum.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
sum = sum.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(args[0] + " + " + args[1] + " is **" + sum + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ public class ChanIDCommand extends ClientCommand{
|
||||||
public ChanIDCommand() {
|
public ChanIDCommand() {
|
||||||
name = "Channel ID";
|
name = "Channel ID";
|
||||||
description = "Retrieves the channel ID.";
|
description = "Retrieves the channel ID.";
|
||||||
usage = "-chanid";
|
usage = PropertiesRetrieval.getCommandSignifier() + "chanid";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("chanid");
|
identifiers.add("chanid");
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
@ -12,7 +13,7 @@ public class ChnameCommand extends ClientCommand{
|
||||||
public ChnameCommand() {
|
public ChnameCommand() {
|
||||||
name = "Channel Name";
|
name = "Channel Name";
|
||||||
description = "Retrieves the channel name.";
|
description = "Retrieves the channel name.";
|
||||||
usage = "-chname";
|
usage = PropertiesRetrieval.getCommandSignifier() + "chname";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("chname");
|
identifiers.add("chname");
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class DivideCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public DivideCommand() {
|
||||||
|
name = "Divide";
|
||||||
|
description = "Divides two numbers.";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "divide <Num 1> <Num 2>";
|
||||||
|
minArgs = 2;
|
||||||
|
maxArgs = 2;
|
||||||
|
identifiers.add("divide");
|
||||||
|
identifiers.add("div");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -divide");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
double num2 = Double.parseDouble(args[1]);
|
||||||
|
String divide = Double.toString(num / num2);
|
||||||
|
String end = divide.substring(Math.max(divide.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
divide = divide.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(args[0] + " / " + args[1] + " is **" + divide + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Emote;
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
@ -13,7 +14,7 @@ public class DontNotifyCommand extends ClientCommand{
|
||||||
public DontNotifyCommand() {
|
public DontNotifyCommand() {
|
||||||
name = "Don't Notify";
|
name = "Don't Notify";
|
||||||
description = "Puts user in Don't Notify status.";
|
description = "Puts user in Don't Notify status.";
|
||||||
usage = "-dontnotify";
|
usage = PropertiesRetrieval.getCommandSignifier() + "dontnotify";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("dontnotify");
|
identifiers.add("dontnotify");
|
||||||
|
@ -26,7 +27,7 @@ public class DontNotifyCommand extends ClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -dontnotify");
|
b.log(event.getAuthor().getName() + " issued a command: -dontnotify");
|
||||||
Role role = null;
|
Role role = null;
|
||||||
for(Role r : event.getGuild().getRoles()) {
|
for(Role r : event.getGuild().getRoles()) {
|
||||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
if(r.getName().toLowerCase().contains(PropertiesRetrieval.getDontNotify())) {
|
||||||
role = r;
|
role = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ public class DontNotifyCommand extends ClientCommand{
|
||||||
|
|
||||||
Emote done = null;
|
Emote done = null;
|
||||||
for(Emote e : event.getGuild().getEmotes()) {
|
for(Emote e : event.getGuild().getEmotes()) {
|
||||||
if(e.getName().contains("ActionComplete")) {
|
if(e.getName().contains(PropertiesRetrieval.getDoneEmote())) {
|
||||||
done = e;
|
done = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class HelpCommand extends ClientCommand {
|
||||||
|
|
||||||
|
public HelpCommand() {
|
||||||
|
name = "Help";
|
||||||
|
description = "Pulls up help menu";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "help [Page #]";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 1;
|
||||||
|
identifiers.add("help");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
|
||||||
|
Biscuit biscuit = Main.getBiscuit();
|
||||||
|
|
||||||
|
int pg = 1;
|
||||||
|
if (args.length > 0) {
|
||||||
|
if(Util.isDigit(args[0])) {
|
||||||
|
pg = Integer.parseInt(args[0]);
|
||||||
|
}else {
|
||||||
|
event.getTextChannel().sendMessage("Usage: ``" + usage + "``").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<BaseCommand> commands = biscuit.getCommandManager().getCommands();
|
||||||
|
|
||||||
|
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
||||||
|
if (pg > pageCount) {
|
||||||
|
pg = pageCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue();
|
||||||
|
String msg = "";
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
int index = (pg - 1) * 8 + i;
|
||||||
|
String line = "";
|
||||||
|
if (index < commands.size()) {
|
||||||
|
line = "**-** ``" + commands.get(index).getUsage() + "``";
|
||||||
|
}
|
||||||
|
if(!(index + 1 >= commands.size() || index == 7)) {
|
||||||
|
line = line + "\n";
|
||||||
|
}
|
||||||
|
if (index < commands.size()) {
|
||||||
|
msg = msg + line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(msg).queue();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class MultiplyCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public MultiplyCommand() {
|
||||||
|
name = "Multiply";
|
||||||
|
description = "Multiplies two numbers.";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "multiply <Num1> <Num2>";
|
||||||
|
minArgs = 2;
|
||||||
|
maxArgs = 2;
|
||||||
|
identifiers.add("multiply");
|
||||||
|
identifiers.add("mul");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -multiply");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
double num2 = Double.parseDouble(args[1]);
|
||||||
|
String prod = Double.toString(num * num2);
|
||||||
|
String end = prod.substring(Math.max(prod.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
prod = prod.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(args[0] + " x " + args[1] + " is **" + prod + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.SpamRecords;
|
import com.fpghoti.biscuit.global.SpamRecords;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ public class NotSpammerCommand extends ClientCommand{
|
||||||
public NotSpammerCommand() {
|
public NotSpammerCommand() {
|
||||||
name = "Not Spammer";
|
name = "Not Spammer";
|
||||||
description = "Delists user as spammer.";
|
description = "Delists user as spammer.";
|
||||||
usage = "-notspammer @<mention-user>";
|
usage = PropertiesRetrieval.getCommandSignifier() + "notspammer @<mention-user>";
|
||||||
minArgs = 1;
|
minArgs = 1;
|
||||||
maxArgs = 1;
|
maxArgs = 1;
|
||||||
identifiers.add("notspammer");
|
identifiers.add("notspammer");
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Emote;
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
@ -13,7 +14,7 @@ public class NotifyCommand extends ClientCommand{
|
||||||
public NotifyCommand() {
|
public NotifyCommand() {
|
||||||
name = "Notify";
|
name = "Notify";
|
||||||
description = "Puts user in Notify status.";
|
description = "Puts user in Notify status.";
|
||||||
usage = "-notify";
|
usage = PropertiesRetrieval.getCommandSignifier() + "notify";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("notify");
|
identifiers.add("notify");
|
||||||
|
@ -26,7 +27,7 @@ public class NotifyCommand extends ClientCommand{
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -notify");
|
b.log(event.getAuthor().getName() + " issued a command: -notify");
|
||||||
Role role = null;
|
Role role = null;
|
||||||
for(Role r : event.getGuild().getRoles()) {
|
for(Role r : event.getGuild().getRoles()) {
|
||||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
if(r.getName().toLowerCase().contains(PropertiesRetrieval.getDontNotify())) {
|
||||||
role = r;
|
role = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ public class NotifyCommand extends ClientCommand{
|
||||||
|
|
||||||
Emote done = null;
|
Emote done = null;
|
||||||
for(Emote e : event.getGuild().getEmotes()) {
|
for(Emote e : event.getGuild().getEmotes()) {
|
||||||
if(e.getName().contains("ActionComplete")) {
|
if(e.getName().contains(PropertiesRetrieval.getDoneEmote())) {
|
||||||
done = e;
|
done = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ public class PingCommand extends ClientCommand{
|
||||||
public PingCommand() {
|
public PingCommand() {
|
||||||
name = "Ping";
|
name = "Ping";
|
||||||
description = "Pings the bot.";
|
description = "Pings the bot.";
|
||||||
usage = "-ping";
|
usage = PropertiesRetrieval.getCommandSignifier() + "ping";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("ping");
|
identifiers.add("ping");
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class PowerCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public PowerCommand() {
|
||||||
|
name = "Power";
|
||||||
|
description = "Finds Num1 ^ Num2";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "power <Num1> <Num2>";
|
||||||
|
minArgs = 2;
|
||||||
|
maxArgs = 2;
|
||||||
|
identifiers.add("power");
|
||||||
|
identifiers.add("pow");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -power");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
double num2 = Double.parseDouble(args[1]);
|
||||||
|
String pow = Double.toString( Math.pow(num,num2));
|
||||||
|
String end = pow.substring(Math.max(pow.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
pow = pow.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(args[0] + "^" + args[1] + " is **" + pow + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.SpamRecords;
|
import com.fpghoti.biscuit.global.SpamRecords;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
@ -13,7 +14,7 @@ public class RecentSpammersCommand extends ClientCommand{
|
||||||
public RecentSpammersCommand() {
|
public RecentSpammersCommand() {
|
||||||
name = "Recent Spammers";
|
name = "Recent Spammers";
|
||||||
description = "Retrieves a list of recent spammers.";
|
description = "Retrieves a list of recent spammers.";
|
||||||
usage = "-recentspammers";
|
usage = PropertiesRetrieval.getCommandSignifier() + "recentspammers";
|
||||||
minArgs = 0;
|
minArgs = 0;
|
||||||
maxArgs = 0;
|
maxArgs = 0;
|
||||||
identifiers.add("recentspammers");
|
identifiers.add("recentspammers");
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.fpghoti.biscuit.commands.client;
|
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
|
||||||
import com.fpghoti.biscuit.api.API;
|
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|
||||||
|
|
||||||
public class ShutDownCommand extends ClientCommand{
|
|
||||||
|
|
||||||
public ShutDownCommand() {
|
|
||||||
name = "Shut Down";
|
|
||||||
description = "Shuts down the bot.";
|
|
||||||
usage = "-shutdown";
|
|
||||||
minArgs = 0;
|
|
||||||
maxArgs = 0;
|
|
||||||
identifiers.add("shutdown");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(String[] args, MessageReceivedEvent event) {
|
|
||||||
Biscuit b = API.getBiscuit();
|
|
||||||
b.log(event.getAuthor().getName() + " issued a command: -shutdown");
|
|
||||||
if(PermUtil.isAdmin(event.getMember())) {
|
|
||||||
|
|
||||||
event.getTextChannel().sendMessage("Shutting down Mr. Bouncer...").queue();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.SpamRecords;
|
import com.fpghoti.biscuit.global.SpamRecords;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ public class SoftMuteCommand extends ClientCommand{
|
||||||
public SoftMuteCommand() {
|
public SoftMuteCommand() {
|
||||||
name = "Soft Mute";
|
name = "Soft Mute";
|
||||||
description = "Soft mutes a user. In this state, they will only be able to send a message every two minutes.";
|
description = "Soft mutes a user. In this state, they will only be able to send a message every two minutes.";
|
||||||
usage = "-softmute @<mention-user>";
|
usage = PropertiesRetrieval.getCommandSignifier() + "softmute @<mention-user>";
|
||||||
minArgs = 1;
|
minArgs = 1;
|
||||||
maxArgs = 1;
|
maxArgs = 1;
|
||||||
identifiers.add("softmute");
|
identifiers.add("softmute");
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class SquareRootCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public SquareRootCommand() {
|
||||||
|
name = "Square Root";
|
||||||
|
description = "Finds square root.";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "squareroot <Num>";
|
||||||
|
minArgs = 1;
|
||||||
|
maxArgs = 1;
|
||||||
|
identifiers.add("squareroot");
|
||||||
|
identifiers.add("sqrt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -squareroot");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
String root = Double.toString(Math.sqrt(num));
|
||||||
|
String end = root.substring(Math.max(root.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
root = root.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage("The sqaure root of " + args[0] + " is **" + root + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class SubtractCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public SubtractCommand() {
|
||||||
|
name = "Subtract";
|
||||||
|
description = "Subtracts two numbers.";
|
||||||
|
usage = PropertiesRetrieval.getCommandSignifier() + "subtract <Num1> <Num2>";
|
||||||
|
minArgs = 2;
|
||||||
|
maxArgs = 2;
|
||||||
|
identifiers.add("subtract");
|
||||||
|
identifiers.add("sub");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -subtract");
|
||||||
|
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||||
|
double num = Double.parseDouble(args[0]);
|
||||||
|
double num2 = Double.parseDouble(args[1]);
|
||||||
|
String sub = Double.toString(num - num2);
|
||||||
|
String end = sub.substring(Math.max(sub.length() - 2, 0));
|
||||||
|
if(end.equals(".0")) {
|
||||||
|
sub = sub.replace(".0","");
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(args[0] + " - " + args[1] + " is **" + sub + "**.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -14,7 +15,7 @@ public class UIDCommand extends ClientCommand{
|
||||||
public UIDCommand() {
|
public UIDCommand() {
|
||||||
name = "User ID";
|
name = "User ID";
|
||||||
description = "Retrieves a user's ID.";
|
description = "Retrieves a user's ID.";
|
||||||
usage = "-uid @<mention-user>";
|
usage = PropertiesRetrieval.getCommandSignifier() + "uid @<mention-user>";
|
||||||
minArgs = 1;
|
minArgs = 1;
|
||||||
maxArgs = 1;
|
maxArgs = 1;
|
||||||
identifiers.add("uid");
|
identifiers.add("uid");
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.SpamRecords;
|
import com.fpghoti.biscuit.global.SpamRecords;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ public class UnSoftMuteCommand extends ClientCommand{
|
||||||
public UnSoftMuteCommand() {
|
public UnSoftMuteCommand() {
|
||||||
name = "Un Soft Mute";
|
name = "Un Soft Mute";
|
||||||
description = "Removes a soft mute from a user.";
|
description = "Removes a soft mute from a user.";
|
||||||
usage = "-unsoftmute @<mention-user>";
|
usage = PropertiesRetrieval.getCommandSignifier() + "unsoftmute @<mention-user>";
|
||||||
minArgs = 1;
|
minArgs = 1;
|
||||||
maxArgs = 1;
|
maxArgs = 1;
|
||||||
identifiers.add("unsoftmute");
|
identifiers.add("unsoftmute");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.fpghoti.biscuit.commands.console;
|
package com.fpghoti.biscuit.commands.console;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Biscuit;
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.api.API;
|
import com.fpghoti.biscuit.api.API;
|
||||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||||
|
|
||||||
|
@ -10,13 +11,16 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
public class SayCommand extends ConsoleCommand{
|
public class SayCommand extends ConsoleCommand{
|
||||||
|
|
||||||
public SayCommand() {
|
public SayCommand() {
|
||||||
name = "Say";
|
name = "Say (Console)";
|
||||||
description = "Makes bot send message on specified channel.";
|
description = "Makes bot send message on specified channel.";
|
||||||
usage = "say <channel-name> <message>";
|
usage = "[CONSOLE] say <channel-name> <message>";
|
||||||
minArgs = 2;
|
minArgs = 2;
|
||||||
maxArgs = 2000;
|
maxArgs = 2000;
|
||||||
|
if(!Main.isPlugin) {
|
||||||
identifiers.add("say");
|
identifiers.add("say");
|
||||||
}
|
}
|
||||||
|
identifiers.add("bsay");
|
||||||
|
}
|
||||||
|
|
||||||
public void execute(String[] args) {
|
public void execute(String[] args) {
|
||||||
Biscuit b = API.getBiscuit();
|
Biscuit b = API.getBiscuit();
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.fpghoti.biscuit.commands.console;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.api.API;
|
||||||
|
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||||
|
|
||||||
|
public class ShutdownConsoleCommand extends ConsoleCommand{
|
||||||
|
|
||||||
|
public ShutdownConsoleCommand() {
|
||||||
|
name = "Shutdown (Console)";
|
||||||
|
description = "Shuts down the bot.";
|
||||||
|
usage = "[CONSOLE] shutdown";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("shutdown");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(String[] args) {
|
||||||
|
Biscuit b = API.getBiscuit();
|
||||||
|
if(args.length == 0) {
|
||||||
|
Main.shutdown();
|
||||||
|
}else{
|
||||||
|
b.log("INCORRECT USAGE! TRY: say <channel-name> <message>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,56 +1,43 @@
|
||||||
package com.fpghoti.biscuit.config;
|
package com.fpghoti.biscuit.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
|
|
||||||
public class ConfigRetrieval {
|
public class ConfigRetrieval {
|
||||||
|
|
||||||
static Logger log = Main.log;
|
static Logger log = Main.log;
|
||||||
|
|
||||||
public static void generateConfig(){
|
public static void generateConfig() {
|
||||||
Properties prop = new Properties();
|
File config;
|
||||||
OutputStream output = null;
|
if(Main.isPlugin) {
|
||||||
|
config = new File(PluginCore.plugin.getDataFolder(), "config.properties");
|
||||||
try {
|
if(!config.exists()) {
|
||||||
FileInputStream inputStream =
|
config.getParentFile().mkdir();
|
||||||
new FileInputStream("config.properties");
|
|
||||||
inputStream.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(FileNotFoundException ex) {
|
}else {
|
||||||
log.info("config.ini missing...\nCreating file...");
|
config = new File("config.properties");
|
||||||
|
}
|
||||||
|
if (!config.exists()) {
|
||||||
try {
|
try {
|
||||||
output = new FileOutputStream("config.properties");
|
Path path = config.toPath();
|
||||||
prop.setProperty("Bot-Token", "");
|
InputStream is = ConfigRetrieval.class.getClassLoader().getResourceAsStream("config.properties");
|
||||||
prop.setProperty("AllowSpamPunish", "true");
|
Files.copy( is, path);
|
||||||
prop.store(output, null);
|
is.close();
|
||||||
|
} catch (Exception e) {
|
||||||
} catch (IOException io) {
|
|
||||||
io.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (output != null) {
|
|
||||||
try {
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(IOException ex) {
|
|
||||||
log.info("CANNOT READ CONFIG!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getFromConfig(String property){
|
public static String getFromConfig(String property){
|
||||||
String setting = "";
|
String setting = "";
|
||||||
|
@ -58,8 +45,16 @@ public class ConfigRetrieval {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
|
|
||||||
|
File config;
|
||||||
|
|
||||||
|
if(Main.isPlugin) {
|
||||||
|
config = new File(PluginCore.plugin.getDataFolder(), "config.properties");
|
||||||
|
}else {
|
||||||
|
config = new File("config.properties");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
input = new FileInputStream("config.properties");
|
input = new FileInputStream(config);
|
||||||
prop.load(input);
|
prop.load(input);
|
||||||
setting = prop.getProperty(property);
|
setting = prop.getProperty(property);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
|
@ -1,60 +1,54 @@
|
||||||
package com.fpghoti.biscuit.config;
|
package com.fpghoti.biscuit.config;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class PropertiesRetrieval {
|
public class PropertiesRetrieval {
|
||||||
|
|
||||||
public static String getToken(){
|
public static String getToken(){
|
||||||
String token = "";
|
return ConfigRetrieval.getFromConfig("Bot-Token");
|
||||||
|
|
||||||
Properties prop = new Properties();
|
|
||||||
InputStream input = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
input = new FileInputStream("config.properties");
|
|
||||||
prop.load(input);
|
|
||||||
token = prop.getProperty("Bot-Token");
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (input != null) {
|
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCommandSignifier(){
|
public static String getCommandSignifier(){
|
||||||
String signifier = "";
|
return ConfigRetrieval.getFromConfig("Command-Signifier");
|
||||||
|
|
||||||
Properties prop = new Properties();
|
|
||||||
InputStream input = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
input = new FileInputStream("config.properties");
|
|
||||||
prop.load(input);
|
|
||||||
signifier = signifier + prop.getProperty("Command-Signifier").charAt(0);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (input != null) {
|
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return signifier;
|
public static String getDoneEmote(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Done-Emote");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDontNotify(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Dont-Notify-Role");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean captchaEnabled(){
|
||||||
|
String value = ConfigRetrieval.getFromConfig("Captcha");
|
||||||
|
return value.equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCaptchaReward(){
|
||||||
|
return ConfigRetrieval.getFromConfig("Captcha-Reward-Role");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultRole(){
|
||||||
|
return ConfigRetrieval.getFromConfig("DefaultRoleName");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean noCaptchaKick(){
|
||||||
|
String value = ConfigRetrieval.getFromConfig("No-Captcha-Kick");
|
||||||
|
return value.equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer noCaptchaKickTime(){
|
||||||
|
String value = ConfigRetrieval.getFromConfig("No-Captcha-Kick-Time");
|
||||||
|
if(!Util.isDigit(value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean logChat(){
|
||||||
|
String value = ConfigRetrieval.getFromConfig("ChatLog");
|
||||||
|
return value.equalsIgnoreCase("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
package com.fpghoti.biscuit.listener;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
|
import com.github.cage.Cage;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.ChannelType;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
|
public class DMListener extends ListenerAdapter{
|
||||||
|
|
||||||
|
Logger log = Main.log;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessageReceived(MessageReceivedEvent event){
|
||||||
|
if (event.isFromType(ChannelType.PRIVATE) && !event.getAuthor().isBot()) {
|
||||||
|
if(PropertiesRetrieval.logChat()) {
|
||||||
|
log.info( "NEW PRIVATE MESSAGE - MSGID: " + event.getMessageId() + "- @" + event.getAuthor().getName() + " " + event.getAuthor().getAsMention() + " - " + event.getMessage().getContentDisplay());
|
||||||
|
}
|
||||||
|
handleCaptcha(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleCaptcha(MessageReceivedEvent event) {
|
||||||
|
PrivateChannel channel = event.getPrivateChannel();
|
||||||
|
User author = event.getAuthor();
|
||||||
|
if(PreUser.getPreUser(author) != null) {
|
||||||
|
PreUser preu = PreUser.getPreUser(author);
|
||||||
|
if(preu.getToken() == null || !event.getMessage().getContentDisplay().equals(preu.getToken())) {
|
||||||
|
|
||||||
|
if(preu.getToken() != null) {
|
||||||
|
channel.sendMessage("Sorry! That's not quite right! Please try again.").queue();
|
||||||
|
}
|
||||||
|
Main.log.info("Generating captcha challenge for user " + author.getName() + " " + author.getAsMention() + "...");
|
||||||
|
|
||||||
|
Cage cage = Main.getBiscuit().getCage();
|
||||||
|
|
||||||
|
preu.genToken();
|
||||||
|
|
||||||
|
OutputStream os;
|
||||||
|
try {
|
||||||
|
//os = new FileOutputStream("captcha/" + author.getId() + ".jpg", false);
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
os = new FileOutputStream("captcha/" + author.getId() + ".jpg", false);
|
||||||
|
}else {
|
||||||
|
File c = new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
||||||
|
os = new FileOutputStream(c, false);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
cage.draw(preu.getToken() , os);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File captcha;
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
captcha = new File("captcha/" + author.getId() + ".jpg");
|
||||||
|
}else {
|
||||||
|
captcha = new File(PluginCore.plugin.getDataFolder(), "captcha/" + author.getId() + ".jpg");
|
||||||
|
}
|
||||||
|
channel.sendMessage("Respond with the exact text in this image (case-sensitive)").queue();
|
||||||
|
channel.sendFile(captcha).queue();
|
||||||
|
|
||||||
|
}else {
|
||||||
|
preu.setDone();
|
||||||
|
Main.log.info(author.getName() + " successfully completed a captcha challenge. Granting role.");
|
||||||
|
|
||||||
|
Role newrole = null;
|
||||||
|
Role defaultrole = null;
|
||||||
|
|
||||||
|
for(Guild g : preu.getGuilds()) {
|
||||||
|
for(Role r : g.getRoles()) {
|
||||||
|
if(r.getName().toLowerCase().contains(PropertiesRetrieval.getCaptchaReward().toLowerCase())) {
|
||||||
|
newrole = r;
|
||||||
|
}else if(r.getName().toLowerCase().contains(PropertiesRetrieval.getDefaultRole().toLowerCase())) {
|
||||||
|
defaultrole = r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(newrole == null) {
|
||||||
|
Main.log.error("Cannot find captcha reward role!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defaultrole == null) {
|
||||||
|
Main.log.error("Cannot find captcha default role!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Member member = g.getMemberById(author.getId());
|
||||||
|
|
||||||
|
g.addRoleToMember(member, newrole).queue();
|
||||||
|
g.removeRoleFromMember(member, defaultrole).queue();
|
||||||
|
preu.remove();
|
||||||
|
}
|
||||||
|
channel.sendMessage("Well done, " + author.getAsMention() + "!").queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,9 +3,12 @@ package com.fpghoti.biscuit.listener;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.Properties;
|
import com.fpghoti.biscuit.global.Properties;
|
||||||
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
|
@ -15,7 +18,8 @@ public class JoinListener extends ListenerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
|
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
|
||||||
log.info("MEMBER JOINED: " + event.getMember().getUser().getName());
|
User user = event.getMember().getUser();
|
||||||
|
log.info("MEMBER JOINED: " + user.getName() + " " + user.getAsMention());
|
||||||
if(Properties.customdefaultrole) {
|
if(Properties.customdefaultrole) {
|
||||||
if(!event.getMember().getUser().isBot()) {
|
if(!event.getMember().getUser().isBot()) {
|
||||||
log.info("Issuing a role..");
|
log.info("Issuing a role..");
|
||||||
|
@ -30,6 +34,10 @@ public class JoinListener extends ListenerAdapter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(PropertiesRetrieval.captchaEnabled()) {
|
||||||
|
new PreUser(event.getMember().getUser());
|
||||||
|
}
|
||||||
|
|
||||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@ import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
import com.fpghoti.biscuit.global.MessageQueue;
|
import com.fpghoti.biscuit.global.MessageQueue;
|
||||||
import com.fpghoti.biscuit.global.SpamRecords;
|
import com.fpghoti.biscuit.global.SpamRecords;
|
||||||
import com.fpghoti.biscuit.util.ChatFilter;
|
import com.fpghoti.biscuit.util.ChatFilter;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.entities.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.exceptions.PermissionException;
|
import net.dv8tion.jda.api.exceptions.PermissionException;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
@ -18,12 +20,16 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
|
|
||||||
Logger log = Main.log;
|
Logger log = Main.log;
|
||||||
|
|
||||||
|
|
||||||
|
/*TODO Cleanup*/
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(MessageReceivedEvent event){
|
public void onMessageReceived(MessageReceivedEvent event){
|
||||||
|
if (event.isFromType(ChannelType.TEXT)) {
|
||||||
if(Util.isLoggable(event.getTextChannel())) {
|
if(Util.isLoggable(event.getTextChannel())) {
|
||||||
|
if(PropertiesRetrieval.logChat()) {
|
||||||
log.info( "NEW MSG - MSGID: " + event.getMessageId() + "- @" + event.getAuthor().getName() + " " + event.getAuthor().getAsMention() + " - CHANNEL: #" + event.getChannel().getName() + " - " + event.getMessage().getContentDisplay());
|
log.info( "NEW MSG - MSGID: " + event.getMessageId() + "- @" + event.getAuthor().getName() + " " + event.getAuthor().getAsMention() + " - CHANNEL: #" + event.getChannel().getName() + " - " + event.getMessage().getContentDisplay());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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.isNaughty(event.getMessage().getContentDisplay()))){
|
||||||
MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
|
MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
|
||||||
|
@ -76,6 +82,8 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// Listen for spammers
|
||||||
|
|
||||||
if(ConfigRetrieval.getFromConfig("AllowSpamPunish").equalsIgnoreCase("true")){
|
if(ConfigRetrieval.getFromConfig("AllowSpamPunish").equalsIgnoreCase("true")){
|
||||||
if(!event.getAuthor().isBot() && !SpamRecords.softmute.contains(event.getAuthor()) && !MessageQueue.chatssent.isEmpty() && MessageQueue.chatssent.get(event.getAuthor()) > 7){
|
if(!event.getAuthor().isBot() && !SpamRecords.softmute.contains(event.getAuthor()) && !MessageQueue.chatssent.isEmpty() && MessageQueue.chatssent.get(event.getAuthor()) > 7){
|
||||||
if(!SpamRecords.spammers.contains(event.getAuthor())){
|
if(!SpamRecords.spammers.contains(event.getAuthor())){
|
||||||
|
@ -107,7 +115,9 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.fpghoti.biscuit.timer.task;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||||
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
|
|
||||||
|
public class DecrementTimer extends BiscuitTimer{
|
||||||
|
|
||||||
|
public DecrementTimer(){
|
||||||
|
delay = (long) 0;
|
||||||
|
period = (long) 60*1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if(Main.ready) {
|
||||||
|
for(PreUser p : PreUser.users) {
|
||||||
|
p.decrementTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.fpghoti.biscuit.user;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
|
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
||||||
|
public class PreUser {
|
||||||
|
|
||||||
|
public static CopyOnWriteArrayList<PreUser> users = new CopyOnWriteArrayList<PreUser>();
|
||||||
|
|
||||||
|
public static PreUser getPreUser(User user) {
|
||||||
|
for(PreUser u : users) {
|
||||||
|
if(u.getUser().getId().equals(user.getId())) {
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean preUserExists(User user) {
|
||||||
|
return getPreUser(user) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
private String token;
|
||||||
|
private int timeLeft;
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
public PreUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
this.token = null;
|
||||||
|
this.done = false;
|
||||||
|
this.timeLeft = PropertiesRetrieval.noCaptchaKickTime() + 1;
|
||||||
|
users.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Going to use custom string gen for more char types in captcha
|
||||||
|
public void genToken() {
|
||||||
|
//token = Main.getBiscuit().getCage().getTokenGenerator().next();
|
||||||
|
token = Util.randomString(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDone() {
|
||||||
|
this.done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decrementTime() {
|
||||||
|
if(!shareGuild()) {
|
||||||
|
remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!done) {
|
||||||
|
if(PropertiesRetrieval.noCaptchaKick()) {
|
||||||
|
timeLeft = timeLeft - 1;
|
||||||
|
if(timeLeft <= 0) {
|
||||||
|
for(Guild g : getGuilds()) {
|
||||||
|
Main.log.info(user.getName() + " " + user.getAsMention() + " waited too long to complete the captcha! Kicking...");
|
||||||
|
g.kick(user.getId()).queue();
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shareGuild() {
|
||||||
|
JDA jda = Main.getBiscuit().getJDA();
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
if(g.isMember(user)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Guild> getGuilds(){
|
||||||
|
ArrayList<Guild> guilds = new ArrayList<Guild>();
|
||||||
|
JDA jda = Main.getBiscuit().getJDA();
|
||||||
|
for(Guild g : jda.getGuilds()) {
|
||||||
|
if(g.isMember(user)){
|
||||||
|
guilds.add(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return guilds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
setDone();
|
||||||
|
Main.log.info("Removing captcha data for user " + user.getName() + " " + user.getAsMention());
|
||||||
|
File captcha;
|
||||||
|
if(!Main.isPlugin) {
|
||||||
|
captcha = new File("captcha/" + user.getId() + ".jpg");
|
||||||
|
}else {
|
||||||
|
captcha = new File(PluginCore.plugin.getDataFolder(), "captcha/" + user.getId() + ".jpg");
|
||||||
|
}
|
||||||
|
token = null;
|
||||||
|
captcha.delete();
|
||||||
|
users.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,4 +28,36 @@ public class Util {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isDigit(String s){
|
||||||
|
return s.matches("[0-9]+");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDeciDigit(String s){
|
||||||
|
int i = 0;
|
||||||
|
String s2 = "";
|
||||||
|
for(Character c : s.toCharArray()) {
|
||||||
|
if(!(i == 0 && c == '-')) {
|
||||||
|
s2 = s2 + c;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return s2.replace(".", "").matches("[0-9]+");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
|
|
||||||
|
public static String randomString(int size) {
|
||||||
|
Random rand = new Random();
|
||||||
|
if (size <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String str = "";
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
int ind = rand.nextInt(chars.length());
|
||||||
|
char rchar = chars.charAt(ind);
|
||||||
|
str = str + rchar;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#Change this to redefine the main command signifier character/String
|
||||||
|
Command-Signifier:-
|
||||||
|
|
||||||
|
#Set to false to disable chat logging
|
||||||
|
ChatLog:true
|
||||||
|
|
||||||
|
#Automatically places spammers in spam mode
|
||||||
|
AllowSpamPunish:true
|
||||||
|
|
||||||
|
Channels-To-Not-Chatlog:ignore_me
|
||||||
|
|
||||||
|
#Bot token provided by Discord
|
||||||
|
Bot-Token:
|
||||||
|
|
||||||
|
#Normal channels will have messages with these words deleted by the bot
|
||||||
|
NaughtyList:piff
|
||||||
|
|
||||||
|
#Bot can automatically assign role upon user join
|
||||||
|
UseCustomDefaultRole:true
|
||||||
|
|
||||||
|
#Does nothing if UseCustomDefaultRole is off
|
||||||
|
DefaultRoleName:Standard
|
||||||
|
|
||||||
|
#Emote to react with when action is complete
|
||||||
|
Done-Emote:ActionComplete
|
||||||
|
|
||||||
|
#Role to disable notifications
|
||||||
|
Dont-Notify-Role:dont_notify
|
||||||
|
|
||||||
|
#Set true to enable captcha
|
||||||
|
#Use with UseCustomDefaultRole enabled
|
||||||
|
#Will require user to have that role for captcha check
|
||||||
|
#Role will be replaced with reward role on clear
|
||||||
|
Captcha=false
|
||||||
|
|
||||||
|
#Reward this role when captcha cleared
|
||||||
|
Captcha-Reward-Role:cleared
|
||||||
|
|
||||||
|
#Kick if Captcha is not completed in a timely manner
|
||||||
|
No-Captcha-Kick:false
|
||||||
|
|
||||||
|
#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
|
||||||
|
No-Captcha-Kick-Time:10
|
|
@ -0,0 +1,9 @@
|
||||||
|
name: Biscuit
|
||||||
|
author: Ghoti_Mayo
|
||||||
|
version: ${project.version}
|
||||||
|
main: com.fpghoti.biscuit.PluginCore
|
||||||
|
description: Discord bot. Also runs as a Spigot plugin.
|
||||||
|
commands:
|
||||||
|
bsay:
|
||||||
|
description: Send a message to a channel as a bot. Perm biscuit.admin
|
||||||
|
usage: /bsay <channel-name-without-#> <message>
|
Loading…
Reference in New Issue