From 57502f3c9f902917bfff887b8d2e20808f2e496f Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 17 Jan 2019 11:19:12 -0500 Subject: [PATCH] added command to start minecraft server --- modules/minecraft.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 modules/minecraft.py diff --git a/modules/minecraft.py b/modules/minecraft.py new file mode 100755 index 0000000..f71b38a --- /dev/null +++ b/modules/minecraft.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Minecraft is a well-crafted program. +""" +import subprocess + +import module + + +@module.require_admin +@module.commands('mc_start') +def minecraft_start_server(bot, trigger): + """ + Starts the minecraft server in case it crashes. + """ + cmd = ["tmux", "send", "-t", "main:2", "./start.sh", "ENTER"] + cmd_re = ["tmux", "send", "-t", "main:2", "^C", "ENTER"] + msg = "Start signal sent to the minecraft server." + if trigger.group(2) == "-r": + msg = "Re-" + msg + subprocess.run(cmd_re, check=True) + subprocess.run(cmd, check=True) + bot.msg(msg)