summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorChris Gahan <chris@ill-logic.com>2006-02-23 15:52:16 +0000
committerChris Gahan <chris@ill-logic.com>2006-02-23 15:52:16 +0000
commit22b2382a8a4b817b3b8b0d7812bfddafe65b73b4 (patch)
tree29b4ecaddbe1b3a746a19363017717fd00e2c0bc /data/rbot/plugins
parentf674064c0c702826f19c6ee1177da0f2b30b2f01 (diff)
chucknorris.rb now supports Vin Diesel and Mr. T, and is rewritten a lot.
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/chucknorris.rb45
1 files changed, 33 insertions, 12 deletions
diff --git a/data/rbot/plugins/chucknorris.rb b/data/rbot/plugins/chucknorris.rb
index 362462e6..b929b6ad 100644
--- a/data/rbot/plugins/chucknorris.rb
+++ b/data/rbot/plugins/chucknorris.rb
@@ -1,29 +1,50 @@
require 'uri/common'
require 'cgi'
+
+FACTMAP = { "mrt" => "Mr\. T",
+ "vin" => "Vin Diesel",
+ "chuck" => "Chuck Norris" }
class ChuckNorrisPlugin < Plugin
def help(plugin, topic="")
- "chucknorris => show a random chuck norris fact."
+ "getfact => show a random Chuck Norris or Vin Diesel or Mr. T fact || chucknorris => show a random Chuck Norris quote || vindiesel => show a random Vin Diesel quote || mrt => I pity the foo who can't figure this one out."
end
-
- def chucknorris(m, params)
- factdata = @bot.httputil.get(URI.parse('http://www.4q.cc/index.php?pid=fact&person=chuck'))
+
+ def getfact(m, params)
+ who = params[:who]
+ m.reply "Errorn!!!" unless who
+
+ if who == 'random'
+ who = FACTMAP.keys[rand(FACTMAP.length)]
+ end
+
+ longwho = FACTMAP[who]
+ unless longwho
+ m.reply "Who the crap is #{who}?!?!"
+ return
+ end
+
+ matcher = %r{<h1> And now a random fact about #{longwho}...</h1>(.+?)<hr />}
+
+ factdata = @bot.httputil.get(URI.parse("http://www.4q.cc/index.php?pid=fact&person=#{who}"))
unless factdata
- m.reply "This Chuck Norris fact made my brain explode. (HTTP error)"
- return
+ m.reply "This #{longwho} fact punched my teeth in. (HTTP error)"
end
-
- if factdata =~ %r{<h1> And now a random fact about Chuck Norris...</h1>(.+?)<hr />}
+ if factdata =~ matcher
m.reply(CGI::unescapeHTML($1))
else
- m.reply "This Chuck Norris fact punched my teeth in. (Parse error)"
+ m.reply "This #{longwho} fact made my brain explode. (Parse error)"
end
-
+
end
end
-plugin = ChuckNorrisPlugin.new
-plugin.map 'chucknorris'
+plugin = ChuckNorrisPlugin.new
+plugin.map 'getfact :who', :action => 'getfact',
+ :defaults => {:who => 'random'}
+plugin.map 'chucknorris :who', :action => 'getfact', :defaults => {:who => "chuck"}
+plugin.map 'mrt :who', :action => 'getfact', :defaults => {:who => "mrt"}
+plugin.map 'vindiesel :who', :action => 'getfact', :defaults => {:who => "vin"}