From 07edf3c56db6d05346a3e2dbfff12698e543c090 Mon Sep 17 00:00:00 2001 From: Spencer Rinehart Date: Mon, 9 Mar 2009 12:07:38 -0400 Subject: reaction: fix trigger regex to work with non-alphanumeric start/end. only match on word boundaries at an end of a trigger if the character at that end of the trigger is a word character. In other words, the trigger "test" should require word boundaries on each side, but the trigger "@test" should only require one on the right side. --- data/rbot/plugins/reaction.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/rbot/plugins/reaction.rb b/data/rbot/plugins/reaction.rb index 55fabcdb..8f2a1637 100644 --- a/data/rbot/plugins/reaction.rb +++ b/data/rbot/plugins/reaction.rb @@ -69,7 +69,9 @@ class ::Reaction @trigger << Regexp.new(rex, true) else rex.sub!(/^(["'])(.*)\1$/, '\2') - @trigger << Regexp.new(/\b#{Regexp.escape(rex)}(?:\b|$)/ui) + prepend = ( rex =~ /^\w/ ? '(?:\b)' : '') + append = ( rex =~ /\w$/ ? '(?:\b|$)' : '') + @trigger << Regexp.new(/#{prepend}#{Regexp.escape(rex)}#{append}/ui) end end -- cgit v1.2.3