Skip to content

Commit d493c58

Browse files
author
Christoffer Holmberg
committed
Ability to define just one color for nicks sent to IRC
This enables users to configure the color used for nicks sent to IRC based on the index of NICK_COLORS. This is a middleground for those who do not want their IRC client to look like a rainbow but sitll have some color for readability.
1 parent b252f56 commit d493c58

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/bot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Bot {
3333
this.discordToken = options.discordToken;
3434
this.commandCharacters = options.commandCharacters || [];
3535
this.ircNickColor = options.ircNickColor !== false; // default to true
36+
this.ircNickColorIndex = (options.ircNickColorIndex < NICK_COLORS.length) ?
37+
options.ircNickColorIndex :
38+
false;
3639
this.channels = _.values(options.channelMapping);
3740
this.ircStatusNotices = options.ircStatusNotices;
3841
this.announceSelfJoin = options.announceSelfJoin;
@@ -317,7 +320,10 @@ class Bot {
317320
let text = this.parseText(message);
318321
let displayUsername = nickname;
319322
if (this.ircNickColor) {
320-
const colorIndex = (nickname.charCodeAt(0) + nickname.length) % NICK_COLORS.length;
323+
// If colorIndex is set in conf use that value
324+
const colorIndex = this.ircNickColorIndex ?
325+
this.ircNickColorIndex :
326+
(nickname.charCodeAt(0) + nickname.length) % NICK_COLORS.length;
321327
displayUsername = irc.colors.wrap(NICK_COLORS[colorIndex], nickname);
322328
}
323329

0 commit comments

Comments
 (0)