Skip to content

Commit

Permalink
Add ColorNicks configuration variable
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvallanger committed May 11, 2018
1 parent 04cfadc commit 199d66b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions bridge/config/config.go
Expand Up @@ -62,6 +62,7 @@ type Protocol struct {
BindAddress string // mattermost, slack // DEPRECATED
Buffer int // api
Charset string // irc
ColorNicks bool // only irc for now
Debug bool // general
DebugLevel int // only for irc now
EditSuffix string // mattermost, slack, discord, telegram, gitter
Expand Down
11 changes: 7 additions & 4 deletions bridge/irc/irc.go
Expand Up @@ -241,13 +241,16 @@ func (b *Birc) doSend() {
throttle := time.NewTicker(rate)
for msg := range b.Local {
<-throttle.C
checksum := crc32.ChecksumIEEE([]byte(msg.Username))
coloredUsername := string(0x03) + string(checksum%0x10) + msg.Username + string(0x03)
username := msg.Username
if b.GetBool("Colornicks") {
checksum := crc32.ChecksumIEEE([]byte(msg.Username))
username = fmt.Sprintf("\x03%d%s\x03", checksum%0x10, msg.Username)
}
if msg.Event == config.EVENT_USER_ACTION {
b.i.Cmd.Action(msg.Channel, coloredUsername+msg.Text)
b.i.Cmd.Action(msg.Channel, username+msg.Text)
} else {
b.Log.Debugf("Sending to channel %s", msg.Channel)
b.i.Cmd.Message(msg.Channel, coloredUsername+msg.Text)
b.i.Cmd.Message(msg.Channel, username+msg.Text)
}
}
}
Expand Down

0 comments on commit 199d66b

Please sign in to comment.