rolling-10

master
Lars Mueller 2020-04-05 13:15:02 +02:00
parent c576ff07bf
commit e9e1f6612b
102 changed files with 913 additions and 78 deletions

6
.gitignore vendored
View File

@ -1,4 +1,2 @@
/MinetestChatBridgeBot/.gradle/
/MinetestChatBridgeBot/build/
/MinetestChatBridgeIRCBot/.gradle/
/MinetestChatBridgeIRCBot/build/
./MinetestChatBridgeBot/.gradle
./MinetestChatBridgeIRCBot/.gradle

View File

@ -0,0 +1,2 @@
#Sun Apr 05 11:34:15 CEST 2020
gradle.version=6.3

Binary file not shown.

View File

@ -2,13 +2,13 @@ buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'java'
}
apply plugin: 'jacoco'
apply plugin: 'application'
@ -22,16 +22,15 @@ repositories {
}
dependencies {
compile "net.dv8tion:JDA:4.0.0_39", 'ch.qos.logback:logback-classic:1.3.0-alpha4'
compile 'net.dv8tion:JDA:4.0.0_39', 'ch.qos.logback:logback-classic:1.3.0-alpha4'
compile group: 'com.google.guava', name: 'guava', version: '23.5-jre'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
attributes(
'Created-By': "Gradle ${gradle.gradleVersion}",
'Main-Class': "appguru.Main"
'Created-By': 'Gradle ${gradle.gradleVersion}',
'Main-Class': 'appguru.Main'
)
}
}

View File

@ -0,0 +1,183 @@
#!/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.
#
##############################################################################
##
## MinetestChatBridgeBot 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="MinetestChatBridgeBot"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and MINETEST_CHAT_BRIDGE_BOT_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/MinetestChatBridgeBot.jar:$APP_HOME/lib/JDA-4.0.0_39.jar:$APP_HOME/lib/logback-classic-1.3.0-alpha4.jar:$APP_HOME/lib/guava-23.5-jre.jar:$APP_HOME/lib/jsr305-3.0.2.jar:$APP_HOME/lib/annotations-16.0.1.jar:$APP_HOME/lib/slf4j-api-1.8.0-beta1.jar:$APP_HOME/lib/nv-websocket-client-2.5.jar:$APP_HOME/lib/okhttp-3.13.0.jar:$APP_HOME/lib/opus-java-1.0.4.pom:$APP_HOME/lib/commons-collections4-4.1.jar:$APP_HOME/lib/trove4j-3.0.3.jar:$APP_HOME/lib/jackson-databind-2.9.8.jar:$APP_HOME/lib/logback-core-1.3.0-alpha4.jar:$APP_HOME/lib/javax.mail-1.6.0.jar:$APP_HOME/lib/checker-qual-2.0.0.jar:$APP_HOME/lib/error_prone_annotations-2.0.18.jar:$APP_HOME/lib/j2objc-annotations-1.1.jar:$APP_HOME/lib/animal-sniffer-annotations-1.14.jar:$APP_HOME/lib/okio-1.17.2.jar:$APP_HOME/lib/opus-java-api-1.0.4.jar:$APP_HOME/lib/opus-java-natives-1.0.4.jar:$APP_HOME/lib/jackson-annotations-2.9.0.jar:$APP_HOME/lib/jackson-core-2.9.8.jar:$APP_HOME/lib/activation-1.1.jar:$APP_HOME/lib/jna-4.4.0.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 $MINETEST_CHAT_BRIDGE_BOT_OPTS -classpath "\"$CLASSPATH\"" appguru.Main "$APP_ARGS"
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,103 @@
@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 MinetestChatBridgeBot 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 MINETEST_CHAT_BRIDGE_BOT_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\MinetestChatBridgeBot.jar;%APP_HOME%\lib\JDA-4.0.0_39.jar;%APP_HOME%\lib\logback-classic-1.3.0-alpha4.jar;%APP_HOME%\lib\guava-23.5-jre.jar;%APP_HOME%\lib\jsr305-3.0.2.jar;%APP_HOME%\lib\annotations-16.0.1.jar;%APP_HOME%\lib\slf4j-api-1.8.0-beta1.jar;%APP_HOME%\lib\nv-websocket-client-2.5.jar;%APP_HOME%\lib\okhttp-3.13.0.jar;%APP_HOME%\lib\opus-java-1.0.4.pom;%APP_HOME%\lib\commons-collections4-4.1.jar;%APP_HOME%\lib\trove4j-3.0.3.jar;%APP_HOME%\lib\jackson-databind-2.9.8.jar;%APP_HOME%\lib\logback-core-1.3.0-alpha4.jar;%APP_HOME%\lib\javax.mail-1.6.0.jar;%APP_HOME%\lib\checker-qual-2.0.0.jar;%APP_HOME%\lib\error_prone_annotations-2.0.18.jar;%APP_HOME%\lib\j2objc-annotations-1.1.jar;%APP_HOME%\lib\animal-sniffer-annotations-1.14.jar;%APP_HOME%\lib\okio-1.17.2.jar;%APP_HOME%\lib\opus-java-api-1.0.4.jar;%APP_HOME%\lib\opus-java-natives-1.0.4.jar;%APP_HOME%\lib\jackson-annotations-2.9.0.jar;%APP_HOME%\lib\jackson-core-2.9.8.jar;%APP_HOME%\lib\activation-1.1.jar;%APP_HOME%\lib\jna-4.4.0.jar
@rem Execute MinetestChatBridgeBot
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MINETEST_CHAT_BRIDGE_BOT_OPTS% -classpath "%CLASSPATH%" appguru.Main %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable MINETEST_CHAT_BRIDGE_BOT_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%MINETEST_CHAT_BRIDGE_BOT_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,172 @@
#!/usr/bin/env bash
##############################################################################
##
## MinetestChatBridgeBot 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="MinetestChatBridgeBot"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and MINETEST_CHAT_BRIDGE_BOT_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/MinetestChatBridgeBot-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" "$@"

