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

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

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