dickserv- irc bot with many useful commands |
git clone git://git.acid.vegas/dickserv.git |
Log | Files | Refs | Archive | README | LICENSE |
weather.py (759B)
1 #!/usr/bin/env python 2 # DickServ IRC Bot - Developed by acidvegas in Python (https://acid.vegas/dickserv) 3 # weather.py 4 5 import httplib 6 7 import config 8 9 def lookup(zip_code): 10 api = httplib.get_json('http://api.wunderground.com/api/{0}/conditions/q/{1}.json'.format(config.api.wunderground_api_key, zip_code)) 11 if 'error' not in api: 12 city = api['current_observation']['display_location']['city'] 13 state = api['current_observation']['display_location']['state'] 14 country = api['current_observation']['display_location']['country'] 15 weather = api['current_observation']['weather'] 16 temp = api['current_observation']['temp_f'] 17 return 'The weather for {0}, {1}, {2} is {3} at {4} F'.format(city, state, country, weather, temp) 18 else: 19 return False