summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-08-01 13:05:15 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-08-01 13:05:15 +0200
commit6f6f42c3d7a9d4df4fe43bd731b8724dafe908ca (patch)
tree26ff6e497562f37f4eac98fb65c4fb3451f6fcf8 /cmd
parentYay go syntax (diff)
Simplify color()
Diffstat (limited to 'cmd')
-rw-r--r--cmd/irc/main.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/irc/main.go b/cmd/irc/main.go
index 8615a3e..02f0304 100644
--- a/cmd/irc/main.go
+++ b/cmd/irc/main.go
@@ -257,9 +257,9 @@ func formatIRCMessage(nick, content string) (line string) {
content = strings.TrimSuffix(content[1:], "\x01")
if strings.HasPrefix(content, "ACTION") {
- line = fmt.Sprintf("%s%s\x00%s", string(c[:]), nick, content[6:])
+ line = fmt.Sprintf("%s%s\x00%s", c, nick, content[6:])
} else {
- line = fmt.Sprintf("\x1dCTCP request from\x1d %s%s\x00: %s", string(c[:]), nick, content)
+ line = fmt.Sprintf("\x1dCTCP request from\x1d %s%s\x00: %s", c, nick, content)
}
return
@@ -270,7 +270,7 @@ func formatIRCMessage(nick, content string) (line string) {
return
}
-func color(nick string) (c [3]rune) {
+func color(nick string) string {
h := fnv.New32()
_, _ = h.Write([]byte(nick))
@@ -283,9 +283,10 @@ func color(nick string) (c [3]rune) {
sum++
}
+ var c [3]rune
c[0] = '\x03'
c[1] = rune(sum/10) + '0'
c[2] = rune(sum%10) + '0'
- return
+ return string(c[:])
}