#NEWLINE# @ internationalizeDocstring #NEWLINE# def nickometer( self , irc , msg , args , nick ) : #NEWLINE# #INDENT# '[<nick>]\n\n        Tells you how lame said nick is.  If <nick> is not given, uses the\n        nick of the person giving the command.\n        ' #NEWLINE# score = minisix . L ( 0 ) #NEWLINE# if ( not nick ) : #NEWLINE# #INDENT# nick = msg . nick #NEWLINE# #UNINDENT# originalNick = nick #NEWLINE# if ( not nick ) : #NEWLINE# #INDENT# irc . error ( 'Give me a nick to judge as the argument, please.' ) #NEWLINE# return #NEWLINE# #UNINDENT# specialCost = [ ( '69' , 500 ) , ( 'dea?th' , 500 ) , ( 'dark' , 400 ) , ( 'n[i1]ght' , 300 ) , ( 'n[i1]te' , 500 ) , ( 'fuck' , 500 ) , ( 'sh[i1]t' , 500 ) , ( 'coo[l1]' , 500 ) , ( 'kew[l1]' , 500 ) , ( 'lame' , 500 ) , ( 'dood' , 500 ) , ( 'dude' , 500 ) , ( '[l1](oo?|u)[sz]er' , 500 ) , ( '[l1]eet' , 500 ) , ( 'e[l1]ite' , 500 ) , ( '[l1]ord' , 500 ) , ( 'pron' , 1000 ) , ( 'warez' , 1000 ) , ( 'xx' , 100 ) , ( '\\[rkx]0' , 1000 ) , ( '\\0[rkx]' , 1000 ) ] #NEWLINE# letterNumberTranslator = utils . str . MultipleReplacer ( dict ( list ( zip ( '023457+8' , 'ozeasttb' ) ) ) ) #NEWLINE# for special in specialCost : #NEWLINE# #INDENT# tempNick = nickOriginalCase #NEWLINE# if ( special [ 0 ] [ 0 ] != '\\' ) : #NEWLINE# #INDENT# tempNick = letterNumberTranslator ( tempNick ) #NEWLINE# #UNINDENT# if ( tempNick and re . search ( special [ 0 ] , tempNick , re . IGNORECASE ) ) : #NEWLINE# #INDENT# score += self . punish ( special [ 1 ] , ( 'matched special case /%s/' % special [ 0 ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# nick = re . sub ( '^\\\\([A-Za-z])' , '\x01' , nick ) #NEWLINE# nick = re . sub ( '^C--$' , 'C' , nick ) #NEWLINE# matches = re . findall ( '[^\\w\\d]{2,}' , nick ) #NEWLINE# for match in matches : #NEWLINE# #INDENT# score += self . punish ( slowPow ( 10 , len ( match ) ) , ( '%s consecutive non-alphas ' % len ( match ) ) ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# nickInitial = nick #NEWLINE# nick = re . sub ( '^([^()]*)(\\()(.*)(\\))([^()]*)$' , '\x01\x03\x05' , nick , 1 ) #NEWLINE# nick = re . sub ( '^([^{}]*)(\\{)(.*)(\\})([^{}]*)$' , '\x01\x03\x05' , nick , 1 ) #NEWLINE# nick = re . sub ( '^([^[\\]]*)(\\[)(.*)(\\])([^[\\]]*)$' , '\x01\x03\x05' , nick , 1 ) #NEWLINE# if ( nick == nickInitial ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# self . log . debug ( 'Removed some matching brackets %r => %r' , nickInitial , nick ) #NEWLINE# #UNINDENT# unmatched = re . findall ( '[][(){}]' , nick ) #NEWLINE# if ( len ( unmatched ) > 0 ) : #NEWLINE# #INDENT# score += self . punish ( slowPow ( 10 , len ( unmatched ) ) , ( '%s unmatched parentheses' % len ( unmatched ) ) ) #NEWLINE# #UNINDENT# k3wlt0k_weights = ( 5 , 5 , 2 , 5 , 2 , 3 , 1 , 2 , 2 , 2 ) #NEWLINE# for i in range ( len ( k3wlt0k_weights ) ) : #NEWLINE# #INDENT# hits = re . findall ( repr ( i ) , nick ) #NEWLINE# if ( hits and ( len ( hits ) > 0 ) ) : #NEWLINE# #INDENT# score += self . punish ( ( ( k3wlt0k_weights [ i ] * len ( hits ) ) * 30 ) , ( '%s occurrences of %s ' % ( len ( hits ) , i ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# nickOriginalCase = nick #NEWLINE# match = re . search ( '^([^A-Za-z]*[A-Z].*[a-z].*?)[-_]?([A-Z])' , nick ) #NEWLINE# if match : #NEWLINE# #INDENT# nick = '' . join ( [ nick [ : match . start ( 2 ) ] , nick [ match . start ( 2 ) ] . lower ( ) , nick [ ( match . start ( 2 ) + 1 ) : ] ] ) #NEWLINE# #UNINDENT# match = re . search ( '^([^A-Za-z]*)([A-Z])([a-z])' , nick ) #NEWLINE# if match : #NEWLINE# #INDENT# nick = '' . join ( [ nick [ : match . start ( 2 ) ] , nick [ match . start ( 2 ) : match . end ( 2 ) ] . lower ( ) , nick [ match . end ( 2 ) : ] ] ) #NEWLINE# #UNINDENT# cshifts = caseShifts ( nick ) #NEWLINE# if ( ( cshifts > 1 ) and re . match ( '.*[A-Z].*' , nick ) ) : #NEWLINE# #INDENT# score += self . punish ( slowPow ( 9 , cshifts ) , ( '%s case shifts' % cshifts ) ) #NEWLINE# #UNINDENT# if re . match ( '.*[XZ][^a-zA-Z]*$' , nickOriginalCase ) : #NEWLINE# #INDENT# score += self . punish ( 50 , 'the last alphanumeric character was lame' ) #NEWLINE# #UNINDENT# nshifts = numberShifts ( nick ) #NEWLINE# if ( nshifts > 1 ) : #NEWLINE# #INDENT# score += self . punish ( slowPow ( 9 , nshifts ) , ( '%s letter/number shifts' % nshifts ) ) #NEWLINE# #UNINDENT# caps = re . findall ( '[A-Z]' , nick ) #NEWLINE# if ( caps and ( len ( caps ) > 0 ) ) : #NEWLINE# #INDENT# score += self . punish ( slowPow ( 7 , len ( caps ) ) , ( '%s extraneous caps' % len ( caps ) ) ) #NEWLINE# #UNINDENT# nick = re . sub ( '[-_]$' , '' , nick ) #NEWLINE# remains = re . findall ( '[^a-zA-Z0-9]' , nick ) #NEWLINE# if ( remains and ( len ( remains ) > 0 ) ) : #NEWLINE# #INDENT# score += self . punish ( ( ( 50 * len ( remains ) ) + slowPow ( 9 , len ( remains ) ) ) , ( '%s extraneous symbols' % len ( remains ) ) ) #NEWLINE# #UNINDENT# percentage = ( ( ( 100 * ( 1 + math . tanh ( ( ( score - 400.0 ) / 400.0 ) ) ) ) * ( 1 - ( 1 / ( 1 + ( score / 5.0 ) ) ) ) ) // 2 ) #NEWLINE# score_string = re . sub ( '(99\\.9*\\d|\\.\\d).*' , '\\1' , repr ( percentage ) ) #NEWLINE# irc . reply ( ( _ ( 'The "lame nick-o-meter" reading for "%s" is %s%%.' ) % ( originalNick , score_string ) ) ) #NEWLINE# self . log . debug ( 'Calculated lameness score for %s as %s (raw score was %s)' , originalNick , score_string , score )