]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
New IRC Framework: WHO the channels we join, so that we get as much user information...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 31 Jul 2007 21:02:42 +0000 (21:02 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 31 Jul 2007 21:02:42 +0000 (21:02 +0000)
lib/rbot/ircbot.rb
lib/rbot/rfc2812.rb

index 1469ac1eac15b301cff4b0b57c519fe100b12751..1e92c30155e48e4b31a06e0ef7749233f88d603e 100644 (file)
@@ -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])
index a66ff440d217090cb325ba96b9bb645357dddcd1..98f086e32b9c5e09a3aea28f85fea94267f567f3 100644 (file)
@@ -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