X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Frss.rb;h=8f5420c5ea73d228ee759fcb17f6bb62cc0388a0;hb=f10419698c7889d84d325e37250f8534f2645767;hp=fcea9197b67a77d04091ba797dfb3c94038ba851;hpb=71e7de53680d14072a93176739c442b3953c70c6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index fcea9197..8f5420c5 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -210,9 +210,17 @@ class RSSFeedsPlugin < Plugin end end + def itemDate(item,ex=nil) + return item.pubDate if item.respond_to?(:pubDate) + return item.date if item.respond_to?(:date) + return ex + end + def freshness_sort(items) notime = Time.at(0) - items.sort { |a, b| (b.pubDate || notime) <=> (a.pubDate || notime) } + items.sort { |a, b| + itemDate(b, notime) <=> itemDate(a, notime) + } end def list_rss(m, params) @@ -430,7 +438,24 @@ class RSSFeedsPlugin < Plugin if opts places = opts[:places] if opts.key?(:places) handle = opts[:handle].to_s if opts.key?(:handle) - date = item.pubDate.strftime("%Y/%m/%d %H.%M.%S") + " :: " if (opts.key?(:date) && opts[:date] && item.pubDate) + if opts.key?(:date) && opts[:date] + if item.respond_to?(:pubDate) + if item.pubDate.class <= Time + date = item.pubDate.strftime("%Y/%m/%d %H.%M.%S") + 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.%S") + else + date = item.date.to_s + end + else + date = "(no date)" + end + date += " :: " + end end title = "#{Bold}#{item.title.chomp.riphtml}#{Bold}" if item.title desc = item.description.gsub(/\s+/,' ').strip.riphtml.shorten(@bot.config['rss.text_max']) if item.description