mirror of
https://gitea.phreedom.club/localhost_frssoft/mastodon-group-bot.git
synced 2024-11-22 12:29:20 +02:00
36 lines
775 B
Go
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
|
|
}
|