twitterbots-go

twitter bots @soulstxt and @lacroix-bot
Log | Files | Refs | README | LICENSE

commit 54a11b72536e24f24d9a29474cefc14b5a3d40f4
parent e54d0de6d5ff8470b540b226e74f945b092bfbb9
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 26 Sep 2020 22:13:49 -0700

Update loading config

Diffstat:
Mmain.go | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/main.go b/main.go @@ -2,17 +2,19 @@ package main import ( "encoding/json" + "flag" "fmt" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" "os" - "path" ) func main() { - client, err := getCreds("soulstxt") + fileName := flag.String("config", "", "config filepath") + flag.Parse() + fmt.Println("Loading config from", *fileName) + client, err := getCreds(fileName) if err != nil { - // temp panic(err) } _, _, err = client.Statuses.Update("just setting up my twttr", nil) @@ -28,13 +30,8 @@ type TwitterCreds struct { AccessSecret string } -func getCreds(serviceName string) (*twitter.Client, error) { - home, err := os.UserHomeDir() - if err != nil { - return nil, err - } - fileName := path.Join(home, ".config", "twitter-creds", serviceName+".conf") - file, err := os.Open(fileName) +func getCreds(configFilename *string) (*twitter.Client, error) { + file, err := os.Open(*configFilename) if err != nil { return nil, err }