summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer Rinehart <anubis@overthemonkey.com>2009-03-09 12:07:38 -0400
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-03-09 20:31:38 +0100
commit07edf3c56db6d05346a3e2dbfff12698e543c090 (patch)
treeb2bd58a94a2765deb2ae115919062930c69632e5
parent6c0c869e08dd790cd8ffea15514e73d62aadb1ec (diff)
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.
-rw-r--r--data/rbot/plugins/reaction.rb4
1 files changed, 3 insertions, 1 deletions
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