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

adds support for <@userId|username> syntax for mentions and direct_mentions #189

Merged
merged 2 commits into from
May 23, 2016

Conversation

colestrode
Copy link
Contributor

For Slack, the RegExp for mentions and direct_mentions does not match if the message uses the valid <@userid|username> syntax. This PR updates the regex so that botkit will emit mention and direct_mention events if the username is included.

Note: usernames can only be in the set [a-z0-9] so there won't be any special characters that could cause problems constructing a regex including usernames. See https://get.slack.help/hc/en-us/articles/216360827-Changing-your-username

@crunchywelch
Copy link

related, other option for a way to do this in #210

fine with either way, just want to be able to get events on nickname mentions as well

@@ -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 + ')?>';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like usernames can contain ".", we'll need to escape those

@benbrown benbrown merged commit c71ff24 into howdyai:master May 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants