diff --git a/commands.rb b/commands.rb index 4de966b..946161d 100644 --- a/commands.rb +++ b/commands.rb @@ -71,6 +71,9 @@ end def process_command_srvstatus(message, command, adm) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) telnet = @conf['telnet'] + if `nc -zvw3 #{telnet['host']} #{telnet['port']}` + `./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}` + end reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` else reply = "Refusal: I am not authorized to provide this information here." @@ -78,3 +81,13 @@ def process_command_srvstatus(message, command, adm) return reply 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 + diff --git a/example_services/egsbot.service b/example_services/egsbot.service new file mode 100644 index 0000000..0b7eece --- /dev/null +++ b/example_services/egsbot.service @@ -0,0 +1,17 @@ +[Unit] +Description=Empyrion Chat Bot by SKYFALL +After=network.target + +[Service] +User=ivo +WorkingDirectory=/opt/skyfall/egs-bot +StandardOutput=file:/var/log/skyfall/egs-bot/run.log +StandardError=file:/var/log/skyfall/egs-bot/error.log +PIDFile=/var/run/skyfall/egsbot.pid +ExecStart=/usr/bin/ruby /opt/skyfall/egs-bot/run.rb +SuccessExitStatus=SIGKILL +Restart=on-failure + +[Install] +WantedBy=multi-user.target + diff --git a/patchnotes.txt b/patchnotes.txt new file mode 100644 index 0000000..ffbb3c9 --- /dev/null +++ b/patchnotes.txt @@ -0,0 +1,5 @@ +New features: ++ Auto self-resurrection after random bot-suicide. ++ This `/patchnotes` command. ++ Instant message confirmation for `/status` command. + diff --git a/run.rb b/run.rb index b8c8599..21d5cc5 100755 --- a/run.rb +++ b/run.rb @@ -123,6 +123,8 @@ def handle_message(message) #else # reply = "Refusal: I am not authorized to provide this information here." #end + when '/patch', '/patchnotes' + reply = process_command_patchnotes(message, command, adm) when '/location', '/whereareyou' 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`}" @@ -144,7 +146,7 @@ def handle_message(message) else reply = "Refusal: I am not authorized to bust a move in this location." end - when '/flex' + when '/flex', '/unclemike' if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) reply = "flex" else diff --git a/scripts/srvstatus.receipt b/scripts/srvstatus.receipt new file mode 100755 index 0000000..18cf61b --- /dev/null +++ b/scripts/srvstatus.receipt @@ -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 +