Guest User

Untitled

a guest
Jun 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. Index: Chat Core/MVIRCChatConnection.h
  2. ===================================================================
  3. --- Chat Core/MVIRCChatConnection.h (revision 4401)
  4. +++ Chat Core/MVIRCChatConnection.h (working copy)
  5. @@ -32,6 +32,9 @@
  6. BOOL _watchCommandSupported;
  7. BOOL _sendQueueProcessing;
  8. BOOL _pendingIdentificationAttempt;
  9. + NSString *_failedNickname;
  10. + NSInteger _failedNicknameCount;
  11. + BOOL _nicknameShortened;
  12. }
  13. + (NSArray *) defaultServerPorts;
  14. @end
  15. Index: Chat Core/MVIRCChatConnection.m
  16. ===================================================================
  17. --- Chat Core/MVIRCChatConnection.m (revision 4401)
  18. +++ Chat Core/MVIRCChatConnection.m (working copy)
  19. @@ -623,6 +623,10 @@
  20. if( ! [_chatConnection connectToHost:server onPort:serverPort error:NULL] )
  21. [self performSelectorOnMainThread:@selector( _didNotConnect ) withObject:nil waitUntilDone:NO];
  22. else [self _resetSendQueueInterval];
  23. +
  24. + _failedNickname = nil;
  25. + _failedNicknameCount = 0;
  26. + _nicknameShortened = NO;
  27. }
  28.  
  29. - (oneway void) _ircRunloop {
  30. @@ -673,6 +677,10 @@
  31. [self scheduleReconnectAttempt];
  32. }
  33.  
  34. + [_failedNickname release];
  35. + _failedNicknameCount = 0;
  36. + _nicknameShortened = NO;
  37. +
  38. [super _didDisconnect];
  39. }
  40.  
  41. @@ -2120,10 +2128,20 @@
  42. NSString *nick = [self nextAlternateNickname];
  43. if( ! [nick length] && [parameters count] >= 2 ) {
  44. NSString *lastNickTried = [self _stringFromPossibleData:[parameters objectAtIndex:1]];
  45. - nick = [lastNickTried stringByAppendingString:@"_"];
  46. +
  47. + if( ( _failedNickname && [_failedNickname isCaseInsensitiveEqualToString:lastNickTried] ) || _nicknameShortened) {
  48. + nick = [[lastNickTried substringToIndex:([lastNickTried length] - 2)] stringByAppendingString:[NSString stringWithFormat:@"_%d", _failedNicknameCount]];
  49. +
  50. + _nicknameShortened = YES;
  51. + } else nick = [lastNickTried stringByAppendingString:@"_"];
  52. }
  53. +
  54. + if ( ! _failedNickname ) _failedNickname = [[self _stringFromPossibleData:[parameters objectAtIndex:1]] copy];
  55.  
  56. if( [nick length] ) [self setNickname:nick];
  57. +
  58. + if ( _failedNicknameCount < 9 ) _failedNicknameCount++;
  59. + else _failedNicknameCount = 0;
  60. } else {
  61. // "<current nickname> <new nickname> :Cannot change nick"
  62. // - Sent to a user who is changing their nickname to a nickname someone else is actively using.
Add Comment
Please, Sign In to add comment