diff options
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/figlet.rb | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/data/rbot/plugins/figlet.rb b/data/rbot/plugins/figlet.rb index eb218edf..040dee25 100644 --- a/data/rbot/plugins/figlet.rb +++ b/data/rbot/plugins/figlet.rb @@ -1,13 +1,27 @@ +#-- vim:sw=2:et +#++ +# +# :title: Figlet plugin + 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')) + :desc => _('Path to the figlet program'), + :on_change => Proc.new { |bot, v| bot.plugins['figlet'].test_figlet }) - def initialize - super + def figlet_path + @bot.config['figlet.path'] + end + + attr_reader :has_figlet + attr_accessor :figlet_font + + def test_figlet + #check that figlet is present + @has_figlet = File.exist?(figlet_path) # check that figlet actually has the font installed @figlet_font = nil @@ -18,7 +32,15 @@ class FigletPlugin < Plugin break end end - + end + + def initialize + super + + + # test for figlet and font presence + test_figlet + # set the commandline params @figlet_params = ['-k', '-w', MAX_WIDTH.to_s] @@ -27,15 +49,16 @@ class FigletPlugin < Plugin end - def figlet_path - @bot.config['figlet.path'] - end - def help(plugin, topic="") "figlet <message> => print using figlet" end def figlet(m, params) + unless @has_figlet + m.reply "figlet couldn't be found. if it's installed, you should set the figlet.path config key to its path" + return + end + message = params[:message].to_s if message =~ /^-/ m.reply "the message can't start with a - sign" |