1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
Casey Primozic 4c9990bafd
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)
2019-10-22 11:58:20 -07:00

49 lines
1.0 KiB
Go

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
}