From c7eab99603c757ac4202e809f5c5923fa23e65ff Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 6 Aug 2006 23:27:51 +0000 Subject: [PATCH] Fix RSS plugin problems caused by watches created before the new Irc framework --- ChangeLog | 7 ++++++- data/rbot/plugins/rss.rb | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3970ad39..b2954b46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,8 +4,13 @@ @bot.kick channel, user, reason to kick a user from a channel * RSS plugin: fix rewatch_rss method + * RSS plugin: the different ways to represent channels before and + after the New IRC Framework was causing strange problems such as + watched feed not being listed as such, undeletable watches, double + watches etc. Fix this by checking both for the Channel objects and + their to_s form when checking for watches or deleting them. -2006-08-06 Giuseppe Bilotta +2006-08-06 Giuseppe Bilotta * Updating the ChangeLog again: describe the new stuff in trunk which will be made available in the next release. Use Gnu style for new diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index b49b6a1d..03bb0b42 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -1,7 +1,12 @@ +#-- vim:sw=2:et +#++ +# # RSS feed plugin for RubyBot # (c) 2004 Stanislav Karchebny # (c) 2005 Ian Monroe # (c) 2005 Mark Kretschmann +# (c) 2006 Giuseppe Bilotta +# # Licensed under MIT License. require 'rss/parser' @@ -54,19 +59,26 @@ class ::RssBlob end def watched_by?(who) - @watchers.include?(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) end def add_watch(who) if watched_by?(who) return nil end - @watchers << who unless watched_by?(who) + @watchers << who return who end def rm_watch(who) + # See comment to watched_by? + # @watchers.delete(who) + @watchers.delete(who.to_s) end def to_a -- 2.39.2