1 DEFAULT_FONTS = ['rectangles', 'smslant']
4 class FigletPlugin < Plugin
7 @figlet_path = "/usr/bin/figlet"
9 # check that figlet actually has the font installed
10 for fontname in DEFAULT_FONTS
11 # check if figlet can render this font properly
12 if system("#{@figlet_path} -f #{fontname} test test test")
13 @figlet_font = fontname
18 # set the commandline params
19 @figlet_params = ['-k', '-w', MAX_WIDTH.to_s]
21 # add the font from DEFAULT_FONTS to the cmdline (if figlet has that font)
22 @figlet_params += ['-f', @figlet_font] if @figlet_font
26 def help(plugin, topic="")
27 "figlet <message> => print using figlet"
31 message = params[:message].to_s
33 m.reply "the message can't start with a - sign"
37 # collect the parameters to pass to safe_exec
38 exec_params = [@figlet_path] + @figlet_params + [message]
41 m.reply Utils.safe_exec(*exec_params)
46 plugin = FigletPlugin.new
47 plugin.map "figlet *message"