Added /patchnotes and improved /status

pull/7/head
Aaron Johnson 6 years ago
parent 5ef10ded51
commit cd73cb4931

@ -71,6 +71,10 @@ end
def process_command_srvstatus(message, command, adm) def process_command_srvstatus(message, command, adm)
if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm)
telnet = @conf['telnet'] telnet = @conf['telnet']
if `nc -zvw3 #{telnet['host']} #{telnet['port']}`
#bot.api.send_message(chat_id: message.chat.id, text: "Server is online!\nGathering server information...")
`./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}`
end
reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}`
else else
reply = "Refusal: I am not authorized to provide this information here." reply = "Refusal: I am not authorized to provide this information here."
@ -78,3 +82,13 @@ def process_command_srvstatus(message, command, adm)
return reply return reply
end end
def process_command_patchnotes(message, command, adm)
if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm)
telnet = @conf['telnet']
reply = `cat patchnotes.txt`
else
reply = "Refusal: I am not authorized to provide this information here."
end
return reply
end

@ -0,0 +1,5 @@
New features:
+ Auto self-resurrection after random bot-suicide.
+ This `/patchnotes` command.
+ Instant message confirmation for `/status` command.

@ -123,6 +123,8 @@ def handle_message(message)
#else #else
# reply = "Refusal: I am not authorized to provide this information here." # reply = "Refusal: I am not authorized to provide this information here."
#end #end
when '/patch', '/patchnotes'
reply = process_command_patchnotes(message, command, adm)
when '/location', '/whereareyou' when '/location', '/whereareyou'
if message_from_admin?(message, adm) || is_chat_authorized?(message, @auth_chat) if message_from_admin?(message, adm) || is_chat_authorized?(message, @auth_chat)
reply = "I am currently located at:\n\nHost: #{`head -n1 /etc/hostname`}ExtIP: #{`curl myip.contegix.com 2>/dev/null`}" reply = "I am currently located at:\n\nHost: #{`head -n1 /etc/hostname`}ExtIP: #{`curl myip.contegix.com 2>/dev/null`}"

@ -0,0 +1,13 @@
#!/usr/bin/env sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
KEY=$1
CHATID=$2
TIME="4"
URL="https://api.telegram.org/bot$KEY/sendMessage"
MESSAGE="Confirmation: The server appears online!
One moment while I collect some server information..."
curl -s --max-time $TIME -d "chat_id=${CHATID}&disable_web_page_preview=1&text=${MESSAGE}" $URL >/dev/null
Loading…
Cancel
Save