diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-08-26 14:32:35 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-08-26 14:32:35 +0000 |
commit | 73c69ae7f8a433d7daa886e322083c113bd63c9c (patch) | |
tree | f7d0106d6725a302f9d2ac83228a547c5f75b72b | |
parent | c986bc82f4b856818e97e24fbf5fc11eef5f25c2 (diff) |
rss plugin: all watchers are now informed of feed updates when anybody asks for the feed to be shown
-rw-r--r-- | data/rbot/plugins/rss.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 483355c7..094b4571 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -414,7 +414,25 @@ class RSSFeedsPlugin < Plugin m.reply "lemme fetch it..."
title = items = nil
- fetched = fetchRss(feed, m, false)
+ we_were_watching = false
+
+ if @watch.key?(feed.handle)
+ # If a feed is being watched, we run the watcher thread
+ # so that all watchers can be informed of changes to
+ # the feed. Before we do that, though, we remove the
+ # show requester from the watchlist, if present, lest
+ # he gets the update twice.
+ if feed.watched_by?(m.replyto)
+ we_were_watching = true
+ feed.rm_watch(m.replyto)
+ end
+ @bot.timer.reschedule(@watch[feed.handle], 0)
+ if we_were_watching
+ feed.add_watch(m.replyto)
+ end
+ else
+ fetched = fetchRss(feed, m, false)
+ end
return unless fetched or feed.xml
if not fetched and feed.items
m.reply "using old data"
|