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:
parent
0ba4f60701
commit
2ab224fec2
@ -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"),
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user