Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #189 from colestrode/mentions
Browse files Browse the repository at this point in the history
adds support for <@userid|username> syntax for mentions and direct_mentions
  • Loading branch information
Ben Brown committed May 23, 2016
2 parents d2e63be + 63754aa commit c71ff24
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/SlackBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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+/, '');

Expand All @@ -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, '')
Expand Down

0 comments on commit c71ff24

Please sign in to comment.