From 2489b49639e49a43b9f2e103281b0d00f44dd3a3 Mon Sep 17 00:00:00 2001 From: Andrei M Date: Thu, 3 May 2012 21:57:46 -0400 Subject: [PATCH] short urls --- modules/short.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 modules/short.py diff --git a/modules/short.py b/modules/short.py new file mode 100644 index 0000000..284e613 --- /dev/null +++ b/modules/short.py @@ -0,0 +1,30 @@ + #!/usr/bin/python3 +""" +short.py - vtluug url shortner +author: andreim +""" + +from urllib.error import HTTPError +import web +import json + +def short(phenny, input): + """.short - Shorten a URL.""" + + url = input.group(2) + if not url: + phenny.reply("No URL provided. CAN I HAS?") + return + + try: + req = web.post("http://vtlu.ug/vtluug", {'lurl': url}) + except (HTTPError, IOError): + phenny.reply("THE INTERNET IS FUCKING BROKEN. Please try again later.") + return + + phenny.reply(req) + +linx.rule = (['short'], r'(.*)') + +if __name__ == '__main__': + print(__doc__.strip())