From 1047c4414cf247dd0499aaef3813d2f28048e731 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 17 Nov 2012 21:16:27 +0000 Subject: Fixed a bug relating to changing nicknames and message origin in the IRC module. --- lib/pure/irc.nim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) = -- cgit 1.4.1-2-gfad0