From 3cb00c266efd55d053113c34d69b2b122e4996d8 Mon Sep 17 00:00:00 2001 From: Edson Menegatti Date: Sun, 29 May 2016 10:40:26 -0300 Subject: [PATCH] Fix #4 Prevent matching mentions within quotes or code snippets. For ease of implementation, the regex searches for ` only after the mention, instead of trying to match it after and before, this mean "`@abc `" will match. --- lib/bot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bot.js b/lib/bot.js index e78cd90..ab2be76 100755 --- a/lib/bot.js +++ b/lib/bot.js @@ -34,7 +34,7 @@ Bot.prototype.run = function () { var self = this, verbose = self.config.verbose, bot = new slackbot(this.config.token), - pattern = "(?:@)(("; + pattern = "^(?!>).*(?:@)(("; var len = _.keys(self.config.alias_maps).length; console.log(len); var helpTxt = "The following aliases are supported: \n"; @@ -44,7 +44,7 @@ Bot.prototype.run = function () { helpTxt += key + "\n\t[" + value.join(", ") + "]\n "; }); - pattern += self.config.helpName + "))"; + pattern += self.config.helpName + "))(?!`)"; helpTxt += self.config.helpName; if (verbose) { console.log("Pattern is: " + pattern);