update linx module from andreim

master
mutantmonkey 2012-03-27 23:20:18 -04:00
parent 8fbc3f6fcc
commit a951f0d3a7
1 changed files with 56 additions and 34 deletions

View File

@ -1,34 +1,56 @@
#!/usr/bin/python3 #!/usr/bin/python3
""" """
linx.py - linx.li uploader linx.py - linx.li tools
author: mutantmonkey <mutantmonkey@mutantmonkey.in> author: mutantmonkey <mutantmonkey@mutantmonkey.in>, andreim <andreim@andreim.net>
""" """
from urllib.error import HTTPError from urllib.error import HTTPError
import web import web
import json import json
def linx(phenny, input): def linx(phenny, input):
""".linx <url> - Upload a URL to linx.li.""" """.linx <url> - Upload a URL to linx.li."""
url = input.group(2) url = input.group(2)
if not url: if not url:
phenny.reply("No URL provided. CAN I HAS?") phenny.reply("No URL provided. CAN I HAS?")
return return
try: try:
req = web.post("http://linx.li/vtluug", {'url': url}) req = web.post("http://linx.li/vtluug", {'url': url})
except (HTTPError, IOError): except (HTTPError, IOError):
phenny.reply("THE INTERNET IS FUCKING BROKEN. Please try again later.") phenny.reply("THE INTERNET IS FUCKING BROKEN. Please try again later.")
return return
data = json.loads(req) data = json.loads(req)
if len(data) <= 0 or not data['success']: if len(data) <= 0 or not data['success']:
phenny.reply('Sorry, upload failed.') phenny.reply('Sorry, upload failed.')
return return
phenny.reply(data['url']) phenny.reply(data['url'])
linx.rule = (['linx'], r'(.*)') linx.rule = (['linx'], r'(.*)')
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__.strip()) print(__doc__.strip())
def lines(phenny, input):
""".lines <nickname> <date (YYYYMMDD)> - 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 <nickname> <date (YYYYMMDD)> - 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):
phenny.reply("THE INTERNET IS FUCKING BROKEN. Please try again later.")
return
phenny.reply(req)
lines.rule = (['lines'], r'([a-z0-9\-_\\]+) (.*)')
if __name__ == '__main__':
print(__doc__.strip())