Skip to content

Commit

Permalink
Revert "Merge pull request #193 from Sanqui/avoid-highlights"
Browse files Browse the repository at this point in the history
This reverts commit ebe340b, reversing
changes made to 0f48dfe.
  • Loading branch information
ekmartin committed Mar 12, 2017
1 parent a67e94c commit 59f4d75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
7 changes: 1 addition & 6 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,9 @@ class Bot {
const nickname = Bot.getDiscordNicknameOnServer(author, fromGuild);
let text = this.parseText(message);
let displayUsername = nickname;

// Join the display name with double "bold" formatting characters
// to prevent unintentional highlights on the IRC side
displayUsername = displayUsername.split('').join('\u200d');

if (this.ircNickColor) {
const colorIndex = (nickname.charCodeAt(0) + nickname.length) % NICK_COLORS.length;
displayUsername = irc.colors.wrap(NICK_COLORS[colorIndex], displayUsername);
displayUsername = irc.colors.wrap(NICK_COLORS[colorIndex], nickname);
}

if (this.isCommandMessage(text)) {
Expand Down
16 changes: 7 additions & 9 deletions test/bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import createDiscordStub from './stubs/discord-stub';
import ClientStub from './stubs/irc-client-stub';
import config from './fixtures/single-test-config.json';

const escapeUsername = username => username.split('').join('\u200d');

chai.should();
chai.use(sinonChai);

Expand Down Expand Up @@ -100,7 +98,7 @@ describe('Bot', function () {
};

bot.sendToIRC(message);
const expected = `<${escapeUsername(message.author.username)}> ${text}`;
const expected = `<${message.author.username}> ${text}`;
ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
});

Expand All @@ -122,7 +120,7 @@ describe('Bot', function () {

this.bot.sendToIRC(message);
// Wrap in colors:
const expected = `<\u000304${escapeUsername(message.author.username)}\u000f> ${text}`;
const expected = `<\u000304${message.author.username}\u000f> ${text}`;
ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
});

Expand All @@ -144,7 +142,7 @@ describe('Bot', function () {
};

this.bot.sendToIRC(message);
const expected = `<\u000304${escapeUsername(message.author.username)}\u000f> ${attachmentUrl}`;
const expected = `<\u000304${message.author.username}\u000f> ${attachmentUrl}`;
ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
});

Expand All @@ -169,9 +167,9 @@ describe('Bot', function () {
this.bot.sendToIRC(message);

ClientStub.prototype.say.should.have.been.calledWith('#irc',
`<\u000304${escapeUsername(message.author.username)}\u000f> ${text}`);
`<\u000304${message.author.username}\u000f> ${text}`);

const expected = `<\u000304${escapeUsername(message.author.username)}\u000f> ${attachmentUrl}`;
const expected = `<\u000304${message.author.username}\u000f> ${attachmentUrl}`;
ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
});

Expand Down Expand Up @@ -245,7 +243,7 @@ describe('Bot', function () {
};

// Wrap it in colors:
const expected = `<\u000312${escapeUsername(message.author.username)}\u000f> #${message.channel.name}`;
const expected = `<\u000312${message.author.username}\u000f> #${message.channel.name}`;
this.bot.sendToIRC(message);
ClientStub.prototype.say
.should.have.been.calledWith('#irc', expected);
Expand Down Expand Up @@ -384,7 +382,7 @@ describe('Bot', function () {
};

bot.sendToIRC(message);
const expected = `<${escapeUsername(nickname)}> ${text}`;
const expected = `<${nickname}> ${text}`;
ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
});

Expand Down

0 comments on commit 59f4d75

Please sign in to comment.