"at" command shoing who is now at warsaw hackerspace.
This commit is contained in:
parent
a5b3b9addd
commit
6e7fd868e2
1 changed files with 23 additions and 0 deletions
23
plugins/commands/at.rb
Normal file
23
plugins/commands/at.rb
Normal 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
|
||||
}
|
Loading…
Reference in a new issue