Handle nickname changes.

FossilOrigin-Name: 7b1c2b91a430c3744d650d3305e867008bc8173de9ed6fdc208b4d7b1f736da9
This commit is contained in:
Jonathan Schleifer 2011-09-09 21:24:18 +00:00
parent ee29d6e973
commit 182774ba6c
3 changed files with 30 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
didSeeUser: (IRCUser*)user
changeNicknameTo: (OFString*)nickname;
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didSeeUserQuit: (IRCUser*)user didSeeUserQuit: (IRCUser*)user
withReason: (OFString*)reason; withReason: (OFString*)reason;

View file

@ -272,6 +272,26 @@
continue; continue;
} }
/* NICK */
if ([action isEqual: @"NICK"] && split.count == 3) {
OFString *who = [split objectAtIndex: 0];
OFString *newNickname = [split objectAtIndex: 2];
IRCUser *user;
who = [who substringWithRange:
of_range(1, who.length - 1)];
newNickname = [newNickname substringWithRange:
of_range(1, newNickname.length - 1)];
user = [IRCUser IRCUserWithString: who];
if ([delegate respondsToSelector:
@selector(connection:didSeeUser:changeNicknameTo:)])
[delegate connection: self
didSeeUser: user
changeNicknameTo: newNickname];
}
/* PRIVMSG */ /* PRIVMSG */
if ([action isEqual: @"PRIVMSG"] && split.count >= 4) { if ([action isEqual: @"PRIVMSG"] && split.count >= 4) {
OFString *from = [split objectAtIndex: 0]; OFString *from = [split objectAtIndex: 0];

View file

@ -87,6 +87,13 @@ OF_APPLICATION_DELEGATE(TestApp)
of_log(@"%@ quit (%@).", user, reason); of_log(@"%@ quit (%@).", user, reason);
} }
- (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user
changeNicknameTo: (OFString *)nickname
{
of_log(@"%@ changed nick to %@.", user, nickname);
}
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceiveMessage: (OFString*)msg didReceiveMessage: (OFString*)msg
fromUser: (IRCUser*)user fromUser: (IRCUser*)user