|
|
@ -38,7 +38,7 @@ Thread.new do |
|
|
|
next |
|
|
|
end |
|
|
|
messages["messages"].each { |x| |
|
|
|
puts "#{x["from"]} says: #{x["content"]}" |
|
|
|
puts "#{x["user"]["username"]} says: #{x["content"]}" |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
@ -57,13 +57,39 @@ while buf = Readline.readline("> ", true) |
|
|
|
puts "/help - this message" |
|
|
|
puts "/send <protcol_id> - direct messages to somebody" |
|
|
|
puts "/exit - quit program" |
|
|
|
puts "/find <username> - find a username by pattern" |
|
|
|
puts "/find-protoid <protoid> - find by a protocol id" |
|
|
|
next |
|
|
|
end |
|
|
|
|
|
|
|
if buf == "/exit" then |
|
|
|
post("/user/delete",{ |
|
|
|
"protocol_id"=> "heimdall-"+nickname |
|
|
|
}) |
|
|
|
exit |
|
|
|
end |
|
|
|
|
|
|
|
if buf.match(/^\/send .*$/) then |
|
|
|
target = buf.match(/^\/send ([^\s]*)$/)[1] |
|
|
|
next |
|
|
|
end |
|
|
|
|
|
|
|
if buf.match(/^\/find .*$/) then |
|
|
|
uname = (buf.match /^\/find (.*)$/)[1] |
|
|
|
users = get("/user/find/by-username?username=#{uname}")["results"] |
|
|
|
puts "Found #{users.length} results: " |
|
|
|
users.each { |x| puts x[0] } |
|
|
|
next |
|
|
|
end |
|
|
|
|
|
|
|
if buf.match(/^\/find-protoid .*$/) then |
|
|
|
pid = (buf.match /^\/find-protoid (.*)$/)[1] |
|
|
|
users = get("/user/find/by-protoid?protocol_id=#{pid}")["results"] |
|
|
|
puts "Found #{users.length} results: " |
|
|
|
users.each { |x| puts x[0] } |
|
|
|
next |
|
|
|
end |
|
|
|
|
|
|
|
if target then |
|
|
|
post("/user/send", { |
|
|
|
"to" => target, |
|
|
@ -71,7 +97,4 @@ while buf = Readline.readline("> ", true) |
|
|
|
"from" => "heimdall-"+nickname |
|
|
|
}) |
|
|
|
end |
|
|
|
if buf.match(/^\/send .*$/) then |
|
|
|
target = buf.match(/^\/send ([^\s]*)$/)[1] |
|
|
|
end |
|
|
|
end |