diff --git a/CHANGELOG.md b/CHANGELOG.md index 5000ca1..92503e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog This project adheres to [Semantic Versioning](http://semver.org/). +## [3.5.1] - 2015-06-26 +### Fixed +- A bug introduced in 3.5.0 where Slack messages sent to IRC wouldn't get parsed. +Adds a test to confirm correct behavior. + ## [3.5.0] - 2015-06-22 ### Added - `commandCharacters` option - makes the bot hide the username prefix for @@ -8,7 +13,8 @@ messages that start with one of the provided characters when posting to IRC. A `Command sent from Slack by username:` message will be posted to the IRC channel before the command is submitted. -## [3.4.0] - 2015-05-22 +#t + [3.4.0] - 2015-05-22 ### Added - Made it possible to require slack-irc as a node module. diff --git a/lib/bot.js b/lib/bot.js index 46aee14..bbb4e9b 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -150,14 +150,13 @@ Bot.prototype.sendToIRC = function(message) { if (ircChannel) { var user = this.slack.getUserByID(message.user); - var body = message.getBody(); - var text; - if (this.isCommandMessage(body)) { + var text = this.parseText(message.getBody()); + + if (this.isCommandMessage(text)) { var prelude = 'Command sent from Slack by ' + user.name + ':'; this.ircClient.say(ircChannel, prelude); - text = body; } else { - text = '<' + user.name + '> ' + body; + text = '<' + user.name + '> ' + text; } logger.debug('Sending message to IRC', channelName, text); diff --git a/test/bot.test.js b/test/bot.test.js index 8fde6df..9193a34 100644 --- a/test/bot.test.js +++ b/test/bot.test.js @@ -91,6 +91,19 @@ describe('Bot', function() { ClientStub.prototype.say.should.not.have.been.called; }); + it('should parse text from slack when sending messages', function() { + var text = '<@USOMEID> <@USOMEID|readable>'; + var message = { + channel: 'slack', + getBody: function() { + return text; + } + }; + + this.bot.sendToIRC(message); + ClientStub.prototype.say.should.have.been.calledWith('#irc', ' @testuser readable'); + }); + it('should parse text from slack', function() { this.bot.parseText('hi\nhi\r\nhi\r').should.equal('hi hi hi '); this.bot.parseText('>><<').should.equal('>><<');