Colorize username sent to IRC using its crc32 IEEE checksum
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/paulrosania/go-charset/charset"
|
"github.com/paulrosania/go-charset/charset"
|
||||||
_ "github.com/paulrosania/go-charset/data"
|
_ "github.com/paulrosania/go-charset/data"
|
||||||
"github.com/saintfish/chardet"
|
"github.com/saintfish/chardet"
|
||||||
|
"hash/crc32"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -240,11 +241,13 @@ func (b *Birc) doSend() {
|
|||||||
throttle := time.NewTicker(rate)
|
throttle := time.NewTicker(rate)
|
||||||
for msg := range b.Local {
|
for msg := range b.Local {
|
||||||
<-throttle.C
|
<-throttle.C
|
||||||
|
checksum := crc32.ChecksumIEEE([]byte(msg.Username))
|
||||||
|
coloredUsername := string(0x03) + string(checksum%0x10) + msg.Username + string(0x03)
|
||||||
if msg.Event == config.EVENT_USER_ACTION {
|
if msg.Event == config.EVENT_USER_ACTION {
|
||||||
b.i.Cmd.Action(msg.Channel, msg.Username+msg.Text)
|
b.i.Cmd.Action(msg.Channel, coloredUsername+msg.Text)
|
||||||
} else {
|
} else {
|
||||||
b.Log.Debugf("Sending to channel %s", msg.Channel)
|
b.Log.Debugf("Sending to channel %s", msg.Channel)
|
||||||
b.i.Cmd.Message(msg.Channel, msg.Username+msg.Text)
|
b.i.Cmd.Message(msg.Channel, coloredUsername+msg.Text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user