diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-08 17:04:02 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-08 17:04:02 +0100 |
commit | 01466928fae8d87d5e09237b4eeb49259f252fb3 (patch) | |
tree | 8645771ad1e954873644306e15fdf3efaca0b582 /data | |
parent | 3449fbea22b9eae423b60db80cb35950a22e81a9 (diff) |
fortune: configurable options for the command
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/fortune.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/data/rbot/plugins/fortune.rb b/data/rbot/plugins/fortune.rb index d83d6a88..6612c111 100644 --- a/data/rbot/plugins/fortune.rb +++ b/data/rbot/plugins/fortune.rb @@ -7,6 +7,9 @@ class FortunePlugin < Plugin Config.register Config::StringValue.new('fortune.path', :default => '', :desc => "Full path to the fortune executable") + Config.register Config::ArrayValue.new('fortune.options', + :default => ['-n', '350', '-s'], + :desc => "Options to be passed on to fortune") def help(plugin, topic="") "fortune [<category>] => get a (short) fortune, optionally specifying fortune category || fortune categories => show categories" @@ -44,12 +47,15 @@ class FortunePlugin < Plugin ## Pick a fortune def fortune(m, params) - db = params[:db] fortune = find_fortune(m) m.reply "fortune executable not found (try setting the 'fortune.path' variable)" unless fortune + command = [fortune] + @bot.config['fortune.options'] + command << params[:db] + command.compact! + begin - ret = Utils.safe_exec(fortune, "-n", "350", "-s", db) + ret = Utils.safe_exec(*command) ## cleanup ret ret = ret.split(/\n+/).map do |l| |