From 07b7f46dd70849f470ccdcbcee4571f702ae709c Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Thu, 12 Sep 2019 20:13:54 -0500 Subject: [PATCH] Added full report function --- commands.rb | 17 +++++++++++++++++ run.rb | 2 ++ 2 files changed, 19 insertions(+) diff --git a/commands.rb b/commands.rb index 67c076e..18efa1b 100644 --- a/commands.rb +++ b/commands.rb @@ -104,6 +104,23 @@ def process_command_check(message, command, adm) end end +def process_command_report(message, command, adm) + if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) + report = "Full Report:\n\n" + @probes.each do |k,v| + zone = v["loc"].to_s + host = k + print "#{host}: #{zone} " + tdata = `ssh #{host} heatbot_gettemp` + print "[#{tdata}°#{@tunit}]\n" + report = report + "#{zone}: #{tdata}°#{@tunit}\n" + end + send_message(message.chat.id,report) + else + send_message(message.chat.id,"I am not authorized to provide this information here.") + end +end + def process_command_test(message, command, adm) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) #reply = `scripts/tempf.py` diff --git a/run.rb b/run.rb index 87120c9..ddfaa3f 100755 --- a/run.rb +++ b/run.rb @@ -261,6 +261,8 @@ def handle_message(message) process_command_chatinfo(message) when '/check', '/c' process_command_check(message, command, adm) + when '/report', '/r' + process_command_report(message, command, adm) when '/test' process_command_test(message, command, adm) when '/pp', '/debug'