Skip to content

Commit fb1ded5

Browse files
committed
fix: remove the bot id in the handled message
1 parent 381abc6 commit fb1ded5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/virtual-assistant.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class VirtualAssistant {
1717
run() {
1818
if(this.slackService) {
1919
this.slackService.on('channel', (message, context) => {
20-
let regexpUser = /<@([^>]+)>/,
21-
matcher = message.match(regexpUser);
22-
if(matcher && matcher[1] === this.slackService.getAuthenticatedUserId()) {
20+
let regexpBot = new RegExp('<@' + this.slackService.getAuthenticatedUserId() + '>');
21+
if(regexpBot.test(message)) {
2322
// Someone talk to the bot
24-
this.onMessage(this.slackService, _.merge(context, {interfaceType: 'channel'}), message);
23+
let messageToHandle = message.replace(regexpBot, '');
24+
this.onMessage(this.slackService, _.merge(context, {interfaceType: 'channel'}), messageToHandle);
2525
}
2626

2727
});

0 commit comments

Comments
 (0)