diff --git a/irc/channel.go b/irc/channel.go index 29a0d1a7..54d9d286 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -53,14 +53,26 @@ func (channel *Channel) Destroy() { } close(channel.replies) + channel.replies = nil close(channel.commands) + channel.commands = nil channel.server.channels.Remove(channel) channel.destroyed = true } +func (channel *Channel) Command(command ChannelCommand) { + if channel.commands == nil { + return + } + channel.commands <- command +} + func (channel *Channel) Reply(replies ...Reply) { + if channel.replies == nil { + return + } for _, reply := range replies { channel.replies <- reply } diff --git a/irc/client.go b/irc/client.go index 56b14c22..f41bf27d 100644 --- a/irc/client.go +++ b/irc/client.go @@ -161,6 +161,7 @@ func (client *Client) Destroy() { client.conn.Close() close(client.replies) + client.replies = nil if client.idleTimer != nil { client.idleTimer.Stop() @@ -177,6 +178,9 @@ func (client *Client) Destroy() { } func (client *Client) Reply(replies ...Reply) { + if client.replies == nil { + return + } for _, reply := range replies { client.replies <- reply } diff --git a/irc/server.go b/irc/server.go index 7b6b073c..5cb8fd37 100644 --- a/irc/server.go +++ b/irc/server.go @@ -292,7 +292,7 @@ func (m *JoinCommand) HandleServer(s *Server) { cmd := &PartCommand{} cmd.SetClient(c) for channel := range c.channels { - channel.commands <- cmd + channel.Command(cmd) } return }