1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 Twitter extracted to new config format

This commit is contained in:
Chris Cummer
2019-04-16 20:33:03 -07:00
parent 4b5045a0bb
commit eaa8825aa5
5 changed files with 46 additions and 27 deletions

View File

@@ -0,0 +1,30 @@
package twitter
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
bearerToken string
count int
screenNames []interface{}
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
localConfig, _ := ymlConfig.Get("wtf.mods.twitter")
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
bearerToken: localConfig.UString("bearerToken", os.Getenv("WTF_TWITTER_BEARER_TOKEN")),
count: localConfig.UInt("count", 5),
screenNames: localConfig.UList("screenName"),
}
return &settings
}