remove support for user deciding to leave a channel

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
. 2016-05-02 19:07:58 +12:00
parent 42b211dc5e
commit 10e9aa473d
2 changed files with 5 additions and 49 deletions

View File

@ -76,32 +76,6 @@ func (c *Client) joinChannel(channelName string) {
c.reply(rplEndOfNames, channelName) 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() { func (c *Client) disconnect() {
c.connected = false c.connected = false
c.signalChan <- signalStop c.signalChan <- signalStop
@ -192,13 +166,9 @@ func (c *Client) clientThread() {
go c.writeThread(writeSignalChan, writeChan) go c.writeThread(writeSignalChan, writeChan)
defer func() { defer func() {
//Part from all channels // Implicit part from all channels
for channelName := range c.channelMap {
c.partChannel(channelName, "Disconnecting")
}
delete(c.server.clientMap, c.key) delete(c.server.clientMap, c.key)
c.connection.Close() c.connection.Close()
}() }()

View File

@ -121,10 +121,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
} }
if args[0] == "0" { if args[0] == "0" {
//Quit all channels // Intend to quit all channels
for channel := range client.channelMap { // But we don't allow that
client.partChannel(channel, "Disconnecting")
}
return return
} }
@ -142,20 +140,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
return return
} }
if len(args) < 1 { // you can check out any time you like, but you can never leave
client.reply(errMoreArgs) // we'll need to transmit client.reply(rplPart, c.nick, channel.name, reason) messages on behalf of other nmdc users, though
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)
}
}
case "PRIVMSG": case "PRIVMSG":
if client.registered == false { if client.registered == false {