summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-11-28 22:45:24 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-11-28 22:45:24 +0000
commitd7ee0dd1fc3d70876fb7d615893e23a47f71a637 (patch)
treeefb49531a27bb63ba7b44c4a7eaf708aa891de51
parent460487856c7f0dc6668f377536d716e116e9d400 (diff)
Hopefully fix the rss watch/unwatch problem for good
-rw-r--r--data/rbot/plugins/rss.rb30
1 files changed, 17 insertions, 13 deletions
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