mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* Another actions test Signed-off-by: Chris Cummer <chriscummer@me.com> * Add BuildTest action Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove lint check for the time being (so many issues) Signed-off-by: Chris Cummer <chriscummer@me.com> * Fix issues found by errcheck Signed-off-by: Chris Cummer <chriscummer@me.com> * Fix errors found by staticcheck Signed-off-by: Chris Cummer <chriscummer@me.com> * Fix issues found by goimports Signed-off-by: Chris Cummer <chriscummer@me.com> * Comment out the action for the time being Signed-off-by: Chris Cummer <chriscummer@me.com> * Fix shadowed variables Signed-off-by: Chris Cummer <chriscummer@me.com> * go mod tidy Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove buildtest.yml Signed-off-by: Chris Cummer <chriscummer@me.com> * go mod tidy Signed-off-by: Chris Cummer <chriscummer@me.com>
47 lines
1.7 KiB
Go
47 lines
1.7 KiB
Go
package twitch
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/olebedev/config"
|
|
"github.com/wtfutil/wtf/cfg"
|
|
"github.com/wtfutil/wtf/utils"
|
|
)
|
|
|
|
const (
|
|
defaultFocusable = true
|
|
)
|
|
|
|
type Settings struct {
|
|
common *cfg.Common
|
|
|
|
numberOfResults int `help:"Number of results to show. Default is 10." optional:"true"`
|
|
clientId string `help:"Client Id (default is env var TWITCH_CLIENT_ID)"`
|
|
languages []string `help:"Stream languages" optional:"true"`
|
|
gameIds []string `help:"Twitch Game IDs" optional:"true"`
|
|
streamType string `help:"Type of stream 'live' (default), 'all', 'vodcast'" optional:"true"`
|
|
userIds []string `help:"Twitch user ids" optional:"true"`
|
|
userLogins []string `help:"Twitch user names" optional:"true"`
|
|
}
|
|
|
|
func defaultLanguage() []interface{} {
|
|
var defaults []interface{}
|
|
defaults = append(defaults, "en")
|
|
return defaults
|
|
}
|
|
|
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
|
twitch := ymlConfig.UString("twitch")
|
|
settings := Settings{
|
|
common: cfg.NewCommonSettingsFromModule(name, twitch, defaultFocusable, ymlConfig, globalConfig),
|
|
numberOfResults: ymlConfig.UInt("numberOfResults", 10),
|
|
clientId: ymlConfig.UString("clientId", os.Getenv("TWITCH_CLIENT_ID")),
|
|
languages: utils.ToStrs(ymlConfig.UList("languages", defaultLanguage())),
|
|
streamType: ymlConfig.UString("streamType", "live"),
|
|
gameIds: utils.ToStrs(ymlConfig.UList("gameIds", make([]interface{}, 0))),
|
|
userIds: utils.ToStrs(ymlConfig.UList("userIds", make([]interface{}, 0))),
|
|
userLogins: utils.ToStrs(ymlConfig.UList("userLogins", make([]interface{}, 0))),
|
|
}
|
|
return &settings
|
|
}
|