fix colon in mirc when renaming self
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
fb34cefc46
commit
7592bf6002
15
server.go
15
server.go
@ -335,11 +335,17 @@ func (s *Server) handleCommand(command string, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mIRC puts a colon in first place when changing nick, hexchat doesn't
|
||||||
|
suppliedNick := args[0]
|
||||||
|
if len(suppliedNick) >= 2 && suppliedNick[0] == ':' {
|
||||||
|
suppliedNick = suppliedNick[1:]
|
||||||
|
}
|
||||||
|
|
||||||
if s.clientNick() == "" {
|
if s.clientNick() == "" {
|
||||||
// allow set, as part of the login phase
|
// allow set, as part of the login phase
|
||||||
s.upstreamLauncher.Self.Nick = args[0]
|
s.upstreamLauncher.Self.Nick = suppliedNick
|
||||||
|
|
||||||
} else if args[0] == s.clientNick() {
|
} else if suppliedNick == s.clientNick() {
|
||||||
// Ignore
|
// Ignore
|
||||||
// Required for compatibility with Lite IRC, which sends USER/NICK in the wrong order
|
// Required for compatibility with Lite IRC, which sends USER/NICK in the wrong order
|
||||||
|
|
||||||
@ -349,9 +355,12 @@ func (s *Server) handleCommand(command string, args []string) {
|
|||||||
defer s.ClientStateLock.Unlock()
|
defer s.ClientStateLock.Unlock()
|
||||||
if s.upstream == nil {
|
if s.upstream == nil {
|
||||||
// Not yet connected, should be safe to change nick
|
// Not yet connected, should be safe to change nick
|
||||||
s.upstreamLauncher.Self.Nick = args[0]
|
s.upstreamLauncher.Self.Nick = suppliedNick
|
||||||
} else {
|
} else {
|
||||||
// Need to disconnect/reconnect the upstream
|
// Need to disconnect/reconnect the upstream
|
||||||
|
s.writeClient(fmt.Sprintf(":%s!%s@%s NICK %s", s.clientNick(), s.clientNick(), s.clientNick(), suppliedNick)) // notify client about what they've done
|
||||||
|
s.upstreamLauncher.Self.Nick = suppliedNick
|
||||||
|
|
||||||
s.nickChangeAttempt++
|
s.nickChangeAttempt++
|
||||||
s.upstream.Disconnect()
|
s.upstream.Disconnect()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user