diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-15 10:42:36 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-15 10:42:36 +0100 |
commit | 129f8c4f5678ab4a753ddb8ffb3088835d17d4d4 (patch) | |
tree | 82fd5ac13679bdfdde16ae9de1ed3597f581a60d /data/rbot | |
parent | 55eb59a4d712752c75d1e5ec6622d591bd69110a (diff) |
rss: clean up options parsing in printFormattedRss
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/rss.rb | 69 |
1 files 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 = {} |