summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/reaction.rb
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot/plugins/reaction.rb')
-rw-r--r--data/rbot/plugins/reaction.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/data/rbot/plugins/reaction.rb b/data/rbot/plugins/reaction.rb
index ad8f2431..ee8abbd5 100644
--- a/data/rbot/plugins/reaction.rb
+++ b/data/rbot/plugins/reaction.rb
@@ -213,11 +213,14 @@ class ReactionPlugin < Plugin
return unless PrivMessage === m
debug "testing #{m} for reactions"
return if @reactions.empty?
- wanted = @reactions.find { |react|
- react === m
- }
- return unless wanted
- match = wanted === m
+ candidates = @reactions.map { |react|
+ blob = react === m
+ blob ? [blob, react] : nil
+ }.compact
+ return if candidates.empty?
+ match, wanted = candidates.sort { |m1, m2|
+ m1.first[0].length <=> m2.first[0].length
+ }.last
matched = match[0]
stuff = match.post_match.strip
target, what = stuff.split(/\s+/, 2)