|
|
@ -47,7 +47,7 @@ func (b *Bot) HandleAirQualityRequest(channelid string, postid string, message s |
|
|
|
zip4 := matches[1] |
|
|
|
zip4 := matches[1] |
|
|
|
|
|
|
|
|
|
|
|
apikey := os.Getenv("AIRNOW_API_KEY") |
|
|
|
apikey := os.Getenv("AIRNOW_API_KEY") |
|
|
|
url := fmt.Sprintf("http://www.airnowapi.org/aq/observation/zipCode/current/?format=application/json&zipCode=%d&distance=25&API_KEY=%s", zip4, apikey) |
|
|
|
url := fmt.Sprintf("http://www.airnowapi.org/aq/observation/zipCode/current/?format=application/json&zipCode=%s&distance=25&API_KEY=%s", zip4, apikey) |
|
|
|
|
|
|
|
|
|
|
|
log.Info().Msgf("calculated url: `%s`", url) |
|
|
|
log.Info().Msgf("calculated url: `%s`", url) |
|
|
|
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ func (b *Bot) HandleAirQualityRequest(channelid string, postid string, message s |
|
|
|
|
|
|
|
|
|
|
|
var parsedAQIResponse AQIResponse |
|
|
|
var parsedAQIResponse AQIResponse |
|
|
|
|
|
|
|
|
|
|
|
log.Info().Msgf("aqi %s: %s", zip, data) |
|
|
|
log.Info().Msgf("aqi %s: %s", zip4, data) |
|
|
|
|
|
|
|
|
|
|
|
err = nil |
|
|
|
err = nil |
|
|
|
err = json.Unmarshal([]byte(data), &parsedAQIResponse) |
|
|
|
err = json.Unmarshal([]byte(data), &parsedAQIResponse) |
|
|
@ -80,5 +80,5 @@ func (b *Bot) HandleAirQualityRequest(channelid string, postid string, message s |
|
|
|
b.SendMsgToChannel("error deserializing AQI data", postid, channelid) |
|
|
|
b.SendMsgToChannel("error deserializing AQI data", postid, channelid) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
b.SendMsgToChannel(fmt.Sprintf("AQI for `%s`: \n```\n%+v\n```\n", loc, parsedAQIResponse), postid, channelid) |
|
|
|
b.SendMsgToChannel(fmt.Sprintf("AQI for `%s`: \n```\n%+v\n```\n", zip4, parsedAQIResponse), postid, channelid) |
|
|
|
} |
|
|
|
} |
|
|
|