@hubot-friends/hubot-slack
Advanced tools
Comparing version
{ | ||
"name": "@hubot-friends/hubot-slack", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "A new Slack adapter for Hubot", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/hubot-friends/hubot-slack#readme", |
@@ -382,3 +382,7 @@ const {Adapter, TextMessage, EnterMessage, LeaveMessage, TopicMessage, CatchAllMessage, User} = require.main.require("hubot/es2015.js"); | ||
if(text.includes(`<@${botId}>`)) { | ||
if(this.robot.alias) { | ||
return text.replace(`<@${botId}>`, `${this.robot.alias}`); | ||
} else { | ||
return text.replace(`<@${botId}>`, `@${botName}`); | ||
} | ||
} | ||
@@ -385,0 +389,0 @@ return text; |
const {describe, it, beforeEach, before, after} = require('node:test'); | ||
const assert = require('node:assert/strict'); | ||
const Module = require('module'); | ||
const SlackBot = require('../src/bot.js'); | ||
@@ -352,2 +353,14 @@ const hookModuleToReturnMockFromRequire = (module, mock) => { | ||
it('Should preprend our alias to a name-lacking message addressed to us in a DM', function(t, done) { | ||
const bot = new SlackBot({alias: '!', logger: {info(){}, debug(){}}}, {appToken: ''}); | ||
bot.self = { | ||
user_id: '1234' | ||
} | ||
const text = bot.replaceBotIdWithName({ | ||
text: '<@1234> foo', | ||
}) | ||
assert.deepEqual(text, '! foo'); | ||
done() | ||
}); | ||
it('Should NOT prepend our name to a name-containing message addressed to us in a DM', function(t, done) { | ||
@@ -354,0 +367,0 @@ const bot_name = slackbot.robot.name; |
211968
0.25%3747
0.43%