From 0160d86a64eebfc2d45edfbeceb3eef11cd4fb9f Mon Sep 17 00:00:00 2001 From: Nathan Blaney Date: Mon, 5 Aug 2013 19:32:53 +1000 Subject: [PATCH 1/4] Create QR code plugin --- plugins/qr.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugins/qr.py diff --git a/plugins/qr.py b/plugins/qr.py new file mode 100644 index 0000000..1502000 --- /dev/null +++ b/plugins/qr.py @@ -0,0 +1,15 @@ +# Plugin by https://github.com/Mu5tank05 +from util import hook, web, http + + +@hook.command('qr') +@hook.command +def qrcode(inp, bot=None): + "qrcode [link] returns a link for a QR code." + + link = "http://blny.tk/qr.php?q=%s" % http.quote_plus(inp) + + try: + return web.isgd(link) + except (web.ShortenError, http.HTTPError): + return link From aa80de0bb4ea858a2a5769981d01b08626ef5a8b Mon Sep 17 00:00:00 2001 From: Nathan Blaney Date: Mon, 5 Aug 2013 20:30:58 +1000 Subject: [PATCH 2/4] Updated to new web.py --- plugins/qr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/qr.py b/plugins/qr.py index 1502000..2c334cc 100644 --- a/plugins/qr.py +++ b/plugins/qr.py @@ -7,9 +7,9 @@ from util import hook, web, http def qrcode(inp, bot=None): "qrcode [link] returns a link for a QR code." - link = "http://blny.tk/qr.php?q=%s" % http.quote_plus(inp) + link = "http://blny.tk/qr.php?q=%s" % http.get_url(inp) try: - return web.isgd(link) + return web.try_isgd(link) except (web.ShortenError, http.HTTPError): return link From a02761bbd4516a0d7dd764c195b32c6728849e57 Mon Sep 17 00:00:00 2001 From: Nathan Blaney Date: Mon, 5 Aug 2013 20:49:50 +1000 Subject: [PATCH 3/4] OK then --- plugins/qr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/qr.py b/plugins/qr.py index 2c334cc..1867925 100644 --- a/plugins/qr.py +++ b/plugins/qr.py @@ -7,7 +7,7 @@ from util import hook, web, http def qrcode(inp, bot=None): "qrcode [link] returns a link for a QR code." - link = "http://blny.tk/qr.php?q=%s" % http.get_url(inp) + link = "http://blny.tk/qr.php?q=%s" % http.quote_plus(inp) try: return web.try_isgd(link) From 41fe6723fc5bcf8bc0c7e48e559cd0c9dd13c5dd Mon Sep 17 00:00:00 2001 From: Nathan Blaney Date: Mon, 5 Aug 2013 20:56:46 +1000 Subject: [PATCH 4/4] Updated to use proper shorten --- plugins/qr.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/qr.py b/plugins/qr.py index 1867925..ae26891 100644 --- a/plugins/qr.py +++ b/plugins/qr.py @@ -8,8 +8,7 @@ def qrcode(inp, bot=None): "qrcode [link] returns a link for a QR code." link = "http://blny.tk/qr.php?q=%s" % http.quote_plus(inp) + + return web.try_isgd(link) + - try: - return web.try_isgd(link) - except (web.ShortenError, http.HTTPError): - return link