Check for redundant join/parts

This commit is contained in:
Harry Jeffery 2013-08-27 13:44:42 +01:00
parent 6a102e8587
commit ebaddea859

View File

@ -61,7 +61,14 @@ func (c *Client) joinChannel(channelName string) {
c.server.channelMap[channelKey] = channel c.server.channelMap[channelKey] = channel
} }
channel.clientMap[strings.ToLower(c.nick)] = c nickKey := strings.ToLower(c.nick)
if _, inChannel := channel.clientMap[nickKey]; inChannel {
//Client is already in the channel, do nothing
return
}
channel.clientMap[nickKey] = c
c.channelMap[channelKey] = channel c.channelMap[channelKey] = channel
for _, client := range channel.clientMap { for _, client := range channel.clientMap {
@ -89,6 +96,11 @@ func (c *Client) partChannel(channelName string) {
return return
} }
if _, inChannel := channel.clientMap[strings.ToLower(c.nick)]; inChannel == false {
//Client isn't in this channel, do nothing
return
}
//Notify clients of the part //Notify clients of the part
for _, client := range channel.clientMap { for _, client := range channel.clientMap {
client.reply(rplPart, c.nick, channelName) client.reply(rplPart, c.nick, channelName)