parameters: (self)
docstring: [Internal]
docstring_summary: [Internal]
docstring_tokens: [ Internal ]
function: def process_data(self):
          """[Internal]"""
  
          try:
              if self.ssl:
                  new_data = self.ssl.read(2**14)
              else:
                  new_data = self.socket.recv(2**14)
          except socket.error, x:
              # The server hung up.
              self.disconnect("Connection reset by peer")
              return
          if not new_data:
              # Read nothing: connection must be down.
              self.disconnect("Connection reset by peer")
              return
  
          lines = _linesep_regexp.split(self.previous_buffer + new_data)
  
          # Save the last, unfinished line.
          self.previous_buffer = lines.pop()
  
          for line in lines:
              if DEBUG:
                  print "FROM SERVER:", line
  
              if not line:
                  continue
  
              prefix = None
              command = None
              arguments = None
              self._handle_event(Event("all_raw_messages",
                                       self.get_server_name(),
                                       None,
                                       [line]))
  
              m = _rfc_1459_command_regexp.match(line)
              if m.group("prefix"):
                  prefix = m.group("prefix")
                  if not self.real_server_name:
                      self.real_server_name = prefix
  
              if m.group("command"):
                  command = m.group("command").lower()
  
              if m.group("argument"):
                  a = m.group("argument").split(" :", 1)
                  arguments = a[0].split()
                  if len(a) == 2:
                      arguments.append(a[1])
  
              # Translate numerics into more readable strings.
              if command in numeric_events:
                  command = numeric_events[command]
  
              if command == "nick":
                  if nm_to_n(prefix) == self.real_nickname:
                      self.real_nickname = arguments[0]
              elif command == "welcome":
                  # Record the nickname in case the client changed nick
                  # in a nicknameinuse callback.
                  self.real_nickname = arguments[0]
  
              if command in ["privmsg", "notice"]:
                  target, message = arguments[0], arguments[1]
                  messages = _ctcp_dequote(message)
  
                  if command == "privmsg":
                      if is_channel(target):
                          command = "pubmsg"
                  else:
                      if is_channel(target):
                          command = "pubnotice"
                      else:
                          command = "privnotice"
  
                  for m in messages:
                      if type(m) is types.TupleType:
                          if command in ["privmsg", "pubmsg"]:
                              command = "ctcp"
                          else:
                              command = "ctcpreply"
  
                          m = list(m)
                          if DEBUG:
                              print "command: %s, source: %s, target: %s, arguments: %s" % (
                                  command, prefix, target, m)
                          self._handle_event(Event(command, prefix, target, m))
                          if command == "ctcp" and m[0] == "ACTION":
                              self._handle_event(Event("action", prefix, target, m[1:]))
                      else:
                          if DEBUG:
                              print "command: %s, source: %s, target: %s, arguments: %s" % (
                                  command, prefix, target, [m])
                          self._handle_event(Event(command, prefix, target, [m]))
              else:
                  target = None
  
                  if command == "quit":
                      arguments = [arguments[0]]
                  elif command == "ping":
                      target = arguments[0]
                  else:
                      target = arguments[0]
                      arguments = arguments[1:]
  
                  if command == "mode":
                      if not is_channel(target):
                          command = "umode"
  
                  if DEBUG:
                      print "command: %s, source: %s, target: %s, arguments: %s" % (
                          command, prefix, target, arguments)
                  self._handle_event(Event(command, prefix, target, arguments))
function_tokens: def process_data ( self ) : try : if self . ssl : new_data = self . ssl . read ( 2 ** 14 ) else : new_data = self . socket . recv ( 2 ** 14 ) except socket . error , x : # The server hung up. self . disconnect ( "Connection reset by peer" ) return if not new_data : # Read nothing: connection must be down. self . disconnect ( "Connection reset by peer" ) return lines = _linesep_regexp . split ( self . previous_buffer + new_data ) # Save the last, unfinished line. self . previous_buffer = lines . pop ( ) for line in lines : if DEBUG : print "FROM SERVER:" , line if not line : continue prefix = None command = None arguments = None self . _handle_event ( Event ( "all_raw_messages" , self . get_server_name ( ) , None , [ line ] ) ) m = _rfc_1459_command_regexp . match ( line ) if m . group ( "prefix" ) : prefix = m . group ( "prefix" ) if not self . real_server_name : self . real_server_name = prefix if m . group ( "command" ) : command = m . group ( "command" ) . lower ( ) if m . group ( "argument" ) : a = m . group ( "argument" ) . split ( " :" , 1 ) arguments = a [ 0 ] . split ( ) if len ( a ) == 2 : arguments . append ( a [ 1 ] ) # Translate numerics into more readable strings. if command in numeric_events : command = numeric_events [ command ] if command == "nick" : if nm_to_n ( prefix ) == self . real_nickname : self . real_nickname = arguments [ 0 ] elif command == "welcome" : # Record the nickname in case the client changed nick # in a nicknameinuse callback. self . real_nickname = arguments [ 0 ] if command in [ "privmsg" , "notice" ] : target , message = arguments [ 0 ] , arguments [ 1 ] messages = _ctcp_dequote ( message ) if command == "privmsg" : if is_channel ( target ) : command = "pubmsg" else : if is_channel ( target ) : command = "pubnotice" else : command = "privnotice" for m in messages : if type ( m ) is types . TupleType : if command in [ "privmsg" , "pubmsg" ] : command = "ctcp" else : command = "ctcpreply" m = list ( m ) if DEBUG : print "command: %s, source: %s, target: %s, arguments: %s" % ( command , prefix , target , m ) self . _handle_event ( Event ( command , prefix , target , m ) ) if command == "ctcp" and m [ 0 ] == "ACTION" : self . _handle_event ( Event ( "action" , prefix , target , m [ 1 : ] ) ) else : if DEBUG : print "command: %s, source: %s, target: %s, arguments: %s" % ( command , prefix , target , [ m ] ) self . _handle_event ( Event ( command , prefix , target , [ m ] ) ) else : target = None if command == "quit" : arguments = [ arguments [ 0 ] ] elif command == "ping" : target = arguments [ 0 ] else : target = arguments [ 0 ] arguments = arguments [ 1 : ] if command == "mode" : if not is_channel ( target ) : command = "umode" if DEBUG : print "command: %s, source: %s, target: %s, arguments: %s" % ( command , prefix , target , arguments ) self . _handle_event ( Event ( command , prefix , target , arguments ) )