mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
check if the location was found before replying
This commit is contained in:
parent
f3bcd83855
commit
3b395f0bc2
|
@ -14,6 +14,7 @@ import (
|
||||||
func Weather(target, location string, tc *twitch.Client) {
|
func Weather(target, location string, tc *twitch.Client) {
|
||||||
sugar := zap.NewExample().Sugar()
|
sugar := zap.NewExample().Sugar()
|
||||||
defer sugar.Sync()
|
defer sugar.Sync()
|
||||||
|
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sugar.Error("Error loading .env file")
|
sugar.Error("Error loading .env file")
|
||||||
|
@ -25,9 +26,12 @@ func Weather(target, location string, tc *twitch.Client) {
|
||||||
sugar.Error(err)
|
sugar.Error(err)
|
||||||
}
|
}
|
||||||
w.CurrentByName(location)
|
w.CurrentByName(location)
|
||||||
// fmt.Println(w)
|
|
||||||
sugar.Infow("Weather",
|
if w.GeoPos.Longitude == 0 && w.GeoPos.Latitude == 0 {
|
||||||
"location", w)
|
reply := "Location not found FeelsBadMan"
|
||||||
reply := fmt.Sprintf("Weather for %s, %s: Feels like: %v°C. Currently %v°C with a high of %v°C and a low of %v°C, humidity: %v%%, wind: %vm/s.", w.Name, w.Sys.Country, w.Main.FeelsLike, w.Main.Temp, w.Main.TempMax, w.Main.TempMin, w.Main.Humidity, w.Wind.Speed)
|
common.Send(target, reply, tc)
|
||||||
common.Send(target, reply, tc)
|
} else {
|
||||||
|
reply := fmt.Sprintf("Weather for %s, %s: Feels like: %v°C. Currently %v°C with a high of %v°C and a low of %v°C, humidity: %v%%, wind: %vm/s.", w.Name, w.Sys.Country, w.Main.FeelsLike, w.Main.Temp, w.Main.TempMax, w.Main.TempMin, w.Main.Humidity, w.Wind.Speed)
|
||||||
|
common.Send(target, reply, tc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue