summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/fortune.rb
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-27 15:59:13 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-27 15:59:13 +0000
commit21949774b91eaec6ecde4eaa8ad121e2c0a36b87 (patch)
tree41a7601e168018ac203bad7ca8d7f9f82515bc28 /data/rbot/plugins/fortune.rb
parent51cf09ec02d089bfdd80e5f728cfc92a234dc437 (diff)
rearrange repo for packaging
Diffstat (limited to 'data/rbot/plugins/fortune.rb')
-rw-r--r--data/rbot/plugins/fortune.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/data/rbot/plugins/fortune.rb b/data/rbot/plugins/fortune.rb
new file mode 100644
index 00000000..184b6b13
--- /dev/null
+++ b/data/rbot/plugins/fortune.rb
@@ -0,0 +1,22 @@
+class FortunePlugin < Plugin
+ def help(plugin, topic="")
+ "fortune [<module>] => get a (short) fortune, optionally specifying fortune db"
+ end
+ def fortune(m, params)
+ db = params[:db]
+ fortune = nil
+ ["/usr/games/fortune", "/usr/bin/fortune", "/usr/local/bin/fortune"].each {|f|
+ if FileTest.executable? f
+ fortune = f
+ break
+ end
+ }
+ m.reply "fortune binary not found" unless fortune
+ ret = Utils.safe_exec(fortune, "-n", "255", "-s", db)
+ m.reply ret.gsub(/\t/, " ").split(/\n/).join(" ")
+ return
+ end
+end
+plugin = FortunePlugin.new
+plugin.map 'fortune :db', :defaults => {:db => 'fortunes'},
+ :requirements => {:db => /^[^-][\w-]+$/}