1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-23 11:42: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,48 @@
package twitterstats
import (
"log"
)
type Client struct {
apiBase string
consumerKey string
consumerSecret string
accessToken string
accessTokenSecret string
screenNames []string
}
func NewClient(settings *Settings) *Client {
usernames := make([]string, len(settings.screenNames))
for i, username := range settings.screenNames {
switch username.(type) {
default:
{
log.Fatalf("All `screenName`s in twitterstats config must be of type string")
}
case string:
usernames[i] = username.(string)
}
}
client := Client{
apiBase: "https://api.twitter.com/1.1/",
consumerKey: settings.consumerKey,
consumerSecret: settings.consumerSecret,
accessToken: settings.accessToken,
accessTokenSecret: settings.accessTokenSecret,
screenNames: usernames,
}
return &client
}
func (client *Client) GetFollowerCounts() []int64 {
return []int64{0, 0, 0, 0, 0} // TODO
}
func (client *Client) GetTweetCounts() []int64 {
return []int64{0, 0, 0, 0, 0} // TODO
}