Skip to content

Commit

Permalink
Merge branch 'master' into zendesk_module
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed Jul 26, 2018
2 parents 9498586 + 8db4dc3 commit ea8148a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 71 deletions.
2 changes: 1 addition & 1 deletion weatherservices/weather/display.go
Expand Up @@ -72,5 +72,5 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
}

func (widget *Widget) title(cityData *owm.CurrentWeatherData) string {
return fmt.Sprintf(" %s %s ", widget.icon(cityData), cityData.Name)
return fmt.Sprintf(" %s %s ", widget.emojiFor(cityData), cityData.Name)
}
47 changes: 47 additions & 0 deletions weatherservices/weather/emoji.go
@@ -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
}
70 changes: 0 additions & 70 deletions weatherservices/weather/widget.go
Expand Up @@ -163,76 +163,6 @@ func (widget *Widget) defaultCityCodes() []interface{} {
return defaults
}

// icon returns an emoji for the current weather
// src: https://github.com/chubin/wttr.in/blob/master/share/translations/en.txt
// Note: these only work for English weather status. Sorry about that
//
// FIXME: Move these into a configuration file so they can be changed without a compile
func (widget *Widget) icon(data *owm.CurrentWeatherData) string {
var icon string

if len(data.Weather) == 0 {
return ""
}

switch data.Weather[0].Description {
case "broken clouds":
icon = "☁️"
case "clear":
icon = "☀️"
case "clear sky":
icon = "☀️"
case "cloudy":
icon = "⛅️"
case "few clouds":
icon = "🌤"
case "fog":
icon = "🌫"
case "haze":
icon = "🌫"
case "heavy intensity rain":
icon = "💦"
case "heavy rain":
icon = "💦"
case "heavy snow":
icon = "⛄️"
case "light intensity shower rain":
icon = "☔️"
case "light rain":
icon = "🌦"
case "light shower snow":
icon = "🌦⛄️"
case "light snow":
icon = "🌨"
case "mist":
icon = "🌬"
case "moderate rain":
icon = "🌧"
case "moderate snow":
icon = "🌨"
case "overcast":
icon = "🌥"
case "overcast clouds":
icon = "🌥"
case "partly cloudy":
icon = "🌤"
case "scattered clouds":
icon = "☁️"
case "shower rain":
icon = "☔️"
case "snow":
icon = "❄️"
case "sunny":
icon = "☀️"
case "thunderstorm":
icon = "⛈"
default:
icon = "💥"
}

return icon
}

func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
switch string(event.Rune()) {
case "/":
Expand Down

0 comments on commit ea8148a

Please sign in to comment.