mastodon-group-bot/config.go
2022-08-26 06:56:21 -04:00

36 lines
775 B
Go

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"`
Max_toots uint16 `json:"Max_toots"`
Toots_interval uint16 `json:"Toots_interval"`
Admins []string `json:"Admins"`
}
func read_conf() (Config, *string) {
ConfPath := flag.String("config", "config.json", "Path to config")
DBPath := flag.String("db", "limits.db", "Path to database")
flag.Parse()
data, err := os.ReadFile(*ConfPath)
if err != nil {
log.Fatal(err)
}
var Conf Config
json.Unmarshal(data, &Conf)
return Conf, DBPath
}