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}"
## 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]
# 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|
## say 'em!
m.reply "Fortune categories: #{categories.join ', '}"
end
-
+
end
plugin = FortunePlugin.new
plugin.map 'fortune categories', :action => "categories"