-
Notifications
You must be signed in to change notification settings - Fork 292
Avoid self-message highlights on IRC #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I have cleaned this pull request up. It now uses zero width space characters which seem to work in all clients so far. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean. I'll test it in an IRC client later and merge.
|
||
// Join the display name with double "bold" formatting characters | ||
// to prevent unintentional highlights on the IRC side | ||
displayUsername = displayUsername.split('').join('\u200d'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe merge this with line 164? I.e. let displayUsername = nickname.split('').join('\u200d');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is more explicit since it doesn't combine the operation with getting the name from another variable (and allows the comment to stand on its own), but I can do it.
test/bot.test.js
Outdated
@@ -98,7 +98,7 @@ describe('Bot', function () { | |||
}; | |||
|
|||
bot.sendToIRC(message); | |||
const expected = `<${message.author.username}> ${text}`; | |||
const expected = `<${message.author.username.split('').join('\u200d')}> ${text}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add a simple helper function somewhere towards the top of the file that does the splitting?
i.e.
const escapeUsername = username => username.split('').join('\u200d');
Tested with Weechat, seems to be working well. Thanks! Released in version 2.2.0. |
Avoid self-message highlights on IRC
When a user connected to both Discord and IRC speaks on Discord, they will likely get unwanted highlights in their IRC client. This is a fix which I believe is standard practice. By putting a zero width space character between each letter of the display name, we ensure IRC clients do not detect the name and highlight on it.
The other line in the commit is a fix where the wrong variable was being used.