From e44f31f30a0e0b77c477085f798377693b1aea37 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Sat, 15 Jan 2022 22:36:34 +0200 Subject: [PATCH] fix: remove unneeded check and create server channel before all other channels --- client/client.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/client/client.go b/client/client.go index e155c5e..e18d0aa 100644 --- a/client/client.go +++ b/client/client.go @@ -97,6 +97,10 @@ func (s *Client) Initialize(host string, port string, tlsEnabled bool) { } func (c *Client) Register(nick string, password string, channel string) { + c.Channels[c.Host] = Channel{ + Users: make(map[string]User), + } + c.SendCommand("CAP", "LS") if password != "" { c.SendCommand("PASS", password) @@ -112,10 +116,9 @@ func (c *Client) Register(nick string, password string, channel string) { if channel != "" { c.ActiveChannel = channel c.SendCommand("JOIN", channel) - } - - c.Channels[c.ActiveChannel] = Channel{ - Users: make(map[string]User), + c.Channels[c.ActiveChannel] = Channel{ + Users: make(map[string]User), + } } } @@ -151,10 +154,5 @@ func (c Client) SendCommand(cmd string, params ...string) { } } - if c.TcpConn != nil { - c.TcpConn.Write([]byte(cmd + paramsString + CRLF)) - } else { - // TODO: properly handle the error instead of Fatal-ing - log.Fatal("No valid connections to write to") - } + c.TcpConn.Write([]byte(cmd + paramsString + CRLF)) }