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"`
|
2022-08-25 19:23:44 +00:00
|
|
|
Max_toots uint16 `json:"Max_toots"`
|
|
|
|
Toots_interval uint16 `json:"Toots_interval"`
|
2022-08-22 11:46:49 +00:00
|
|
|
Admins []string `json:"Admins"`
|
|
|
|
}
|
|
|
|
|
2022-08-26 10:56:21 +00:00
|
|
|
func read_conf() (Config, *string) {
|
2022-08-22 11:46:49 +00:00
|
|
|
ConfPath := flag.String("config", "config.json", "Path to config")
|
2022-08-26 10:56:21 +00:00
|
|
|
DBPath := flag.String("db", "limits.db", "Path to database")
|
2022-08-22 11:46:49 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
data, err := os.ReadFile(*ConfPath)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var Conf Config
|
|
|
|
json.Unmarshal(data, &Conf)
|
|
|
|
|
2022-08-26 10:56:21 +00:00
|
|
|
return Conf, DBPath
|
2022-08-22 11:46:49 +00:00
|
|
|
}
|