summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb1
-rw-r--r--lib/rbot/rfc2812.rb38
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 1469ac1e..1e92c301 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -612,6 +612,7 @@ class Bot
@plugins.delegate("listen", m)
@plugins.delegate("join", m)
+ sendq "WHO #{data[:channel]}", data[:channel], 2
}
@client[:part] = proc {|data|
m = PartMessage.new(self, server, data[:source], data[:channel], data[:message])
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index a66ff440..98f086e3 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -1114,6 +1114,44 @@ module Irc
when RPL_DATASTR
data[:text] = argv[1]
handle(:datastr, data)
+ when RPL_WHOREPLY
+ data[:channel] = argv[1]
+ data[:user] = argv[2]
+ data[:host] = argv[3]
+ data[:userserver] = argv[4]
+ data[:nick] = argv[5]
+ if argv[6] =~ /^(H|G)(\*)?(.*)?$/
+ data[:away] = ($1 == 'G')
+ data[:ircop] = $2
+ data[:modes] = $3.scan(/./).map { |mode|
+ m = @server.supports[:prefix][:prefixes].index(mode.to_sym)
+ @server.supports[:prefix][:modes][m]
+ } rescue []
+ else
+ warning "Strange WHO reply: #{serverstring.inspect}"
+ end
+ data[:hopcount], data[:real] = argv[7].split(" ", 2)
+
+ user = @server.get_user(data[:nick])
+
+ user.user = data[:user]
+ user.host = data[:host]
+ user.away = data[:away] # FIXME doesn't provide the actual message
+ # TODO ircop status
+ # TODO userserver
+ # TODO hopcount
+ # TODO real
+
+ channel = @server.get_channel(data[:channel])
+
+ channel.add_user(user, :silent=>true)
+ data[:modes].map { |mode|
+ channel.mode[mode].set(user)
+ }
+
+ handle(:who, data)
+ when RPL_ENDOFWHO
+ handle(:eowho, data)
else
handle(:unknown, data)
end