def ctcpExtract(message):
 extended_messages = []
 normal_messages = []
 retval = {'extended': extended_messages, 'normal': normal_messages}
 messages = string.split(message, X_DELIM)
 odd = 0
 while messages:
  if odd:
   extended_messages.append(messages.pop(0))
  else:
   normal_messages.append(messages.pop(0))
  odd = (not odd)
 extended_messages[:] = filter(None, extended_messages)
 normal_messages[:] = filter(None, normal_messages)
 extended_messages[:] = map(ctcpDequote, extended_messages)
 for i in xrange(len(extended_messages)):
  m = string.split(extended_messages[i], SPC, 1)
  tag = m[0]
  if (len(m) > 1):
   data = m[1]
  else:
   data = None
  extended_messages[i] = (tag, data)
 return retval

def ctcpExtract ( message ) : extended_messages = [ ] normal_messages = [ ] retval = { 'extended' : extended_messages , 'normal' : normal_messages } messages = string . split ( message , X_DELIM ) odd = 0 while messages : if odd : extended_messages . append ( messages . pop ( 0 ) ) else : normal_messages . append ( messages . pop ( 0 ) ) odd = ( not odd ) extended_messages [ : ] = filter ( None , extended_messages ) normal_messages [ : ] = filter ( None , normal_messages ) extended_messages [ : ] = map ( ctcpDequote , extended_messages ) for i in xrange ( len ( extended_messages ) ) : m = string . split ( extended_messages [ i ] , SPC , 1 ) tag = m [ 0 ] if ( len ( m ) > 1 ) : data = m [ 1 ] else : data = None extended_messages [ i ] = ( tag , data ) return retval
extract ctcp data from a string .