fix weather url

master
Paul Walko 2017-02-11 06:52:53 +00:00
parent 7ad0d5af9e
commit 58d41a0acd
3 changed files with 14 additions and 18 deletions

View File

@ -6,7 +6,7 @@ author: mutantmonkey <mutantmonkey@mutantmonkey.in>
import random import random
otherbot = "truncatedcone" otherbot = "quone"
def botfight(phenny, input): def botfight(phenny, input):
""".botfight - Fight the other bot in the channel.""" """.botfight - Fight the other bot in the channel."""

View File

@ -6,7 +6,7 @@ author: mutantmonkey <mutantmonkey@mutantmonkey.in>
""" """
from tools import GrumbleError from tools import GrumbleError
import web import requests
import json import json
@ -15,26 +15,22 @@ def linx(phenny, input, short=False):
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")
return return
try: try:
req = web.post("https://linx.li/upload/remote", {'url': url, 'short': short, 'api_key': phenny.config.linx_api_key})
except (web.HTTPError, web.ConnectionError):
raise GrumbleError("Couldn't reach linx.li")
data = json.loads(req) url = url.replace(".onion/", ".onion.to/")
if len(data) <= 0 or not data['success']:
phenny.reply('Sorry, upload failed.') r = requests.get("https://linx.vtluug.org/upload?", params={"url": url}, headers={"Accept": "application/json"})
return if "url" in r.json():
phenny.reply(r.json()["url"])
else:
phenny.reply(r.json()["error"])
except Exception as exc:
raise GrumbleError(exc)
phenny.reply(data['url'])
linx.rule = (['linx'], r'(.*)') linx.rule = (['linx'], r'(.*)')
def lnx(phenny, input):
"""
same as .linx but returns a short url.
"""
linx(phenny, input, True)
lnx.rule = (['lnx'], r'(.*)')

View File

@ -80,7 +80,7 @@ def f_weather(phenny, input):
phenny.say("No ICAO code found, sorry") phenny.say("No ICAO code found, sorry")
return return
uri = 'http://weather.noaa.gov/pub/data/observations/metar/stations/%s.TXT' uri = 'http://tgftp.nws.noaa.gov/data/observations/metar/stations/%s.TXT'
try: try:
bytes = web.get(uri % icao_code) bytes = web.get(uri % icao_code)
except AttributeError: except AttributeError: