From 129f8c4f5678ab4a753ddb8ffb3088835d17d4d4 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 15 Mar 2009 10:42:36 +0100 Subject: rss: clean up options parsing in printFormattedRss --- data/rbot/plugins/rss.rb | 69 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index de7678a8..dcd50b57 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -972,44 +972,47 @@ class RSSFeedsPlugin < Plugin return seconds end - def printFormattedRss(feed, item, opts=nil) + def printFormattedRss(feed, item, options={}) # debug item - places = feed.watchers - handle = feed.handle.empty? ? "" : "::#{feed.handle}:: " + opts = { + :places => feed.watchers, + :handle => feed.handle.empty? ? "" : "::#{feed.handle}:: ", + :date => false + }.merge options + date = String.new - if opts - places = opts[:places] if opts.key?(:places) - handle = opts[:handle].to_s if opts.key?(:handle) - if opts.key?(:date) && opts[:date] - if item.respond_to?(:updated) - if item.updated.content.class <= Time - date = item.updated.content.strftime("%Y/%m/%d %H:%M") - else - date = item.updated.content.to_s - end - elsif item.respond_to?(:source) and item.source.respond_to?(:updated) - if item.source.updated.content.class <= Time - date = item.source.updated.content.strftime("%Y/%m/%d %H:%M") - else - date = item.source.updated.content.to_s - end - elsif item.respond_to?(:pubDate) - if item.pubDate.class <= Time - date = item.pubDate.strftime("%Y/%m/%d %H:%M") - else - date = item.pubDate.to_s - end - elsif item.respond_to?(:date) - if item.date.class <= Time - date = item.date.strftime("%Y/%m/%d %H:%M") - else - date = item.date.to_s - end + + places = opts[:places] + handle = opts[:handle].to_s + if opts[:date] + if item.respond_to?(:updated) + if item.updated.content.class <= Time + date = item.updated.content.strftime("%Y/%m/%d %H:%M") + else + date = item.updated.content.to_s + end + elsif item.respond_to?(:source) and item.source.respond_to?(:updated) + if item.source.updated.content.class <= Time + date = item.source.updated.content.strftime("%Y/%m/%d %H:%M") + else + date = item.source.updated.content.to_s + end + elsif item.respond_to?(:pubDate) + if item.pubDate.class <= Time + date = item.pubDate.strftime("%Y/%m/%d %H:%M") + else + date = item.pubDate.to_s + end + elsif item.respond_to?(:date) + if item.date.class <= Time + date = item.date.strftime("%Y/%m/%d %H:%M") else - date = "(no date)" + date = item.date.to_s end - date += " :: " + else + date = "(no date)" end + date << " :: " end tit_opt = {} -- cgit v1.2.3