This commit is contained in:
YouROK
2025-03-22 00:14:29 +03:00
parent 635882ea57
commit 11d9714234
11 changed files with 785 additions and 142 deletions

View File

@@ -0,0 +1,36 @@
package config
import (
"encoding/json"
"os"
"path/filepath"
"server/log"
"server/settings"
)
type Config struct {
HostTG string
WhiteIds []int64
BlackIds []int64
}
var Cfg *Config
func LoadConfig() {
Cfg = &Config{}
fn := filepath.Join(settings.Path, "tg.cfg")
buf, err := os.ReadFile(fn)
if err != nil {
Cfg.WhiteIds = []int64{}
Cfg.BlackIds = []int64{}
buf, _ = json.MarshalIndent(Cfg, "", " ")
if buf != nil {
os.WriteFile(fn, buf, 0666)
}
return
}
err = json.Unmarshal(buf, &Cfg)
if err != nil {
log.TLogln("Error read tg config:", err)
}
}