From e57a9b40c47fd02f316bddbaa420e935afaa3c21 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 28 Dec 2018 01:42:49 -0600 Subject: [PATCH 1/5] Added flex alias --- run.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.rb b/run.rb index b8c8599..4b4eb6c 100755 --- a/run.rb +++ b/run.rb @@ -144,7 +144,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 From d3e8145f6dea8cd3306926ce5fbdf76be6e9dfd9 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Tue, 9 Apr 2019 18:26:47 -0500 Subject: [PATCH 2/5] Added systemd service example --- example_services/egsbot.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 example_services/egsbot.service diff --git a/example_services/egsbot.service b/example_services/egsbot.service new file mode 100644 index 0000000..fde63f6 --- /dev/null +++ b/example_services/egsbot.service @@ -0,0 +1,15 @@ +[Unit] +Description=Empyrion Chat Bot by SKYFALL +After=network.target + +[Service] +Type=forking +User=ivo +PIDFile=/var/run/egsbot.pid +ExecStart=/opt/skyfall/egsbot/run.rb +SuccessExitStatus=SIGKILL +Restart=on-failure + +[Install] +WantedBy=multi-user.target + From 5ef10ded51af50477b7804bd58f41f009a71f4b7 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Tue, 9 Apr 2019 19:07:59 -0500 Subject: [PATCH 3/5] Fixed service file basic functionality (still needs logging fixed) --- example_services/egsbot.service | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/example_services/egsbot.service b/example_services/egsbot.service index fde63f6..0b7eece 100644 --- a/example_services/egsbot.service +++ b/example_services/egsbot.service @@ -3,10 +3,12 @@ Description=Empyrion Chat Bot by SKYFALL After=network.target [Service] -Type=forking User=ivo -PIDFile=/var/run/egsbot.pid -ExecStart=/opt/skyfall/egsbot/run.rb +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 From cd73cb49311a0878b0ed1009bd4ccfa3f595de4a Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sun, 21 Apr 2019 22:58:53 -0500 Subject: [PATCH 4/5] Added /patchnotes and improved /status --- commands.rb | 14 ++++++++++++++ patchnotes.txt | 5 +++++ run.rb | 2 ++ scripts/srvstatus.receipt | 13 +++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 patchnotes.txt create mode 100755 scripts/srvstatus.receipt diff --git a/commands.rb b/commands.rb index 4de966b..5f2885e 100644 --- a/commands.rb +++ b/commands.rb @@ -71,6 +71,10 @@ 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']}` + #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']}` else reply = "Refusal: I am not authorized to provide this information here." @@ -78,3 +82,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/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 4b4eb6c..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`}" 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 + From 5b4640e0073f8cd3f2c3ebe96d109d1622223264 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sun, 21 Apr 2019 23:02:38 -0500 Subject: [PATCH 5/5] Some light update cleanup --- commands.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/commands.rb b/commands.rb index 5f2885e..946161d 100644 --- a/commands.rb +++ b/commands.rb @@ -72,7 +72,6 @@ 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']}` - #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']}`