#NEWLINE# def do_command( self , e , cmd ) : #NEWLINE# #INDENT# self . activated = True #NEWLINE# logger . debug ( 'Received command: %s' , cmd ) #NEWLINE# nickname = e . source . nick #NEWLINE# if ( nickname not in self . limit_access_to ) : #NEWLINE# #INDENT# self . send_user_message ( nickname , ( "I'm sorry, %s, you are not allowed to give commands to this debugger." % ( usernames , ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if cmd . startswith ( '!allow' ) : #NEWLINE# #INDENT# allows = cmd . split ( ' ' ) #NEWLINE# usernames = allows [ 1 : ] #NEWLINE# if ( not self . limit_access_to ) : #NEWLINE# #INDENT# self . limit_access_to . append ( nickname ) #NEWLINE# #UNINDENT# self . limit_access_to . extend ( usernames ) #NEWLINE# self . send_channel_message ( ( 'The following users have been granted access to the debugger: %s.' % ', ' . join ( usernames ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if cmd . startswith ( '!forbid' ) : #NEWLINE# #INDENT# forbids = cmd . split ( ' ' ) #NEWLINE# usernames = forbids [ 1 : ] #NEWLINE# try : #NEWLINE# #INDENT# for username in usernames : #NEWLINE# #INDENT# self . limit_access_to . remove ( username ) #NEWLINE# #UNINDENT# self . send_channel_message ( ( 'The following users have been forbidden access to the debugger: %s.' % ', ' . join ( usernames ) ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# self . send_channel_message ( ( "The users %s are not in the 'allows' list.  You must have a defined 'allows' list to remove users from it." % ', ' . join ( usernames ) ) ) #NEWLINE# #UNINDENT# if ( not self . limit_access_to ) : #NEWLINE# #INDENT# self . send_channel_message ( 'No users are allowed to interact with the debugger; continuing from breakpoint.' ) #NEWLINE# self . queue . put ( 'continue' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if cmd . startswith ( '!set_dpaste_minimum_response_length' ) : #NEWLINE# #INDENT# value = cmd . split ( ' ' ) #NEWLINE# try : #NEWLINE# #INDENT# self . dpaste_minimum_response_length = int ( value [ 1 ] ) #NEWLINE# self . send_channel_message ( ( 'Messages longer than %s lines will now be posted to dpaste if possible.' % self . dpaste_minimum_response_length ) ) #NEWLINE# #UNINDENT# except ( TypeError , IndexError , ValueError ) : #NEWLINE# #INDENT# self . send_channel_message ( 'An error was encountered while setting the dpaste_minimum_response_length setting. %s' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if cmd . startswith ( '!set_message_wait_seconds' ) : #NEWLINE# #INDENT# value = cmd . split ( ' ' ) #NEWLINE# try : #NEWLINE# #INDENT# self . message_wait_seconds = float ( value [ 1 ] ) #NEWLINE# self . send_channel_message ( ( 'There will be a delay of %s seconds between sending each message.' % self . message_wait_seconds ) ) #NEWLINE# #UNINDENT# except ( TypeError , IndexError , ValueError ) : #NEWLINE# #INDENT# self . send_channel_message ( 'An error was encountered while setting the message_wait_seconds setting.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if cmd . startswith ( '!help' ) : #NEWLINE# #INDENT# available_commands = textwrap . dedent ( '\n                Available Commands:\n                * !!allow NICKNAME\n                  Add NICKNAME to the list of users that are allowed to\n                  interact with the debugger. Current value: {limit_access_to}.\n\n                * !!forbid NICKNAME\n                  Remove NICKNAME from the list of users that are allowed\n                  to interact with the debugger.\n\n                * !!set_dpaste_minimum_response_length INTEGER\n                  Try to send messages this length or longer in lines\n                  to dpaste rather than sending them to IRC directly.\n                  Current value: {dpaste_minimum_response_length}.\n\n                * !!set_message_wait_seconds FLOAT\n                  Set the number of seconds to wait between sending messages\n                  (this is a measure used to prevent being kicked from\n                  Freenode and other IRC servers that enforce limits on the\n                  number of messages a client an send in a given period of\n                  time. Current value: {message_wait_seconds}.\n            ' . format ( limit_access_to = self . limit_access_to , dpaste_minimum_response_length = self . dpaste_minimum_response_length , message_wait_seconds = self . message_wait_seconds ) ) #NEWLINE# self . send_channel_message ( available_commands , dpaste = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . queue . put ( cmd . strip ( ) )