1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
2018-08-03 05:19:12 -07:00

49 lines
1.4 KiB
Go

package weather
import (
owm "github.com/briandowns/openweathermap"
)
var weatherEmoji = map[string]string{
"default": "💥",
"broken clouds": "🌤",
"clear": " ",
"clear sky": " ",
"cloudy": "⛅️",
"few clouds": "🌤",
"fog": "🌫",
"haze": "🌫",
"heavy intensity rain": "💦",
"heavy rain": "💦",
"heavy snow": "⛄️",
"light intensity shower rain": "☔️",
"light rain": "🌦",
"light shower snow": "🌦⛄️",
"light snow": "🌨",
"mist": "🌬",
"moderate rain": "🌧",
"moderate snow": "🌨",
"overcast": "🌥",
"overcast clouds": "🌥",
"partly cloudy": "🌤",
"scattered clouds": "🌤",
"shower rain": "☔️",
"smoke": "🔥",
"snow": "❄️",
"sunny": "☀️",
"thunderstorm": "⛈",
}
func (widget *Widget) emojiFor(data *owm.CurrentWeatherData) string {
if len(data.Weather) == 0 {
return ""
}
emoji := weatherEmoji[data.Weather[0].Description]
if emoji == "" {
emoji = weatherEmoji["default"]
}
return emoji
}