diff --git a/src/IRCConnection.h b/src/IRCConnection.h index 7eebd4b..7f44d53 100644 --- a/src/IRCConnection.h +++ b/src/IRCConnection.h @@ -43,6 +43,9 @@ didSeeUser: (IRCUser*)user leaveChannel: (IRCChannel*)channel withReason: (OFString*)reason; +- (void)connection: (IRCConnection*)connection + didSeeUserQuit: (IRCUser*)user + withReason: (OFString*)reason; - (void)connection: (IRCConnection*)connection didReceiveMessage: (OFString*)msg fromUser: (IRCUser*)user diff --git a/src/IRCConnection.m b/src/IRCConnection.m index 801aa6a..34172aa 100644 --- a/src/IRCConnection.m +++ b/src/IRCConnection.m @@ -233,6 +233,33 @@ continue; } + /* QUIT */ + if (splitted.count >= 2 && + [[splitted objectAtIndex: 1] isEqual: @"QUIT"]) { + OFString *who = [splitted objectAtIndex: 0]; + IRCUser *user; + OFString *reason = nil; + size_t pos = who.length + 1 + + [[splitted objectAtIndex: 1] length]; + + who = [who substringWithRange: + of_range(1, who.length - 1)]; + + user = [IRCUser IRCUserWithString: who]; + + if (splitted.count > 2) + reason = [line substringWithRange: + of_range(pos + 2, line.length - pos - 2)]; + + if ([delegate respondsToSelector: + @selector(connection:didSeeUserQuit:withReason:)]) + [delegate connection: self + didSeeUserQuit: user + withReason: reason]; + + continue; + } + /* PRIVMSG */ if (splitted.count >= 4 && [[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) { diff --git a/tests/test.m b/tests/test.m index ff8f327..2e75ad3 100644 --- a/tests/test.m +++ b/tests/test.m @@ -80,6 +80,13 @@ OF_APPLICATION_DELEGATE(TestApp) of_log(@"%@ left %@ (%@).", user, channel, reason); } +- (void)connection: (IRCConnection*)connection + didSeeUserQuit: (IRCUser*)user + withReason: (OFString*)reason +{ + of_log(@"%@ quit (%@).", user, reason); +} + - (void)connection: (IRCConnection*)connection didReceiveMessage: (OFString*)msg fromUser: (IRCUser*)user