mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add language option to prettyweather
This commit is contained in:
@@ -10,10 +10,11 @@ import (
|
||||
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
result string
|
||||
unit string
|
||||
city string
|
||||
view string
|
||||
result string
|
||||
unit string
|
||||
city string
|
||||
view string
|
||||
language string
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
@@ -37,12 +38,14 @@ func (widget *Widget) prettyWeather() {
|
||||
widget.unit = wtf.Config.UString("wtf.mods.prettyweather.unit", "m")
|
||||
widget.city = wtf.Config.UString("wtf.mods.prettyweather.city", "")
|
||||
widget.view = wtf.Config.UString("wtf.mods.prettyweather.view", "0")
|
||||
widget.language = wtf.Config.UString("wtf.mods.prettyweather.language", "en")
|
||||
req, err := http.NewRequest("GET", "https://wttr.in/"+widget.city+"?"+widget.view+"?"+widget.unit, nil)
|
||||
if err != nil {
|
||||
widget.result = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set("Accept-Language", widget.language)
|
||||
req.Header.Set("User-Agent", "curl")
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user