Skip to content

Commit

Permalink
Fix a bug from 3.5.0 where Slack messages wouldn't get parsed before …
Browse files Browse the repository at this point in the history
…posting to IRC
  • Loading branch information
ekmartin committed Jun 26, 2015
1 parent 7c704da commit 1aa20be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# 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
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.

Expand Down
9 changes: 4 additions & 5 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions test/bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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> @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('>><<');
Expand Down

0 comments on commit 1aa20be

Please sign in to comment.