remove support for user deciding to leave a channel
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
42b211dc5e
commit
10e9aa473d
32
client.go
32
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()
|
||||
}()
|
||||
|
||||
|
22
server.go
22
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user