]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/fortune.rb
plugin(points): new message parser, see #34
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / fortune.rb
index 6612c11190f3554ec110feb175f1f9ba1ae2c1e2..fc54aebc353cda9220640cc8130b068a6878450c 100644 (file)
@@ -31,7 +31,7 @@ class FortunePlugin < Plugin
     end
 
     return nil unless fortune
-      
+
     # Try setting the config entry
     config_par = {:key => 'fortune.path', :value => [fortune], :silent => true }
     debug "Setting fortune.path to #{fortune}"
@@ -48,7 +48,10 @@ class FortunePlugin < Plugin
   ## Pick a fortune
   def fortune(m, params)
     fortune = find_fortune(m)
-    m.reply "fortune executable not found (try setting the 'fortune.path' variable)" unless fortune
+    if not fortune or fortune.empty?
+      m.reply "fortune executable not found (try setting the 'fortune.path' variable)"
+      return
+    end
 
     command = [fortune] + @bot.config['fortune.options']
     command << params[:db]
@@ -82,7 +85,10 @@ class FortunePlugin < Plugin
   # Print the fortune categories
   def categories(m, params)
     fortune = find_fortune(m)
-    m.reply "fortune executable not found (try setting the 'fortune.path' variable)" unless fortune
+    if not fortune or fortune.empty?
+      m.reply "fortune executable not found (try setting the 'fortune.path' variable)"
+      return
+    end
 
     ## list all fortune databases
     categories = Utils.safe_exec(fortune, "-f").split(/\n+ */).map{ |f|
@@ -94,7 +100,7 @@ class FortunePlugin < Plugin
     ## say 'em!
     m.reply "Fortune categories: #{categories.join ', '}"
   end
+
 end
 plugin = FortunePlugin.new
 plugin.map 'fortune categories', :action => "categories"