Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into zendesk_module
- Loading branch information
Showing
3 changed files
with
48 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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": "☔️", | ||
"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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters