mirror of
https://github.com/taigrr/wtf
synced 2026-03-21 07:02:17 -07:00
Implement initial twitterstats module
* 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)
This commit is contained in:
committed by
Casey Primozic
parent
d7b0669796
commit
4c9990bafd
39
modules/twitterstats/settings.go
Normal file
39
modules/twitterstats/settings.go
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user