X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fdigg.rb;h=259629196d6368496253ad04755102e3faa36585;hb=16336b4a240a4265d1f2df1e30d7b68d3a924287;hp=e125d3c46b1becb99032aad3fa653eae0ad5f101;hpb=ec65a623fa42c033f1fbd74532b6a0e2cfd8c60f;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/digg.rb b/data/rbot/plugins/digg.rb index e125d3c4..25962919 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,11 +9,11 @@ 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 - puts "max is #{max}" - xml = @bot.httputil.get(URI.parse("http://digg.com/rss/index.xml")) + debug "max is #{max}" + xml = @bot.httputil.get('http://digg.com/rss/index.xml') unless xml m.reply "digg news parse failed" return @@ -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, 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