diff --git a/empyrion-bot.rb b/empyrion-bot.rb index 770e8dd..c22e1db 100755 --- a/empyrion-bot.rb +++ b/empyrion-bot.rb @@ -18,16 +18,20 @@ def handle_message(message) telnet = conf['telnet'] case message.text.split(" ")[0].split("@")[0].downcase #Strip command from arguments and @tags when '/start' + puts "Received command: start" reply = "This bot will eventually (hopefully) be able retrieve information and pass start/stop commands from/to an Empyrion server, to make life easier for meatbags like you.\n\n" + - "Commands available:\n/start (Shows this message)\n/srvstart\n/srvstop\n/status\n/address" + "Commands available:\n/start (Shows this message)\n/srvstart\n/srvstop\n/status" when '/srvstart' + puts "Received command: srvstart" reply = `./srvstart` when '/srvstop' + puts "Received command: srvstop" reply = `./srvstop` when '/status' + puts "Received command: status" reply = `./srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` - when '/location', '/ip', '/address' - reply = `curl myip.contegix.com` + when '/location', '/whereareyou' + reply = "I am currently located at:\n\nHost: #{`echo $HOSTNAME`}ExtIP: #{`curl myip.contegix.com`}" end puts "Sending #{reply.inspect}" return reply diff --git a/srvstatus b/srvstatus index 3c4df63..5642308 100755 --- a/srvstatus +++ b/srvstatus @@ -7,12 +7,12 @@ pass=$3 if nc -zvw3 $host $port 2>/dev/null; then ./srvstatus.expect $host $port $pass > /tmp/.stat grep -B1 -A8 Empyrion\ dedicated\ server /tmp/.stat | egrep -v Playfield\|Game\ seed - echo "\nOnline players:\n- - - - - - - - - - - - - -" + printf "\nOnline players:\n- - - - - - - - - - - - -" sed -n '/Global\ online/,/Global\ players/p' /tmp/.stat | awk -F\= '{print $3}' | sed 's/....$//' rm /tmp/.stat exit 0 else - echo "Server is DOWN!" + printf "Server is DOWN!" exit 1 fi