From 73c69ae7f8a433d7daa886e322083c113bd63c9c Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 26 Aug 2007 14:32:35 +0000 Subject: rss plugin: all watchers are now informed of feed updates when anybody asks for the feed to be shown --- data/rbot/plugins/rss.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'data/rbot') 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" -- cgit v1.2.3