Merge pull request #8 from edjsu/use-key

Use Client.key for channel clientMap and modeMap lookups and insertions
This commit is contained in:
Harry Jeffery 2016-03-19 15:00:57 +00:00
commit c5165c37e6

View File

@ -60,7 +60,7 @@ func (c *Client) joinChannel(channelName string) {
newChannel = true newChannel = true
} }
if _, inChannel := channel.clientMap[c.nick]; inChannel { if _, inChannel := channel.clientMap[c.key]; inChannel {
//Client is already in the channel, do nothing //Client is already in the channel, do nothing
return return
} }
@ -71,8 +71,8 @@ func (c *Client) joinChannel(channelName string) {
mode.operator = true mode.operator = true
} }
channel.clientMap[c.nick] = c channel.clientMap[c.key] = c
channel.modeMap[c.nick] = mode channel.modeMap[c.key] = mode
c.channelMap[channelKey] = channel c.channelMap[channelKey] = channel
for _, client := range channel.clientMap { for _, client := range channel.clientMap {
@ -91,7 +91,7 @@ func (c *Client) joinChannel(channelName string) {
for _, client := range channel.clientMap { for _, client := range channel.clientMap {
prefix := "" prefix := ""
if mode, exists := channel.modeMap[client.nick]; exists { if mode, exists := channel.modeMap[client.key]; exists {
prefix = mode.Prefix() prefix = mode.Prefix()
} }