added command to start minecraft server

This commit is contained in:
iou1name 2019-01-17 11:19:12 -05:00
parent f9afc7bfe0
commit 57502f3c9f

23
modules/minecraft.py Executable file
View File

@ -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)