Add support for handling PART and fix parsing of JOIN.

FossilOrigin-Name: 92093d341f66e0a9f0227e44f122b8caca3ced8aff1f50d88b4bb7d4a4a4ba81
This commit is contained in:
Jonathan Schleifer 2011-09-09 16:23:50 +00:00
parent 3180fb3557
commit 8e1e22cbf7
2 changed files with 42 additions and 9 deletions

View file

@ -31,19 +31,23 @@
@protocol IRCConnectionDelegate @protocol IRCConnectionDelegate
@optional @optional
- (void)connection: (IRCConnection*)conn - (void)connection: (IRCConnection*)connection
didReceiveLine: (OFString*)line; didReceiveLine: (OFString*)line;
- (void)connection: (IRCConnection*)conn - (void)connection: (IRCConnection*)connection
didSendLine: (OFString*)line; didSendLine: (OFString*)line;
- (void)connectionWasEstablished: (IRCConnection*)conn; - (void)connectionWasEstablished: (IRCConnection*)connection;
- (void)connection: (IRCConnection*)conn - (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user didSeeUser: (IRCUser*)user
joinChannel: (IRCChannel*)channel; 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 didReceiveMessage: (OFString*)msg
fromUser: (IRCUser*)user fromUser: (IRCUser*)user
inChannel: (IRCChannel*)channel; inChannel: (IRCChannel*)channel;
- (void)connection: (IRCConnection*)conn - (void)connection: (IRCConnection*)connection
didReceivePrivateMessage: (OFString*)msg didReceivePrivateMessage: (OFString*)msg
fromUser: (IRCUser*)user; fromUser: (IRCUser*)user;
@end @end

View file

@ -182,9 +182,6 @@
who = [who substringWithRange: who = [who substringWithRange:
of_range(1, who.length - 1)]; of_range(1, who.length - 1)];
where = [where substringWithRange:
of_range(1, where.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
if ([who hasPrefix: if ([who hasPrefix:
@ -204,6 +201,38 @@
continue; 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 */ /* PRIVMSG */
if (splitted.count >= 4 && if (splitted.count >= 4 &&
[[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) { [[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) {