diff --git a/twitter/client.go b/twitter/client.go index eea00841..817878ab 100644 --- a/twitter/client.go +++ b/twitter/client.go @@ -5,6 +5,8 @@ import ( "fmt" "os" "strconv" + + "github.com/senorprogrammer/wtf/wtf" ) /* NOTE: Currently single application ONLY @@ -22,12 +24,13 @@ type Client struct { // NewClient creates and returns a new Twitter client func NewClient(url string) *Client { client := Client{ - apiBase: url, - screenName: "wtfutil", - count: 5, - bearerToken: os.Getenv("WTF_TWITTER_BEARER_TOKEN"), + apiBase: url, + screenName: "wtfutil", + count: 5, } + client.loadAPICredentials() + return &client } @@ -62,3 +65,10 @@ func (client *Client) tweets() (tweets []Tweet, err error) { return } + +func (client *Client) loadAPICredentials() { + client.bearerToken = wtf.Config.UString( + "wtf.mods.twitter.bearerToken", + os.Getenv("WTF_TWITTER_BEARER_TOKEN"), + ) +}