From 73961d65682d53bb7f53897094a878d531516048 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 31 Jul 2007 21:02:42 +0000 Subject: New IRC Framework: WHO the channels we join, so that we get as much user information as possible about the user on channel --- lib/rbot/ircbot.rb | 1 + lib/rbot/rfc2812.rb | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'lib/rbot') 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 -- cgit v1.2.3