mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'master' into zendesk_module
This commit is contained in:
commit
ea8148a172
@ -72,5 +72,5 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) title(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
weatherservices/weather/emoji.go
Normal file
47
weatherservices/weather/emoji.go
Normal file
@ -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
|
||||||
|
}
|
@ -163,76 +163,6 @@ func (widget *Widget) defaultCityCodes() []interface{} {
|
|||||||
return defaults
|
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 {
|
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||||
switch string(event.Rune()) {
|
switch string(event.Rune()) {
|
||||||
case "/":
|
case "/":
|
||||||
|
Loadingβ¦
x
Reference in New Issue
Block a user