#NEWLINE# def identify( m ) : #NEWLINE# #INDENT# "Passes along Nickserv's password request and asks user to identify." #NEWLINE# logger = logging . getLogger ( 'GorillaBot' ) #NEWLINE# m . bot . response_lock . acquire ( ) #NEWLINE# identified = False #NEWLINE# ignored_messages = [ ] #NEWLINE# while ( not identified ) : #NEWLINE# #INDENT# password = getpass ( 'Please enter your password to identify to NickServ: ' ) #NEWLINE# m . bot . private_message ( 'NickServ' , ( 'identify ' + password ) , True ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# msg = m . bot . message_q . get ( True , 120 ) #NEWLINE# #UNINDENT# except Empty : #NEWLINE# #INDENT# logger . error ( 'No response from NickServ when trying to identify. Shutting down.' ) #NEWLINE# m . bot . shutdown . set ( ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( ( not isinstance ( msg , message . Notice ) ) or ( msg . sender != 'NickServ!NickServ@services.' ) ) : #NEWLINE# #INDENT# ignored_messages . append ( msg ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( 'Invalid' in msg . body ) : #NEWLINE# #INDENT# logger . info ( 'Invalid password entered.' ) #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'You are now identified' in msg . body ) : #NEWLINE# #INDENT# logger . info ( 'You have successfully identified.' ) #NEWLINE# identified = True #NEWLINE# m . bot . configuration [ 'password' ] = password #NEWLINE# m . bot . update_configuration ( m . bot . configuration ) #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ignored_messages . append ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for msg in ignored_messages : #NEWLINE# #INDENT# m . bot . message_q . put ( msg ) #NEWLINE# #UNINDENT# m . bot . response_lock . release ( ) #NEWLINE# m . bot . join ( )