X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Ffiglet.rb;h=eb218edff066e0dddfc8643e9e1cd5b33cabf9ed;hb=60c45f4da1d3a299d61698cbf7a1cdd232e6133c;hp=cf9ee8e8df664409046ccdf087e9af324937c2aa;hpb=ac4bae6db135bb64bf6cafcb5bb1819a9f546b1c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/figlet.rb b/data/rbot/plugins/figlet.rb index cf9ee8e8..eb218edf 100644 --- a/data/rbot/plugins/figlet.rb +++ b/data/rbot/plugins/figlet.rb @@ -1,15 +1,19 @@ -DEFAULT_FONTS = ['rectangles', 'smslant'] -MAX_WIDTH=68 - 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 @@ -23,6 +27,10 @@ class FigletPlugin < Plugin end + def figlet_path + @bot.config['figlet.path'] + end + def help(plugin, topic="") "figlet => print using figlet" end @@ -35,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)