lib/dazeus/dazeus.rb in dazeus-0.0.1.201306161801 vs lib/dazeus/dazeus.rb in dazeus-0.0.1.201306211031
- old
+ new
@@ -65,17 +65,33 @@
response['success']
end
def names(network, channel, &block)
fn = lambda do |response|
- block.call(response)
unsubscribe('NAMES', &fn)
+ block.call(response)
end
subscribe('NAMES', &fn)
send_names(network, channel)
end
+ def names_sync(network, channel)
+ resolved = false
+ result = nil
+ names(network, channel) do |names|
+ resolved = true
+ result = names
+ end
+
+ # Wait for the names request to be resolved
+ loop do
+ break if resolved
+ once
+ end
+ result
+ end
+
def send_whois(network, nick)
response = send_receive({:do => 'whois', :params => [network, nick]})
response['success']
end
@@ -84,9 +100,25 @@
block.call(response)
unsubscribe('WHOIS', &fn)
end
subscribe('WHOIS', &fn)
send_whois(network, nick)
+ end
+
+ def whois_sync(network, nick)
+ resolved = false
+ result = nil
+ whois(network, nick) do |whois|
+ resolved = true
+ result = whois
+ end
+
+ # Wait for the whois request to be resolved
+ loop do
+ break if resolved
+ once
+ end
+ result
end
def join(network, channel)
response = send_receive({:do => 'join', :params => [network, channel]})
response['success']