From 5d23c7d550d500590c083364cda4d85b5851321c Mon Sep 17 00:00:00 2001 From: Andrei M Date: Wed, 28 Mar 2012 19:12:09 -0400 Subject: [PATCH] linx: remove requirement of date, check arguments --- modules/linx.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/linx.py b/modules/linx.py index cddd824..3e1799f 100644 --- a/modules/linx.py +++ b/modules/linx.py @@ -34,14 +34,26 @@ if __name__ == '__main__': print(__doc__.strip()) def lines(phenny, input): - """.lines - Returns the number of lines a user posted on a specific date.""" + """.lines () - Returns the number of lines a user posted on a specific date.""" - nickname = input.group(2) - date = input.group(3) - if not nickname or not date: - phenny.reply(".lines - Returns the number of lines a user posted on a specific date.") + if input.group(2): + info = input.group(2).split(" ") + + + if len(info) == 1: + nickname = info[0] + date = "today" + elif len(info) == 2: + nickname = info[0] + date = info[1] + else: + phenny.reply(".lines () - Returns the number of lines a user posted on a specific date.") + return + else: + phenny.reply(".lines () - Returns the number of lines a user posted on a specific date.") return + try: req = web.post("http://linx.li/vtluuglines", {'nickname': nickname, 'date': date}) except (HTTPError, IOError): @@ -50,7 +62,7 @@ def lines(phenny, input): phenny.reply(req) -lines.rule = (['lines'], r'([A-Za-z0-9\-_\\]+) (.*)') +lines.rule = (['lines'], r'(.*)') if __name__ == '__main__': print(__doc__.strip())