diff --git a/client.go b/client.go index 62d4fcd..99b5740 100644 --- a/client.go +++ b/client.go @@ -76,32 +76,6 @@ func (c *Client) joinChannel(channelName string) { c.reply(rplEndOfNames, channelName) } -func (c *Client) partChannel(channelName, reason string) { - channelKey := strings.ToLower(channelName) - channel, exists := c.server.channelMap[channelKey] - if exists == false { - return - } - - if _, inChannel := channel.clientMap[c.key]; inChannel == false { - //Client isn't in this channel, do nothing - return - } - - //Notify clients of the part - for _, client := range channel.clientMap { - client.reply(rplPart, c.nick, channel.name, reason) - } - - delete(c.channelMap, channelKey) - delete(channel.modeMap, c.key) - delete(channel.clientMap, c.key) - - if len(channel.clientMap) == 0 { - delete(c.server.channelMap, channelKey) - } -} - func (c *Client) disconnect() { c.connected = false c.signalChan <- signalStop @@ -192,13 +166,9 @@ func (c *Client) clientThread() { go c.writeThread(writeSignalChan, writeChan) defer func() { - //Part from all channels - for channelName := range c.channelMap { - c.partChannel(channelName, "Disconnecting") - } + // Implicit part from all channels delete(c.server.clientMap, c.key) - c.connection.Close() }() diff --git a/server.go b/server.go index 26eece6..55cbc93 100644 --- a/server.go +++ b/server.go @@ -121,10 +121,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { } if args[0] == "0" { - //Quit all channels - for channel := range client.channelMap { - client.partChannel(channel, "Disconnecting") - } + // Intend to quit all channels + // But we don't allow that return } @@ -142,20 +140,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { return } - if len(args) < 1 { - client.reply(errMoreArgs) - return - } - - reason := strings.Join(args[1:], " ") - - channels := strings.Split(args[0], ",") - for _, channel := range channels { - //Part the channel if it's valid - if channelRegexp.MatchString(channel) { - client.partChannel(channel, reason) - } - } + // you can check out any time you like, but you can never leave + // we'll need to transmit client.reply(rplPart, c.nick, channel.name, reason) messages on behalf of other nmdc users, though case "PRIVMSG": if client.registered == false {