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) {
 | 
				
			||||||
 | 
								log.info("config.ini missing...\nCreating file...");  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								try {
 | 
				
			||||||
 | 
									output = new FileOutputStream("config.properties");
 | 
				
			||||||
 | 
									prop.setProperty("Bot-Token", "");
 | 
				
			||||||
 | 
									prop.setProperty("AllowSpamPunish", "true");
 | 
				
			||||||
 | 
									prop.store(output, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								} catch (IOException io) {
 | 
				
			||||||
 | 
									io.printStackTrace();
 | 
				
			||||||
 | 
								} finally {
 | 
				
			||||||
 | 
									if (output != null) {
 | 
				
			||||||
 | 
										try {
 | 
				
			||||||
 | 
											output.close();
 | 
				
			||||||
 | 
										} catch (IOException e) {
 | 
				
			||||||
 | 
											e.printStackTrace();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							catch(IOException ex) {
 | 
				
			||||||
 | 
								log.info("CANNOT READ CONFIG!");                  
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static String getFromConfig(String property){
 | 
				
			||||||
 | 
									String setting = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									Properties prop = new Properties();
 | 
				
			||||||
 | 
									InputStream input = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									try {
 | 
				
			||||||
 | 
										input = new FileInputStream("config.properties");
 | 
				
			||||||
 | 
										prop.load(input);
 | 
				
			||||||
 | 
										setting = prop.getProperty(property);
 | 
				
			||||||
 | 
									} catch (IOException ex) {
 | 
				
			||||||
 | 
										ex.printStackTrace();
 | 
				
			||||||
 | 
									} finally {
 | 
				
			||||||
 | 
										if (input != null) {
 | 
				
			||||||
 | 
											try {
 | 
				
			||||||
 | 
												input.close();
 | 
				
			||||||
 | 
											} catch (IOException e) {
 | 
				
			||||||
 | 
												e.printStackTrace();
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									return setting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,60 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.FileInputStream;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					import java.util.Properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PropertiesRetrieval {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static String getToken(){
 | 
				
			||||||
 | 
							String 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(){
 | 
				
			||||||
 | 
							String 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;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.global;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.concurrent.ConcurrentHashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.TextChannel;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MessageQueue {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static HashMap<User, Integer> chatssent = new HashMap<>();
 | 
				
			||||||
 | 
						public static HashMap<User, Integer> spammsgs = new HashMap<>();
 | 
				
			||||||
 | 
						public static HashMap<User, Integer> chatssent10s = new HashMap<>();
 | 
				
			||||||
 | 
						public static HashMap<User, Integer> chatssent2m = new HashMap<>();
 | 
				
			||||||
 | 
						public static ConcurrentHashMap<String, TextChannel> removemessages = new ConcurrentHashMap<>();
 | 
				
			||||||
 | 
						public static ConcurrentHashMap<String, TextChannel> fastremovemessages = new ConcurrentHashMap<>();
 | 
				
			||||||
 | 
						public static ConcurrentHashMap<String, TextChannel> slowremovemessages = new ConcurrentHashMap<>();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.global;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Properties {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							public static String naughtyList = "piff";
 | 
				
			||||||
 | 
							public static String twnaughtyList = "piff";
 | 
				
			||||||
 | 
							public static boolean customdefaultrole = false;
 | 
				
			||||||
 | 
							public static String roleName = "";
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.global;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpamRecords {
 | 
				
			||||||
 | 
						public static List<User> spammers = new ArrayList<>();
 | 
				
			||||||
 | 
						public static List<User> elist = new ArrayList<>();
 | 
				
			||||||
 | 
						public static List<User> warnedspm = new ArrayList<>();
 | 
				
			||||||
 | 
						public static List<User> softmute = new ArrayList<>();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.Main;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.Properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.Role;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.hooks.ListenerAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class JoinListener extends ListenerAdapter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Logger log = Main.log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void onGuildMemberJoin(GuildMemberJoinEvent event) {
 | 
				
			||||||
 | 
							log.info("MEMBER JOINED: " + event.getMember().getUser().getName());
 | 
				
			||||||
 | 
							if(Properties.customdefaultrole) {
 | 
				
			||||||
 | 
								if(!event.getMember().getUser().isBot()) {
 | 
				
			||||||
 | 
									log.info("Issuing a role..");
 | 
				
			||||||
 | 
									Role role = null;
 | 
				
			||||||
 | 
									for(Role r : event.getGuild().getRoles()) {
 | 
				
			||||||
 | 
										if(r.getName().contains(Properties.roleName)) {
 | 
				
			||||||
 | 
											role = r;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if(role == null) {
 | 
				
			||||||
 | 
										log.error("Cannot find role!");
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									event.getGuild().addRoleToMember(event.getMember(), role).queue();
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.Main;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.util.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.hooks.ListenerAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MessageDeleteListener extends ListenerAdapter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Logger log = Main.log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void onMessageDelete(MessageDeleteEvent event) {
 | 
				
			||||||
 | 
							if(Util.isLoggable(event.getTextChannel())) {
 | 
				
			||||||
 | 
								log.info("MESSAGE DELETED - MSGID: " + event.getMessageId());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.Main;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.util.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.hooks.ListenerAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MessageEditListener extends ListenerAdapter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Logger log = Main.log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void onMessageUpdate(MessageUpdateEvent event) {
 | 
				
			||||||
 | 
							if(Util.isLoggable(event.getTextChannel()) && (!event.getAuthor().getName().equalsIgnoreCase("jbot") && !event.getAuthor().isBot())) {
 | 
				
			||||||
 | 
								log.info("MESSAGE EDITED - MSGID: " + event.getMessageId() + "- @" + event.getAuthor().getName() + " " + event.getAuthor().getAsMention() +  " - CHANNEL: #" + event.getChannel().getName() + " - NEW TEXT - " + event.getMessage().getContentDisplay());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,113 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.Main;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.config.ConfigRetrieval;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.SpamRecords;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.util.ChatFilter;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.util.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.Permission;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.exceptions.PermissionException;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.hooks.ListenerAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MessageReceiveListener extends ListenerAdapter{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Logger log = Main.log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void onMessageReceived(MessageReceivedEvent event){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(Util.isLoggable(event.getTextChannel())) {
 | 
				
			||||||
 | 
								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()))){
 | 
				
			||||||
 | 
								MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							//staff channels do not need filtering, as the filter could actually be a hinderance
 | 
				
			||||||
 | 
							if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.isNaughty(event.getMessage().getContentDisplay())){
 | 
				
			||||||
 | 
								String text = event.getMessage().getContentDisplay();
 | 
				
			||||||
 | 
								log.info("Removed Msg - REASON NAUGHTY WORD(S) - by " + event.getAuthor().getName() + ": " + text);
 | 
				
			||||||
 | 
								event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").complete();
 | 
				
			||||||
 | 
								MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!event.getAuthor().isBot() && !MessageQueue.chatssent.containsKey(event.getAuthor())){
 | 
				
			||||||
 | 
								MessageQueue.chatssent.put(event.getAuthor(), 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!event.getAuthor().isBot() && !MessageQueue.spammsgs.containsKey(event.getAuthor())){
 | 
				
			||||||
 | 
								MessageQueue.spammsgs.put(event.getAuthor(), 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!MessageQueue.chatssent10s.containsKey(event.getAuthor()) && SpamRecords.spammers.contains(event.getAuthor())){
 | 
				
			||||||
 | 
								MessageQueue.chatssent10s.put(event.getAuthor(), 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!MessageQueue.chatssent2m.containsKey(event.getAuthor()) && SpamRecords.softmute.contains(event.getAuthor())){
 | 
				
			||||||
 | 
								MessageQueue.chatssent2m.put(event.getAuthor(), 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!event.getAuthor().isBot()){
 | 
				
			||||||
 | 
								MessageQueue.spammsgs.put(event.getAuthor(), MessageQueue.spammsgs.get(event.getAuthor()) + 1);
 | 
				
			||||||
 | 
								MessageQueue.chatssent.put(event.getAuthor(),  MessageQueue.chatssent.get(event.getAuthor()) + 1);
 | 
				
			||||||
 | 
								if(SpamRecords.softmute.contains(event.getAuthor())){
 | 
				
			||||||
 | 
									MessageQueue.chatssent2m.put(event.getAuthor(),  MessageQueue.chatssent2m.get(event.getAuthor()) + 1);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if(SpamRecords.spammers.contains(event.getAuthor())){
 | 
				
			||||||
 | 
									MessageQueue.chatssent10s.put(event.getAuthor(),  MessageQueue.chatssent10s.get(event.getAuthor()) + 1);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if(SpamRecords.softmute.contains(event.getAuthor()) && MessageQueue.chatssent2m.get(event.getAuthor()) > 1){
 | 
				
			||||||
 | 
								String text = event.getMessage().getContentDisplay();
 | 
				
			||||||
 | 
								log.info("Removed Msg - REASON SOFTMUTED - by " + event.getAuthor().getName() + ": " + text);
 | 
				
			||||||
 | 
								MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if(SpamRecords.spammers.contains(event.getAuthor())){
 | 
				
			||||||
 | 
								if(MessageQueue.chatssent10s.get(event.getAuthor()) > 1){
 | 
				
			||||||
 | 
									String text = event.getMessage().getContentDisplay();
 | 
				
			||||||
 | 
									log.info("Removed Msg - REASON FLAGGED AS SPAM - by " + event.getAuthor().getName() + ": " + text);
 | 
				
			||||||
 | 
									MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							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(!SpamRecords.spammers.contains(event.getAuthor())){
 | 
				
			||||||
 | 
										if(event.getGuild().getSelfMember().hasPermission(Permission.NICKNAME_MANAGE)){
 | 
				
			||||||
 | 
											try{
 | 
				
			||||||
 | 
												//ignores music channels so that music bots can operate normally
 | 
				
			||||||
 | 
												if(!event.getChannel().getName().toLowerCase().contains("music")){
 | 
				
			||||||
 | 
													if(SpamRecords.warnedspm.contains(event.getAuthor())){
 | 
				
			||||||
 | 
														MessageQueue.removemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
														SpamRecords.spammers.add(event.getAuthor());
 | 
				
			||||||
 | 
														event.getTextChannel().sendMessage("*Flagging " + event.getAuthor().getAsMention() + " as spam!*").queue();
 | 
				
			||||||
 | 
														log.info("User " + event.getAuthor().getName() + " has been flagged as spam!");
 | 
				
			||||||
 | 
													}else{
 | 
				
			||||||
 | 
														MessageQueue.chatssent.remove(event.getAuthor());
 | 
				
			||||||
 | 
														SpamRecords.warnedspm.add(event.getAuthor());
 | 
				
			||||||
 | 
														event.getTextChannel().sendMessage("**STOP spamming, " + event.getAuthor().getAsMention() + "! You have been warned!**").queue();
 | 
				
			||||||
 | 
														log.info("User " + event.getAuthor().getName() + " has been warned for spam!");
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}catch(PermissionException e){
 | 
				
			||||||
 | 
												log.info("Bot does not have permission to change the nick name of " + event.getAuthor().getName() + "!");
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if(event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)){
 | 
				
			||||||
 | 
										MessageQueue.fastremovemessages.put(event.getMessage().getId(), event.getTextChannel());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.TimerTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class BiscuitTimer extends TimerTask{
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						protected Long delay;
 | 
				
			||||||
 | 
						protected Long period;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public long getDelay() {
 | 
				
			||||||
 | 
							if(delay != null) {
 | 
				
			||||||
 | 
								return delay;
 | 
				
			||||||
 | 
							}else {
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public long getPeriod() {
 | 
				
			||||||
 | 
							if(period != null) {
 | 
				
			||||||
 | 
								return period;
 | 
				
			||||||
 | 
							}else {
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer.task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.timer.BiscuitTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.exceptions.ErrorResponseException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BotMsgRemoveTimer extends BiscuitTimer{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public BotMsgRemoveTimer(){
 | 
				
			||||||
 | 
							delay = (long) 0;
 | 
				
			||||||
 | 
							period = (long) 5*1000;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void run() {
 | 
				
			||||||
 | 
							for(String m : MessageQueue.removemessages.keySet()){
 | 
				
			||||||
 | 
								try{
 | 
				
			||||||
 | 
									MessageQueue.removemessages.get(m).deleteMessageById(m).complete();
 | 
				
			||||||
 | 
								}catch(ErrorResponseException ex){
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							MessageQueue.removemessages.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer.task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.timer.BiscuitTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ChatCountTimer extends BiscuitTimer {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public ChatCountTimer(){
 | 
				
			||||||
 | 
							delay = (long) 0;
 | 
				
			||||||
 | 
							period = (long) 10*1000;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void run() {
 | 
				
			||||||
 | 
							MessageQueue.chatssent.clear();
 | 
				
			||||||
 | 
							MessageQueue.spammsgs.clear();
 | 
				
			||||||
 | 
							MessageQueue.chatssent10s.clear();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer.task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.timer.BiscuitTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.exceptions.ErrorResponseException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class FastMsgRemoveTimer extends BiscuitTimer{
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public FastMsgRemoveTimer(){
 | 
				
			||||||
 | 
							delay = (long) 0;
 | 
				
			||||||
 | 
							period = (long) 1*1000;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void run() {
 | 
				
			||||||
 | 
							for(String m : MessageQueue.fastremovemessages.keySet()){
 | 
				
			||||||
 | 
								try{
 | 
				
			||||||
 | 
									MessageQueue.fastremovemessages.get(m).deleteMessageById(m).complete();
 | 
				
			||||||
 | 
								}catch(ErrorResponseException ex){
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							MessageQueue.fastremovemessages.clear();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer.task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.timer.BiscuitTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.exceptions.ErrorResponseException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SlowMsgRemoveTimer extends BiscuitTimer{
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public SlowMsgRemoveTimer(){
 | 
				
			||||||
 | 
							delay = (long) 0;
 | 
				
			||||||
 | 
							period = (long) 5*1000;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void run() {
 | 
				
			||||||
 | 
							for(String m : MessageQueue.slowremovemessages.keySet()){
 | 
				
			||||||
 | 
								try{
 | 
				
			||||||
 | 
									MessageQueue.slowremovemessages.get(m).deleteMessageById(m).complete();
 | 
				
			||||||
 | 
								}catch(ErrorResponseException ex){
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							MessageQueue.slowremovemessages.clear();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.timer.task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.MessageQueue;
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.timer.BiscuitTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SoftMuteTimer extends BiscuitTimer{
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public SoftMuteTimer(){
 | 
				
			||||||
 | 
							delay = (long) 0;
 | 
				
			||||||
 | 
							period = (long) 120*1000;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void run() {
 | 
				
			||||||
 | 
							MessageQueue.chatssent2m.clear();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,86 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.global.Properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ChatFilter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//CHAT FILTER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static Boolean isNaughty(String sentence){
 | 
				
			||||||
 | 
							for(String s : sentence.split(" ")){
 | 
				
			||||||
 | 
								if(isNaughtyWord(s)){
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static Boolean isNaughtyWord(String word){
 | 
				
			||||||
 | 
							String wordp = "";
 | 
				
			||||||
 | 
							String word2 = word.toLowerCase();
 | 
				
			||||||
 | 
							if(word2.length() >= 2 && word2.charAt(word2.length() -1) == '!'){
 | 
				
			||||||
 | 
								for(int i = 0; i < word2.length() -1; i++ ){
 | 
				
			||||||
 | 
									wordp += word2.charAt(i);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								word2 = wordp;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							wordp = "";
 | 
				
			||||||
 | 
							for(int i = 0; i < word2.length(); i++ ){
 | 
				
			||||||
 | 
								if(word2.charAt(i) != '!'){
 | 
				
			||||||
 | 
									wordp += word2.charAt(i);
 | 
				
			||||||
 | 
								}else{
 | 
				
			||||||
 | 
									wordp += 'i';
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							word2 = wordp;
 | 
				
			||||||
 | 
							word2 = word2.replaceAll("\\p{Punct}+", "").replaceAll("1", "i").replaceAll("5", "s").replaceAll("6", "g").replaceAll("3", "e");
 | 
				
			||||||
 | 
							String[] list = Properties.naughtyList.split(",");
 | 
				
			||||||
 | 
							for(String item : list){
 | 
				
			||||||
 | 
								if(word.equalsIgnoreCase(item) || word.equalsIgnoreCase(item + "s")){
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							word2 = null;
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static Boolean isTWNaughty(String sentence){
 | 
				
			||||||
 | 
							for(String s : sentence.split(" ")){
 | 
				
			||||||
 | 
								if(isTWNaughtyWord(s)){
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static Boolean isTWNaughtyWord(String word){
 | 
				
			||||||
 | 
							String wordp = "";
 | 
				
			||||||
 | 
							String word2 = word.toLowerCase();
 | 
				
			||||||
 | 
							if(word2.length() >= 2 && word2.charAt(word2.length() -1) == '!'){
 | 
				
			||||||
 | 
								for(int i = 0; i < word2.length() -1; i++ ){
 | 
				
			||||||
 | 
									wordp += word2.charAt(i);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								word2 = wordp;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							wordp = "";
 | 
				
			||||||
 | 
							for(int i = 0; i < word2.length(); i++ ){
 | 
				
			||||||
 | 
								if(word2.charAt(i) != '!'){
 | 
				
			||||||
 | 
									wordp += word2.charAt(i);
 | 
				
			||||||
 | 
								}else{
 | 
				
			||||||
 | 
									wordp += 'i';
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							word2 = wordp;
 | 
				
			||||||
 | 
							word2 = word2.replaceAll("\\p{Punct}+", "").replaceAll("1", "i").replaceAll("5", "s").replaceAll("6", "g").replaceAll("3", "e");
 | 
				
			||||||
 | 
							String[] list = Properties.twnaughtyList.split(",");
 | 
				
			||||||
 | 
							for(String item : list){
 | 
				
			||||||
 | 
								if(word.equalsIgnoreCase(item) || word.equalsIgnoreCase(item + "s")){
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							word2 = null;
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.Permission;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.Member;
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.Role;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PermUtil {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static boolean isAdmin(Member member){
 | 
				
			||||||
 | 
							if(member.hasPermission(Permission.ADMINISTRATOR)){
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static boolean isMod(Member member){
 | 
				
			||||||
 | 
							if(isAdmin(member)){
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}else{
 | 
				
			||||||
 | 
								for(Role role : member.getRoles()){
 | 
				
			||||||
 | 
									if(role.getName().equalsIgnoreCase("bouncerkey")){
 | 
				
			||||||
 | 
										return true;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static boolean canMute(Member member){
 | 
				
			||||||
 | 
							if(member.hasPermission(Permission.MESSAGE_MANAGE)){
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}else{
 | 
				
			||||||
 | 
								for(Role role : member.getRoles()){
 | 
				
			||||||
 | 
									if(role.getName().equalsIgnoreCase("bouncerkey")){
 | 
				
			||||||
 | 
										return true;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					package com.fpghoti.biscuit.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fpghoti.biscuit.config.ConfigRetrieval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.dv8tion.jda.api.entities.TextChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Util {
 | 
				
			||||||
 | 
						public static int randInt(int min, int max) {
 | 
				
			||||||
 | 
						    Random rand = new Random();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    int randomNum = rand.nextInt((max - min) + 1) + min;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    return randomNum;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static Boolean isLoggable(TextChannel c) {
 | 
				
			||||||
 | 
							if(c == null) {
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							Boolean a = true;
 | 
				
			||||||
 | 
							for(String s: ConfigRetrieval.getFromConfig("Channels-To-Not-Chatlog").split(",")) {
 | 
				
			||||||
 | 
								if(c.getName().equalsIgnoreCase(s)) {
 | 
				
			||||||
 | 
									a = false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return a;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					<configuration>
 | 
				
			||||||
 | 
					  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
 | 
				
			||||||
 | 
					    <encoder>
 | 
				
			||||||
 | 
					      <pattern>[%date] %level - %msg%n</pattern>
 | 
				
			||||||
 | 
					    </encoder>
 | 
				
			||||||
 | 
					  </appender>
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  <property name="DEV_HOME" value="./logs" />
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					     <appender name="FILE-AUDIT"
 | 
				
			||||||
 | 
					        class="ch.qos.logback.core.rolling.RollingFileAppender">
 | 
				
			||||||
 | 
					        <file>${DEV_HOME}/chatlog.log</file>
 | 
				
			||||||
 | 
					        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
 | 
				
			||||||
 | 
					            <Pattern>
 | 
				
			||||||
 | 
					                <pattern>[%date] %level - %msg%n</pattern>
 | 
				
			||||||
 | 
					            </Pattern>
 | 
				
			||||||
 | 
					        </encoder>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
 | 
				
			||||||
 | 
					      <fileNamePattern>${DEV_HOME}/archived/chatlog.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
 | 
				
			||||||
 | 
					      <maxFileSize>450kb</maxFileSize>
 | 
				
			||||||
 | 
					    </rollingPolicy>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    </appender>
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  <root level="INFO">
 | 
				
			||||||
 | 
					    <appender-ref ref="STDOUT" />
 | 
				
			||||||
 | 
					    <appender-ref ref="FILE-AUDIT" />
 | 
				
			||||||
 | 
					  </root>
 | 
				
			||||||
 | 
					</configuration> 
 | 
				
			||||||
		Loading…
	
		Reference in New Issue