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