[_idleSuffix release];
_idleSuffix = idleSuffix;
[[NSUserDefaults standardUserDefaults] setObject:idleSuffix forKey:kBetterAwayIdleSuffix];
+
+ for (IRCClient* client in _world.clients) {
+ NSMutableString* nick = [NSMutableString stringWithString:client.localNickname];
+ NSString* suffix = [@"|" stringByAppendingString:[self idleSuffix]];
+ [nick replaceOccurrencesOfString:suffix withString:@"" options:0 range:NSMakeRange(0, [nick length])];
+ [client changeNick:nick];
+ }
}
#pragma mark -- NSWorkspace Notifications --
- (void)onDisplaySleep:(id)sender
{
- for (IRCClient* client in _world.clients)
- [client changeNick:[NSString stringWithFormat:@"%@|%@", client.config.nick, [self idleSuffix]]];
+ for (IRCClient* client in _world.clients) {
+ NSMutableString* nick = [NSMutableString stringWithString:client.localNickname];
+ NSString* suffix = [@"|" stringByAppendingString:[self idleSuffix]];
+ [nick replaceOccurrencesOfString:suffix withString:@"" options:0 range:NSMakeRange(0, [nick length])];
+ [nick appendString:suffix];
+ [client printDebugInformation:[@"BetterAway setting nickname to " stringByAppendingString:nick]];
+ [client changeNick:nick];
+ }
}
- (void)onDisplayWake:(id)sender
{
- for (IRCClient* client in _world.clients)
- [client changeNick:client.config.nick];
+ for (IRCClient* client in _world.clients) {
+ NSMutableString* nick = [NSMutableString stringWithString:client.localNickname];
+ NSString* suffix = [@"|" stringByAppendingString:[self idleSuffix]];
+ [nick replaceOccurrencesOfString:suffix withString:@"" options:0 range:NSMakeRange(0, [nick length])];
+ [client printDebugInformation:[@"BetterAway setting nickname to " stringByAppendingString:nick]];
+ [client changeNick:nick];
+ }
}
#pragma mark -- Plugin API --
message:(NSString *)messageString
command:(NSString *)commandString
{
- if ([[commandString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualTo:kBetterAwayIdleCommand]) {
+ if ([[commandString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] compare:kBetterAwayIdleCommand options:NSCaseInsensitiveSearch] == NSOrderedSame) {
NSString* idleSuffix = [messageString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (![idleSuffix length])
- [client printBoth:client.world.selectedChannel type:TVCLogLineSystemType text:[@"Idle suffix is currently " stringByAppendingString:[self idleSuffix]]];
+ [client printDebugInformation:[@"Idle suffix is currently " stringByAppendingString:[self idleSuffix]]];
else {
[self setIdleSuffix:idleSuffix];
- [client printBoth:client.world.selectedChannel type:TVCLogLineSystemType text:[@"Set idle suffix to " stringByAppendingString:idleSuffix]];
+ [client printDebugInformation:[@"Set idle suffix to " stringByAppendingString:idleSuffix]];
}
}
}