fix: remove unneeded check and create server channel before all other channels

This commit is contained in:
2022-01-15 22:36:34 +02:00
parent 22d5e39899
commit e44f31f30a
+8 -10
View File
@@ -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))
}