Add support for parsing NOTICE.

FossilOrigin-Name: e7642f3cbb58d7c120ba2282081d99b062d15acfbb2aeadadaa3e77886aa4b60
This commit is contained in:
Jonathan Schleifer 2011-09-10 13:10:59 +00:00
parent 182774ba6c
commit c4da72d924
3 changed files with 68 additions and 2 deletions

View file

@ -56,6 +56,13 @@
- (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

View file

@ -217,7 +217,7 @@
}
/* 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;
@ -306,7 +306,6 @@
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]) {
@ -334,6 +333,51 @@
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];
}