Applied a patch to weather.py from Chris Waigl, and fixed search.py.

master
Sean B. Palmer 2008-11-24 21:14:22 +00:00
parent 4eb5bb8942
commit d26fc8d81f
2 changed files with 17 additions and 19 deletions

View File

@ -31,9 +31,8 @@ def search(query):
def result(query):
results = search(query)
if results['responseData']:
return results['responseData']['results'][0]['unescapedUrl']
return None
try: return results['responseData']['results'][0]['unescapedUrl']
except IndexError: return None
def count(query):
results = search(query)

View File

@ -64,11 +64,14 @@ def local(icao, hour, minute):
return str(hour) + ':' + str(minute) + 'Z'
def code(phenny, search):
from icao import data
if search.upper() in [loc[0] for loc in data]:
return search.upper()
else:
name, country, latitude, longitude = location(search)
if name == '?': return False
sumOfSquares = (99999999999999999999999999999, 'ICAO')
from icao import data
for icao_code, lat, lon in data:
latDiff = abs(latitude - lat)
lonDiff = abs(longitude - lon)
@ -87,11 +90,7 @@ def f_weather(self, origin, match, args):
if not icao_code:
return self.msg(origin.sender, 'Try .weather London, for example?')
if (not len(icao_code) == 4) or \
(len(icao_code) > 1 and icao_code[0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and
icao_code[1] in 'abcdefghijklmnopqrstuvwxyz'):
icao_code = code(self, icao_code)
else: icao_code = icao_code.upper()
if not icao_code:
self.msg(origin.sender, 'No ICAO code found, sorry')