diff --git a/lib/SlackBot.js b/lib/SlackBot.js index 33e34044c..acd694249 100755 --- a/lib/SlackBot.js +++ b/lib/SlackBot.js @@ -416,6 +416,9 @@ function Slackbot(configuration) { slack_botkit.log('** Setting up custom handlers for processing Slack messages'); slack_botkit.on('message_received', function(bot, message) { + var mentionSyntax = '<@' + bot.identity.id + '(\\|' + bot.identity.name.replace('.', '\\.') + ')?>'; + var mention = new RegExp(mentionSyntax, 'i'); + var direct_mention = new RegExp('^' + mentionSyntax, 'i'); if (message.ok != undefined) { @@ -463,7 +466,6 @@ function Slackbot(configuration) { } // remove direct mention so the handler doesn't have to deal with it - var direct_mention = new RegExp('^\<\@' + bot.identity.id + '\>', 'i'); message.text = message.text.replace(direct_mention, '') .replace(/^\s+/, '').replace(/^\:\s+/, '').replace(/^\s+/, ''); @@ -481,9 +483,6 @@ function Slackbot(configuration) { return false; } - var direct_mention = new RegExp('^\<\@' + bot.identity.id + '\>', 'i'); - var mention = new RegExp('\<\@' + bot.identity.id + '\>', 'i'); - if (message.text.match(direct_mention)) { // this is a direct mention message.text = message.text.replace(direct_mention, '')