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:
30
modules/twitter/settings.go
Normal file
30
modules/twitter/settings.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user