From ed18ba7370544244141199767365022651710021 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 22 Sep 2007 07:12:41 +0000 Subject: reaction plugin: order reaction candidates by number of captures as secondary order --- data/rbot/plugins/reaction.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'data/rbot/plugins') diff --git a/data/rbot/plugins/reaction.rb b/data/rbot/plugins/reaction.rb index 4f757ddd..8892cf7a 100644 --- a/data/rbot/plugins/reaction.rb +++ b/data/rbot/plugins/reaction.rb @@ -220,7 +220,10 @@ class ReactionPlugin < Plugin }.compact return if candidates.empty? match, wanted = candidates.sort { |m1, m2| - m1.first[0].length <=> m2.first[0].length + # Order by longest matching text first, + # and by number of captures second + longer = m1.first[0].length <=> m2.first[0].length + longer == 0 ? m1.first.length <=> m2.first.length : longer }.last matched = match[0] before = match.pre_match.strip -- cgit v1.2.3