Support twitch.tv nick capitalization (sent in the display-name tag)

Twitch uses this tag to send capitalization for nicknames, set by users
in Settings, and always sends the regular nick field lowercase.

A large portion of Twitch users set it, and using the wrong
capitalization to address a Twitch user looks out of place.

This sets a user's nick to the correct capitalization, when received.

And therefore also helps with autocompletion.
This commit is contained in:
mooff 2021-10-05 14:46:26 +01:00
parent e9f0313892
commit 692a21e279

View file

@ -105,6 +105,23 @@ module.exports = function (irc, network) {
}
}
if (irc.network.cap.isEnabled("twitch.tv/tags") && data.tags) {
// Twitch uses display-name to confer capitalization that users have set
// for their nicknames in Settings, and otherwise sends them lowercase.
const displayName = data.tags["display-name"];
// Promote the correct capitalization for the user, when present
if (displayName && displayName.toLowerCase() === data.nick) {
if (from.nick !== displayName) {
from.nick = displayName;
client.emit("users", {
chan: chan.id,
});
}
}
}
// msg is constructed down here because `from` is being copied in the constructor
const msg = new Msg({
type: data.type,