Initial Commit
This commit is contained in:
commit
ffd6e5978b
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,5 @@
|
|||
target/
|
||||
Bot/
|
||||
logs/
|
||||
bin/
|
||||
testconfig.properties
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Biscuit</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,12 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -0,0 +1,19 @@
|
|||
#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
|
|
@ -0,0 +1,122 @@
|
|||
<?xml version="1.0" encoding="UTF-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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>MrBouncer</artifactId>
|
||||
<version>3.0</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.fpghoti.mrbouncer.MrBouncer</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>oss.sonatype.org</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>soluvas-public-thirdparty</id>
|
||||
<url>http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>4.5.0</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20171018</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.1</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.6</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neovisionaries</groupId>
|
||||
<artifactId>nv-websocket-client</artifactId>
|
||||
<version>2.3</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
<?xml version="1.0" encoding="UTF-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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>Biscuit</artifactId>
|
||||
<version>ALPHA-0.1</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.fpghoti.biscuit.Biscuit</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>oss.sonatype.org</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>soluvas-public-thirdparty</id>
|
||||
<url>http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jcabi</groupId>
|
||||
<artifactId>jcabi-aspects</artifactId>
|
||||
<version>0.22.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.0.0_46</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>4.5.0</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20171018</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.1</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.6</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neovisionaries</groupId>
|
||||
<artifactId>nv-websocket-client</artifactId>
|
||||
<version>2.3</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,75 @@
|
|||
package com.fpghoti.biscuit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.commands.CommandManager;
|
||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
public class Biscuit {
|
||||
|
||||
private JDA jda;
|
||||
private Logger logger;
|
||||
private CommandManager commandManager;
|
||||
private Timer timer;
|
||||
private List<BiscuitTimer> timers;
|
||||
|
||||
public Biscuit(JDA jda, Logger log) {
|
||||
this.jda = jda;
|
||||
this.logger = log;
|
||||
|
||||
commandManager = new CommandManager();
|
||||
timer = new Timer();
|
||||
timers = new ArrayList<BiscuitTimer>();
|
||||
}
|
||||
|
||||
public void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public void warn(String message) {
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
public void error(String message) {
|
||||
logger.error(message);
|
||||
}
|
||||
|
||||
public JDA getJDA() {
|
||||
return jda;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public void say(TextChannel channel, String message) {
|
||||
channel.sendMessage(message).queue();
|
||||
}
|
||||
|
||||
|
||||
public void loadTimers() {
|
||||
timer.cancel();
|
||||
timer = new Timer();
|
||||
for(BiscuitTimer t : timers) {
|
||||
timer.schedule(t,t.getDelay(), t.getPeriod());
|
||||
}
|
||||
}
|
||||
|
||||
public void addTimer(BiscuitTimer bt) {
|
||||
timers.add(bt);
|
||||
}
|
||||
|
||||
public void removeTimer(BiscuitTimer bt) {
|
||||
timers.remove(bt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package com.fpghoti.biscuit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||
import com.fpghoti.biscuit.commands.CommandListener;
|
||||
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
||||
import com.fpghoti.biscuit.commands.client.ChnameCommand;
|
||||
import com.fpghoti.biscuit.commands.client.DontNotifyCommand;
|
||||
import com.fpghoti.biscuit.commands.client.NotSpammerCommand;
|
||||
import com.fpghoti.biscuit.commands.client.NotifyCommand;
|
||||
import com.fpghoti.biscuit.commands.client.PingCommand;
|
||||
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.UIDCommand;
|
||||
import com.fpghoti.biscuit.commands.client.UnSoftMuteCommand;
|
||||
import com.fpghoti.biscuit.commands.console.SayCommand;
|
||||
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.global.Properties;
|
||||
import com.fpghoti.biscuit.listener.JoinListener;
|
||||
import com.fpghoti.biscuit.listener.MessageDeleteListener;
|
||||
import com.fpghoti.biscuit.listener.MessageEditListener;
|
||||
import com.fpghoti.biscuit.listener.MessageReceiveListener;
|
||||
import com.fpghoti.biscuit.timer.task.BotMsgRemoveTimer;
|
||||
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
||||
import com.fpghoti.biscuit.timer.task.FastMsgRemoveTimer;
|
||||
import com.fpghoti.biscuit.timer.task.SlowMsgRemoveTimer;
|
||||
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
||||
|
||||
import ch.qos.logback.core.rolling.RollingFileAppender;
|
||||
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
|
||||
import net.dv8tion.jda.api.AccountType;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
|
||||
public class Main {
|
||||
|
||||
private static JDA jda;
|
||||
|
||||
public RollingFileAppender<String> we;
|
||||
public SizeAndTimeBasedRollingPolicy<String> wes;
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger("ch.qos.logback.core.ConsoleAppender");
|
||||
public static Scanner sc;
|
||||
public static Biscuit biscuit;
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
ConfigRetrieval.generateConfig();
|
||||
log.info("========================= Welcome to Biscuit =========================");
|
||||
startJDA();
|
||||
biscuit = new Biscuit(jda, log);
|
||||
startCommandListener();
|
||||
|
||||
jda.addEventListener(new MessageReceiveListener());
|
||||
jda.addEventListener(new MessageEditListener());
|
||||
jda.addEventListener(new MessageDeleteListener());
|
||||
jda.addEventListener(new JoinListener());
|
||||
|
||||
String link = "NULL";
|
||||
Properties.naughtyList = ConfigRetrieval.getFromConfig("NaughtyList");
|
||||
Properties.customdefaultrole = ConfigRetrieval.getFromConfig("UseCustomDefaultRole").equalsIgnoreCase("true");
|
||||
Properties.roleName = ConfigRetrieval.getFromConfig("DefaultRoleName");
|
||||
|
||||
biscuit.addTimer(new ChatCountTimer());
|
||||
biscuit.addTimer(new BotMsgRemoveTimer());
|
||||
biscuit.addTimer(new FastMsgRemoveTimer());
|
||||
biscuit.addTimer(new SlowMsgRemoveTimer());
|
||||
biscuit.addTimer(new SoftMuteTimer());
|
||||
|
||||
biscuit.loadTimers();
|
||||
|
||||
List<BaseCommand> commands = biscuit.getCommandManager().getCommands();
|
||||
|
||||
//Client
|
||||
|
||||
commands.add(new PingCommand());
|
||||
commands.add(new SoftMuteCommand());
|
||||
commands.add(new UnSoftMuteCommand());
|
||||
commands.add(new NotSpammerCommand());
|
||||
commands.add(new RecentSpammersCommand());
|
||||
commands.add(new ChanIDCommand());
|
||||
commands.add(new ShutDownCommand());
|
||||
commands.add(new UIDCommand());
|
||||
commands.add(new ChnameCommand());
|
||||
commands.add(new NotifyCommand());
|
||||
commands.add(new DontNotifyCommand());
|
||||
|
||||
//Console
|
||||
|
||||
commands.add(new SayCommand());
|
||||
|
||||
link = "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot";
|
||||
log.info("Connection successful!");
|
||||
log.info("Startup successful!");
|
||||
log.info("You can add this bot to Discord using this link:");
|
||||
log.info(link);
|
||||
log.info("======================================================================");
|
||||
log.info("CHAT LOGS BEGIN HERE:");
|
||||
}
|
||||
|
||||
private static void startJDA() {
|
||||
String token = PropertiesRetrieval.getToken();
|
||||
log.info("Connecting bot to Discord.");
|
||||
try{
|
||||
jda = new JDABuilder(AccountType.BOT).setToken(token).build();
|
||||
try {
|
||||
jda.awaitReady();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
jda.setAutoReconnect(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("There was an issue connecting to Discord. Bot shutting down!");
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static void startCommandListener() {
|
||||
sc = new Scanner(System.in);
|
||||
CommandListener cl = new CommandListener();
|
||||
cl.sc = sc;
|
||||
cl.jda = jda;
|
||||
jda.addEventListener(cl);
|
||||
new Thread(cl).start();
|
||||
}
|
||||
|
||||
|
||||
public static void shutdown() {
|
||||
log.info("Shutting down...");
|
||||
sc.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.fpghoti.biscuit.api;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
|
||||
public class API {
|
||||
|
||||
public static Biscuit getBiscuit() {
|
||||
return Main.biscuit;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseCommand{
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String usage;
|
||||
protected int minArgs;
|
||||
protected int maxArgs;
|
||||
protected List<String> identifiers;
|
||||
protected List<String> notes;
|
||||
|
||||
public BaseCommand() {
|
||||
this.identifiers = new ArrayList<String>();
|
||||
this.notes = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public abstract CommandType getType();
|
||||
|
||||
public String[] validate(String input, StringBuilder identifier) {
|
||||
String match = matchIdentifier(input);
|
||||
|
||||
if (match != null) {
|
||||
identifier = identifier.append(match);
|
||||
int i = identifier.length();
|
||||
String[] args = input.substring(i).trim().split(" ");
|
||||
if (args[0].isEmpty()) {
|
||||
args = new String[0];
|
||||
}
|
||||
int l = args.length;
|
||||
if (l >= minArgs && l <= maxArgs) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String matchIdentifier(String input) {
|
||||
String lower = input.toLowerCase();
|
||||
|
||||
int index = -1;
|
||||
int n = identifiers.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String identifier = identifiers.get(i).toLowerCase();
|
||||
if (lower.matches(identifier + "(\\s+.*|\\s*)")) {
|
||||
if (index == -1 || identifier.length() > identifiers.get(index).length()) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
return identifiers.get(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public void setIdentifiers(List<String> identifiers) {
|
||||
this.identifiers = identifiers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public List<String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public abstract class ClientCommand extends BaseCommand{
|
||||
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void execute(String[] args, MessageReceivedEvent event);
|
||||
|
||||
public CommandType getType() {
|
||||
return CommandType.CLIENT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
|
||||
public Scanner sc;
|
||||
public JDA jda;
|
||||
Logger log = Main.log;
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent event){
|
||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(PropertiesRetrieval.getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||
log.info("True");
|
||||
API.getBiscuit().getCommandManager().parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
while(sc.hasNextLine()) {
|
||||
String command = sc.nextLine();
|
||||
String label = command.split(" ")[0];
|
||||
String[] args = new String[command.split(" ").length - 1];
|
||||
for(int i = 1; i < command.split(" ").length; i++) {
|
||||
args[i - 1] = command.split(" ")[i];
|
||||
}
|
||||
runCommand(label, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void runCommand(String label, String[] args) {
|
||||
log.info(label);
|
||||
API.getBiscuit().getCommandManager().dispatch(label, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
private List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
|
||||
public void parse(String message, MessageReceivedEvent e){
|
||||
ArrayList<String> split = new ArrayList<String>();
|
||||
String fixed = message.replaceFirst(PropertiesRetrieval.getCommandSignifier(), "");
|
||||
String[] splitMsg = fixed.split(" ");
|
||||
for(String s: splitMsg){
|
||||
split.add(s);
|
||||
}
|
||||
String label = split.get(0);
|
||||
String[] args = new String[split.size() - 1];
|
||||
split.subList(1, split.size()).toArray(args);
|
||||
|
||||
dispatch(e, label, args);
|
||||
}
|
||||
|
||||
|
||||
public boolean dispatch(String label, String[] args) {
|
||||
return dispatch(null,label,args);
|
||||
}
|
||||
|
||||
public boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
||||
String input = label + " ";
|
||||
for (String s : args) {
|
||||
input += s + " ";
|
||||
}
|
||||
|
||||
BaseCommand match = null;
|
||||
String[] trimmedArgs = null;
|
||||
StringBuilder identifier = new StringBuilder();
|
||||
|
||||
for(BaseCommand cmd : commands) {
|
||||
StringBuilder tmpIdentifier = new StringBuilder();
|
||||
String[] tmpArgs = cmd.validate(input, tmpIdentifier);
|
||||
if (tmpIdentifier.length() > identifier.length()) {
|
||||
identifier = tmpIdentifier;
|
||||
match = cmd;
|
||||
trimmedArgs = tmpArgs;
|
||||
}
|
||||
}
|
||||
|
||||
if(match != null) {
|
||||
if (trimmedArgs == null || (trimmedArgs.length > 0 && trimmedArgs[0].equals("?"))) {
|
||||
commandReply(e, "``Command:" + " " + match.getName() + "``");
|
||||
commandReply(e, "``Description:" + " " + match.getDescription() + "``");
|
||||
commandReply(e, "``Usage:" + " " + match.getUsage() + "``");
|
||||
List<String> notes = match.getNotes();
|
||||
for (String note : notes) {
|
||||
commandReply(e, note);
|
||||
}
|
||||
} else {
|
||||
if(match instanceof ClientCommand && e != null) {
|
||||
((ClientCommand)match).execute(trimmedArgs, e);
|
||||
}else if(match instanceof ConsoleCommand && e == null) {
|
||||
((ConsoleCommand)match).execute(trimmedArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void commandReply(MessageReceivedEvent e, String msg) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(e != null) {
|
||||
b.say(e.getTextChannel(), msg);
|
||||
}else {
|
||||
b.log(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addCommand(BaseCommand command) {
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void removeCommand(BaseCommand command) {
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public List<BaseCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
public enum CommandType {
|
||||
CLIENT,
|
||||
CONSOLE
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
public abstract class ConsoleCommand extends BaseCommand{
|
||||
|
||||
public abstract void execute(String[] args);
|
||||
|
||||
public CommandType getType() {
|
||||
return CommandType.CONSOLE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ChanIDCommand extends ClientCommand{
|
||||
|
||||
public ChanIDCommand() {
|
||||
name = "Channel ID";
|
||||
description = "Retrieves the channel ID.";
|
||||
usage = "-chanid";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("chanid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
||||
String id = event.getTextChannel().getId();
|
||||
event.getTextChannel().sendMessage(id).queue();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
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 ChnameCommand extends ClientCommand{
|
||||
|
||||
public ChnameCommand() {
|
||||
name = "Channel Name";
|
||||
description = "Retrieves the channel name.";
|
||||
usage = "-chname";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("chname");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class DontNotifyCommand extends ClientCommand{
|
||||
|
||||
public DontNotifyCommand() {
|
||||
name = "Don't Notify";
|
||||
description = "Puts user in Don't Notify status.";
|
||||
usage = "-dontnotify";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("dontnotify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -dontnotify");
|
||||
Role role = null;
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
||||
role = r;
|
||||
}
|
||||
}
|
||||
if(role == null) {
|
||||
b.error("Cannot find role!");
|
||||
return;
|
||||
}
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains("ActionComplete")) {
|
||||
done = e;
|
||||
}
|
||||
}
|
||||
if(done == null) {
|
||||
b.error("Cannot find emote!");
|
||||
return;
|
||||
}
|
||||
|
||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class NotSpammerCommand extends ClientCommand{
|
||||
|
||||
public NotSpammerCommand() {
|
||||
name = "Not Spammer";
|
||||
description = "Delists user as spammer.";
|
||||
usage = "-notspammer @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("notspammer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -notspammer " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.spammers.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer flagged as spam.").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class NotifyCommand extends ClientCommand{
|
||||
|
||||
public NotifyCommand() {
|
||||
name = "Notify";
|
||||
description = "Puts user in Notify status.";
|
||||
usage = "-notify";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("notify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -notify");
|
||||
Role role = null;
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
||||
role = r;
|
||||
}
|
||||
}
|
||||
if(role == null) {
|
||||
b.error("Cannot find role!");
|
||||
return;
|
||||
}
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains("ActionComplete")) {
|
||||
done = e;
|
||||
}
|
||||
}
|
||||
if(done == null) {
|
||||
b.error("Cannot find emote!");
|
||||
return;
|
||||
}
|
||||
|
||||
event.getGuild().removeRoleFromMember(event.getMember(),role).queue();
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class PingCommand extends ClientCommand{
|
||||
|
||||
public PingCommand() {
|
||||
name = "Ping";
|
||||
description = "Pings the bot.";
|
||||
usage = "-ping";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("ping");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
||||
event.getTextChannel().sendMessage("Pong!").queue();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
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.global.SpamRecords;
|
||||
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class RecentSpammersCommand extends ClientCommand{
|
||||
|
||||
public RecentSpammersCommand() {
|
||||
name = "Recent Spammers";
|
||||
description = "Retrieves a list of recent spammers.";
|
||||
usage = "-recentspammers";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("recentspammers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
||||
String msg = "Recent spammers:";
|
||||
for( User u: SpamRecords.spammers){
|
||||
msg = msg + " " + u.getAsMention();
|
||||
}
|
||||
event.getTextChannel().sendMessage(msg).queue();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class SoftMuteCommand extends ClientCommand{
|
||||
|
||||
public SoftMuteCommand() {
|
||||
name = "Soft Mute";
|
||||
description = "Soft mutes a user. In this state, they will only be able to send a message every two minutes.";
|
||||
usage = "-softmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("softmute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -softmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.softmute.add(u);
|
||||
u.openPrivateChannel().queue();
|
||||
event.getTextChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class UIDCommand extends ClientCommand{
|
||||
|
||||
public UIDCommand() {
|
||||
name = "User ID";
|
||||
description = "Retrieves a user's ID.";
|
||||
usage = "-uid @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("uid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))
|
||||
event.getTextChannel().sendMessage("DEBUG: " + s+ " retrieved.").queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class UnSoftMuteCommand extends ClientCommand{
|
||||
|
||||
public UnSoftMuteCommand() {
|
||||
name = "Un Soft Mute";
|
||||
description = "Removes a soft mute from a user.";
|
||||
usage = "-unsoftmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("unsoftmute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -unsoftmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.softmute.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer soft-muted.").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
public class SayCommand extends ConsoleCommand{
|
||||
|
||||
public SayCommand() {
|
||||
name = "Say";
|
||||
description = "Makes bot send message on specified channel.";
|
||||
usage = "say <channel-name> <message>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2000;
|
||||
identifiers.add("say");
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(args.length > 0) {
|
||||
String target = args[0];
|
||||
String message = "";
|
||||
if(args.length > 1) {
|
||||
message = args[1];
|
||||
if(args.length > 2) {
|
||||
for(int i = 2; i < args.length; i++) {
|
||||
message = message + " " + args[i];
|
||||
}
|
||||
}
|
||||
for(Guild guild : b.getJDA().getGuilds()) {
|
||||
|
||||
for(TextChannel c : guild.getTextChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(target) || c.getName().equalsIgnoreCase("#" + target)) {
|
||||
c.sendMessage(message).queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: say " + target + " <message>");
|
||||
}
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: say <channel-name> <message>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.fpghoti.biscuit.config;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
|
||||
public class ConfigRetrieval {
|
||||
|
||||
static Logger log = Main.log;
|
||||
|
||||
public static void generateConfig(){
|
||||
Properties prop = new Properties();
|
||||
OutputStream output = null;
|
||||
|
||||
try {
|
||||
FileInputStream inputStream =
|
||||
new FileInputStream("config.properties");
|
||||
inputStream.close();
|
||||
|
||||
}
|
||||
catch(FileNotFoundException ex) {
|
||||