Make more use of the Client.key struct field

This commit is contained in:
ed 2016-03-07 13:50:52 -05:00 committed by Harry Jeffery
parent e580513fa5
commit 74dd329440
2 changed files with 9 additions and 9 deletions

View File

@ -106,7 +106,7 @@ func (c *Client) partChannel(channelName, reason string) {
return return
} }
if _, inChannel := channel.clientMap[strings.ToLower(c.nick)]; inChannel == false { if _, inChannel := channel.clientMap[c.key]; inChannel == false {
//Client isn't in this channel, do nothing //Client isn't in this channel, do nothing
return return
} }
@ -117,8 +117,8 @@ func (c *Client) partChannel(channelName, reason string) {
} }
delete(c.channelMap, channelKey) delete(c.channelMap, channelKey)
delete(channel.modeMap, strings.ToLower(c.nick)) delete(channel.modeMap, c.key)
delete(channel.clientMap, strings.ToLower(c.nick)) delete(channel.clientMap, c.key)
if len(channel.clientMap) == 0 { if len(channel.clientMap) == 0 {
delete(c.server.channelMap, channelKey) delete(c.server.channelMap, channelKey)
@ -227,7 +227,7 @@ func (c *Client) clientThread() {
c.partChannel(channelName, "Disconnecting") c.partChannel(channelName, "Disconnecting")
} }
delete(c.server.clientMap, strings.ToLower(c.nick)) delete(c.server.clientMap, c.key)
c.connection.Close() c.connection.Close()
}() }()

View File

@ -184,14 +184,14 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
if chanExists { if chanExists {
if channel.mode.noExternal { if channel.mode.noExternal {
if _, inChannel := channel.clientMap[strings.ToLower(client.nick)]; !inChannel { if _, inChannel := channel.clientMap[client.key]; !inChannel {
//Not in channel, not allowed to send //Not in channel, not allowed to send
client.reply(errCannotSend, args[0]) client.reply(errCannotSend, args[0])
return return
} }
} }
if channel.mode.moderated { if channel.mode.moderated {
clientMode := channel.modeMap[strings.ToLower(client.nick)] clientMode := channel.modeMap[client.key]
if !clientMode.operator && !clientMode.voice { if !clientMode.operator && !clientMode.voice {
//It's moderated and we're not +v or +o, do nothing //It's moderated and we're not +v or +o, do nothing
client.reply(errCannotSend, args[0]) client.reply(errCannotSend, args[0])
@ -239,7 +239,7 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
return return
} }
clientMode := channel.modeMap[strings.ToLower(client.nick)] clientMode := channel.modeMap[client.key]
if channel.mode.topicLocked && !clientMode.operator { if channel.mode.topicLocked && !clientMode.operator {
client.reply(errNoPriv) client.reply(errNoPriv)
return return
@ -271,7 +271,7 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
for channelName, channel := range s.channelMap { for channelName, channel := range s.channelMap {
if channel.mode.secret { if channel.mode.secret {
if _, inChannel := channel.clientMap[strings.ToLower(client.nick)]; !inChannel { if _, inChannel := channel.clientMap[client.key]; !inChannel {
//Not in the channel, skip //Not in the channel, skip
continue continue
} }
@ -419,7 +419,7 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
return return
} }
if cm, ok := channel.modeMap[strings.ToLower(client.nick)]; !ok || !cm.operator { if cm, ok := channel.modeMap[client.key]; !ok || !cm.operator {
//Not a channel operator. //Not a channel operator.
//If they're not an irc operator either, they'll fail //If they're not an irc operator either, they'll fail