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)