Report abuse


			
# pwd ; ls -l
/usr/share/rbot/plugins
total 632
-rwx------ 1 ant  ant     212 2008-04-28 14:07 0001-A-better-rescue-for-failures.patch
-rw-r--r-- 1 root root   1747 2008-03-20 17:33 autoop.rb
-rw-r--r-- 1 root root    390 2008-03-20 17:33 autorejoin.rb
-rw-r--r-- 1 root root   8520 2008-03-20 17:33 bans.rb
-rw-r--r-- 1 root root   1631 2008-03-20 17:33 bash.rb
-rw-r--r-- 1 root root    454 2008-03-20 17:33 cal.rb
-rw-r--r-- 1 root root   2149 2008-03-20 17:33 chucknorris.rb
-rw-r--r-- 1 root root 229967 2008-03-20 17:33 chucknorris.yml.gz
-rw-r--r-- 1 root root  13777 2008-03-20 17:33 deepthoughts.rb
-rw-r--r-- 1 root root   2643 2008-03-20 17:33 demauro.rb
-rw-r--r-- 1 root root   2150 2008-03-20 17:33 dice.rb
-rw-r--r-- 1 root root   1384 2008-03-20 17:33 digg.rb
-rw-r--r-- 1 root root    757 2008-03-20 17:33 eightball.rb
-rw-r--r-- 1 root root  21711 2008-03-20 17:33 excuse.rb
-rw-r--r-- 1 ant  ant    1386 2007-12-03 13:08 eztv-0.1.rb
-rw-r--r-- 1 root root   2039 2008-03-20 17:33 fish.rb
-rw-r--r-- 1 root root   4374 2008-03-20 17:33 forecast.rb
-rw-r--r-- 1 root root    719 2008-03-20 17:33 fortune.rb
-rw-r--r-- 1 root root   3142 2008-03-20 17:33 freshmeat.rb
-rw-r--r-- 1 root root   1150 2008-03-20 17:33 google.rb
-rw-r--r-- 1 root root   1016 2008-03-20 17:33 grouphug.rb
-rw-r--r-- 1 ant  ant    2144 2007-05-07 18:29 horo-0.1.rb
-rw-r--r-- 1 root root    375 2008-03-20 17:33 host.rb
-rw-r--r-- 1 root root    691 2008-03-20 17:33 httpd.rb.disabled
-rw-r--r-- 1 root root   2339 2008-03-20 17:33 imdb.rb
-rw-r--r-- 1 root root   4046 2008-03-20 17:33 insult.rb
-rw-r--r-- 1 root root   5543 2008-03-20 17:33 iplookup.rb
-rw-r--r-- 1 root root   2433 2008-03-20 17:33 karma.rb
-rw-r--r-- 1 root root  15581 2008-03-20 17:33 keywords.rb
-rw-r--r-- 1 root root   4359 2008-03-20 17:33 lart.rb
-rw-r--r-- 1 root root    905 2008-03-20 17:33 lastfm.rb
-rw-r--r-- 1 root root   5898 2008-03-20 17:33 markov.rb
-rw-r--r-- 1 root root   3287 2008-03-20 17:33 math.rb
-rw-r--r-- 1 ant  ant    3375 2007-05-07 16:44 moon-0.2.rb
-rw-r--r-- 1 root root   5363 2008-03-20 17:33 nickserv.rb
-rw-r--r-- 1 ant  ant    1285 2007-05-07 14:17 note-0.1.rb
-rw-r--r-- 1 root root   1106 2008-03-20 17:33 nslookup.rb
-rw-r--r-- 1 root root    366 2008-03-20 17:33 opme.rb
-rw-r--r-- 1 root root    953 2008-03-11 16:02 qdb-0.3.rb
-rw-r--r-- 1 root root   1429 2008-03-20 17:33 quakeauth.rb
-rw-r--r-- 1 root root  12853 2008-03-20 17:33 quotes.rb
-rw-r--r-- 1 root root   6710 2008-03-20 17:33 remind.rb
-rw-r--r-- 1 root root   1586 2008-03-20 17:33 roshambo.rb
-rw-r--r-- 1 root root    268 2008-03-20 17:33 rot13.rb
-rw-r--r-- 1 root root   5986 2008-03-20 17:33 roulette.rb
-rw-r--r-- 1 root root  17165 2008-03-20 17:33 rss.rb
-rw-r--r-- 1 root root   1033 2008-03-20 17:33 rubyurl.rb.disabled
-rw-r--r-- 1 root root   2872 2008-03-20 17:33 seen.rb
-rw-r--r-- 1 root root   2761 2008-03-20 17:33 slashdot.rb
-rw-r--r-- 1 root root   1021 2008-03-20 17:33 spell.rb
-rw-r--r-- 1 root root   8171 2008-03-20 17:33 theyfightcrime.rb
-rw-r--r-- 1 root root   1094 2008-03-20 17:33 threat.rb
-rw-r--r-- 1 root root   1051 2008-03-20 17:33 tinyurl.rb.disabled
-rw-r--r-- 1 root root    445 2008-02-06 14:24 toilet.rb
-rw-r--r-- 1 root root   5588 2008-03-20 17:33 topic.rb
-rw-r--r-- 1 root root   2317 2008-03-20 17:33 tube.rb
-rw-r--r-- 1 ant  ant     532 2007-05-25 13:00 unicode-0.1.rb
-rw-r--r-- 1 root root   1948 2008-03-20 17:33 urban.rb.disabled
-rw-r--r-- 1 root root  13666 2008-03-20 17:33 url.rb
-rw-r--r-- 1 root root  26360 2008-03-20 17:33 weather.rb
-rw-r--r-- 1 root root   3389 2008-03-20 17:33 wow.rb
-rw-r--r-- 1 root root   1959 2008-03-20 17:33 wserver.rb
-rw-r--r-- 1 root root    790 2008-03-20 17:33 xmlrpc.rb.disabled

# cat 0001-A-better-rescue-for-failures.patch
--- a/qdb.rb
+++ b/qdb.rb
@@ -30,7 +30,7 @@ class QdbPlugin < Plugin
       end

     rescue => e
-      m.reply "Fail"
+      m.reply "%s caught (%s)" % [e.class, e.backtrace[0]]
     end
   end

--
1.5.2.1

# patch qdb-0.3.rb 0001-A-better-rescue-for-failures.patch
patching file qdb-0.3.rb

# fgrep -n backtrace qdb-0.3.rb
33:      m.reply "%s caught (%s)" % [e.class, e.backtrace[0]]


# cat qdb-0.3.rb
#-- vim:sw=2:et
#++
#
# :title: Qdb quote fetcher
#
# Author:: Jan Wikholm 
# Copyright:: (C) 2008 Jan Wikholm
# License:: MIT
#

require 'rubygems'
require 'hpricot'

class QdbPlugin < Plugin

  def help(plugin, topic="")
      "qdb  => fetch qdb quote by id"
  end

  def retrieve(m)
    request = m.params
    url = "http://www.qdb.us/#{request}"
    begin
      doc = Hpricot(@bot.httputil.get(url))
      quote = (doc/"table[@class='quote']/tr[2]/td[1]/p").text.split("\n")
      if quote.size <= @bot.config['send.max_lines']
        quote.each {|line| m.reply line }
      else
        m.reply "quote too long (%s lines), see for yerself: %s or change limit by: config set send.max_lines NUMBER" % [quote.size, url]
      end

    rescue => e
      m.reply "%s caught (%s)" % [e.class, e.backtrace[0]]
    end
  end

  def privmsg(m)
    retrieve(m)
  end
end

plugin = QdbPlugin.new
plugin.map "qdb *request", :action => 'retrieve', :thread => "yes" #so it won't lock

--

[msg(bender)] qdb 28937
02:15PM [Bender(~rbot@[deleted my IP address] ArgumentError caught
          (/usr/share/rbot/plugins/qdb-0.3.rb:26:in `<=')