fulvia/modules/minecraft.py

24 lines
562 B
Python
Raw Normal View History

#!/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)