From 4d25b749c765dd6c2d88f3be961d3249de2c7000 Mon Sep 17 00:00:00 2001 From: Yaohan Chen Date: Tue, 24 Jul 2007 22:16:55 +0000 Subject: * dictclient: adjusted output format --- data/rbot/plugins/dictclient.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/dictclient.rb b/data/rbot/plugins/dictclient.rb index 2cd782ce..910583ff 100644 --- a/data/rbot/plugins/dictclient.rb +++ b/data/rbot/plugins/dictclient.rb @@ -42,7 +42,12 @@ class ::Definition end def body - definition[1..-1].join.gsub(/\s+/, ' ').strip + # two or more consecutive newlines are replaced with double spaces, while single + # newlines are replaced with single spaces + lb = /\r?\n/ + definition[1..-1].join. + gsub(/\s*(:#{lb}){2,}\s*/, ' '). + gsub(/\s*#{lb}\s*/, ' ').strip end end @@ -127,7 +132,7 @@ class DictClientPlugin < Plugin ).gsub( '', r.body.truncate(@bot.config['dictclient.max_length_per_def']) ) - }.join ' ' + }.join ' | ' end else _("No definition for %{phrase} found from %{database}.") % @@ -162,7 +167,7 @@ class DictClientPlugin < Plugin def cmd_databases(m, params) with_dict(m) do |d| m.reply _("Databases: %{list}") % { - :list => d.show_db.collect {|db, des| "#{format_database db}: #{des}"}.join('; ') + :list => d.show_db.collect {|db, des| "#{format_database db}: #{des}"}.join(' | ') } end end @@ -170,7 +175,7 @@ class DictClientPlugin < Plugin def cmd_strategies(m, params) with_dict(m) do |d| m.reply _("Strategies: %{list}") % { - :list => d.show_strat.collect {|s, des| "#{s}: #{des}"}.join('; ') + :list => d.show_strat.collect {|s, des| "#{s}: #{des}"}.join(' | ') } end end -- cgit v1.2.3