remove support for online-renaming yourself
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
f0cbe04d88
commit
f8a06775f5
34
client.go
34
client.go
@ -8,40 +8,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Client) setNick(nick string) {
|
||||
//Set up new nick
|
||||
oldNick := c.nick
|
||||
oldKey := c.key
|
||||
c.nick = nick
|
||||
c.key = strings.ToLower(c.nick)
|
||||
|
||||
delete(c.server.clientMap, oldKey)
|
||||
c.server.clientMap[c.key] = c
|
||||
|
||||
//Update the relevant channels and notify everyone who can see us about our
|
||||
//nick change
|
||||
c.reply(rplNickChange, oldNick, c.nick)
|
||||
visited := make(map[*Client]struct{}, 100)
|
||||
for _, channel := range c.channelMap {
|
||||
delete(channel.clientMap, oldKey)
|
||||
|
||||
for _, client := range channel.clientMap {
|
||||
if _, skip := visited[client]; skip {
|
||||
continue
|
||||
}
|
||||
client.reply(rplNickChange, oldNick, c.nick)
|
||||
visited[client] = struct{}{}
|
||||
}
|
||||
|
||||
//Insert the new nick after iterating through channel.clientMap to avoid
|
||||
//sending a duplicate message to ourselves
|
||||
channel.clientMap[c.key] = c
|
||||
|
||||
channel.modeMap[c.key] = channel.modeMap[oldKey]
|
||||
delete(channel.modeMap, oldKey)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) joinChannel(channelName string) {
|
||||
newChannel := false
|
||||
|
||||
|
27
server.go
27
server.go
@ -94,31 +94,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
||||
case "VERSION":
|
||||
client.reply(rplVersion, VERSION)
|
||||
case "NICK":
|
||||
if len(args) < 1 {
|
||||
client.reply(errNoNick)
|
||||
return
|
||||
}
|
||||
|
||||
newNick := args[0]
|
||||
|
||||
//Check newNick is of valid formatting (regex)
|
||||
if nickRegexp.MatchString(newNick) == false {
|
||||
client.reply(errInvalidNick, newNick)
|
||||
return
|
||||
}
|
||||
|
||||
if _, exists := s.clientMap[strings.ToLower(newNick)]; exists {
|
||||
client.reply(errNickInUse, newNick)
|
||||
return
|
||||
}
|
||||
|
||||
//Protect the server name from being used
|
||||
if strings.ToLower(newNick) == strings.ToLower(s.name) {
|
||||
client.reply(errNickInUse, newNick)
|
||||
return
|
||||
}
|
||||
|
||||
client.setNick(newNick)
|
||||
client.reply(rplKill, "Can't change nicks on this server", "")
|
||||
client.disconnect()
|
||||
|
||||
case "USER":
|
||||
if client.nick == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user