mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* Create module skeleton based off of the existing twitter module * Strip out unused pieces and try to make it as minimal as possible * Implement settings parsing, converting the untyped `screenNames` slice into an slice of strings * Implement initial minimal display, showing a table with all usernames and their follower count + # of tweets (using dummy metrics for now)
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package twitterstats
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/olebedev/config"
|
|
"github.com/wtfutil/wtf/cfg"
|
|
)
|
|
|
|
const (
|
|
defaultFocusable = true
|
|
defaultTitle = "Twitter Stats"
|
|
)
|
|
|
|
type Settings struct {
|
|
common *cfg.Common
|
|
|
|
consumerKey string
|
|
consumerSecret string
|
|
accessToken string
|
|
accessTokenSecret string
|
|
|
|
screenNames []interface{}
|
|
}
|
|
|
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
|
settings := Settings{
|
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
|
|
|
consumerKey: ymlConfig.UString("consumerKey", os.Getenv("WTF_TWITTER_CONSUMER_KEY")),
|
|
consumerSecret: ymlConfig.UString("consumerSecret", os.Getenv("WTF_TWITTER_CONSUMER_SECRET")),
|
|
accessToken: ymlConfig.UString("accessToken", os.Getenv("WTF_TWITTER_ACCESS_TOKEN")),
|
|
accessTokenSecret: ymlConfig.UString("accessTokenSecret", os.Getenv("WTF_TWITTER_ACCESS_TOKEN_SECRET")),
|
|
|
|
screenNames: ymlConfig.UList("screenNames"),
|
|
}
|
|
|
|
return &settings
|
|
}
|