|
@@ -11,14 +11,18 @@ import (
|
|
|
"gogs.netdome.biz/paul/cheapo/internal/game"
|
|
"gogs.netdome.biz/paul/cheapo/internal/game"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-// chattoClientFromEnv builds a Chatto client from CHATTO_BASE_URL and
|
|
|
|
|
-// CHATTO_TOKEN environment variables. The token is provided by the operator;
|
|
|
|
|
|
|
+// chattoClientFromEnv builds a Chatto client from the CHATTO_TOKEN
|
|
|
|
|
+// environment variable; CHATTO_BASE_URL defaults to the public Chatto
|
|
|
|
|
+// server (https://chat.chatto.run). The token is provided by the operator;
|
|
|
// this tool never fetches credentials itself.
|
|
// this tool never fetches credentials itself.
|
|
|
func chattoClientFromEnv() (*chatto.Client, error) {
|
|
func chattoClientFromEnv() (*chatto.Client, error) {
|
|
|
base := os.Getenv("CHATTO_BASE_URL")
|
|
base := os.Getenv("CHATTO_BASE_URL")
|
|
|
|
|
+ if base == "" {
|
|
|
|
|
+ base = "https://chat.chatto.run"
|
|
|
|
|
+ }
|
|
|
token := os.Getenv("CHATTO_TOKEN")
|
|
token := os.Getenv("CHATTO_TOKEN")
|
|
|
- if base == "" || token == "" {
|
|
|
|
|
- return nil, fmt.Errorf("CHATTO_BASE_URL and CHATTO_TOKEN must be set")
|
|
|
|
|
|
|
+ if token == "" {
|
|
|
|
|
+ return nil, fmt.Errorf("CHATTO_TOKEN must be set (base URL: %s, overridable via CHATTO_BASE_URL)", base)
|
|
|
}
|
|
}
|
|
|
return chatto.NewClient(base, token), nil
|
|
return chatto.NewClient(base, token), nil
|
|
|
}
|
|
}
|