From 3449fbea22b9eae423b60db80cb35950a22e81a9 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 8 Jan 2009 16:36:26 +0100 Subject: fortune plugin: fix autodetection An empty String is not false in Ruby, so check for it properly. Also, find_fortune needs a message passed to it, to be used when it discovers the correct path. --- data/rbot/plugins/fortune.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/fortune.rb b/data/rbot/plugins/fortune.rb index 79a900fd..d83d6a88 100644 --- a/data/rbot/plugins/fortune.rb +++ b/data/rbot/plugins/fortune.rb @@ -12,9 +12,9 @@ class FortunePlugin < Plugin "fortune [] => get a (short) fortune, optionally specifying fortune category || fortune categories => show categories" end - def find_fortune + def find_fortune(m) fortune = @bot.config['fortune.path'] - return fortune if fortune + return fortune if fortune and not fortune.empty? ["/usr/bin/fortune", "/usr/share/bin/fortune", @@ -45,7 +45,7 @@ class FortunePlugin < Plugin ## Pick a fortune def fortune(m, params) db = params[:db] - fortune = find_fortune + fortune = find_fortune(m) m.reply "fortune executable not found (try setting the 'fortune.path' variable)" unless fortune begin @@ -75,7 +75,7 @@ class FortunePlugin < Plugin # Print the fortune categories def categories(m, params) - fortune = find_fortune + fortune = find_fortune(m) m.reply "fortune executable not found (try setting the 'fortune.path' variable)" unless fortune ## list all fortune databases -- cgit v1.2.3