Browse Source

Consolidated all into one command #dev.

master
MagicBot 2 years ago
parent
commit
c002eec8bd
  1. 4
      src/discord/MagicBot.java
  2. 38
      src/discord/handlers/DevRequestHandler.java

4
src/discord/MagicBot.java

@ -227,7 +227,7 @@ public class MagicBot extends ListenerAdapter { @@ -227,7 +227,7 @@ public class MagicBot extends ListenerAdapter {
TrashRequestHandler.handleRequest(event, args);
break;
case "#devbuild":
DevBuildHandler.handleRequest(event, args);
DevRequestHandler.handleRequest(event, args);
break;
default:
junkbot(command, args);
@ -306,7 +306,7 @@ public class MagicBot extends ListenerAdapter { @@ -306,7 +306,7 @@ public class MagicBot extends ListenerAdapter {
"#server reboot/shutdown are your options.\n" +
"#logs magicbot/world/login n (tail)\n" +
"#flash <text> Send flash message\n" +
"#devbuild <branch> Builds <branch> on Dev server.\n" +
"#dev build <target>/restart/debug/shutdown\n" +
"#trash <blank>/detail/flush";
sendResponse(event, helpString);
}

38
src/discord/handlers/DevBuildHandler.java → src/discord/handlers/DevRequestHandler.java

@ -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);
}
}
}
Loading…
Cancel
Save