|
|
@ -60,7 +60,6 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
def process_command_location(message, command, adm)
|
|
|
|
def process_command_location(message, command, adm)
|
|
|
|
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 icanhazip.com 2>/dev/null`}\\\`"
|
|
|
|
|
|
|
|
reply = "I am currently located at:\n\nHost: #{`head -n1 /etc/hostname`}ExtIP: #{`curl icanhazip.com 2>/dev/null`}"
|
|
|
|
reply = "I am currently located at:\n\nHost: #{`head -n1 /etc/hostname`}ExtIP: #{`curl icanhazip.com 2>/dev/null`}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
reply = "I am not authorized to provide this information here."
|
|
|
|
reply = "I am not authorized to provide this information here."
|
|
|
@ -104,12 +103,7 @@ def process_command_report(message, command, adm, simple=false)
|
|
|
|
@probes.each do |k,v|
|
|
|
|
@probes.each do |k,v|
|
|
|
|
zone = v["loc"].to_s
|
|
|
|
zone = v["loc"].to_s
|
|
|
|
host = k
|
|
|
|
host = k
|
|
|
|
#print "#{host}: #{zone} "
|
|
|
|
|
|
|
|
tdata = process_tdata(host, simple)
|
|
|
|
tdata = process_tdata(host, simple)
|
|
|
|
#tdata = `ssh #{host} heatbot_gettemp`
|
|
|
|
|
|
|
|
#print "[#{tdata}°#{@tunit}]\n"
|
|
|
|
|
|
|
|
#report = report + "#{zone}: #{tdata}°#{@tunit}\n"
|
|
|
|
|
|
|
|
#print "[#{tdata}]\n"
|
|
|
|
|
|
|
|
report = report + "#{zone}: #{tdata}\n"
|
|
|
|
report = report + "#{zone}: #{tdata}\n"
|
|
|
|
STDOUT.flush
|
|
|
|
STDOUT.flush
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -120,29 +114,3 @@ def process_command_report(message, command, adm, simple=false)
|
|
|
|
send_message(message.chat.id,"I am not authorized to provide this information here.")
|
|
|
|
send_message(message.chat.id,"I am not authorized to provide this information here.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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`
|
|
|
|
|
|
|
|
#some interactive code to select a probe
|
|
|
|
|
|
|
|
select_loc = "Server Room: Intake"
|
|
|
|
|
|
|
|
#end interactive code
|
|
|
|
|
|
|
|
#probe = @probes[0] #set manually for now
|
|
|
|
|
|
|
|
reply = ""
|
|
|
|
|
|
|
|
hostdata = host_lookup(select_loc)
|
|
|
|
|
|
|
|
puts "var:".blue+" hostdata".blue.bold+"::".bold + hostdata.to_s
|
|
|
|
|
|
|
|
if ! hostdata.empty?
|
|
|
|
|
|
|
|
hostdata.each do |k,v|
|
|
|
|
|
|
|
|
puts "match:".blue+" host".blue.bold+"::".bold + k.to_s
|
|
|
|
|
|
|
|
reply += k.to_s+"\n"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reply = "No matching locations!"
|
|
|
|
|
|
|
|
puts "hostdata is empty!"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
puts reply
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reply = "I am not authorized to provide this information here."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return reply
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|