#NEWLINE# def __init__( self , s = '' , command = '' , args = ( ) , prefix = '' , msg = None , reply_env = None ) : #NEWLINE# #INDENT# assert ( not ( msg and s ) ) , 'IrcMsg.__init__ cannot accept both s and msg' #NEWLINE# if ( ( not s ) and ( not command ) and ( not msg ) ) : #NEWLINE# #INDENT# raise MalformedIrcMsg ( 'IRC messages require a command.' ) #NEWLINE# #UNINDENT# self . _str = None #NEWLINE# self . _repr = None #NEWLINE# self . _hash = None #NEWLINE# self . _len = None #NEWLINE# self . reply_env = reply_env #NEWLINE# self . tags = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if s : #NEWLINE# #INDENT# originalString = s #NEWLINE# try : #NEWLINE# #INDENT# if ( not s . endswith ( '\n' ) ) : #NEWLINE# #INDENT# s += '\n' #NEWLINE# #UNINDENT# self . _str = s #NEWLINE# if ( s [ 0 ] == '@' ) : #NEWLINE# #INDENT# ( server_tags , s ) = s . split ( ' ' , 1 ) #NEWLINE# self . server_tags = parse_server_tags ( server_tags [ 1 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . server_tags = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( s [ 0 ] == ':' ) : #NEWLINE# #INDENT# ( self . prefix , s ) = s [ 1 : ] . split ( None , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . prefix = '' #NEWLINE# #UNINDENT# if ( ' :' in s ) : #NEWLINE# #INDENT# ( s , last ) = s . split ( ' :' , 1 ) #NEWLINE# self . args = s . split ( ) #NEWLINE# self . args . append ( last . rstrip ( '\r\n' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . args = s . split ( ) #NEWLINE# #UNINDENT# self . command = self . args . pop ( 0 ) #NEWLINE# if ( 'time' in self . server_tags ) : #NEWLINE# #INDENT# s = self . server_tags [ 'time' ] #NEWLINE# date = datetime . datetime . strptime ( s , '%Y-%m-%dT%H:%M:%S.%fZ' ) #NEWLINE# date = minisix . make_datetime_utc ( date ) #NEWLINE# self . time = minisix . datetime__timestamp ( date ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . time = time . time ( ) #NEWLINE# #UNINDENT# #UNINDENT# except ( IndexError , ValueError ) : #NEWLINE# #INDENT# raise MalformedIrcMsg ( repr ( originalString ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg is not None ) : #NEWLINE# #INDENT# if prefix : #NEWLINE# #INDENT# self . prefix = prefix #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . prefix = msg . prefix #NEWLINE# #UNINDENT# if command : #NEWLINE# #INDENT# self . command = command #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . command = msg . command #NEWLINE# #UNINDENT# if args : #NEWLINE# #INDENT# self . args = args #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . args = msg . args #NEWLINE# #UNINDENT# if reply_env : #NEWLINE# #INDENT# self . reply_env = reply_env #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if msg . reply_env : #NEWLINE# #INDENT# self . reply_env = msg . reply_env . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . reply_env = None #NEWLINE# #UNINDENT# #UNINDENT# self . tags = msg . tags . copy ( ) #NEWLINE# self . server_tags = msg . server_tags #NEWLINE# self . time = msg . time #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . prefix = prefix #NEWLINE# self . command = command #NEWLINE# assert all ( ircutils . isValidArgument , args ) , args #NEWLINE# self . args = self #NEWLINE# self . time = None #NEWLINE# self . server_tags = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# self . args = tuple ( self . args ) #NEWLINE# if isUserHostmask ( self . prefix ) : #NEWLINE# #INDENT# ( self . nick , self . user , self . host ) = ircutils . splitHostmask ( self . prefix ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( self . nick , self . user , self . host ) = ( ( self . prefix , ) * 3 )