Skip to content

Commit

Permalink
optimize CBCharacter and upgrade JDA
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Feb 14, 2021
1 parent 0973153 commit 8782242
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 541 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
.gradle/
build/
out/
routes.js
database.db
!.idea/copyright/hirobot.xml
!.idea/copyright/profiles_settings.xml
hiro-akiba-8f9a5c0a58a0.json
.env
bday.init.json5
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repositories {
}

dependencies {
implementation(group = "net.dv8tion", name = "JDA", version = "4.2.0_221")
implementation(group = "net.dv8tion", name = "JDA", version = "4.2.0_227")
implementation(group = "com.jagrosh", name = "jda-utilities-command", version = "3.0.4")

implementation(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.10.1")
Expand All @@ -49,8 +49,6 @@ dependencies {
implementation(group = "com.zaxxer", name = "HikariCP", version = "3.4.1")
implementation(group = "org.xerial", name = "sqlite-jdbc", version = "3.30.1")

implementation(group = "com.google.cloud", name = "google-cloud-dialogflow", version = "2.0.0")

}

tasks.withType<JavaCompile> {
Expand All @@ -65,5 +63,5 @@ configure<JavaPluginConvention> {

tasks.withType<Wrapper> {
distributionType = DistributionType.ALL
gradleVersion = "6.1.1"
gradleVersion = "6.8"
}
2 changes: 2 additions & 0 deletions data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 14 additions & 17 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ 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
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
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
Expand All @@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
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" ;;
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

Expand All @@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
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"

# 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" "$@"
25 changes: 7 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ 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"

Expand All @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -61,28 +64,14 @@ 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%\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 %CMD_LINE_ARGS%
"%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
Expand Down
47 changes: 0 additions & 47 deletions roles_map.json5

This file was deleted.

1 change: 0 additions & 1 deletion routes-raw.json

This file was deleted.

56 changes: 0 additions & 56 deletions routes.json

This file was deleted.

14 changes: 7 additions & 7 deletions src/main/java/me/duncte123/hirobot/Hiro.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import me.duncte123.hirobot.database.objects.Birthday;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
Expand Down Expand Up @@ -113,15 +112,11 @@ private void helpConsumer(CommandEvent event) {
}
}

event.reply(builder.toString(), (unused) -> {
if (event.isFromType(ChannelType.TEXT)) {
event.reactSuccess();
}
}, (t) -> event.replyWarning("Help cannot be sent because you are blocking Direct Messages."));
event.reply(builder.toString());
}

private void loadBirthdays() throws IOException {
final var bdayInit = new File("bday.init.json5");
final var bdayInit = new File("./data/bday.init.json5");

if (bdayInit.exists()) {
final List<Birthday> dataArray = ReactionHelpers.MAPPER.readValue(bdayInit, new TypeReference<>() {});
Expand All @@ -143,6 +138,11 @@ private static Map<String, String> loadEnvironment() throws IOException {
final List<String> lines = Files.readAllLines(new File(".env").toPath());

for (String line : lines) {
// ignore comments
if (line.startsWith("#")) {
continue;
}

final String[] kv = line.split("=");

env.put(kv[0], kv[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/duncte123/hirobot/ReactionHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ReactionHelpers {
}*/

public static void load() throws IOException {
final ObjectNode d = (ObjectNode) MAPPER.readTree(new File("roles_map.json5"));
final ObjectNode d = (ObjectNode) MAPPER.readTree(new File("./data/roles_map.json5"));

d.fieldNames().forEachRemaining((key) -> {
final long longKey = Long.parseLong(key);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/duncte123/hirobot/RoutesJSRegexParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
public class RoutesJSRegexParser {

public static void main(String[] args) throws Exception {
File input = new File("routes-raw.json");
File output = new File("valentines.json");
File input = new File("./data/routes-raw.json");
File output = new File("./data/valentines.json");

String content = Files.readString(input.toPath());

Expand Down
Loading

0 comments on commit 8782242

Please sign in to comment.