From d7ee0dd1fc3d70876fb7d615893e23a47f71a637 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 28 Nov 2006 22:45:24 +0000 Subject: Hopefully fix the rss watch/unwatch problem for good --- data/rbot/plugins/rss.rb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 16e1e643..4a0a618e 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -51,7 +51,17 @@ class ::RssBlob @handle = url end @type = type - @watchers = watchers + @watchers=[] + sanitize_watchers(watchers) + end + + # Downcase all watchers, possibly turning them into Strings if they weren't + def sanitize_watchers(list=@watchers) + ls = list.dup + @watchers.clear + ls.each { |w| + add_watch(w) + } end def watched? @@ -59,28 +69,19 @@ class ::RssBlob end def watched_by?(who) - # We need to check bot 'who' itself and the String form, because rss - # watches added before the new Irc framework represented watchers as - # Strings whereas they are now Channels. - # - @watchers.include?(who) || @watchers.include?(who.to_s) + @watchers.include?(who.downcase) end def add_watch(who) if watched_by?(who) return nil end - # TODO FIXME? should we just store watchers as Strings instead? - # This should then be @watchers << who.downcase - @watchers << who + @watchers << who.downcase return who end def rm_watch(who) - # See comment to watched_by? - # - @watchers.delete(who) - @watchers.delete(who.to_s) + @watchers.delete(who.downcase) end def to_a @@ -122,6 +123,9 @@ class RSSFeedsPlugin < Plugin @feeds[k.downcase] = @feeds[k] @feeds.delete(k) } + @feeds.each { |k, f| + f.sanitize_watchers + } else @feeds = Hash.new end -- cgit v1.2.3