+ def select_nonempty(*ar)\r
+ debug ar\r
+ ret = ar.map { |i| (i && i.empty?) ? nil : i }.compact.first\r
+ (ret && ret.empty?) ? nil : ret\r
+ end\r
+\r
+ def printFormattedRss(feed, item, opts=nil)\r
+ debug item\r
+ places = feed.watchers\r
+ handle = "::#{feed.handle}:: "\r
+ date = String.new\r
+ if opts\r
+ places = opts[:places] if opts.key?(:places)\r
+ handle = opts[:handle].to_s if opts.key?(:handle)\r
+ if opts.key?(:date) && opts[:date]\r
+ if item.respond_to?(:updated)\r
+ if item.updated.content.class <= Time\r
+ date = item.updated.content.strftime("%Y/%m/%d %H:%M")\r
+ else\r
+ date = item.updated.content.to_s\r
+ end\r
+ elsif item.respond_to?(:source) and item.source.respond_to?(:updated)\r
+ if item.source.updated.content.class <= Time\r
+ date = item.source.updated.content.strftime("%Y/%m/%d %H:%M")\r
+ else\r
+ date = item.source.updated.content.to_s\r
+ end\r
+ elsif item.respond_to?(:pubDate) \r
+ if item.pubDate.class <= Time\r
+ date = item.pubDate.strftime("%Y/%m/%d %H:%M")\r
+ else\r
+ date = item.pubDate.to_s\r
+ end\r
+ elsif item.respond_to?(:date)\r
+ if item.date.class <= Time\r
+ date = item.date.strftime("%Y/%m/%d %H:%M")\r
+ else\r
+ date = item.date.to_s\r
+ end\r
+ else\r
+ date = "(no date)"\r
+ end\r
+ date += " :: "\r
+ end\r
+ end\r
+\r
+ tit_opt = {}\r
+ # Twitters don't need a cap on the title length since they have a hard\r
+ # limit to 160 characters, and most of them are under 140 characters\r
+ tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter'\r
+\r
+ if item.title\r
+ base_title = item.title.to_s.dup\r
+ # git changesets are SHA1 hashes (40 hex digits), way too long, get rid of them, as they are\r
+ # visible in the URL anyway\r
+ # TODO make this optional?\r
+ base_title.sub!(/^Changeset \[([\da-f]{40})\]:/) { |c| "(git commit)"} if feed.type == 'trac'\r
+ title = "#{Bold}#{base_title.ircify_html(tit_opt)}#{Bold}"\r
+ end\r
+\r
+ desc_opt = {}\r
+ desc_opt[:limit] = @bot.config['rss.text_max']\r
+ desc_opt[:a_href] = :link_out if @bot.config['rss.show_links']\r
+\r
+ # We prefer content_encoded here as it tends to provide more html formatting \r
+ # for use with ircify_html.\r
+ if item.respond_to?(:content_encoded) && item.content_encoded\r
+ desc = item.content_encoded.ircify_html(desc_opt)\r
+ elsif item.respond_to?(:description) && item.description\r
+ desc = item.description.ircify_html(desc_opt)\r