Add support for parsing NOTICE.
FossilOrigin-Name: e7642f3cbb58d7c120ba2282081d99b062d15acfbb2aeadadaa3e77886aa4b60
This commit is contained in:
parent
182774ba6c
commit
c4da72d924
3 changed files with 68 additions and 2 deletions
|
@ -56,6 +56,13 @@
|
||||||
- (void)connection: (IRCConnection*)connection
|
- (void)connection: (IRCConnection*)connection
|
||||||
didReceivePrivateMessage: (OFString*)msg
|
didReceivePrivateMessage: (OFString*)msg
|
||||||
fromUser: (IRCUser*)user;
|
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
|
@end
|
||||||
|
|
||||||
@interface IRCConnection: OFObject
|
@interface IRCConnection: OFObject
|
||||||
|
|
|
@ -217,7 +217,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PART */
|
/* PART */
|
||||||
if ([action isEqual: @"part"] && split.count >= 3) {
|
if ([action isEqual: @"PART"] && split.count >= 3) {
|
||||||
OFString *who = [split objectAtIndex: 0];
|
OFString *who = [split objectAtIndex: 0];
|
||||||
OFString *where = [split objectAtIndex: 2];
|
OFString *where = [split objectAtIndex: 2];
|
||||||
IRCUser *user;
|
IRCUser *user;
|
||||||
|
@ -306,7 +306,6 @@
|
||||||
of_range(1, from.length - 1)];
|
of_range(1, from.length - 1)];
|
||||||
msg = [line substringWithRange:
|
msg = [line substringWithRange:
|
||||||
of_range(pos + 2, line.length - pos - 2)];
|
of_range(pos + 2, line.length - pos - 2)];
|
||||||
|
|
||||||
user = [IRCUser IRCUserWithString: from];
|
user = [IRCUser IRCUserWithString: from];
|
||||||
|
|
||||||
if (![to isEqual: nickname]) {
|
if (![to isEqual: nickname]) {
|
||||||
|
@ -334,6 +333,51 @@
|
||||||
continue;
|
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];
|
[pool releaseObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
tests/test.m
15
tests/test.m
|
@ -108,4 +108,19 @@ OF_APPLICATION_DELEGATE(TestApp)
|
||||||
{
|
{
|
||||||
of_log(@"(%@): %@", user, msg);
|
of_log(@"(%@): %@", user, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)connection: (IRCConnection*)connection
|
||||||
|
didReceiveNotice: (OFString*)notice
|
||||||
|
fromUser: (IRCUser*)user
|
||||||
|
{
|
||||||
|
of_log(@"NOTICE: (%@): %@", user, notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)connection: (IRCConnection*)connection
|
||||||
|
didReceiveNotice: (OFString*)notice
|
||||||
|
fromUser: (IRCUser*)user
|
||||||
|
inChannel: (IRCChannel*)channel
|
||||||
|
{
|
||||||
|
of_log(@"NOTICE: [%@] %@: %@", channel, user, notice);
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue