Added /whereareyou and a couple other small alterations

pull/1/head
Aaron Johnson 7 years ago
parent 047ae54176
commit efc35888a2

@ -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

@ -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

Loading…
Cancel
Save