From af66d5ff7b6303cdfb32912ec7b9c399e6dcdb3a Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Tue, 25 Dec 2018 01:55:47 -0600 Subject: [PATCH] Added tons of functionality --- empyrion-bot.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/empyrion-bot.rb b/empyrion-bot.rb index 4d47ad9..770e8dd 100755 --- a/empyrion-bot.rb +++ b/empyrion-bot.rb @@ -4,23 +4,28 @@ require 'rubygems' require 'yaml' require 'telegram/bot' -conf = YAML.load(File.read("bot_config.yaml")) +#conf = YAML.load(File.read("bot_config.yaml")) +conf = YAML.load_file("bot_config.yaml") token = conf['token'] +telnet = conf['telnet'] +puts conf['telnet'] +puts "Empyrion Host: #{telnet['host']}" +puts "Bot token: #{token}" -puts 'Bot token: ' + token - -def parse_message(message) +def handle_message(message) reply = 'Empty String' - case message.text + conf = YAML.load_file("bot_config.yaml") + telnet = conf['telnet'] + case message.text.split(" ")[0].split("@")[0].downcase #Strip command from arguments and @tags when '/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" when '/srvstart' - reply = "UNAVAILABLE: This command would start the game server if the code were there." + reply = `./srvstart` when '/srvstop' - reply = "UNAVAILABLE: This command would stop the game server if the code were there." + reply = `./srvstop` when '/status' - reply = "UNAVAILABLE: This command would provide server status and possibly version... If the code were there." + reply = `./srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` when '/location', '/ip', '/address' reply = `curl myip.contegix.com` end @@ -30,7 +35,7 @@ end Telegram::Bot::Client.run(token) do |bot| bot.listen do |message| - reply = parse_message message + reply = handle_message message bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") end end