talk: Let the token be in a file
This commit is contained in:
parent
318a3f8d16
commit
43ca576345
1 changed files with 8 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -54,6 +55,13 @@ type QResponse struct {
|
||||||
const talkBaseURL = "https://api.api.ai/v1"
|
const talkBaseURL = "https://api.api.ai/v1"
|
||||||
|
|
||||||
func inittalk() {
|
func inittalk() {
|
||||||
|
if strings.HasPrefix(*talktoken, "@") {
|
||||||
|
data, err := ioutil.ReadFile((*talktoken)[1:])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
*talktoken = string(data)
|
||||||
|
}
|
||||||
if *talktoken == "" {
|
if *talktoken == "" {
|
||||||
panic(fmt.Errorf("API token for api.ai must be provided! (provide it or --disable talk)"))
|
panic(fmt.Errorf("API token for api.ai must be provided! (provide it or --disable talk)"))
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue