1
0
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:
Casey Primozic
2019-10-22 11:58:20 -07:00
committed by Casey Primozic
parent d7b0669796
commit 4c9990bafd
4 changed files with 149 additions and 0 deletions

View 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
}