Index: src/IRCConnection.h ================================================================== --- src/IRCConnection.h +++ src/IRCConnection.h @@ -29,23 +29,27 @@ @class IRCUser; @class IRCChannel; @protocol IRCConnectionDelegate @optional -- (void)connection: (IRCConnection*)conn +- (void)connection: (IRCConnection*)connection didReceiveLine: (OFString*)line; -- (void)connection: (IRCConnection*)conn +- (void)connection: (IRCConnection*)connection didSendLine: (OFString*)line; -- (void)connectionWasEstablished: (IRCConnection*)conn; -- (void)connection: (IRCConnection*)conn +- (void)connectionWasEstablished: (IRCConnection*)connection; +- (void)connection: (IRCConnection*)connection didSeeUser: (IRCUser*)user joinChannel: (IRCChannel*)channel; -- (void)connection: (IRCConnection*)conn +- (void)connection: (IRCConnection*)connection + didSeeUser: (IRCUser*)user + leaveChannel: (IRCChannel*)channel + withReason: (OFString*)reason; +- (void)connection: (IRCConnection*)connection didReceiveMessage: (OFString*)msg fromUser: (IRCUser*)user inChannel: (IRCChannel*)channel; -- (void)connection: (IRCConnection*)conn +- (void)connection: (IRCConnection*)connection didReceivePrivateMessage: (OFString*)msg fromUser: (IRCUser*)user; @end @interface IRCConnection: OFObject Index: src/IRCConnection.m ================================================================== --- src/IRCConnection.m +++ src/IRCConnection.m @@ -180,13 +180,10 @@ IRCUser *user; IRCChannel *channel; who = [who substringWithRange: of_range(1, who.length - 1)]; - where = [where substringWithRange: - of_range(1, where.length - 1)]; - user = [IRCUser IRCUserWithString: who]; if ([who hasPrefix: [nickname stringByAppendingString: @"!"]]) { channel = [IRCChannel channelWithName: where]; @@ -199,10 +196,42 @@ @selector(connection:didSeeUser:joinChannel:)]) [delegate connection: self didSeeUser: user joinChannel: channel]; + continue; + } + + /* PART */ + if (splitted.count >= 3 && + [[splitted objectAtIndex: 1] isEqual: @"PART"]) { + OFString *who = [splitted objectAtIndex: 0]; + OFString *where = [splitted objectAtIndex: 2]; + IRCUser *user; + IRCChannel *channel; + OFString *reason = nil; + size_t pos = who.length + 1 + + [[splitted objectAtIndex: 1] length] + 1 + + where.length; + + who = [who substringWithRange: + of_range(1, who.length - 1)]; + user = [IRCUser IRCUserWithString: who]; + channel = [channels objectForKey: where]; + + if (splitted.count > 3) + reason = [line substringWithRange: + of_range(pos + 2, line.length - pos - 2)]; + + if ([delegate respondsToSelector: + @selector(connection:didSeeUser:leaveChannel: + withReason:)]) + [delegate connection: self + didSeeUser: user + leaveChannel: channel + withReason: reason]; + continue; } /* PRIVMSG */ if (splitted.count >= 4 &&