From 43ca576345860c9a60c1cbf11ad23082ba95952d Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 9 May 2017 13:37:23 +0200 Subject: [PATCH] talk: Let the token be in a file --- mods/talk.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/talk.go b/mods/talk.go index 5b2b910..f6208c6 100644 --- a/mods/talk.go +++ b/mods/talk.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "io/ioutil" "log" "net/http" "strconv" @@ -54,6 +55,13 @@ type QResponse struct { const talkBaseURL = "https://api.api.ai/v1" func inittalk() { + if strings.HasPrefix(*talktoken, "@") { + data, err := ioutil.ReadFile((*talktoken)[1:]) + if err != nil { + panic(err) + } + *talktoken = string(data) + } if *talktoken == "" { panic(fmt.Errorf("API token for api.ai must be provided! (provide it or --disable talk)")) }