diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-09-24 18:11:00 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-09-24 18:11:00 +0200 |
commit | d4c5eb46ce33816fb7ccc5e477d9e572fdfb2f5c (patch) | |
tree | c5e3c49923b315e9d08afd6ccacb1d01ad652c95 /lib/rbot | |
parent | 86fada3ab193fd369c13323a8f03825493222df4 (diff) |
irc.rb: User#channels method
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/irc.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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 |