From 7592bf6002b41fac690a401374e19c1440189344 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Tue, 10 May 2016 19:08:26 +1200 Subject: [PATCH] fix colon in mirc when renaming self --HG-- branch : nmdc-ircfrontend --- server.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 508c496..e3383a0 100644 --- a/server.go +++ b/server.go @@ -335,11 +335,17 @@ func (s *Server) handleCommand(command string, args []string) { 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() == "" { // 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 // 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() if s.upstream == nil { // Not yet connected, should be safe to change nick - s.upstreamLauncher.Self.Nick = args[0] + s.upstreamLauncher.Self.Nick = suppliedNick } else { // 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.upstream.Disconnect() }