diff --git a/src/discord/MagicBot.java b/src/discord/MagicBot.java index 8744e3e4..571442e7 100644 --- a/src/discord/MagicBot.java +++ b/src/discord/MagicBot.java @@ -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 { "#setavail true/false Toggle status of database access.\n" + "#server reboot/shutdown are your options.\n" + "#logs magicbot/world/login n (tail)\n" + - "#flash send flash message\n" + + "#flash Send flash message\n" + + "#devbuild Builds on Dev server.\n" + "#trash /detail/flush"; sendResponse(event, helpString); } diff --git a/src/discord/handlers/DevBuildHandler.java b/src/discord/handlers/DevBuildHandler.java new file mode 100644 index 00000000..a1fd5fa6 --- /dev/null +++ b/src/discord/handlers/DevBuildHandler.java @@ -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"); + } + } +} \ No newline at end of file