def get_weather(phenny, input): """.w zipcode - Fetches the weather report for the given zipcode (postal code; city, state/country) """ import wunderground report_type = 'conditions' unicode_input = unicode(input) if unicode_input[1:8] == 'weather': location_str = unicode_input[9:] elif unicode_input[1:3] == 'w ': location_str = unicode_input[3:] try: json_data = wunderground.format_json(location_str, input.weather_API, report_type) output_results(phenny, json_data) except Exception, e: print e phenny.say('Could not find results for "%s", please reword the search and try again.' % location_str)
def get_forecast(phenny, input): """.fc zipcode - Fetches the daily forecast for the given zipcode (postal code; city, state/country)""" import wunderground report_type = 'forecast' unicode_input = unicode(input) if unicode_input[1:9] == 'forecast': location_str = unicode_input[10:] elif unicode_input[1:4] == 'fc ': location_str = unicode_input[4:] try: json_data = wunderground.format_json(location_str, input.weather_API, report_type) output_results(phenny, json_data) except Exception, e: print e phenny.say('Could not find results for "%s", please reword the search and try again.' % location_str)