Add support for handling QUIT.

FossilOrigin-Name: 4e9e1552b600a04f8d4d11ce63a30b6ab1a289091dcf5bc410a0d8add4b543c1
This commit is contained in:
Jonathan Schleifer 2011-09-09 16:46:04 +00:00
parent 393e3f78e8
commit 8bef7c2e26
3 changed files with 37 additions and 0 deletions

View file

@ -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

View file

@ -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"]) {