diff options
author | Himbeer <himbeer@disroot.org> | 2024-10-13 22:35:13 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-10-13 22:35:13 +0200 |
commit | 5f4a7ad627aab0fe53ddba433d85a6beb939e9da (patch) | |
tree | 2b2722258f24ac2ab511f1ef931409bcf635b10a | |
parent | 9e2212367e5d0ae6f74fd4e39f2faa5636949eb1 (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.go | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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(), }) } |