1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Update Twitter client to use config.yml or ENV vars

This commit is contained in:
Chris Cummer 2018-07-31 21:01:12 -07:00
parent 0ba4f60701
commit 2ab224fec2

View File

@ -5,6 +5,8 @@ import (
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
"github.com/senorprogrammer/wtf/wtf"
) )
/* NOTE: Currently single application ONLY /* NOTE: Currently single application ONLY
@ -25,9 +27,10 @@ func NewClient(url string) *Client {
apiBase: url, apiBase: url,
screenName: "wtfutil", screenName: "wtfutil",
count: 5, count: 5,
bearerToken: os.Getenv("WTF_TWITTER_BEARER_TOKEN"),
} }
client.loadAPICredentials()
return &client return &client
} }
@ -62,3 +65,10 @@ func (client *Client) tweets() (tweets []Tweet, err error) {
return return
} }
func (client *Client) loadAPICredentials() {
client.bearerToken = wtf.Config.UString(
"wtf.mods.twitter.bearerToken",
os.Getenv("WTF_TWITTER_BEARER_TOKEN"),
)
}