1 class FigletPlugin < Plugin
2 DEFAULT_FONTS = ['rectangles', 'smslant']
5 BotConfig.register BotConfigStringValue.new('figlet.path',
6 :default => '/usr/bin/figlet',
7 :desc => _('Path to the figlet program'))
12 # check that figlet actually has the font installed
14 for fontname in DEFAULT_FONTS
15 # check if figlet can render this font properly
16 if system("#{figlet_path} -f #{fontname} test test test")
17 @figlet_font = fontname
22 # set the commandline params
23 @figlet_params = ['-k', '-w', MAX_WIDTH.to_s]
25 # add the font from DEFAULT_FONTS to the cmdline (if figlet has that font)
26 @figlet_params += ['-f', @figlet_font] if @figlet_font
31 @bot.config['figlet.path']
34 def help(plugin, topic="")
35 "figlet <message> => print using figlet"
39 message = params[:message].to_s
41 m.reply "the message can't start with a - sign"
45 # collect the parameters to pass to safe_exec
46 exec_params = [figlet_path] + @figlet_params + [message]
49 m.reply Utils.safe_exec(*exec_params)
54 plugin = FigletPlugin.new
55 plugin.map "figlet *message"