From d4c5eb46ce33816fb7ccc5e477d9e572fdfb2f5c Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 24 Sep 2008 18:11:00 +0200 Subject: irc.rb: User#channels method --- lib/rbot/irc.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 2eb676e2..19ea3370 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -4,6 +4,8 @@ # Channels is the User on (of those the client is on too)? # We may want this so that when a User leaves all Channels and he hasn't # sent us privmsgs, we know we can remove him from the Server @users list +# FIXME for the time being, we do it with a method that scans the server +# (if defined), so the method is slow and should not be used frequently. # * Maybe ChannelList and UserList should be HashesOf instead of ArrayOf? # See items marked as TODO Ho. # The framework to do this is now in place, thanks to the new [] method @@ -1041,6 +1043,14 @@ module Irc raise "Can't resolve channel #{channel}" end end + + def channels + if @server + @server.channels.select { |ch| ch.has_user?(self) } + else + Array.new + end + end end -- cgit v1.2.3