summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2012-11-17 21:16:27 +0000
committerDominik Picheta <dominikpicheta@googlemail.com>2012-11-17 21:16:27 +0000
commit1047c4414cf247dd0499aaef3813d2f28048e731 (patch)
tree58c9b00fc1753e18fff858be523f511cc92eb09b
parent7f6633a06feeac8d6bd1eb1e6d8e841591326618 (diff)
downloadNim-1047c4414cf247dd0499aaef3813d2f28048e731.tar.gz
Fixed a bug relating to changing nicknames and message origin in the IRC module.
-rw-r--r--lib/pure/irc.nim13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/pure/irc.nim b/lib/pure/irc.nim
index 921c6b09c..c546b25db 100644
--- a/lib/pure/irc.nim
+++ b/lib/pure/irc.nim
@@ -255,9 +255,16 @@ proc processLine(irc: var TIRC, line: string): TIRCEvent =
       irc.lastPong = epochTime()
     if result.cmd == MNumeric:
       if result.numeric == "001":
+        # Check the nickname.
+        if irc.nick != result.params[0]:
+          assert ' ' notin result.params[0]
+          irc.nick = result.params[0]
         for chan in items(irc.channelsToJoin):
           irc.join(chan)
-
+    if result.cmd == MNick:
+      if result.nick == irc.nick:
+        irc.nick = result.params[0]
+    
 proc processOther(irc: var TIRC, ev: var TIRCEvent): bool =
   result = false
   if epochTime() - irc.lastPing >= 20.0:
@@ -313,6 +320,10 @@ proc isConnected*(irc: var TIRC): bool =
   ## Returns whether this IRC client is connected to an IRC server.
   return irc.status == SockConnected
 
+proc getNick*(irc: var TIRC): string =
+  ## Returns the current nickname of the client.
+  return irc.nick
+
 # -- Asyncio dispatcher
 
 proc connect*(irc: PAsyncIRC) =