From 5d116465f221091fc381f6048ae1013d5cb60971 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 6 Oct 2008 22:05:17 +0200 Subject: figlet: strip first and last empty line(s) --- data/rbot/plugins/figlet.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/figlet.rb b/data/rbot/plugins/figlet.rb index 64be496c..0eebc813 100644 --- a/data/rbot/plugins/figlet.rb +++ b/data/rbot/plugins/figlet.rb @@ -122,10 +122,16 @@ class FigletPlugin < Plugin exec_params = [send(:"#{key}_path")] + @params[key] + [message] # run the program - m.reply Utils.safe_exec(*exec_params), :max_lines => 0 + m.reply strip_first_last_empty_line(Utils.safe_exec(*exec_params)), :max_lines => 0 end alias :toilet :figlet + private + + def strip_first_last_empty_line(txt) + txt.gsub(/\A(?:^\s*\r?\n)+/m,'').rstrip + end + end plugin = FigletPlugin.new -- cgit v1.2.3