diff --git a/commands.rb b/commands.rb index f5b71b1..a2f54a9 100644 --- a/commands.rb +++ b/commands.rb @@ -73,7 +73,7 @@ def process_command_srvstatus(message, command, adm) telnet = @conf['telnet'] print 'Checking connectivity to Empyrion service... ' STDOUT.flush - if `nc -zvw3 #{telnet['host']} #{telnet['port']} >/dev/null 2>&1` + if system("nc -zvw3 #{telnet['host']} #{telnet['port']} >/dev/null 2>&1") print "Server responded!\nSending message receipt... " STDOUT.flush if `./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}` @@ -81,11 +81,12 @@ def process_command_srvstatus(message, command, adm) else print "Receipt FAILED to send (non-zero exit code on scripts/srvstatus.receipt) !!!\nContinuing to fetch details anyway...\n" end + reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` else - print "Server did not respond! Passing to scripts/srvstatus for sending the failure message (revisit this for code efficiency review\n)" + print "Server did not respond!\nSending failure message...\n" + reply = "Server is not responding!" end STDOUT.flush - reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` else reply = "Refusal: I am not authorized to provide this information here." end