diff --git a/.gradle/6.7/executionHistory/executionHistory.bin b/.gradle/6.7/executionHistory/executionHistory.bin new file mode 100644 index 0000000..6e18ae7 Binary files /dev/null and b/.gradle/6.7/executionHistory/executionHistory.bin differ diff --git a/.gradle/6.7/fileChanges/last-build.bin b/.gradle/6.7/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/6.7/fileChanges/last-build.bin differ diff --git a/.gradle/6.7/fileHashes/fileHashes.bin b/.gradle/6.7/fileHashes/fileHashes.bin new file mode 100644 index 0000000..c67f0ab Binary files /dev/null and b/.gradle/6.7/fileHashes/fileHashes.bin differ diff --git a/.gradle/6.7/fileHashes/resourceHashesCache.bin b/.gradle/6.7/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..e78576a Binary files /dev/null and b/.gradle/6.7/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/6.7/gc.properties b/.gradle/6.7/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/6.7/javaCompile/classAnalysis.bin b/.gradle/6.7/javaCompile/classAnalysis.bin new file mode 100644 index 0000000..d2ac9e1 Binary files /dev/null and b/.gradle/6.7/javaCompile/classAnalysis.bin differ diff --git a/.gradle/6.7/javaCompile/taskHistory.bin b/.gradle/6.7/javaCompile/taskHistory.bin new file mode 100644 index 0000000..c0876d8 Binary files /dev/null and b/.gradle/6.7/javaCompile/taskHistory.bin differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..85c5ae0 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Mon Jul 19 19:31:14 EDT 2021 +gradle.version=6.7 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..e533c41 Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin new file mode 100644 index 0000000..83b4f95 Binary files /dev/null and b/.gradle/checksums/md5-checksums.bin differ diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin new file mode 100644 index 0000000..2e40fcc Binary files /dev/null and b/.gradle/checksums/sha1-checksums.bin differ diff --git a/.gradle/configuration-cache/gc.properties b/.gradle/configuration-cache/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..6759da8 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +SugarcaneWikiFAQ \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..95c73e6 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..38aedfd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..38167d7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules/SugarcaneWikiFAQ.iml b/.idea/modules/SugarcaneWikiFAQ.iml new file mode 100644 index 0000000..abeecc0 --- /dev/null +++ b/.idea/modules/SugarcaneWikiFAQ.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WebAPI/index.html b/WebAPI/index.html new file mode 100644 index 0000000..23b2645 --- /dev/null +++ b/WebAPI/index.html @@ -0,0 +1,10 @@ + + + + + + + +

IntelliJ Base HTML Page

+ + \ No newline at end of file diff --git a/WebAPI/no.html b/WebAPI/no.html new file mode 100644 index 0000000..47ce858 --- /dev/null +++ b/WebAPI/no.html @@ -0,0 +1,10 @@ + + + + + Not Supported Method + + +

Error 405: Method Not Supported

+ + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..3b905d6 --- /dev/null +++ b/build.gradle @@ -0,0 +1,33 @@ +plugins { + id 'java' + id 'application' + id 'com.github.johnrengelman.shadow' version '5.2.0' +} + +mainClassName = 'org.sugarcanemc.wikifaqbot.Bot' + +group 'org.sugarcanemc.wikifaqbot' +version '0.1.0' +def jdaVer = '4.3.0_298' + +sourceCompatibility = targetCompatibility = 1.8 + +repositories { + mavenCentral() + maven { + url "https://m2.dv8tion.net/releases" + } +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + implementation("net.dv8tion:JDA:$jdaVer") + compile group: 'org.yaml', name: 'snakeyaml', version: '1.27' +} + +compileJava.options.encoding = 'UTF-8' + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ b/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ new file mode 100644 index 0000000..24a6be5 --- /dev/null +++ b/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +############################################################################## +## +## SugarcaneWikiFAQ start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/.." >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="SugarcaneWikiFAQ" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and SUGARCANE_WIKI_FAQ_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/lib/SugarcaneWikiFAQ-0.1.0-all.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save() { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" -jar "\"$CLASSPATH\"" "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ.bat b/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ.bat new file mode 100644 index 0000000..069aa35 --- /dev/null +++ b/build/install/SugarcaneWikiFAQ-shadow/bin/SugarcaneWikiFAQ.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem SugarcaneWikiFAQ startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%.. + +@rem Add default JVM options here. You can also use JAVA_OPTS and SUGARCANE_WIKI_FAQ_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\lib\SugarcaneWikiFAQ-0.1.0-all.jar + +@rem Execute SugarcaneWikiFAQ +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SUGARCANE_WIKI_FAQ_OPTS% -jar "%CLASSPATH%" %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable SUGARCANE_WIKI_FAQ_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%SUGARCANE_WIKI_FAQ_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega \ No newline at end of file diff --git a/build/scriptsShadow/SugarcaneWikiFAQ b/build/scriptsShadow/SugarcaneWikiFAQ new file mode 100644 index 0000000..24a6be5 --- /dev/null +++ b/build/scriptsShadow/SugarcaneWikiFAQ @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +############################################################################## +## +## SugarcaneWikiFAQ start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/.." >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="SugarcaneWikiFAQ" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and SUGARCANE_WIKI_FAQ_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/lib/SugarcaneWikiFAQ-0.1.0-all.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save() { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" -jar "\"$CLASSPATH\"" "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/build/scriptsShadow/SugarcaneWikiFAQ.bat b/build/scriptsShadow/SugarcaneWikiFAQ.bat new file mode 100644 index 0000000..069aa35 --- /dev/null +++ b/build/scriptsShadow/SugarcaneWikiFAQ.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem SugarcaneWikiFAQ startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%.. + +@rem Add default JVM options here. You can also use JAVA_OPTS and SUGARCANE_WIKI_FAQ_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\lib\SugarcaneWikiFAQ-0.1.0-all.jar + +@rem Execute SugarcaneWikiFAQ +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SUGARCANE_WIKI_FAQ_OPTS% -jar "%CLASSPATH%" %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable SUGARCANE_WIKI_FAQ_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%SUGARCANE_WIKI_FAQ_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega \ No newline at end of file diff --git a/build/tmp/compileJava/source-classes-mapping.txt b/build/tmp/compileJava/source-classes-mapping.txt new file mode 100644 index 0000000..04083ba --- /dev/null +++ b/build/tmp/compileJava/source-classes-mapping.txt @@ -0,0 +1,18 @@ +org/sugarcanemc/wikifaqbot/config/ConfigUtils.java + org.sugarcanemc.wikifaqbot.config.ConfigUtils +org/sugarcanemc/wikifaqbot/commands/InfoCmd.java + org.sugarcanemc.wikifaqbot.commands.InfoCmd +org/sugarcanemc/wikifaqbot/commands/DiceCmd.java + org.sugarcanemc.wikifaqbot.commands.DiceCmd +org/sugarcanemc/wikifaqbot/config/Config.java + org.sugarcanemc.wikifaqbot.config.Config +org/sugarcanemc/wikifaqbot/commands/PingCmd.java + org.sugarcanemc.wikifaqbot.commands.PingCmd +org/sugarcanemc/wikifaqbot/config/ConfigHandler.java + org.sugarcanemc.wikifaqbot.config.ConfigHandler +org/sugarcanemc/wikifaqbot/webapi/WebAPI.java + org.sugarcanemc.wikifaqbot.webapi.WebAPI +org/sugarcanemc/wikifaqbot/Bot.java + org.sugarcanemc.wikifaqbot.Bot +org/sugarcanemc/wikifaqbot/commands/CoinCmd.java + org.sugarcanemc.wikifaqbot.commands.CoinCmd diff --git a/build/tmp/shadowJar/MANIFEST.MF b/build/tmp/shadowJar/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/build/tmp/shadowJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..4a0f378 --- /dev/null +++ b/config.yml @@ -0,0 +1,2 @@ +prefix: "$" +botToken: "ODY2ODE5NzQ2MDM2ODQyNTI2.YPYGzA.qz-ELkl_GOWZ7qbCJSNvimLPZyo" \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..be52383 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/run/config.yml b/run/config.yml new file mode 100644 index 0000000..da95c0b --- /dev/null +++ b/run/config.yml @@ -0,0 +1,2 @@ +prefix: "!" +botToken: "ODY2ODE5NzQ2MDM2ODQyNTI2.YPYGzA.qz-ELkl_GOWZ7qbCJSNvimLPZyo" \ No newline at end of file diff --git a/run/start.cmd b/run/start.cmd new file mode 100644 index 0000000..2045a57 --- /dev/null +++ b/run/start.cmd @@ -0,0 +1,4 @@ +@echo off +title Sugarcane Bot +"C:\Program Files\Java\jre1.8.0_291\bin\java.exe" -Xmx2G -Xms2G -jar SugarcaneWikiFAQ-0.1.0.jar +pause \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d000718 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'SugarcaneWikiFAQ' + diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/Bot.java b/src/main/java/org/sugarcanemc/wikifaqbot/Bot.java new file mode 100644 index 0000000..44199f3 --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/Bot.java @@ -0,0 +1,41 @@ +package org.sugarcanemc.wikifaqbot; + +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.JDABuilder; +import net.dv8tion.jda.api.entities.Activity; +import org.sugarcanemc.wikifaqbot.commands.CoinCmd; +import org.sugarcanemc.wikifaqbot.commands.DiceCmd; +import org.sugarcanemc.wikifaqbot.commands.InfoCmd; +import org.sugarcanemc.wikifaqbot.commands.PingCmd; +import org.sugarcanemc.wikifaqbot.config.Config; +import org.sugarcanemc.wikifaqbot.config.ConfigHandler; +import org.sugarcanemc.wikifaqbot.config.ConfigUtils; + +import java.io.File; + +public class Bot { + + public static void main(String[] args) throws Exception { + String configPath = ConfigHandler.configPath.toString(); + File file = new File(configPath); + + if (!file.exists()) { + ConfigUtils.createConfig(); + } + + ConfigHandler handler = ConfigHandler.getInstance(); + Config config = handler.getConfig(); + String prefix = config.getPrefix(); + String botToken = config.getBotToken(); + + JDA jda = JDABuilder.createDefault(botToken) + .setActivity(Activity.competing("being the very best")) + .addEventListeners(new InfoCmd()) + .addEventListeners(new PingCmd()) + .addEventListeners(new DiceCmd()) + .addEventListeners(new CoinCmd()) + .build(); + jda.awaitReady(); + System.out.println("Finished Building Bot!"); + } +} \ No newline at end of file diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/commands/CoinCmd.java b/src/main/java/org/sugarcanemc/wikifaqbot/commands/CoinCmd.java new file mode 100644 index 0000000..22427e9 --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/commands/CoinCmd.java @@ -0,0 +1,39 @@ +package org.sugarcanemc.wikifaqbot.commands; + +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.sugarcanemc.wikifaqbot.config.ConfigHandler; + +import java.io.FileNotFoundException; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +public class CoinCmd extends ListenerAdapter { + @Override + public void onMessageReceived(MessageReceivedEvent e) { + if (e.getAuthor().isBot()) return; + + Message message = e.getMessage(); + String content = message.getContentRaw(); + String prefix = null; + try { prefix = ConfigHandler.getInstance().getConfig().getPrefix(); } catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace(); } + + if (content.equalsIgnoreCase(prefix + "coinflip")) { + Random rand = new Random(); + int upperbound = 2; + MessageChannel channel = e.getChannel(); + + int i = rand.nextInt(upperbound); + if (i == 0) { + channel.sendTyping().queue(); + channel.sendMessage("The coin landed on **heads**").queue(); + } else { + channel.sendTyping().queue(); + channel.sendMessage("The coin landed on **tails**").queue(); + } + System.out.println(i); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/commands/DiceCmd.java b/src/main/java/org/sugarcanemc/wikifaqbot/commands/DiceCmd.java new file mode 100644 index 0000000..2706db9 --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/commands/DiceCmd.java @@ -0,0 +1,32 @@ +package org.sugarcanemc.wikifaqbot.commands; + +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.sugarcanemc.wikifaqbot.config.ConfigHandler; + +import java.io.FileNotFoundException; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +public class DiceCmd extends ListenerAdapter { + @Override + public void onMessageReceived(MessageReceivedEvent e) { + if (e.getAuthor().isBot()) return; + + Message message = e.getMessage(); + String content = message.getContentRaw(); + String prefix = null; + try { prefix = ConfigHandler.getInstance().getConfig().getPrefix(); } catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace(); } + + if (content.equalsIgnoreCase(prefix + "dice")) { + Random rand = ThreadLocalRandom.current(); + MessageChannel channel = e.getChannel(); + + int roll = rand.nextInt(6) + 1; + channel.sendTyping().queue(); + channel.sendMessage("Your roll: " + roll).queue(); + } + } +} diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/commands/InfoCmd.java b/src/main/java/org/sugarcanemc/wikifaqbot/commands/InfoCmd.java new file mode 100644 index 0000000..32f779d --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/commands/InfoCmd.java @@ -0,0 +1,32 @@ +package org.sugarcanemc.wikifaqbot.commands; + +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.sugarcanemc.wikifaqbot.config.ConfigHandler; + +import java.io.FileNotFoundException; + +public class InfoCmd extends ListenerAdapter { + + public void onMessageReceived(MessageReceivedEvent e) { + if (e.getAuthor().isBot()) return; + Message message = e.getMessage(); + String content = message.getContentRaw(); + String prefix = null; + try { prefix = ConfigHandler.getInstance().getConfig().getPrefix(); } catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace();} + + if (content.equalsIgnoreCase(prefix + "info")) { + EmbedBuilder info = new EmbedBuilder(); + info.setTitle("📚・Information・📚"); + info.setDescription("Information about Sugarcane"); + info.addField("Creator", "nevetS-718", false); + info.setFooter("SugarcaneMC", "https://cdn.discordapp.com/icons/855918593497759754/a_978a67a83330554987cd7521f638fea8.gif?size=4096"); + info.setColor(0x73fc03); + + e.getChannel().sendTyping().queue(); + e.getChannel().sendMessage(info.build()).queue(); + } + } +} diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/commands/PingCmd.java b/src/main/java/org/sugarcanemc/wikifaqbot/commands/PingCmd.java new file mode 100644 index 0000000..fffed3b --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/commands/PingCmd.java @@ -0,0 +1,28 @@ +package org.sugarcanemc.wikifaqbot.commands; + +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.sugarcanemc.wikifaqbot.config.ConfigHandler; + +import java.io.FileNotFoundException; + +public class PingCmd extends ListenerAdapter { + + @Override + public void onMessageReceived(MessageReceivedEvent e) { + if (e.getAuthor().isBot()) return; + + Message message = e.getMessage(); + String content = message.getContentRaw(); + String prefix = null; + try { prefix = ConfigHandler.getInstance().getConfig().getPrefix(); } catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace(); } + + if (content.equalsIgnoreCase(prefix + "ping")) { + MessageChannel channel = e.getChannel(); + channel.sendTyping().queue(); + channel.sendMessage("Pong!").queue(); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/config/Config.java b/src/main/java/org/sugarcanemc/wikifaqbot/config/Config.java new file mode 100644 index 0000000..a7f47f0 --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/config/Config.java @@ -0,0 +1,22 @@ +package org.sugarcanemc.wikifaqbot.config; + +public class Config { + private String prefix; + private String botToken; + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getBotToken() { + return botToken; + } + + public void setBotToken(String botToken) { + this.botToken = botToken; + } +} \ No newline at end of file diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigHandler.java b/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigHandler.java new file mode 100644 index 0000000..ed1c79b --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigHandler.java @@ -0,0 +1,59 @@ +package org.sugarcanemc.wikifaqbot.config; + +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class ConfigHandler { + + public static final Path configPath = Paths.get("./config.yml"); + + private static ConfigHandler configHandler; + + Config config; + + public static ConfigHandler getInstance() throws FileNotFoundException { + return getInstance(configPath); + } + + public static ConfigHandler getInstance(Path configPath) throws FileNotFoundException { + if (configHandler == null) { + configHandler = new ConfigHandler(configPath); + } + return configHandler; + } + + private ConfigHandler(Path configPath) throws FileNotFoundException { + this.config = loadConfig(configPath); + } + + public Config loadConfig(Path configPath) throws FileNotFoundException { + Constructor constructor = new Constructor(Config.class); + Yaml yaml = new Yaml(constructor); + return yaml.load(new FileInputStream(configPath.toFile())); + } + + public void dumpConfig() throws IllegalArgumentException, IllegalAccessException, IOException { + dumpConfig(this.config, this.configPath); + } + + public void dumpConfig(Config config, Path configPath) throws IllegalArgumentException, IllegalAccessException, IOException { + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + options.setPrettyFlow(true); + Yaml yml = new Yaml(options); + yml.dump(config, new FileWriter(configPath.toFile())); + } + + public Config getConfig() { + return this.config; + } + +} \ No newline at end of file diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigUtils.java b/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigUtils.java new file mode 100644 index 0000000..00ec44f --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/config/ConfigUtils.java @@ -0,0 +1,36 @@ +package org.sugarcanemc.wikifaqbot.config; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +public class ConfigUtils { + + public static void createConfig() { + + System.out.println("Attemption to create file..."); + + try { + File config = new File("config.yml"); + + if (config.createNewFile()) { + System.out.println(config.getName() + " has been successfully created!"); + } else { + System.out.println(config.getName() + " already exists!"); + } + } catch (IOException e) { + System.out.println("An error has occurred"); + e.printStackTrace(); + } + + try { + FileWriter writer = new FileWriter("config.yml"); + writer.write("prefix: \"!\"\nbotToken: \"BOTTOKEN\"\nmode: \"default\""); + writer.close(); + System.out.println("Successfully wrote to config.yml"); + } catch (IOException e) { + System.out.println("An error occurred while writing to config.yml"); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/org/sugarcanemc/wikifaqbot/webapi/WebAPI.java b/src/main/java/org/sugarcanemc/wikifaqbot/webapi/WebAPI.java new file mode 100644 index 0000000..3c10609 --- /dev/null +++ b/src/main/java/org/sugarcanemc/wikifaqbot/webapi/WebAPI.java @@ -0,0 +1,77 @@ +package org.sugarcanemc.wikifaqbot.webapi; + +import java.io.*; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.StringTokenizer; + + +public class WebAPI implements Runnable { + + static final File WEB_ROOT = new File("/WebAPI"); + static final String DEFAULT_File = "index.html"; + static final String FILE_NOT_FOUND = "404.html"; + static final String METHOD_NOT_SUPPORTED = "mns.html"; // (file not supported) + + // port + static final int PORT = 80; + // port + + static final boolean verbose = true; + + private Socket connect; + + public void webapi(Socket c) { + connect = c; + } + + public static void main(String[] args){ + try { + ServerSocket serverConnect = new ServerSocket(PORT); + System.out.println("[WebAPI] WebAPI Started on " + "IP" + PORT); + //TODO Make sys.out read IP + while(true) { + WebAPI server = new WebAPI(); + if (verbose) { + System.out.println("[WebAPI] Connection Open."); + } + + Thread thread = new Thread(server); + thread.start(); + + } + } catch (IOException e) { + System.err.println("[WebAPI] Server Connection error"); + e.printStackTrace(); + } + + } + + + @Override + public void run() { + BufferedReader in = null; PrintWriter out = null; BufferedOutputStream dataOut = null; + String fileRequested = null; + + try{ + in = new BufferedReader(new InputStreamReader(connect.getInputStream())); + out = new PrintWriter(connect.getOutputStream()); + dataOut = new BufferedOutputStream(connect.getOutputStream()); + String input = in.readLine(); + StringTokenizer parse = new StringTokenizer(input); + String method = parse.nextToken().toUpperCase(); + fileRequested = parse.nextToken().toLowerCase(); + if(!method.equals("GET") && !method.equals("HEAD")) { + if (verbose) { + System.out.println("501 Not Implemeted: " + method + "method."); + } + } + else{ + + } + } catch(IOException e){ + e.printStackTrace(); + } + + } +}