"at" command shoing who is now at warsaw hackerspace.

This commit is contained in:
Robert "ar" Gerus 2013-06-09 15:20:12 +02:00
parent a5b3b9addd
commit 6e7fd868e2

23
plugins/commands/at.rb Normal file
View file

@ -0,0 +1,23 @@
require 'net/http'
require 'json'
require 'time'
Client.register_command("at") { |args|
now = []
recently = []
r_msg = ""
h = JSON.parse(Net::HTTP.get(URI(Config[:commands][:at][:url])))
h["users"].each { |u|
if (Time.now.to_i - u["timestamp"]) > 600 then
recently << u["login"]
else
now << u["login"]
end
}
r_msg += "now: #{now.join(' ')} " if not now.empty?
r_msg += "recently: #{recently.join(' ')} " if not recently.empty?
r_msg += "unknown: #{h["unknown"]} " if h["unknown"] > 0
r_msg
}