linx: remove requirement of date, check arguments

master
Andrei M 2012-03-28 19:12:09 -04:00 committed by mutantmonkey
parent 4476412821
commit 5d23c7d550
1 changed files with 18 additions and 6 deletions

View File

@ -34,14 +34,26 @@ if __name__ == '__main__':
print(__doc__.strip()) print(__doc__.strip())
def lines(phenny, input): def lines(phenny, input):
""".lines <nickname> <date (YYYYMMDD)> - Returns the number of lines a user posted on a specific date.""" """.lines <nickname> (<today/yesterday/YYYYMMDD>) - Returns the number of lines a user posted on a specific date."""
nickname = input.group(2) if input.group(2):
date = input.group(3) info = input.group(2).split(" ")
if not nickname or not date:
phenny.reply(".lines <nickname> <date (YYYYMMDD)> - Returns the number of lines a user posted on a specific date.")
if len(info) == 1:
nickname = info[0]
date = "today"
elif len(info) == 2:
nickname = info[0]
date = info[1]
else:
phenny.reply(".lines <nickname> (<today/yesterday/YYYYMMDD>) - Returns the number of lines a user posted on a specific date.")
return
else:
phenny.reply(".lines <nickname> (<today/yesterday/YYYYMMDD>) - Returns the number of lines a user posted on a specific date.")
return return
try: try:
req = web.post("http://linx.li/vtluuglines", {'nickname': nickname, 'date': date}) req = web.post("http://linx.li/vtluuglines", {'nickname': nickname, 'date': date})
except (HTTPError, IOError): except (HTTPError, IOError):
@ -50,7 +62,7 @@ def lines(phenny, input):
phenny.reply(req) phenny.reply(req)
lines.rule = (['lines'], r'([A-Za-z0-9\-_\\]+) (.*)') lines.rule = (['lines'], r'(.*)')
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__.strip()) print(__doc__.strip())