]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/figlet.rb
lart plugin: replace "me" with sourcenick
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / figlet.rb
index b8561f4702ae4d26ced879a310c709aa966b98fa..eb218edff066e0dddfc8643e9e1cd5b33cabf9ed 100644 (file)
@@ -2,15 +2,18 @@ class FigletPlugin < Plugin
   DEFAULT_FONTS = ['rectangles', 'smslant']
   MAX_WIDTH=68
 
+  Config.register Config::StringValue.new('figlet.path',
+     :default => '/usr/bin/figlet',
+     :desc => _('Path to the figlet program'))
+
   def initialize
     super
-    @figlet_path = "/usr/bin/figlet"
 
     # check that figlet actually has the font installed
     @figlet_font = nil
     for fontname in DEFAULT_FONTS
       # check if figlet can render this font properly
-      if system("#{@figlet_path} -f #{fontname} test test test")
+      if system("#{figlet_path} -f #{fontname} test test test")
         @figlet_font = fontname
         break
       end
@@ -24,6 +27,10 @@ class FigletPlugin < Plugin
 
   end
 
+  def figlet_path
+    @bot.config['figlet.path']
+  end
+
   def help(plugin, topic="")
     "figlet <message> => print using figlet"
   end
@@ -36,7 +43,7 @@ class FigletPlugin < Plugin
     end
 
     # collect the parameters to pass to safe_exec
-    exec_params = [@figlet_path] + @figlet_params + [message]
+    exec_params = [figlet_path] + @figlet_params + [message]
 
     # run figlet
     m.reply Utils.safe_exec(*exec_params)