|
|
|
@ -14,11 +14,12 @@ import org.pmw.tinylog.Logger;
@@ -14,11 +14,12 @@ import org.pmw.tinylog.Logger;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
public class DevBuildHandler { |
|
|
|
|
public class DevRequestHandler { |
|
|
|
|
|
|
|
|
|
public static void handleRequest(MessageReceivedEvent event, String[] args) { |
|
|
|
|
|
|
|
|
|
String buildTarget; |
|
|
|
|
String serverCommand; |
|
|
|
|
String buildTarget = ""; |
|
|
|
|
String execString = ""; |
|
|
|
|
|
|
|
|
|
// Early exit if database unavailable or is not an admin
|
|
|
|
@ -31,9 +32,34 @@ public class DevBuildHandler {
@@ -31,9 +32,34 @@ public class DevBuildHandler {
|
|
|
|
|
if (args.length != 1) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
buildTarget = args[0].toLowerCase().trim(); |
|
|
|
|
execString = "/bin/sh -c ./mbdevbuild.sh " + buildTarget; |
|
|
|
|
serverCommand = args[0].toLowerCase().trim(); |
|
|
|
|
|
|
|
|
|
if (args.length == 2) |
|
|
|
|
buildTarget = args[1].toLowerCase().trim(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// only reboot or shutdown
|
|
|
|
|
|
|
|
|
|
if ("rebootshutdown".contains(serverCommand) == false) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
switch (serverCommand) { |
|
|
|
|
|
|
|
|
|
case "build" : |
|
|
|
|
execString = "/bin/sh -c ./mbdevbuild.sh " + buildTarget; |
|
|
|
|
break; |
|
|
|
|
case "reboot": |
|
|
|
|
execString = "/bin/sh -c ./mbdevrestart.sh"; |
|
|
|
|
break; |
|
|
|
|
case "debug": |
|
|
|
|
execString = "/bin/sh -c ./mbdevdebug.sh"; |
|
|
|
|
break; |
|
|
|
|
case "shutdown": |
|
|
|
|
execString = "/bin/sh -c ./mbdevkill.sh"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (execString.isEmpty() == false) { |
|
|
|
|
try { |
|
|
|
@ -41,8 +67,8 @@ public class DevBuildHandler {
@@ -41,8 +67,8 @@ public class DevBuildHandler {
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
MagicBot.sendResponse(event, "MagicBot has for to built " + buildTarget + "on Dev"); |
|
|
|
|
Logger.info(event.getAuthor().getName() + " built " + buildTarget + " on Dev"); |
|
|
|
|
MagicBot.sendResponse(event, "MagicBot has executed your " + serverCommand); |
|
|
|
|
Logger.info(event.getAuthor().getName() + " told dev to " + serverCommand + " " + buildTarget); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |