github.com/wtfutil/wtf@v0.43.0/modules/weatherservices/weather/emoji.go (about)

     1  package weather
     2  
     3  import (
     4  	owm "github.com/briandowns/openweathermap"
     5  )
     6  
     7  var weatherEmoji = map[string]string{
     8  	"default":                     "💥",
     9  	"broken clouds":               "🌤",
    10  	"clear":                       "🌎",
    11  	"clear sky":                   "🌎",
    12  	"cloudy":                      "⛅️",
    13  	"few clouds":                  "🌤",
    14  	"fog":                         "🌫",
    15  	"haze":                        "🌫",
    16  	"heavy intensity rain":        "💦",
    17  	"heavy rain":                  "💦",
    18  	"heavy snow":                  "⛄️",
    19  	"light intensity drizzle":     "🌧",
    20  	"light intensity shower rain": "☔️",
    21  	"light rain":                  "🌦",
    22  	"light shower snow":           "🌦⛄️",
    23  	"light snow":                  "🌨",
    24  	"mist":                        "🌬",
    25  	"moderate rain":               "🌧",
    26  	"moderate snow":               "🌨",
    27  	"overcast":                    "🌥",
    28  	"overcast clouds":             "🌥",
    29  	"partly cloudy":               "🌤",
    30  	"scattered clouds":            "🌤",
    31  	"shower rain":                 "☔️",
    32  	"smoke":                       "🔥",
    33  	"snow":                        "❄️",
    34  	"sunny":                       "☀️",
    35  	"thunderstorm":                "⛈",
    36  }
    37  
    38  func (widget *Widget) emojiFor(data *owm.CurrentWeatherData) string {
    39  	if len(data.Weather) == 0 {
    40  		return ""
    41  	}
    42  
    43  	emoji := weatherEmoji[data.Weather[0].Description]
    44  	if emoji == "" {
    45  		emoji = weatherEmoji["default"]
    46  	}
    47  
    48  	return emoji
    49  }