diff --git a/.gitignore b/.gitignore index 86a1311..574dddf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /bot_config.yaml /.ignore -/static_text/custom/ +/static_text/custom/* diff --git a/commands.rb b/commands.rb index 2ac7f14..f333b97 100644 --- a/commands.rb +++ b/commands.rb @@ -38,7 +38,8 @@ end def process_command_start(message, command, adm) reply = "Introduction: I am #{@botname}, and I am here to make life easier for meatbag admins like you. Currently I can retrieve information " + "from an Empyrion server as well as kill the server process. I also have some pretty sweet dance moves.\n\n" + - "Commands available:\n/start or /help (Shows this message)\n/voice or /chat (Shows voice chat info)\n/srvstart (Currently non-functional)\n/srvstop\n/status\n/whoami or /chatinfo\n/whereareyou or /location\n\n" + + "Commands available:\n/start or /help (Shows this message)\n/voice or /chat (Shows voice chat info)\n/srvstart (Currently non-functional)\n/srvstop\n" + + "/status (show version and online players)\n/whoami or /chatinfo\n/whereareyou or /location\n\n" + "Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates.\n" + "You can also view the source code at the following location:\nhttps://git.skyfall.tech/skyfall/empyrion-bot" if message_from_admin?(message, adm) @@ -124,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/run.rb b/run.rb index 87df885..9d973f7 100755 --- a/run.rb +++ b/run.rb @@ -328,8 +328,11 @@ def handle_message(message) when '/srvstop' reply = process_command_srvstop(message, command, adm) send_message(message.chat.id, reply) - when '/status' + when '/status', '/stat', '/stats', '/list', '/check' reply = process_command_srvstatus(message, command, adm) + if command == '/check' + reply = "Hi Matt, here's the /status.\n\n" + reply + end send_message(message.chat.id, reply) when '/patch', '/patchnotes' reply = process_command_patchnotes(message, command, adm) 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.