phenny-1/modules/linx.py

37 lines
842 B
Python
Raw Normal View History

2012-03-27 23:20:18 -04:00
#!/usr/bin/python3
"""
linx.py - linx.li tools
author: andreim <andreim@andreim.net>
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
2012-03-27 23:20:18 -04:00
"""
from tools import GrumbleError
2017-02-11 01:52:53 -05:00
import requests
2012-03-27 23:20:18 -04:00
import json
2012-06-21 19:29:31 -04:00
def linx(phenny, input, short=False):
""".linx <url> - Upload a remote URL to linx.li."""
2012-03-27 23:20:18 -04:00
url = input.group(2)
if not url:
2017-02-11 01:52:53 -05:00
phenny.reply("No URL provided")
2012-03-27 23:20:18 -04:00
return
try:
2017-02-11 01:52:53 -05:00
url = url.replace(".onion/", ".onion.to/")
r = requests.get("https://linx.vtluug.org/upload?", params={"url": url}, headers={"Accept": "application/json"})
if "url" in r.json():
phenny.reply(r.json()["url"])
else:
phenny.reply(r.json()["error"])
except Exception as exc:
raise GrumbleError(exc)
2012-03-27 23:20:18 -04:00
linx.rule = (['linx'], r'(.*)')