Created
February 15, 2010 12:36
-
-
Save jsimmons/304613 to your computer and use it in GitHub Desktop.
irc parser.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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