Browse Source

Command added to remote build on Dev server.

master
MagicBot 2 years ago
parent
commit
0fd5d09e3e
  1. 6
      src/discord/MagicBot.java
  2. 48
      src/discord/handlers/DevBuildHandler.java

6
src/discord/MagicBot.java

@ -226,6 +226,9 @@ public class MagicBot extends ListenerAdapter { @@ -226,6 +226,9 @@ public class MagicBot extends ListenerAdapter {
case "#trash":
TrashRequestHandler.handleRequest(event, args);
break;
case "#devbuild":
DevBuildHandler.handleRequest(event, args);
break;
default:
junkbot(command, args);
break;
@ -302,7 +305,8 @@ public class MagicBot extends ListenerAdapter { @@ -302,7 +305,8 @@ public class MagicBot extends ListenerAdapter {
"#setavail true/false Toggle status of database access.\n" +
"#server reboot/shutdown are your options.\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" +
"#trash <blank>/detail/flush";
sendResponse(event, helpString);
}

48
src/discord/handlers/DevBuildHandler.java

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package discord.handlers;
import discord.MagicBot;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.pmw.tinylog.Logger;
import java.io.IOException;
public class DevBuildHandler {
public static void handleRequest(MessageReceivedEvent event, String[] args) {
String buildTarget;
String execString = "";
// Early exit if database unavailable or is not an admin
if (MagicBot.isAdminEvent(event) == false)
return;
// No command supplied?
if (args.length != 1)
return;
buildTarget = args[0].toLowerCase().trim();
execString = "/bin/sh -c ./mbdevbuild.sh " + buildTarget;
if (execString.isEmpty() == false) {
try {
Runtime.getRuntime().exec(execString);
} 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");
}
}
}
Loading…
Cancel
Save