From 75c79750d45c7fb818d59ceb88a6a03f43f6b0a6 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Fri, 21 Jul 2023 22:57:38 -0500 Subject: [PATCH] Added check to /srvstop to make sure server is up before sending stop command --- commands.rb | 14 ++++++++++++-- static_text/patchnotes.txt | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/commands.rb b/commands.rb index 8356db7..f333b97 100644 --- a/commands.rb +++ b/commands.rb @@ -125,8 +125,18 @@ def process_command_srvstop(message, command, adm) return "Refusal: Although I respect your wishes, master, I am not authorized to perform this function for this group." else telnet = @conf['telnet'] - `./scripts/srvstop #{telnet['host']} #{telnet['port']} #{telnet['pass']}` - return "Affirmation: I am shutting down the Empyrion service." + print 'Checking connectivity to Empyrion service... ' + STDOUT.flush + if system("nc -zvw3 #{telnet['host']} #{telnet['port']} >/dev/null 2>&1") + print "OK\n".green.bold + "Sending shutdown message:\n" + STDOUT.flush + reply = "Affirmation: I am shutting down the Empyrion service." + `./scripts/srvstop #{telnet['host']} #{telnet['port']} #{telnet['pass']}` + else + print "Server did not respond!\nSending failure message...\n".red.bold + reply = "Exclamation: Server is not responding!" + end + return reply end end diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index 7717f18..44b1ea9 100644 --- a/static_text/patchnotes.txt +++ b/static_text/patchnotes.txt @@ -1,6 +1,12 @@ SkyfallTech EGS Telebot Patch Notes: +v0.5.01 ++ Added check to /srvstop to see if the server is even running first + * (Previously reported a successful shutdown even if the there was nothing running) ++ Added common aliases for /status command ++ Added an Easter egg command + v0.5.00 + Added Voicechat information feature (/voice). + Rewrite of message handling based on Skyfall Heatbot.