aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-10-13 22:35:13 +0200
committerHimbeer <himbeer@disroot.org>2024-10-13 22:35:13 +0200
commit5f4a7ad627aab0fe53ddba433d85a6beb939e9da (patch)
tree2b2722258f24ac2ab511f1ef931409bcf635b10a
parent9e2212367e5d0ae6f74fd4e39f2faa5636949eb1 (diff)
Accept any parameter type to ClientConn.SendChatMsg
Previously, only strings were accepted. Using fmt.Sprintln internally and trimming the newline is more idiomatic because it allows easy pretty-printing of types with string overrides as well as errors. Call sites are going to be updated over time alongside other modifications.
-rw-r--r--chat.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/chat.go b/chat.go
index 6da9e0a..2a8cda4 100644
--- a/chat.go
+++ b/chat.go
@@ -28,10 +28,10 @@ func (cc *ClientConn) DoChatMsg(msg string) {
}
// SendChatMsg sends a chat message to the ClientConn.
-func (cc *ClientConn) SendChatMsg(msg ...string) {
+func (cc *ClientConn) SendChatMsg(msg ...any) {
cc.SendCmd(&mt.ToCltChatMsg{
Type: mt.SysMsg,
- Text: strings.Join(msg, " "),
+ Text: strings.TrimSpace(fmt.Sprintln(msg...)),
Timestamp: time.Now().Unix(),
})
}