From 9146eb38bbe0a0f3db7f1e7dca4213b8fbaeb1d7 Mon Sep 17 00:00:00 2001 From: Hofei Date: Tue, 2 Feb 2021 00:10:14 +0100 Subject: [PATCH] =?UTF-8?q?vorl=C3=A4ufige=20lauff=C3=A4hige=20Version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- serverbot.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/serverbot.py b/serverbot.py index 9975bac..b28b191 100644 --- a/serverbot.py +++ b/serverbot.py @@ -38,20 +38,9 @@ class EmpyrionBot(api.Bot): pass def start_server(self, nachricht, users, key): - print("start server") - puffer = "Starte Server\n" - nachricht = self.send_message(key, puffer) - cmd = shlex.split(CONFIG["steamcmd"]["start"], posix=False) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE) - while p.poll() is None: - output = p.stdout.readline().decode("utf-8") - if output: - if check_nachrichten_laenge(f"{puffer} {output}"): - puffer = f"{puffer} {output}" - self.edit_message_text(puffer, key, nachricht["result"]["message_id"]) - else: - puffer = output - nachricht = self.send_message(key, puffer) + print("starte server") + os.chdir("C:\steamCMD\empyriondedicatedserver") + subprocess.run(['EmpyrionLauncher.exe', '-startDedi', '-dedicated dedicated_HP2.yaml']) def stop_server(self, nachricht, users, key): puffer = "" @@ -74,7 +63,11 @@ class EmpyrionBot(api.Bot): self.edit_message_text(puffer, key, nachricht["result"]["message_id"]) def status_server(self, nachricht, users, key): - [print(p) for p in psutil.process_iter() if "Empyrion" in p.name()] + text = [str(p) for p in psutil.process_iter() if "Empyrion" in p.name()] + if text: + self.send_message(key, "\n".join(text)) + else: + self.send_message(key, "Kein Prozess aktiv") def update_server(self, nachricht, users, key): # Zu Suchender String zum analysieren des Errorlogpfades: @@ -111,6 +104,7 @@ class EmpyrionBot(api.Bot): if kommando == "/start": self.start(nachricht, users, key) elif kommando == "/start_server": + pass self.start_server(nachricht, users, key) elif kommando == "/stop_server": pass