Index: src/IRCConnection.h ================================================================== --- src/IRCConnection.h +++ src/IRCConnection.h @@ -54,10 +54,17 @@ fromUser: (IRCUser*)user inChannel: (IRCChannel*)channel; - (void)connection: (IRCConnection*)connection didReceivePrivateMessage: (OFString*)msg fromUser: (IRCUser*)user; +- (void)connection: (IRCConnection*)connection + didReceiveNotice: (OFString*)notice + fromUser: (IRCUser*)user; +- (void)connection: (IRCConnection*)connection + didReceiveNotice: (OFString*)notice + fromUser: (IRCUser*)user + inChannel: (IRCChannel*)channel; @end @interface IRCConnection: OFObject { OFTCPSocket *sock; Index: src/IRCConnection.m ================================================================== --- src/IRCConnection.m +++ src/IRCConnection.m @@ -215,11 +215,11 @@ continue; } /* PART */ - if ([action isEqual: @"part"] && split.count >= 3) { + if ([action isEqual: @"PART"] && split.count >= 3) { OFString *who = [split objectAtIndex: 0]; OFString *where = [split objectAtIndex: 2]; IRCUser *user; IRCChannel *channel; OFString *reason = nil; @@ -304,11 +304,10 @@ from = [from substringWithRange: of_range(1, from.length - 1)]; msg = [line substringWithRange: of_range(pos + 2, line.length - pos - 2)]; - user = [IRCUser IRCUserWithString: from]; if (![to isEqual: nickname]) { IRCChannel *channel; @@ -328,10 +327,55 @@ [delegate connection: self didReceivePrivateMessage: msg fromUser: user]; } + + continue; + } + + /* NOTICE */ + if ([action isEqual: @"NOTICE"] && split.count >= 4) { + OFString *from = [split objectAtIndex: 0]; + OFString *to = [split objectAtIndex: 2]; + IRCUser *user = nil; + OFString *notice; + size_t pos = from.length + 1 + + [[split objectAtIndex: 1] length] + 1 + + to.length; + + from = [from substringWithRange: + of_range(1, from.length - 1)]; + notice = [line substringWithRange: + of_range(pos + 2, line.length - pos - 2)]; + + if (![from containsString: @"!"] || [to isEqual: @"*"]) + /* System message - ignore for now */ + continue; + + user = [IRCUser IRCUserWithString: from]; + + if (![to isEqual: nickname]) { + IRCChannel *channel; + + channel = [channels objectForKey: to]; + + if ([delegate respondsToSelector: + @selector(connection:didReceiveNotice: + fromUser:inChannel:)]) + [delegate connection: self + didReceiveNotice: notice + fromUser: user + inChannel: channel]; + } else { + if ([delegate respondsToSelector: + @selector(connection:didReceiveNotice: + fromUser:)]) + [delegate connection: self + didReceiveNotice: notice + fromUser: user]; + } continue; } [pool releaseObjects]; Index: tests/test.m ================================================================== --- tests/test.m +++ tests/test.m @@ -106,6 +106,21 @@ didReceivePrivateMessage: (OFString*)msg fromUser: (IRCUser*)user { of_log(@"(%@): %@", user, msg); } + +- (void)connection: (IRCConnection*)connection + didReceiveNotice: (OFString*)notice + fromUser: (IRCUser*)user +{ + of_log(@"NOTICE: (%@): %@", user, notice); +} + +- (void)connection: (IRCConnection*)connection + didReceiveNotice: (OFString*)notice + fromUser: (IRCUser*)user + inChannel: (IRCChannel*)channel +{ + of_log(@"NOTICE: [%@] %@: %@", channel, user, notice); +} @end