X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Frss.rb;h=882a15fbd7c3a5c80c426814044a23d5cfa0f30d;hb=1ea3decbbacd73bf93f52f3ce392914cc924df4f;hp=03bb0b42038e2c0dbb27a09a77c99a82a60b1d45;hpb=c7eab99603c757ac4202e809f5c5923fa23e65ff;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 03bb0b42..882a15fb 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -70,6 +70,8 @@ class ::RssBlob 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 return who end @@ -106,7 +108,7 @@ class RSSFeedsPlugin < Plugin BotConfig.register BotConfigIntegerValue.new('rss.thread_sleep', :default => 300, :validate => Proc.new{|v| v > 30}, - :desc => "How many characters to use of a RSS item text") + :desc => "How many seconds to sleep before checking RSS feeds again") @@watchThreads = Hash.new @@mutex = Mutex.new @@ -122,6 +124,10 @@ class RSSFeedsPlugin < Plugin rewatch_rss end + def name + "rss" + end + def watchlist @feeds.select { |h, f| f.watched? } end @@ -231,7 +237,7 @@ class RSSFeedsPlugin < Plugin def freshness_sort(items) notime = Time.at(0) items.sort { |a, b| - itemDate(b, notime) <=> itemDate(a, notime) + itemDate(b, notime) || 0 <=> itemDate(a, notime) || 0 } end @@ -418,7 +424,8 @@ class RSSFeedsPlugin < Plugin } if dispItems.length > 0 debug "Found #{dispItems.length} new items in #{feed}" - dispItems.each { |item| + # When displaying watched feeds, publish them from older to newer + dispItems.reverse.each { |item| @@mutex.synchronize { printFormattedRss(feed, item) }