Skip to content

Instantly share code, notes, and snippets.

@jsimmons
Created February 15, 2010 12:36
Show Gist options
  • Save jsimmons/304613 to your computer and use it in GitHub Desktop.
Save jsimmons/304613 to your computer and use it in GitHub Desktop.
irc parser.py
def parse(msg):
prefix, trailing = None, None
if msg[0] == ':':
prefix, msg = msg[1:].split(' ', 1)
if msg.find(' :') != -1:
msg, trailing = msg.split(' :', 1)
args = msg.split()
if trailing != None:
args.append(trailing)
return prefix, args.pop(0), args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment