From 5aa25762dd0da394d653cc7bbabe47ce6bdda073 Mon Sep 17 00:00:00 2001 From: Matthias H Date: Thu, 20 Feb 2014 02:22:37 +0100 Subject: [PATCH] [plugin] removed digg, broken api --- data/rbot/plugins/digg.rb | 51 --------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 data/rbot/plugins/digg.rb diff --git a/data/rbot/plugins/digg.rb b/data/rbot/plugins/digg.rb deleted file mode 100644 index dc0ea6c8..00000000 --- a/data/rbot/plugins/digg.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Hacked up digg headlines plugin... - -require 'time' -require 'rexml/document' -require 'uri/common' - -class DiggPlugin < Plugin - include REXML - 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('http://services.digg.com/2.0/story.getTopNews?type=rss') - unless xml - m.reply "digg news unavailable" - return - end - doc = Document.new xml - unless doc - m.reply "digg news parse failed (invalid xml)" - return - end - done = 0 - oneline = false - if max < 0 - max = (0 - max) - oneline = true - end - max = 8 if max > 8 - matches = Array.new - doc.elements.each("rss/channel/item") {|e| - 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 - matches.each {|mat| - m.reply sprintf("%42s | %13s", mat[0][0,42], mat[1]) - } - end - end -end -plugin = DiggPlugin.new -plugin.map 'digg :limit', :defaults => {:limit => 5}, - :requirements => {:limit => /^-?\d+$/} -- 2.39.5