summaryrefslogtreecommitdiffstats
path: root/bridge/irc
diff options
context:
space:
mode:
authorYuval Langer <yuval.langer@gmail.com>2018-05-12 00:02:43 +0300
committerWim <wim@42.be>2018-05-11 23:02:43 +0200
commitf0738a93c3d42bec580d69f8a0df6306e3f357c2 (patch)
tree15564159af97998413a45a43149adfdc6faf46ef /bridge/irc
parent75381c2c6e32b7a7b36c4b6a662feae2b1b0fb5a (diff)
downloadmatterbridge-msglm-f0738a93c3d42bec580d69f8a0df6306e3f357c2.tar.gz
matterbridge-msglm-f0738a93c3d42bec580d69f8a0df6306e3f357c2.tar.bz2
matterbridge-msglm-f0738a93c3d42bec580d69f8a0df6306e3f357c2.zip
[WIP] Colorize username sent to IRC using its crc32 IEEE checksum (#423)
* Colorize username sent to IRC using its crc32 IEEE checksum * Add `ColorNicks` configuration variable * Add `ColorNicks` setting
Diffstat (limited to 'bridge/irc')
-rw-r--r--bridge/irc/irc.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 1e26b770..cb0a6fe7 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -12,6 +12,7 @@ import (
"github.com/paulrosania/go-charset/charset"
_ "github.com/paulrosania/go-charset/data"
"github.com/saintfish/chardet"
+ "hash/crc32"
"io"
"io/ioutil"
"net"
@@ -246,11 +247,16 @@ func (b *Birc) doSend() {
throttle := time.NewTicker(rate)
for msg := range b.Local {
<-throttle.C
+ 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, msg.Username+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, msg.Username+msg.Text)
+ b.i.Cmd.Message(msg.Channel, username+msg.Text)
}
}
}