From 12bb59d25725c15d3e12d0886c084ac30b502c5e Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 18 Feb 2017 19:58:24 -0800 Subject: [PATCH] Irc: more parseArgs tweaks - Make parsePrefixedArgs() a class method - Split the input if parseArgs() is given a raw string instead of a list --- classes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index 1c907ed..fa18ddb 100644 --- a/classes.py +++ b/classes.py @@ -1329,9 +1329,13 @@ class Protocol(): @staticmethod def parseArgs(args): - """Parses a string of RFC1459-style arguments split into a list, where ":" may + """ + Parses a string or list of of RFC1459-style arguments, where ":" may be used for multi-word arguments that last until the end of a line. """ + if isinstance(args, str): + args = args.split(' ') + real_args = [] for idx, arg in enumerate(args): if arg.startswith(':') and idx != 0: @@ -1432,10 +1436,11 @@ class Protocol(): target = self.irc.nickToUid(target) or target return target - def parsePrefixedArgs(self, args): + @classmethod + def parsePrefixedArgs(cls, args): """Similar to parseArgs(), but stripping leading colons from the first argument of a line (usually the sender field).""" - args = self.parseArgs(args) + args = cls.parseArgs(args) args[0] = args[0].split(':', 1)[1] return args