View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem MinetestChatBridgeBot 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 MINETEST_CHAT_BRIDGE_BOT_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\MinetestChatBridgeBot-all.jar
@rem Execute MinetestChatBridgeBot
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MINETEST_CHAT_BRIDGE_BOT_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 MINETEST_CHAT_BRIDGE_BOT_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%MINETEST_CHAT_BRIDGE_BOT_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Created-By: Gradle ${gradle.gradleVersion}
Main-Class: appguru.Main

View File

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Created-By: Gradle ${gradle.gradleVersion}
Main-Class: appguru.Main

View File

@ -27,23 +27,35 @@ public class Main {
public static ProcessBridge PROCESS_BRIDGE;
public static void main(String[] args) throws IOException {
if (args.length > 4) {
File log=new File(args[4]);
if (!log.isFile() || !log.canWrite()) {
OUT.println("ERR: Log file doesn't exist or can't be written to.");
} else {
OUT = new PrintStream(new FileOutputStream(log, true));
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
OUT.close();
}));
}
if (args.length > 5) {
PREFIX=args[5];
if (args.length > 6) {
DISCORD_PREFIX=args[6];
if (args.length > 7) {
GUILD_ID=args[7];
int required_args = 4;
if (args.length < required_args) {
OUT.println("ERR: Not enough arguments given ("+required_args+" required)");
System.exit(1);
}
boolean send_embeds = true;
if (args.length > required_args) {
send_embeds = args[required_args].equalsIgnoreCase("true");
required_args++;
if (args.length > required_args) {
File log=new File(args[required_args]);
if (!log.isFile() || !log.canWrite()) {
OUT.println("ERR: Log file doesn't exist or can't be written to.");
} else {
OUT = new PrintStream(new FileOutputStream(log, true));
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
OUT.close();
}));
}
required_args++;
if (args.length > required_args) {
PREFIX=args[required_args];
required_args++;
if (args.length > required_args) {
DISCORD_PREFIX=args[required_args];
required_args++;
if (args.length > required_args) {
GUILD_ID=args[required_args];
}
}
}
}
@ -80,7 +92,7 @@ public class Main {
}
try {
Bot i=new Bot(token, PROCESS_BRIDGE, channelname);
Bot i=new Bot(token, PROCESS_BRIDGE, channelname, send_embeds);
i.registerInfo("status", "Status", "", Color.CYAN, null);
i.registerCommand("status", new StatusCommand());
@ -95,8 +107,7 @@ public class Main {
"• Minetest chatcommands - Use `"+PREFIX+"` as prefix\n"+
"**More**\n"+
"• See the GitHub Readme linked in the title",Color.GREEN, null);
}
catch (LoginException e) {
} catch (LoginException e) {
System.out.println("ERR: Invalid token. Login failed.");
return;
}

View File

@ -50,7 +50,7 @@ public class Bot extends ListenerAdapter {
public EmbedBuilder success;
public EmbedBuilder message;
public Bot(String token, ProcessBridge pb, String text_channel) throws LoginException {
public Bot(String token, ProcessBridge pb, String text_channel, boolean send_embeds) throws LoginException {
Main.OUT.println("INFO: Starting client");
JDABuilder builder=new JDABuilder(AccountType.BOT);
builder.setToken(token);
@ -67,8 +67,10 @@ public class Bot extends ListenerAdapter {
success.setColor(new Color(0, 255,0));
success.setTitle("Success");
message=new EmbedBuilder();
if (send_embeds) {
message=new EmbedBuilder();
}
jda.addEventListener(this);
}
@ -101,11 +103,7 @@ public class Bot extends ListenerAdapter {
@Override
public void onGuildJoin(GuildJoinEvent e) {
/*Iterator it=jda.getGuildCache().iterator();it.hasNext();
if (it.hasNext()) {
e.getGuild().leave().queue();
}*/
// IDEA: leave
// TODO leave
}
public String escapeName(String name) {
@ -125,32 +123,38 @@ public class Bot extends ListenerAdapter {
bridge.write("[EXT]"+members.inverse().get(e.getMember().getUser().getIdLong()));
}
public synchronized MessageEmbed buildMessage(String msg, Color color) {
message.setColor(color);
message.setDescription(msg);
message.setTimestamp(Instant.now());
return message.build();
public synchronized Message buildMessage(String msg, Color color) {
MessageBuilder mb = new MessageBuilder();
if (message != null) {
message.setColor(color);
message.setDescription(msg);
message.setTimestamp(Instant.now());
mb.setEmbed(message.build());
} else {
mb.setContent(msg);
}
return mb.build();
}
public void sendToAll(String message, Color color) {
sendToAll(buildMessage(message, color));
}
public void sendToAll(MessageEmbed message) {
public void sendToAll(Message message) {
jda.getTextChannelById(global_channel).sendMessage(message).queue();
}
public void sendToMembers(String message, Color c, String... targets) {
sendToMembers(buildMessage(message, c), targets);
public void sendToMembers(String message, Color color, String... targets) {
sendToMembers(buildMessage(message, color), targets);
}
public void sendToMembers(MessageEmbed m, String... targets) {
public void sendToMembers(Message m, String... targets) {
for (String member:targets) {
sendToMember(member, m);
}
}
public void sendToMember(String member, MessageEmbed m) {
public void sendToMember(String member, Message m) {
Long member_id=members.get(member);
if (member_id != null) {
jda.getUserById(member_id).openPrivateChannel().queue(pc -> pc.sendMessage(m).queue());
@ -210,14 +214,16 @@ public class Bot extends ListenerAdapter {
this.sendToAll(color_and_message[1], new Color(Integer.parseInt(color_and_message[0].substring(1), 16)));
} else if (line.startsWith("[ERR]")) {
String[] lineparts=linecontent.split(" ", 2);
//error.setTimestamp(Instant.now());
error.setDescription(lineparts[1]);
sendToMember(lineparts[0], error.build());
MessageBuilder mb = new MessageBuilder();
mb.setEmbed(error.build());
sendToMember(lineparts[0], mb.build());
} else if (line.startsWith("[SUC]")) {
String[] lineparts=linecontent.split(" ", 2);
//success.setTimestamp(Instant.now());
success.setDescription(lineparts[1]);
sendToMember(lineparts[0], success.build());
MessageBuilder mb = new MessageBuilder();
mb.setEmbed(success.build());
sendToMember(lineparts[0], mb.build());
} else if (line.startsWith("[PMS]")) {
String line_content=line.substring(5);
String[] parts=line_content.split(" ", 3); // Color, targets and message - No need to handle stuff like blocks, already done by MT

View File

@ -0,0 +1,2 @@
#Sat Oct 19 11:53:52 CEST 2019
gradle.version=4.10.2

View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## MinetestChatBridgeIRCBot 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="MinetestChatBridgeIRCBot"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and MINETEST_CHAT_BRIDGE_IRC_BOT_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/MinetestChatBridgeIRCBot.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 $MINETEST_CHAT_BRIDGE_IRC_BOT_OPTS -classpath "\"$CLASSPATH\"" appguru.Main "$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" "$@"

View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem MinetestChatBridgeIRCBot 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 MINETEST_CHAT_BRIDGE_IRC_BOT_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\MinetestChatBridgeIRCBot.jar
@rem Execute MinetestChatBridgeIRCBot
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MINETEST_CHAT_BRIDGE_IRC_BOT_OPTS% -classpath "%CLASSPATH%" appguru.Main %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable MINETEST_CHAT_BRIDGE_IRC_BOT_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%MINETEST_CHAT_BRIDGE_IRC_BOT_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Created-By: Gradle 4.10.2
Main-Class: appguru.Main

View File

@ -81,6 +81,15 @@ Targets/Mentions: Roles or chatters mentioned using `@`
* Supports configuring case insensitive roles
* Removed outdated `config_help.md`
### `rolling-9`
* Fixes [`rolling-8`]
### `rolling-10`
* Supports sending messages instead of embeds (discord bridge)
* Fixes
## API
### HUD notifications
@ -193,7 +202,7 @@ Located under `<modpath/gamepath>/adv_chat/default_config.json`
"other" : null
},
"bridges" : {
"discord" : {"channelname":"allgemein", "prefix": "?", "minetest_prefix": "!","token":"S.U.Pxxs.E.R.T.9998OKEN", "blacklist":{"~~new_role~~":true}, "guild_id": 580416319703351296},
"discord" : {"channelname":"allgemein", "prefix": "?", "minetest_prefix": "!", "token":"S.U.Pxxs.E.R.T.9998OKEN", "blacklist":{"~~new_role~~":true}, "guild_id": 580416319703351296, "send_embeds": true},
"irc" : {"channelname":"#mtchatbridgetest", "prefix": "?", "minetest_prefix": "!", "nickname": "MT_Chat_Bridge", "network": "irc.freenode.net", "port": 7000, "ssl": true}
}
}
@ -233,6 +242,7 @@ Table with the following entries :
* `convert_internal_markdown`/`convert_minetest_markdown`: Optional boolean. Whether Markdown sent from Minetest/internal chat messages should be left untouched as if it was Discord Markdown
* `handle_irc_styles`: Optional string. How IRC styles should be converted to Discord Markdown. Possible values: `"disabled"`, `"escape_markdown"` and `"convert"`
* `strip_discord_markdown_in_minetest`: Optional boolean. Whether Discord Markdown should be stripped from Minetest chat.
* `send_embeds`: Optional boolean, whether the bot should send embeds or messages.
Example :

View File

@ -44,7 +44,8 @@ local conf_spec={type="table", required_children={
bridge={type="string", possible_values={"files", "sockets"}},
convert_internal_markdown={type="boolean"},
convert_minetest_markdown={type="boolean"},
handle_irc_styles={type="string", possible_values={"escape_markdown", "convert", "disabled"}}
handle_irc_styles={type="string", possible_values={"escape_markdown", "convert", "disabled"}},
send_embeds={type="boolean"}
}
},
command_blacklist={type="table", keys={type="number"}, values={type="string"}},

View File

@ -148,10 +148,11 @@ bridge.serve()
minetest.register_on_mods_loaded(function()
local java="java"
local jarpath=minetest.get_modpath("adv_chat").."/MinetestChatBridgeBot/build/libs/MinetestChatBridgeBot-all.jar"
local token=bridges.discord.token or "NTc4MjM0NjM5NTc2MDcyMjEx.XPgWKA.ilzmvz-I7XTIML6Emj1jBx4ejLw"
local token=bridges.discord.token
local text_channel=bridges.discord.channelname
local prefixes='"'..bridges.discord.minetest_prefix..'" "'..bridges.discord.prefix..'"'
local guild_id=bridges.discord.guild_id.." " or ""
local send_embeds=(bridges.discord.send_embeds and "true") or "false"
bridge.start(java..' -jar "'..jarpath..'" "'..token..'" "'..text_channel..'" "%s" "%s" "%s" '..prefixes.." "..guild_id.." &")
bridge.start(java..' -jar "'..jarpath..'" "'..token..'" "'..text_channel..'" "%s" "%s" '..send_embeds..' "%s" '..prefixes.." "..guild_id.." &")
end)

View File

@ -1,7 +1,7 @@
adv_chat={}
modlib.mod.extend("adv_chat", "conf")
-- Some IFNDEFS hehe
-- Some IFNDEFS
local bridge_ifndefs={
bridge=adv_chat.bridges.discord or adv_chat.bridges.irc,
discord=adv_chat.bridges.discord,
@ -28,15 +28,13 @@ modlib.mod.extend("adv_chat", "hud_channels")
if bridge_ifndefs.bridge then
modlib.mod.extend("adv_chat", "chatcommands")
modlib.mod.extend("adv_chat", "process_bridges")
local env = minetest.request_insecure_environment() or error("Error: adv_chat needs to be added to the trusted mods for chat bridges to work. See the Readme for more info.")
adv_chat.set_os_execute(env.os.execute)
adv_chat.set_insecure_environment(env)
adv_chat.set_socket(env.require("socket"))
if adv_chat.bridges.irc then
modlib.mod.extend("adv_chat", "irc")
end
if adv_chat.bridges.discord then
modlib.mod.extend("adv_chat", "discord")
end

View File

@ -59,7 +59,7 @@ end
channels={} --channelname -> definition : {hud_pos, mode, autoremove, max_messages, max_lines, wrap_chars, smartwrap}
roles={} -- Role -> players -> true
if roles_case_insensitive then
modlib.table.set_case_insensitive_index(teams)
modlib.table.set_case_insensitive_index(roles)
end
chatters={} -- Chatter -> stuff
to_be_sent={} --Receiver -> { {sender, message, date, time} }

Some files were not shown because too many files have changed in this diff Show More