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 didSeeUser: (IRCUser*)user
leaveChannel: (IRCChannel*)channel leaveChannel: (IRCChannel*)channel
withReason: (OFString*)reason; withReason: (OFString*)reason;
- (void)connection: (IRCConnection*)connection
didSeeUserQuit: (IRCUser*)user
withReason: (OFString*)reason;
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceiveMessage: (OFString*)msg didReceiveMessage: (OFString*)msg
fromUser: (IRCUser*)user fromUser: (IRCUser*)user

View file

@ -233,6 +233,33 @@
continue; 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 */ /* PRIVMSG */
if (splitted.count >= 4 && if (splitted.count >= 4 &&
[[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) { [[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) {

View file

@ -80,6 +80,13 @@ OF_APPLICATION_DELEGATE(TestApp)
of_log(@"%@ left %@ (%@).", user, channel, reason); of_log(@"%@ left %@ (%@).", user, channel, reason);
} }
- (void)connection: (IRCConnection*)connection
didSeeUserQuit: (IRCUser*)user
withReason: (OFString*)reason
{
of_log(@"%@ quit (%@).", user, reason);
}
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceiveMessage: (OFString*)msg didReceiveMessage: (OFString*)msg
fromUser: (IRCUser*)user fromUser: (IRCUser*)user