mastodon-group-bot/config.go

33 lines
601 B
Go
Raw Normal View History

2022-08-22 11:46:49 +00:00
package main
import (
"encoding/json"
"flag"
"log"
"os"
)
type Config struct {
Server string `json:"Server"`
ClientID string `json:"ClientID"`
ClientSecret string `json:"ClientSecret"`
AccessToken string `json:"AccessToken"`
WelcomeMessage string `json:"WelcomeMessage"`
Admins []string `json:"Admins"`
}
func read_conf() Config {
ConfPath := flag.String("config", "config.json", "Path to config")
flag.Parse()
data, err := os.ReadFile(*ConfPath)
if err != nil {
log.Fatal(err)
}
var Conf Config
json.Unmarshal(data, &Conf)
return Conf
}