summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorSpencer RInehart <anubis@vt.edu>2008-06-25 15:21:08 -0400
committerdmitry kim <jason@nichego.net>2008-06-25 23:57:08 +0400
commitbaee671df9879de90925425f7998904ce3b049fa (patch)
treebccb517092763c7c1d5910db349da071462a34e9 /data/rbot
parent7a128ab6457c9b79ed31a5562be98e1718bfaf80 (diff)
urban plugin: when urbandictionary.com goes offline, don't throw errors.
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/urban.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb
index d4aaef62..9c55a06e 100644
--- a/data/rbot/plugins/urban.rb
+++ b/data/rbot/plugins/urban.rb
@@ -17,6 +17,7 @@ class UrbanPlugin < Plugin
u = URBAN + URI.escape(word)
u += '&page=' + p.to_s if p > 1
s = @bot.httputil.get(u)
+ return m.reply "Couldn't get the urban dictionary definition for #{word}" if s.nil?
notfound = s.match %r{<div style="color: #669FCE"><i>.*?</i> isn't defined}
@@ -47,6 +48,7 @@ class UrbanPlugin < Plugin
resp = @bot.httputil.head('http://www.urbandictionary.com/random.php',
:max_redir => -1,
:cache => false)
+ return m.reply "Couldn't get the urban dictionary word of the day" if resp.nil?
if resp.code == "302" && (loc = resp['location'])
words = URI.unescape(loc.match(/define.php\?term=(.*)$/)[1]) rescue nil
end