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