X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fdigg.rb;h=dc0ea6c897abaaf0d5d295bc8f51e0cbe963fd9f;hb=052217de30c59206d7025b582d4604557a747470;hp=8e3aeb4e01e4ed279bd629596dfa6a8cf4608793;hpb=43ac960aa89e5a02291fe875627dac88ae7fda34;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/digg.rb b/data/rbot/plugins/digg.rb index 8e3aeb4e..dc0ea6c8 100644 --- a/data/rbot/plugins/digg.rb +++ b/data/rbot/plugins/digg.rb @@ -1,4 +1,4 @@ -# Hacked up slashdot headlines plugin... +# Hacked up digg headlines plugin... require 'time' require 'rexml/document' @@ -9,13 +9,13 @@ class DiggPlugin < Plugin def help(plugin, topic="") "digg [=5] => show digg headlines, [=5] => return up to headlines (use a negative number to show all the headlines on one line)" end - + def digg(m, params) max = params[:limit].to_i debug "max is #{max}" - xml = @bot.httputil.get_cached(URI.parse("http://digg.com/rss/index.xml")) + xml = @bot.httputil.get('http://services.digg.com/2.0/story.getTopNews?type=rss') unless xml - m.reply "digg news parse failed" + m.reply "digg news unavailable" return end doc = Document.new xml @@ -32,11 +32,11 @@ class DiggPlugin < Plugin max = 8 if max > 8 matches = Array.new doc.elements.each("rss/channel/item") {|e| - matches << [ e.elements["title"].text, + matches << [ e.elements["title"].text.strip, Time.parse(e.elements["pubDate"].text).strftime('%a @ %I:%M%p') ] done += 1 break if done >= max - } + } if oneline m.reply matches.collect{|mat| mat[0]}.join(" | ") else